From ceab91eb5dd92d5cdf896aeec6126474810a8832 Mon Sep 17 00:00:00 2001 From: Willem Date: Sun, 27 Dec 2015 16:11:57 +0100 Subject: [PATCH] Renamed jaxb support classes --- .../config/builder/TPQConfigBuilder.java | 6 +++--- .../tpquery/model/AbstractTPQueryNode.java | 7 ++++--- ...XMLMarshaller.java => ModelXMLInfoSet.java} | 6 +++--- ...Marshaller.java => ModelXMLMarshaller.java} | 18 +++++++++--------- .../net/forwardfire/tpquery/model/TPQuery.java | 5 +++-- .../forwardfire/tpquery/model/TPQueryHint.java | 7 ++++--- .../tpquery/model/TPQueryParameter.java | 7 ++++--- .../forwardfire/tpquery/model/TPQuerySet.java | 2 +- ...erTest.java => ModelXMLMarshallerTest.java} | 14 +++++++------- 9 files changed, 38 insertions(+), 34 deletions(-) rename ff-tpquery-store/src/main/java/net/forwardfire/tpquery/model/{AbstractXMLMarshaller.java => ModelXMLInfoSet.java} (95%) rename ff-tpquery-store/src/main/java/net/forwardfire/tpquery/model/{TPQuerySetXMLMarshaller.java => ModelXMLMarshaller.java} (83%) rename ff-tpquery-store/src/test/java/net/forwardfire/tpquery/model/{XMLMarshallerTest.java => ModelXMLMarshallerTest.java} (90%) diff --git a/ff-tpquery-store/src/main/java/net/forwardfire/tpquery/config/builder/TPQConfigBuilder.java b/ff-tpquery-store/src/main/java/net/forwardfire/tpquery/config/builder/TPQConfigBuilder.java index 96d77c1..625955d 100644 --- a/ff-tpquery-store/src/main/java/net/forwardfire/tpquery/config/builder/TPQConfigBuilder.java +++ b/ff-tpquery-store/src/main/java/net/forwardfire/tpquery/config/builder/TPQConfigBuilder.java @@ -34,7 +34,7 @@ import org.apache.commons.lang3.Validate; import net.forwardfire.tpquery.config.TPQConfig; import net.forwardfire.tpquery.model.TPQuerySet; -import net.forwardfire.tpquery.model.TPQuerySetXMLMarshaller; +import net.forwardfire.tpquery.model.ModelXMLMarshaller; import net.forwardfire.tpquery.statement.TPQStatementMarshaller; /** @@ -48,7 +48,7 @@ public class TPQConfigBuilder { private final TPQConfig storeConfig; private final Supplier resultBuilder; - private final TPQuerySetXMLMarshaller xmlDriver; + private final ModelXMLMarshaller xmlDriver; private final TPQStatementMarshaller statementMarshaller; /** @@ -62,7 +62,7 @@ public class TPQConfigBuilder { Validate.notNull(resultBuilder,"Can't build with null builder."); this.storeConfig = storeConfig; this.resultBuilder = resultBuilder; - this.xmlDriver = new TPQuerySetXMLMarshaller(); + this.xmlDriver = new ModelXMLMarshaller(); this.statementMarshaller = new TPQStatementMarshaller(); } diff --git a/ff-tpquery-store/src/main/java/net/forwardfire/tpquery/model/AbstractTPQueryNode.java b/ff-tpquery-store/src/main/java/net/forwardfire/tpquery/model/AbstractTPQueryNode.java index 7691a67..7267b15 100644 --- a/ff-tpquery-store/src/main/java/net/forwardfire/tpquery/model/AbstractTPQueryNode.java +++ b/ff-tpquery-store/src/main/java/net/forwardfire/tpquery/model/AbstractTPQueryNode.java @@ -30,8 +30,9 @@ import javax.xml.bind.annotation.XmlElement; import org.apache.commons.lang3.Validate; -import net.forwardfire.tpquery.model.AbstractXMLMarshaller.Attribute; -import net.forwardfire.tpquery.model.AbstractXMLMarshaller.Element; +import net.forwardfire.tpquery.model.ModelXMLInfoSet.Attribute; +import net.forwardfire.tpquery.model.ModelXMLInfoSet.Element; +import net.forwardfire.tpquery.model.ModelXMLInfoSet.Meta; /** * AbstractTPQueryNode has the shared properties of an query(set) node. @@ -58,7 +59,7 @@ public abstract class AbstractTPQueryNode { /** * @return the name */ - @XmlAttribute(name=Attribute.NAME,required=AbstractXMLMarshaller.Meta.REQUIRED) + @XmlAttribute(name=Attribute.NAME,required=Meta.REQUIRED) public String getName() { return name; } diff --git a/ff-tpquery-store/src/main/java/net/forwardfire/tpquery/model/AbstractXMLMarshaller.java b/ff-tpquery-store/src/main/java/net/forwardfire/tpquery/model/ModelXMLInfoSet.java similarity index 95% rename from ff-tpquery-store/src/main/java/net/forwardfire/tpquery/model/AbstractXMLMarshaller.java rename to ff-tpquery-store/src/main/java/net/forwardfire/tpquery/model/ModelXMLInfoSet.java index 1d55b90..3f48a8b 100644 --- a/ff-tpquery-store/src/main/java/net/forwardfire/tpquery/model/AbstractXMLMarshaller.java +++ b/ff-tpquery-store/src/main/java/net/forwardfire/tpquery/model/ModelXMLInfoSet.java @@ -23,16 +23,16 @@ package net.forwardfire.tpquery.model; /** - * AbstractXMLMarshaller has all jaxb meta info. + * ModelXMLInfoSet has all jaxb model info. * * @author Willem Cazander * @version 1.0 Jan 16, 2015 */ -abstract class AbstractXMLMarshaller { +class ModelXMLInfoSet { protected static final String XML_ENCODING = "UTF-8"; - protected AbstractXMLMarshaller() { + protected ModelXMLInfoSet() { } protected static class Meta { diff --git a/ff-tpquery-store/src/main/java/net/forwardfire/tpquery/model/TPQuerySetXMLMarshaller.java b/ff-tpquery-store/src/main/java/net/forwardfire/tpquery/model/ModelXMLMarshaller.java similarity index 83% rename from ff-tpquery-store/src/main/java/net/forwardfire/tpquery/model/TPQuerySetXMLMarshaller.java rename to ff-tpquery-store/src/main/java/net/forwardfire/tpquery/model/ModelXMLMarshaller.java index 664906e..455995b 100644 --- a/ff-tpquery-store/src/main/java/net/forwardfire/tpquery/model/TPQuerySetXMLMarshaller.java +++ b/ff-tpquery-store/src/main/java/net/forwardfire/tpquery/model/ModelXMLMarshaller.java @@ -33,29 +33,29 @@ import javax.xml.bind.Unmarshaller; import org.apache.commons.lang3.Validate; /** - * Jaxb marshaller of the query sets. + * Jaxb model marshaller of the query sets. * * @author Willem Cazander * @version 1.0 Jan 14, 2015 */ -public class TPQuerySetXMLMarshaller extends AbstractXMLMarshaller { +public class ModelXMLMarshaller extends ModelXMLInfoSet { - private final JAXBContext querySetContext; + private final JAXBContext jaxbContext; /** * Creates a query set xml marshaller. * @throws JAXBException When context could not be build. */ - public TPQuerySetXMLMarshaller() throws JAXBException { + public ModelXMLMarshaller() throws JAXBException { this(JAXBContext.newInstance(TPQuerySet.class)); } /** * Creates a query set xml marshaller. - * @param querySetContext The jaxb query set context. + * @param jaxbContext The jaxb query set context. */ - public TPQuerySetXMLMarshaller(JAXBContext querySetContext) { - this.querySetContext = Validate.notNull(querySetContext,"querySetContext is null."); + public ModelXMLMarshaller(JAXBContext jaxbContext) { + this.jaxbContext = Validate.notNull(jaxbContext,"jaxbContext is null."); } /** @@ -68,7 +68,7 @@ public class TPQuerySetXMLMarshaller extends AbstractXMLMarshaller { Validate.notNull(querySet,"querySet is null."); Validate.notNull(output,"OutputStream is null."); - Marshaller marshaller = querySetContext.createMarshaller(); + Marshaller marshaller = jaxbContext.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); marshaller.setProperty(Marshaller.JAXB_ENCODING, XML_ENCODING); marshaller.marshal(querySet, output); @@ -83,7 +83,7 @@ public class TPQuerySetXMLMarshaller extends AbstractXMLMarshaller { public TPQuerySet unmarshal(InputStream input) throws JAXBException { Validate.notNull(input,"InputStream is null."); - Unmarshaller unmarshaller = querySetContext.createUnmarshaller(); + Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); return (TPQuerySet) unmarshaller.unmarshal(input); } } diff --git a/ff-tpquery-store/src/main/java/net/forwardfire/tpquery/model/TPQuery.java b/ff-tpquery-store/src/main/java/net/forwardfire/tpquery/model/TPQuery.java index a80b8d6..4762899 100644 --- a/ff-tpquery-store/src/main/java/net/forwardfire/tpquery/model/TPQuery.java +++ b/ff-tpquery-store/src/main/java/net/forwardfire/tpquery/model/TPQuery.java @@ -30,7 +30,8 @@ import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import org.apache.commons.lang3.Validate; -import net.forwardfire.tpquery.model.AbstractXMLMarshaller.Element; +import net.forwardfire.tpquery.model.ModelXMLInfoSet.Element; +import net.forwardfire.tpquery.model.ModelXMLInfoSet.Meta; import net.forwardfire.tpquery.statement.TPQStatement; import net.forwardfire.tpquery.statement.TPQStatementMarshallerAdapter; @@ -65,7 +66,7 @@ public final class TPQuery extends AbstractTPQueryNode { /** * @return the queryParts */ - @XmlElement(name=Element.QUERY_PART,required=AbstractXMLMarshaller.Meta.REQUIRED) + @XmlElement(name=Element.QUERY_PART,required=Meta.REQUIRED) @XmlJavaTypeAdapter(TPQStatementMarshallerAdapter.class) public List getQueryParts() { return queryParts; diff --git a/ff-tpquery-store/src/main/java/net/forwardfire/tpquery/model/TPQueryHint.java b/ff-tpquery-store/src/main/java/net/forwardfire/tpquery/model/TPQueryHint.java index 515cb6f..b1fdccb 100644 --- a/ff-tpquery-store/src/main/java/net/forwardfire/tpquery/model/TPQueryHint.java +++ b/ff-tpquery-store/src/main/java/net/forwardfire/tpquery/model/TPQueryHint.java @@ -24,7 +24,8 @@ package net.forwardfire.tpquery.model; import javax.xml.bind.annotation.XmlAttribute; -import net.forwardfire.tpquery.model.AbstractXMLMarshaller.Attribute; +import net.forwardfire.tpquery.model.ModelXMLInfoSet.Attribute; +import net.forwardfire.tpquery.model.ModelXMLInfoSet.Meta; /** * Query hint are optional hint. @@ -57,7 +58,7 @@ public final class TPQueryHint { /** * @return the name */ - @XmlAttribute(name=Attribute.NAME,required=AbstractXMLMarshaller.Meta.REQUIRED) + @XmlAttribute(name=Attribute.NAME,required=Meta.REQUIRED) public String getName() { return name; } @@ -72,7 +73,7 @@ public final class TPQueryHint { /** * @return the value */ - @XmlAttribute(name=Attribute.VALUE,required=AbstractXMLMarshaller.Meta.REQUIRED) + @XmlAttribute(name=Attribute.VALUE,required=Meta.REQUIRED) public String getValue() { return value; } diff --git a/ff-tpquery-store/src/main/java/net/forwardfire/tpquery/model/TPQueryParameter.java b/ff-tpquery-store/src/main/java/net/forwardfire/tpquery/model/TPQueryParameter.java index ffc1d0d..e102366 100644 --- a/ff-tpquery-store/src/main/java/net/forwardfire/tpquery/model/TPQueryParameter.java +++ b/ff-tpquery-store/src/main/java/net/forwardfire/tpquery/model/TPQueryParameter.java @@ -24,7 +24,8 @@ package net.forwardfire.tpquery.model; import javax.xml.bind.annotation.XmlAttribute; -import net.forwardfire.tpquery.model.AbstractXMLMarshaller.Attribute; +import net.forwardfire.tpquery.model.ModelXMLInfoSet.Attribute; +import net.forwardfire.tpquery.model.ModelXMLInfoSet.Meta; /** * Defines the query parameter. @@ -59,7 +60,7 @@ public final class TPQueryParameter { /** * @return the name */ - @XmlAttribute(name=Attribute.NAME,required=AbstractXMLMarshaller.Meta.REQUIRED) + @XmlAttribute(name=Attribute.NAME,required=Meta.REQUIRED) public String getName() { return name; } @@ -103,7 +104,7 @@ public final class TPQueryParameter { /** * @return the valueType */ - @XmlAttribute(name=Attribute.VALUE_TYPE,required=AbstractXMLMarshaller.Meta.REQUIRED) + @XmlAttribute(name=Attribute.VALUE_TYPE,required=Meta.REQUIRED) public String getValueType() { return valueType; } diff --git a/ff-tpquery-store/src/main/java/net/forwardfire/tpquery/model/TPQuerySet.java b/ff-tpquery-store/src/main/java/net/forwardfire/tpquery/model/TPQuerySet.java index d65917d..5407a8a 100644 --- a/ff-tpquery-store/src/main/java/net/forwardfire/tpquery/model/TPQuerySet.java +++ b/ff-tpquery-store/src/main/java/net/forwardfire/tpquery/model/TPQuerySet.java @@ -28,7 +28,7 @@ import java.util.List; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; -import net.forwardfire.tpquery.model.AbstractXMLMarshaller.Element; +import net.forwardfire.tpquery.model.ModelXMLInfoSet.Element; /** * Query sets is an tree node which holds more query sets and queries. diff --git a/ff-tpquery-store/src/test/java/net/forwardfire/tpquery/model/XMLMarshallerTest.java b/ff-tpquery-store/src/test/java/net/forwardfire/tpquery/model/ModelXMLMarshallerTest.java similarity index 90% rename from ff-tpquery-store/src/test/java/net/forwardfire/tpquery/model/XMLMarshallerTest.java rename to ff-tpquery-store/src/test/java/net/forwardfire/tpquery/model/ModelXMLMarshallerTest.java index e353fa1..443dd10 100644 --- a/ff-tpquery-store/src/test/java/net/forwardfire/tpquery/model/XMLMarshallerTest.java +++ b/ff-tpquery-store/src/test/java/net/forwardfire/tpquery/model/ModelXMLMarshallerTest.java @@ -16,14 +16,14 @@ import net.forwardfire.tpquery.TPQManager; import net.forwardfire.tpquery.model.TPQuery; import net.forwardfire.tpquery.model.TPQueryParameter; import net.forwardfire.tpquery.model.TPQuerySet; -import net.forwardfire.tpquery.model.AbstractXMLMarshaller; -import net.forwardfire.tpquery.model.TPQuerySetXMLMarshaller; +import net.forwardfire.tpquery.model.ModelXMLInfoSet; +import net.forwardfire.tpquery.model.ModelXMLMarshaller; import net.forwardfire.tpquery.statement.TPQStatementPartInclude; import net.forwardfire.tpquery.statement.TPQStatementPartParameter; import net.forwardfire.tpquery.statement.TPQStatementPartText; import net.forwardfire.tpquery.store.executor.TPQExecutorStatement; -public class XMLMarshallerTest { +public class ModelXMLMarshallerTest { private TPQuerySet createTest() throws Exception { @@ -77,7 +77,7 @@ public class XMLMarshallerTest { @Test public void testRoundTrip() throws Exception { TPQuerySet qs = createTest(); - TPQuerySetXMLMarshaller xmlDriver = new TPQuerySetXMLMarshaller(); + ModelXMLMarshaller xmlDriver = new ModelXMLMarshaller(); ByteArrayOutputStream out = new ByteArrayOutputStream(4096); xmlDriver.marshal(qs, out); @@ -91,9 +91,9 @@ public class XMLMarshallerTest { @Test public void testXMLMarshallerClasses() throws Exception { - assertNotNull(new AbstractXMLMarshaller.Meta()); - assertNotNull(new AbstractXMLMarshaller.Element()); - assertNotNull(new AbstractXMLMarshaller.Attribute()); + assertNotNull(new ModelXMLInfoSet.Meta()); + assertNotNull(new ModelXMLInfoSet.Element()); + assertNotNull(new ModelXMLInfoSet.Attribute()); } @Test