From 8bb27c09c69ec9c9d2c67fc9673b4b7f8b9ab88a Mon Sep 17 00:00:00 2001 From: Willem Date: Mon, 24 Oct 2016 17:53:20 +0200 Subject: [PATCH] droppped jaxb from objects. --- .../unitxc/model/ModelJAXBInfoSet.java | 99 ------------ .../unitxc/model/ModelJAXBMarshaller.java | 117 -------------- .../unitxc/model/ModelJAXBObjectWrap.java | 59 ------- .../model/ModelJAXBObjectWrapAdapter.java | 44 ----- .../model/ModelJAXBTypedMarshaller.java | 152 ------------------ .../unitxc/model/UnitXCConfig.java | 7 - .../forwardfire/unitxc/model/UnitXCGroup.java | 19 --- .../unitxc/model/UnitXCGroupJump.java | 11 -- .../model/UnitXCGroupJumpParameter.java | 5 - .../forwardfire/unitxc/model/UnitXCType.java | 19 --- .../unitxc/model/UnitXConverterResult.java | 16 +- .../model/UnitXConverterResultStep.java | 12 +- .../step/AbstractUnitXConverterStep.java | 13 +- .../step/UnitXCConverterStepAutoRounding.java | 8 - .../step/UnitXCConverterStepCondition.java | 14 -- .../step/UnitXCConverterStepOperation.java | 11 -- .../step/UnitXCConverterStepPowerOfTen.java | 11 -- .../step/UnitXCConverterStepReference.java | 7 - ...UnitXConverterStepValueNamedParameter.java | 6 - .../UnitXConverterStepValueNamedVariable.java | 7 - ...nitXConverterStepValueReferenceDouble.java | 7 - ...erterStepValueReferenceDoubleFraction.java | 7 - ...itXConverterStepValueReferenceInteger.java | 6 - ...nitXConverterStepValueReferenceString.java | 6 - .../unitxc/UnitXCConverterStepTest.java | 8 +- 25 files changed, 20 insertions(+), 651 deletions(-) delete mode 100644 ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/ModelJAXBInfoSet.java delete mode 100644 ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/ModelJAXBMarshaller.java delete mode 100644 ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/ModelJAXBObjectWrap.java delete mode 100644 ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/ModelJAXBObjectWrapAdapter.java delete mode 100644 ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/ModelJAXBTypedMarshaller.java diff --git a/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/ModelJAXBInfoSet.java b/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/ModelJAXBInfoSet.java deleted file mode 100644 index b3ab224..0000000 --- a/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/ModelJAXBInfoSet.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright (c) 2013-2015, Willem Cazander - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted provided - * that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, this list of conditions and the - * following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and - * the following disclaimer in the documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR - * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.forwardfire.unitxc.model; - -/** - * ModelXMLInfoSet has all jaxb meta info. - * - * @author Willem Cazander - * @version 1.0 Jan 16, 2015 - */ -public class ModelJAXBInfoSet { - - protected ModelJAXBInfoSet() { - } - - protected static class Meta { - protected static final boolean REQUIRED = true; - protected Meta() { - } - } - - public static class Element { - protected static final String UNIT_CONFIG = "unitConfig"; - protected static final String UNIT_GROUP = "unitGroup"; - protected static final String UNIT_TYPE = "unitType"; - protected static final String DESCRIPTION = "description"; - protected static final String CONVERTER_RESULT = "converterResult"; - protected static final String CONVERTER_RESULT_STEP = "converterResultStep"; - protected static final String DERIVED_FROM = "derivedFrom"; - protected static final String TYPE_FLAG = "typeFlag"; - protected static final String TYPE_FLAGS = "typeFlags"; - protected static final String WEBSITE_LINK = "websiteLink"; - protected static final String WEBSITE_LINKS = "websiteLinks"; - protected static final String GROUP_JUMP = "groupJump"; - protected static final String GROUP_JUMP_PARAMETER = "groupJumpParameter"; - public static final String STEP_REASON = "stepReason"; - public static final String STEP_REASONS = "stepReasons"; - - public static final String OPERATION = "operation"; - public static final String CONDITION = "condition"; - public static final String REFERENCE = "reference"; - public static final String POWER_10 = "power10"; - public static final String ROUNDING = "rounding"; - - public static final String NAMED_VARIABLE = "namedVariable"; - public static final String NAMED_PARAMETER = "namedParameter"; - - public static final String VALUE_DOUBLE = "valueDouble"; - public static final String VALUE_DOUBLE_FRACTION = "valueDoubleFraction"; - public static final String VALUE_INTEGER = "valueInteger"; - public static final String VALUE_STRING = "valueString"; - - protected Element() { - } - } - - public static class Attribute { - protected static final String ID = "id"; - public static final String NAME = "name"; - protected static final String NAME_PLURAL = "namePlural"; - protected static final String UNIT_GROUP_ID = "unitGroupId"; - - protected static final String START_VALUE = "startValue"; - protected static final String RESULT_VALUE = "resultValue"; - protected static final String CONVERT_TIME = "convertTime"; - protected static final String START_TYPE_ID = "startTypeId"; - protected static final String RESULT_TYPE_ID = "resultTypeId"; - - protected static final String BASE_TYPE_ID = "baseTypeId"; - protected static final String GROUP_LEVEL = "groupLevel"; - - protected static final String ALIAS_OF_TYPE = "aliasOfType"; - - protected static final String ROUNDING = "rounding"; - - protected Attribute() { - } - } -} diff --git a/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/ModelJAXBMarshaller.java b/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/ModelJAXBMarshaller.java deleted file mode 100644 index a56a4bd..0000000 --- a/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/ModelJAXBMarshaller.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright (c) 2013-2015, Willem Cazander - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted provided - * that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, this list of conditions and the - * following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and - * the following disclaimer in the documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR - * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.forwardfire.unitxc.model; - -import javax.xml.bind.JAXBContext; -import javax.xml.bind.JAXBException; -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLOutputFactory; - -import org.apache.commons.lang3.ArrayUtils; - -import net.forwardfire.unitxc.model.step.UnitXCConverterStepAutoRounding; -import net.forwardfire.unitxc.model.step.UnitXCConverterStepCondition; -import net.forwardfire.unitxc.model.step.UnitXCConverterStepOperation; -import net.forwardfire.unitxc.model.step.UnitXCConverterStepPowerOfTen; -import net.forwardfire.unitxc.model.step.UnitXCConverterStepReference; -import net.forwardfire.unitxc.model.step.value.UnitXConverterStepValueNamedParameter; -import net.forwardfire.unitxc.model.step.value.UnitXConverterStepValueNamedVariable; -import net.forwardfire.unitxc.model.step.value.UnitXConverterStepValueReferenceDouble; -import net.forwardfire.unitxc.model.step.value.UnitXConverterStepValueReferenceDoubleFraction; -import net.forwardfire.unitxc.model.step.value.UnitXConverterStepValueReferenceInteger; -import net.forwardfire.unitxc.model.step.value.UnitXConverterStepValueReferenceString; - -/** - * Jaxb marshaller of the query sets. - * - * @author Willem Cazander - * @version 1.0 Jan 14, 2015 - */ -public class ModelJAXBMarshaller { - - private final ModelJAXBTypedMarshaller configModelMarshaller; - private final ModelJAXBTypedMarshaller groupModelMarshaller; - private final ModelJAXBTypedMarshaller typeModelMarshaller; - private final ModelJAXBTypedMarshaller resultModelMarshaller; - - private final static Class[] JAXB_TYPES = new Class[] { - UnitXCConfig.class, - UnitXCGroup.class, - UnitXConverterResult.class, - UnitXCConverterStepReference.class, - UnitXCConverterStepOperation.class, - UnitXCConverterStepCondition.class, - UnitXCConverterStepPowerOfTen.class, - UnitXCConverterStepAutoRounding.class, - UnitXConverterStepValueNamedParameter.class, - UnitXConverterStepValueNamedVariable.class, - UnitXConverterStepValueReferenceDouble.class, - UnitXConverterStepValueReferenceDoubleFraction.class, - UnitXConverterStepValueReferenceInteger.class, - UnitXConverterStepValueReferenceString.class, - }; - - - public ModelJAXBMarshaller() throws JAXBException { - this(new Class[]{}); - } - - public ModelJAXBMarshaller(Class[] extraTypes) throws JAXBException { - this(JAXBContext.newInstance(ArrayUtils.addAll(getJAXBTypes(), extraTypes))); - } - - public ModelJAXBMarshaller(JAXBContext jaxbContext) throws JAXBException { - this(XMLInputFactory.newInstance(),XMLOutputFactory.newInstance(),jaxbContext); - } - - public ModelJAXBMarshaller(XMLInputFactory xmlInputFactory,XMLOutputFactory xmlOutputFactory, JAXBContext jaxbContext) { - this.configModelMarshaller = buildTypedMarshaller(UnitXCConfig.class, xmlInputFactory, xmlOutputFactory, jaxbContext); - this.groupModelMarshaller = buildTypedMarshaller(UnitXCGroup.class, xmlInputFactory, xmlOutputFactory, jaxbContext); - this.typeModelMarshaller = buildTypedMarshaller(UnitXCType.class, xmlInputFactory, xmlOutputFactory, jaxbContext); - this.resultModelMarshaller = buildTypedMarshaller(UnitXConverterResult.class, xmlInputFactory, xmlOutputFactory, jaxbContext); - } - - public static Class[] getJAXBTypes() { - return JAXB_TYPES; - } - - public ModelJAXBTypedMarshaller getUnitXCConfig() { - return configModelMarshaller; - } - - public ModelJAXBTypedMarshaller getUnitXCGroup() { - return groupModelMarshaller; - } - - public ModelJAXBTypedMarshaller getUnitXCType() { - return typeModelMarshaller; - } - - public ModelJAXBTypedMarshaller getUnitXConverterResult() { - return resultModelMarshaller; - } - - private static ModelJAXBTypedMarshaller buildTypedMarshaller(Class typeClass,XMLInputFactory xmlInputFactory,XMLOutputFactory xmlOutputFactory, JAXBContext jaxbContext) { - return new ModelJAXBTypedMarshaller(typeClass,xmlInputFactory,xmlOutputFactory,jaxbContext); - } -} diff --git a/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/ModelJAXBObjectWrap.java b/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/ModelJAXBObjectWrap.java deleted file mode 100644 index 79d67d4..0000000 --- a/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/ModelJAXBObjectWrap.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2013-2015, Willem Cazander - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted provided - * that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, this list of conditions and the - * following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and - * the following disclaimer in the documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR - * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package net.forwardfire.unitxc.model; - -import javax.xml.bind.annotation.XmlAnyElement; - -/** - * - * - * @author Willem Cazander - * @version 1.0 Apr 3, 2016 - */ -public class ModelJAXBObjectWrap { - - private T value; - - public ModelJAXBObjectWrap() { - } - - public ModelJAXBObjectWrap(T value) { - setValue(value); - } - - /** - * @return the value - */ - @XmlAnyElement - public T getValue() { - return value; - } - - /** - * @param value the value to set - */ - public void setValue(T value) { - this.value = value; - } -} diff --git a/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/ModelJAXBObjectWrapAdapter.java b/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/ModelJAXBObjectWrapAdapter.java deleted file mode 100644 index ac0c029..0000000 --- a/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/ModelJAXBObjectWrapAdapter.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2013-2015, Willem Cazander - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted provided - * that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, this list of conditions and the - * following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and - * the following disclaimer in the documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR - * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.forwardfire.unitxc.model; - -import javax.xml.bind.annotation.adapters.XmlAdapter; - -/** - * Adds extra wrap tag to any object. - * - * @author Willem Cazander - * @version 1.0 Apr 3, 2016 - */ -public class ModelJAXBObjectWrapAdapter extends XmlAdapter, Object> { - - @Override - public Object unmarshal(ModelJAXBObjectWrap v) throws Exception { - return v.getValue(); - } - - @Override - public ModelJAXBObjectWrap marshal(Object v) throws Exception { - return new ModelJAXBObjectWrap(v); - } -} diff --git a/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/ModelJAXBTypedMarshaller.java b/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/ModelJAXBTypedMarshaller.java deleted file mode 100644 index e1ad835..0000000 --- a/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/ModelJAXBTypedMarshaller.java +++ /dev/null @@ -1,152 +0,0 @@ -package net.forwardfire.unitxc.model; - -import java.io.InputStream; -import java.io.OutputStream; -import java.lang.reflect.InvocationHandler; -import java.lang.reflect.Method; -import java.lang.reflect.Proxy; -import java.nio.charset.StandardCharsets; -import java.util.HashMap; -import java.util.Map; - -import javax.xml.bind.JAXBContext; -import javax.xml.bind.JAXBException; -import javax.xml.bind.Marshaller; -import javax.xml.bind.Unmarshaller; -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLOutputFactory; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; -import javax.xml.stream.XMLStreamWriter; - -import org.apache.commons.lang3.StringUtils; -import org.apache.commons.lang3.Validate; - -public class ModelJAXBTypedMarshaller { - - private final Class typeClass; - private final XMLInputFactory xmlInputFactory; - private final XMLOutputFactory xmlOutputFactory; - private final JAXBContext jaxbContext; - - public ModelJAXBTypedMarshaller(Class typeClass, XMLInputFactory xmlInputFactory, - XMLOutputFactory xmlOutputFactory, JAXBContext jaxbContext) { - this.typeClass = Validate.notNull(typeClass); - this.xmlInputFactory = Validate.notNull(xmlInputFactory); - this.xmlOutputFactory = Validate.notNull(xmlOutputFactory); - this.jaxbContext = Validate.notNull(jaxbContext); - } - - protected Unmarshaller createUnmarshaller() throws JAXBException { - return jaxbContext.createUnmarshaller(); - } - - protected Marshaller createMarshaller(String encoding) throws JAXBException { - Validate.notNull(encoding, "encoding is null."); - Marshaller marshaller = jaxbContext.createMarshaller(); - //marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); // done by stax proxy now - marshaller.setProperty(Marshaller.JAXB_ENCODING, encoding); - return marshaller; - } - - public void marshal(T jaxbElement, XMLStreamWriter writer) throws JAXBException { - marshal(jaxbElement, writer, StandardCharsets.UTF_8.name()); - } - - public void marshal(T jaxbElement, XMLStreamWriter writer, String encoding) throws JAXBException { - Validate.notNull(jaxbElement, "jaxbElement is null."); - Validate.notNull(writer, "reader is null."); - Validate.notNull(encoding, "encoding is null."); - createMarshaller(encoding).marshal(jaxbElement, writer); - } - - public void marshal(T jaxbElement, OutputStream output) throws JAXBException, XMLStreamException { - marshal(jaxbElement, output, StandardCharsets.UTF_8.name()); - } - - public void marshal(T jaxbElement, OutputStream output, String encoding) throws JAXBException, XMLStreamException { - Validate.notNull(jaxbElement, "jaxbElement is null."); - Validate.notNull(output, "ouput is null."); - Validate.notNull(encoding, "encoding is null."); - marshal(jaxbElement, IndentingXMLStreamWriterProxy.wrap(xmlOutputFactory.createXMLStreamWriter(output, encoding)), encoding); - } - - public T unmarshal(XMLStreamReader reader) throws JAXBException { - Validate.notNull(reader, "reader is null."); - return createUnmarshaller().unmarshal(reader, typeClass).getValue(); - } - - public T unmarshal(InputStream input, String encoding) throws JAXBException, XMLStreamException { - Validate.notNull(input, "input is null."); - Validate.notNull(encoding, "encoding is null."); - return unmarshal(xmlInputFactory.createXMLStreamReader(input, encoding)); - } - - public T unmarshal(InputStream input) throws JAXBException, XMLStreamException { - return unmarshal(input, StandardCharsets.UTF_8.name()); - } - - static class IndentingXMLStreamWriterProxy implements InvocationHandler { - - private final XMLStreamWriter target; - private int depth = 0; - private boolean firstLine = true; - private final Map hasChildElement = new HashMap<>(); - - public IndentingXMLStreamWriterProxy(XMLStreamWriter target) { - this.target = Validate.notNull(target); - } - - public static XMLStreamWriter wrap(XMLStreamWriter writer) { - ClassLoader cl = Thread.currentThread().getContextClassLoader(); - if (cl == null) { - IndentingXMLStreamWriterProxy.class.getClassLoader(); - } - return (XMLStreamWriter) Proxy.newProxyInstance(cl, new Class[]{XMLStreamWriter.class}, new IndentingXMLStreamWriterProxy(writer)); - } - - public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { - String m = method.getName(); - // Needs to be BEFORE the actual event, so that for instance the - // sequence writeStartElem, writeAttr, writeStartElem, writeEndElem,writeEndElem - // is correctly handled - if ("writeStartElement".equals(m)) { - // update state of parent node - if (depth > 0) { - hasChildElement.put(depth - 1, true); - } - // reset state of current node - hasChildElement.put(depth, false); - // indent for current depth - if (!firstLine) { - writeLineWrap(); - } - depth++; - } else if ("writeEndElement".equals(m)) { - depth--; - if (hasChildElement.get(depth) == true) { - writeLineWrap(); - } - } else if ("writeEmptyElement".equals(m)) { - // update state of parent node - if (depth > 0) { - hasChildElement.put(depth - 1, true); - } - writeLineWrap(); - } else if ("writeComment".equals(m)) { - writeLineWrap(); - } else if ("writeEndDocument".equals(m)) { - target.writeCharacters(StringUtils.LF); - } - method.invoke(target, args); - firstLine = false; - return null; - } - - private void writeLineWrap() throws XMLStreamException { - target.writeCharacters(StringUtils.LF); - // indent for current depth - target.writeCharacters(StringUtils.repeat(StringUtils.SPACE, depth)); - } - } -} diff --git a/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/UnitXCConfig.java b/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/UnitXCConfig.java index 2bb371e..849617a 100644 --- a/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/UnitXCConfig.java +++ b/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/UnitXCConfig.java @@ -26,10 +26,6 @@ package net.forwardfire.unitxc.model; import java.util.ArrayList; import java.util.List; -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - import org.apache.commons.lang3.Validate; /** @@ -38,7 +34,6 @@ import org.apache.commons.lang3.Validate; * @author Willem Cazander * @version 1.0 Oct 17, 2015 */ -@XmlRootElement(name=ModelJAXBInfoSet.Element.UNIT_CONFIG) public class UnitXCConfig { private UnitXCRounding rounding; @@ -51,7 +46,6 @@ public class UnitXCConfig { /** * @return the rounding */ - @XmlAttribute(name=ModelJAXBInfoSet.Attribute.ROUNDING) public UnitXCRounding getRounding() { return rounding; } @@ -66,7 +60,6 @@ public class UnitXCConfig { /** * @return the unit groups. */ - @XmlElement(name=ModelJAXBInfoSet.Element.UNIT_GROUP) public List getUnitGroups() { return unitGroups; } diff --git a/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/UnitXCGroup.java b/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/UnitXCGroup.java index 1740221..983b04f 100644 --- a/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/UnitXCGroup.java +++ b/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/UnitXCGroup.java @@ -26,12 +26,6 @@ package net.forwardfire.unitxc.model; import java.util.ArrayList; import java.util.List; -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlElementWrapper; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlTransient; - import org.apache.commons.lang3.Validate; import org.apache.commons.lang3.builder.ReflectionToStringBuilder; @@ -41,7 +35,6 @@ import org.apache.commons.lang3.builder.ReflectionToStringBuilder; * @author Willem Cazander * @version 1.0 Oct 10, 2015 */ -@XmlRootElement(name=ModelJAXBInfoSet.Element.UNIT_GROUP) public class UnitXCGroup { private String id; @@ -81,7 +74,6 @@ public class UnitXCGroup { /** * @return the id */ - @XmlAttribute(name=ModelJAXBInfoSet.Attribute.ID) public String getId() { return id; } @@ -95,7 +87,6 @@ public class UnitXCGroup { /** * @return the name */ - @XmlAttribute(name=ModelJAXBInfoSet.Attribute.NAME) public String getName() { return name; } @@ -110,7 +101,6 @@ public class UnitXCGroup { /** * @return the description */ - @XmlElement(name=ModelJAXBInfoSet.Element.DESCRIPTION) public String getDescription() { return description; } @@ -125,7 +115,6 @@ public class UnitXCGroup { /** * @return the baseTypeId */ - @XmlAttribute(name=ModelJAXBInfoSet.Attribute.BASE_TYPE_ID) public String getBaseTypeId() { return baseTypeId; } @@ -140,7 +129,6 @@ public class UnitXCGroup { /** * @return the groupLevel */ - @XmlAttribute(name=ModelJAXBInfoSet.Attribute.GROUP_LEVEL) public UnitXCGroupLevel getGroupLevel() { return groupLevel; } @@ -155,8 +143,6 @@ public class UnitXCGroup { /** * @return the derivedFrom */ - @XmlElement(name=ModelJAXBInfoSet.Element.DERIVED_FROM) - @XmlElementWrapper public List getDerivedFrom() { return derivedFrom; } @@ -172,8 +158,6 @@ public class UnitXCGroup { /** * @return the unit types. */ - @XmlElement(name=ModelJAXBInfoSet.Element.UNIT_TYPE) - @XmlElementWrapper public List getUnitTypes() { return unitTypes; } @@ -196,8 +180,6 @@ public class UnitXCGroup { /** * @return the groupJumps */ - @XmlElement(name=ModelJAXBInfoSet.Element.GROUP_JUMP) - @XmlElementWrapper public List getGroupJumps() { return groupJumps; } @@ -213,7 +195,6 @@ public class UnitXCGroup { /** * @return the typeGenerator */ - @XmlTransient public UnitXCTypeGenerator getTypeGenerator() { return typeGenerator; } diff --git a/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/UnitXCGroupJump.java b/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/UnitXCGroupJump.java index f5ba59b..46c82fd 100644 --- a/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/UnitXCGroupJump.java +++ b/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/UnitXCGroupJump.java @@ -26,11 +26,6 @@ package net.forwardfire.unitxc.model; import java.util.ArrayList; import java.util.List; -import javax.xml.bind.annotation.XmlAnyElement; -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlElementWrapper; - import org.apache.commons.lang3.Validate; import net.forwardfire.unitxc.model.step.UnitXConverterStep; @@ -62,7 +57,6 @@ public class UnitXCGroupJump { /** * @return the id */ - @XmlAttribute(name=ModelJAXBInfoSet.Attribute.ID) public String getId() { return id; } @@ -76,7 +70,6 @@ public class UnitXCGroupJump { /** * @return the toGroupId */ - @XmlAttribute(name=ModelJAXBInfoSet.Attribute.UNIT_GROUP_ID) public String getUnitGroupId() { return unitGroupId; } @@ -91,8 +84,6 @@ public class UnitXCGroupJump { /** * @return the toGroupConverterSteps */ - @XmlElementWrapper - @XmlAnyElement public List getToGroupConverterSteps() { return toGroupConverterSteps; } @@ -108,8 +99,6 @@ public class UnitXCGroupJump { /** * @return the jumpParameters */ - @XmlElementWrapper - @XmlElement(name=ModelJAXBInfoSet.Element.GROUP_JUMP_PARAMETER) public List getJumpParameters() { return jumpParameters; } diff --git a/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/UnitXCGroupJumpParameter.java b/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/UnitXCGroupJumpParameter.java index 26a1c66..6d4029c 100644 --- a/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/UnitXCGroupJumpParameter.java +++ b/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/UnitXCGroupJumpParameter.java @@ -23,11 +23,8 @@ package net.forwardfire.unitxc.model; -import javax.xml.bind.annotation.XmlAttribute; - import org.apache.commons.lang3.Validate; - /** * The unit group jump. * @@ -56,7 +53,6 @@ public class UnitXCGroupJumpParameter { /** * @return the id */ - @XmlAttribute(name=ModelJAXBInfoSet.Attribute.ID) public String getId() { return id; } @@ -70,7 +66,6 @@ public class UnitXCGroupJumpParameter { /** * @return the unitGroupId */ - @XmlAttribute(name=ModelJAXBInfoSet.Attribute.UNIT_GROUP_ID) public String getUnitGroupId() { return unitGroupId; } diff --git a/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/UnitXCType.java b/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/UnitXCType.java index 06a61be..5b05cd8 100644 --- a/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/UnitXCType.java +++ b/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/UnitXCType.java @@ -26,12 +26,6 @@ package net.forwardfire.unitxc.model; import java.util.ArrayList; import java.util.List; -import javax.xml.bind.annotation.XmlAnyElement; -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlElementWrapper; -import javax.xml.bind.annotation.XmlTransient; - import org.apache.commons.lang3.Validate; import org.apache.commons.lang3.builder.ReflectionToStringBuilder; @@ -73,7 +67,6 @@ public class UnitXCType { /** * @return the id */ - @XmlAttribute(name=ModelJAXBInfoSet.Attribute.ID) public String getId() { return id; } @@ -87,7 +80,6 @@ public class UnitXCType { /** * @return the name */ - @XmlAttribute(name=ModelJAXBInfoSet.Attribute.NAME) public String getName() { return name; } @@ -102,7 +94,6 @@ public class UnitXCType { /** * @return the namePlural */ - @XmlAttribute(name=ModelJAXBInfoSet.Attribute.NAME_PLURAL) public String getNamePlural() { return namePlural; } @@ -117,7 +108,6 @@ public class UnitXCType { /** * @return the aliasOfType */ - @XmlAttribute(name=ModelJAXBInfoSet.Attribute.ALIAS_OF_TYPE) public String getAliasOfType() { return aliasOfType; } @@ -132,7 +122,6 @@ public class UnitXCType { /** * @return the unitGroup */ - @XmlTransient public UnitXCGroup getUnitGroup() { return unitGroup; } @@ -147,8 +136,6 @@ public class UnitXCType { /** * @return the toBaseConverterSteps */ - @XmlElementWrapper - @XmlAnyElement public List getToBaseConverterSteps() { return toBaseConverterSteps; } @@ -164,8 +151,6 @@ public class UnitXCType { /** * @return the fromBaseConverterSteps */ - @XmlElementWrapper - @XmlAnyElement public List getFromBaseConverterSteps() { return fromBaseConverterSteps; } @@ -181,8 +166,6 @@ public class UnitXCType { /** * @return the typeFlags */ - @XmlElement(name=ModelJAXBInfoSet.Element.TYPE_FLAG) - @XmlElementWrapper(name=ModelJAXBInfoSet.Element.TYPE_FLAGS) public List getTypeFlags() { return typeFlags; } @@ -198,8 +181,6 @@ public class UnitXCType { /** * @return the websiteLinks */ - @XmlElement(name=ModelJAXBInfoSet.Element.WEBSITE_LINK) - @XmlElementWrapper(name=ModelJAXBInfoSet.Element.WEBSITE_LINKS) public List getWebsiteLinks() { return websiteLinks; } diff --git a/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/UnitXConverterResult.java b/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/UnitXConverterResult.java index df0b224..3419cfb 100644 --- a/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/UnitXConverterResult.java +++ b/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/UnitXConverterResult.java @@ -25,9 +25,7 @@ package net.forwardfire.unitxc.model; import java.util.List; -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; +import org.apache.commons.lang3.builder.ReflectionToStringBuilder; /** * Holds the convert result and meta steps how we got there. @@ -35,7 +33,6 @@ import javax.xml.bind.annotation.XmlRootElement; * @author Willem Cazander * @version 1.0 Oct 17, 2015 */ -@XmlRootElement(name=ModelJAXBInfoSet.Element.CONVERTER_RESULT) public class UnitXConverterResult { private Double startValue; @@ -48,7 +45,6 @@ public class UnitXConverterResult { /** * @return the startValue */ - @XmlAttribute(name=ModelJAXBInfoSet.Attribute.START_VALUE) public Double getStartValue() { return startValue; } @@ -63,7 +59,6 @@ public class UnitXConverterResult { /** * @return the resultSteps */ - @XmlElement(name=ModelJAXBInfoSet.Element.CONVERTER_RESULT_STEP) public List getResultSteps() { return resultSteps; } @@ -78,7 +73,6 @@ public class UnitXConverterResult { /** * @return the resultValue */ - @XmlAttribute(name=ModelJAXBInfoSet.Attribute.RESULT_VALUE) public Double getResultValue() { return resultValue; } @@ -93,7 +87,6 @@ public class UnitXConverterResult { /** * @return the convertTime */ - @XmlAttribute(name=ModelJAXBInfoSet.Attribute.CONVERT_TIME) public Long getConvertTime() { return convertTime; } @@ -108,7 +101,6 @@ public class UnitXConverterResult { /** * @return the startTypeId */ - @XmlAttribute(name=ModelJAXBInfoSet.Attribute.START_TYPE_ID) public String getStartTypeId() { return startTypeId; } @@ -123,7 +115,6 @@ public class UnitXConverterResult { /** * @return the resultTypeId */ - @XmlAttribute(name=ModelJAXBInfoSet.Attribute.RESULT_TYPE_ID) public String getResultTypeId() { return resultTypeId; } @@ -134,4 +125,9 @@ public class UnitXConverterResult { public void setResultTypeId(String resultTypeId) { this.resultTypeId = resultTypeId; } + + @Override + public String toString() { + return ReflectionToStringBuilder.toString(this); + } } diff --git a/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/UnitXConverterResultStep.java b/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/UnitXConverterResultStep.java index 35e3c70..6266d15 100644 --- a/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/UnitXConverterResultStep.java +++ b/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/UnitXConverterResultStep.java @@ -23,8 +23,7 @@ package net.forwardfire.unitxc.model; -import javax.xml.bind.annotation.XmlAnyElement; -import javax.xml.bind.annotation.XmlAttribute; +import org.apache.commons.lang3.builder.ReflectionToStringBuilder; import net.forwardfire.unitxc.model.step.UnitXConverterStep; @@ -44,7 +43,6 @@ public class UnitXConverterResultStep { /** * @return the startValue */ - @XmlAttribute(name=ModelJAXBInfoSet.Attribute.START_VALUE) public Double getStartValue() { return startValue; } @@ -59,7 +57,6 @@ public class UnitXConverterResultStep { /** * @return the resultValue */ - @XmlAttribute(name=ModelJAXBInfoSet.Attribute.RESULT_VALUE) public Double getResultValue() { return resultValue; } @@ -74,7 +71,6 @@ public class UnitXConverterResultStep { /** * @return the convertTime */ - @XmlAttribute(name=ModelJAXBInfoSet.Attribute.CONVERT_TIME) public Long getConvertTime() { return convertTime; } @@ -89,7 +85,6 @@ public class UnitXConverterResultStep { /** * @return the convertStep */ - @XmlAnyElement public UnitXConverterStep getConvertStep() { return convertStep; } @@ -100,4 +95,9 @@ public class UnitXConverterResultStep { public void setConvertStep(UnitXConverterStep convertStep) { this.convertStep = convertStep; } + + @Override + public String toString() { + return ReflectionToStringBuilder.toString(this); + } } diff --git a/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/step/AbstractUnitXConverterStep.java b/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/step/AbstractUnitXConverterStep.java index 7182824..7e2bc17 100644 --- a/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/step/AbstractUnitXConverterStep.java +++ b/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/step/AbstractUnitXConverterStep.java @@ -26,12 +26,8 @@ package net.forwardfire.unitxc.model.step; import java.util.ArrayList; import java.util.List; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlElementWrapper; - import org.apache.commons.lang3.Validate; - -import net.forwardfire.unitxc.model.ModelJAXBInfoSet; +import org.apache.commons.lang3.builder.ReflectionToStringBuilder; /** * @@ -52,8 +48,6 @@ public abstract class AbstractUnitXConverterStep implements UnitXConverterStep { return this; } - @XmlElement(name=ModelJAXBInfoSet.Element.STEP_REASON) - @XmlElementWrapper(name=ModelJAXBInfoSet.Element.STEP_REASONS) public final List getStepReasons() { return stepReasons; } @@ -66,4 +60,9 @@ public abstract class AbstractUnitXConverterStep implements UnitXConverterStep { public final void addStepReason(String stepReason) { stepReasons.add(Validate.notBlank(stepReason)); } + + @Override + public final String toString() { + return ReflectionToStringBuilder.toString(this); + } } diff --git a/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/step/UnitXCConverterStepAutoRounding.java b/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/step/UnitXCConverterStepAutoRounding.java index 6aac9f9..759610f 100644 --- a/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/step/UnitXCConverterStepAutoRounding.java +++ b/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/step/UnitXCConverterStepAutoRounding.java @@ -1,15 +1,9 @@ package net.forwardfire.unitxc.model.step; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; - -import net.forwardfire.unitxc.model.ModelJAXBInfoSet; -import net.forwardfire.unitxc.model.ModelJAXBObjectWrapAdapter; import net.forwardfire.unitxc.model.step.value.UnitXConverterStepValueNamedVariable; import net.forwardfire.unitxc.model.step.value.UnitXConverterStepValueRead; import net.forwardfire.unitxc.model.step.value.UnitXConverterStepValueReadWrite; -@XmlRootElement(name=ModelJAXBInfoSet.Element.ROUNDING) public class UnitXCConverterStepAutoRounding extends AbstractUnitXConverterStep { private UnitXConverterStepValueRead operand; @@ -62,7 +56,6 @@ public class UnitXCConverterStepAutoRounding extends AbstractUnitXConverterStep /** * @return the operand */ - @XmlJavaTypeAdapter(value=ModelJAXBObjectWrapAdapter.class) public UnitXConverterStepValueRead getOperand() { return operand; } @@ -77,7 +70,6 @@ public class UnitXCConverterStepAutoRounding extends AbstractUnitXConverterStep /** * @return the result */ - @XmlJavaTypeAdapter(value=ModelJAXBObjectWrapAdapter.class) public UnitXConverterStepValueReadWrite getResult() { return result; } diff --git a/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/step/UnitXCConverterStepCondition.java b/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/step/UnitXCConverterStepCondition.java index 4e57aa9..2cf10d2 100644 --- a/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/step/UnitXCConverterStepCondition.java +++ b/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/step/UnitXCConverterStepCondition.java @@ -26,14 +26,6 @@ package net.forwardfire.unitxc.model.step; import java.util.ArrayList; import java.util.List; -import javax.xml.bind.annotation.XmlAnyElement; -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlElementWrapper; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; - -import net.forwardfire.unitxc.model.ModelJAXBInfoSet; -import net.forwardfire.unitxc.model.ModelJAXBObjectWrapAdapter; import net.forwardfire.unitxc.model.step.value.UnitXConverterStepValueRead; /** @@ -42,7 +34,6 @@ import net.forwardfire.unitxc.model.step.value.UnitXConverterStepValueRead; * @author Willem Cazander * @version 1.0 Oct 17, 2015 */ -@XmlRootElement(name=ModelJAXBInfoSet.Element.CONDITION) public class UnitXCConverterStepCondition extends AbstractUnitXConverterStep { private UnitXCConverterStepConditionEquality equality; @@ -64,7 +55,6 @@ public class UnitXCConverterStepCondition extends AbstractUnitXConverterStep { /** * @return the equality */ - @XmlAttribute public UnitXCConverterStepConditionEquality getEquality() { return equality; } @@ -79,7 +69,6 @@ public class UnitXCConverterStepCondition extends AbstractUnitXConverterStep { /** * @return the operandA */ - @XmlJavaTypeAdapter(value=ModelJAXBObjectWrapAdapter.class) public UnitXConverterStepValueRead getOperandA() { return operandA; } @@ -94,7 +83,6 @@ public class UnitXCConverterStepCondition extends AbstractUnitXConverterStep { /** * @return the operandB */ - @XmlJavaTypeAdapter(value=ModelJAXBObjectWrapAdapter.class) public UnitXConverterStepValueRead getOperandB() { return operandB; } @@ -109,8 +97,6 @@ public class UnitXCConverterStepCondition extends AbstractUnitXConverterStep { /** * @return the conditionalSteps */ - @XmlElementWrapper - @XmlAnyElement public List getConditionalSteps() { return conditionalSteps; } diff --git a/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/step/UnitXCConverterStepOperation.java b/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/step/UnitXCConverterStepOperation.java index 0271bf3..13282ac 100644 --- a/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/step/UnitXCConverterStepOperation.java +++ b/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/step/UnitXCConverterStepOperation.java @@ -23,12 +23,6 @@ package net.forwardfire.unitxc.model.step; -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; - -import net.forwardfire.unitxc.model.ModelJAXBInfoSet; -import net.forwardfire.unitxc.model.ModelJAXBObjectWrapAdapter; import net.forwardfire.unitxc.model.step.value.UnitXConverterStepValueRead; import net.forwardfire.unitxc.model.step.value.UnitXConverterStepValueReadWrite; @@ -38,7 +32,6 @@ import net.forwardfire.unitxc.model.step.value.UnitXConverterStepValueReadWrite; * @author Willem Cazander * @version 1.0 Oct 17, 2015 */ -@XmlRootElement(name=ModelJAXBInfoSet.Element.OPERATION) public class UnitXCConverterStepOperation extends AbstractUnitXConverterStep { private UnitXCConverterStepOperationOperator operator; @@ -64,7 +57,6 @@ public class UnitXCConverterStepOperation extends AbstractUnitXConverterStep { /** * @return the operator */ - @XmlAttribute public UnitXCConverterStepOperationOperator getOperator() { return operator; } @@ -79,7 +71,6 @@ public class UnitXCConverterStepOperation extends AbstractUnitXConverterStep { /** * @return the operandA */ - @XmlJavaTypeAdapter(value=ModelJAXBObjectWrapAdapter.class) public UnitXConverterStepValueRead getOperandA() { return operandA; } @@ -94,7 +85,6 @@ public class UnitXCConverterStepOperation extends AbstractUnitXConverterStep { /** * @return the operandB */ - @XmlJavaTypeAdapter(value=ModelJAXBObjectWrapAdapter.class) public UnitXConverterStepValueRead getOperandB() { return operandB; } @@ -109,7 +99,6 @@ public class UnitXCConverterStepOperation extends AbstractUnitXConverterStep { /** * @return the result */ - @XmlJavaTypeAdapter(value=ModelJAXBObjectWrapAdapter.class) public UnitXConverterStepValueReadWrite getResult() { return result; } diff --git a/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/step/UnitXCConverterStepPowerOfTen.java b/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/step/UnitXCConverterStepPowerOfTen.java index ed57eed..f7449e0 100644 --- a/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/step/UnitXCConverterStepPowerOfTen.java +++ b/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/step/UnitXCConverterStepPowerOfTen.java @@ -23,12 +23,6 @@ package net.forwardfire.unitxc.model.step; -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; - -import net.forwardfire.unitxc.model.ModelJAXBInfoSet; -import net.forwardfire.unitxc.model.ModelJAXBObjectWrapAdapter; import net.forwardfire.unitxc.model.step.value.UnitXConverterStepValueRead; import net.forwardfire.unitxc.model.step.value.UnitXConverterStepValueReadWrite; @@ -38,7 +32,6 @@ import net.forwardfire.unitxc.model.step.value.UnitXConverterStepValueReadWrite; * @author Willem Cazander * @version 1.0 Oct 17, 2015 */ -@XmlRootElement(name=ModelJAXBInfoSet.Element.POWER_10) public class UnitXCConverterStepPowerOfTen extends AbstractUnitXConverterStep { private UnitXConverterStepValueRead operand; @@ -89,7 +82,6 @@ public class UnitXCConverterStepPowerOfTen extends AbstractUnitXConverterStep { /** * @return the exponent */ - @XmlAttribute public int getExponent() { return exponent; } @@ -104,7 +96,6 @@ public class UnitXCConverterStepPowerOfTen extends AbstractUnitXConverterStep { /** * @return the exponentReverse */ - @XmlAttribute public boolean isExponentReverse() { return exponentReverse; } @@ -119,7 +110,6 @@ public class UnitXCConverterStepPowerOfTen extends AbstractUnitXConverterStep { /** * @return the operand */ - @XmlJavaTypeAdapter(value=ModelJAXBObjectWrapAdapter.class) public UnitXConverterStepValueRead getOperand() { return operand; } @@ -134,7 +124,6 @@ public class UnitXCConverterStepPowerOfTen extends AbstractUnitXConverterStep { /** * @return the result */ - @XmlJavaTypeAdapter(value=ModelJAXBObjectWrapAdapter.class) public UnitXConverterStepValueReadWrite getResult() { return result; } diff --git a/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/step/UnitXCConverterStepReference.java b/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/step/UnitXCConverterStepReference.java index 3f6ed5b..4a410ca 100644 --- a/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/step/UnitXCConverterStepReference.java +++ b/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/step/UnitXCConverterStepReference.java @@ -25,10 +25,6 @@ package net.forwardfire.unitxc.model.step; import java.util.List; -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlRootElement; - -import net.forwardfire.unitxc.model.ModelJAXBInfoSet; import net.forwardfire.unitxc.model.UnitXCType; /** @@ -37,7 +33,6 @@ import net.forwardfire.unitxc.model.UnitXCType; * @author Willem Cazander * @version 1.0 Oct 7, 2016 */ -@XmlRootElement(name=ModelJAXBInfoSet.Element.REFERENCE) public class UnitXCConverterStepReference extends AbstractUnitXConverterStep { private String unitTypeId; @@ -61,7 +56,6 @@ public class UnitXCConverterStepReference extends AbstractUnitXConverterStep { /** * @return the unitTypeId */ - @XmlAttribute public String getUnitTypeId() { return unitTypeId; } @@ -76,7 +70,6 @@ public class UnitXCConverterStepReference extends AbstractUnitXConverterStep { /** * @return the toBaseSteps */ - @XmlAttribute public Boolean getToBaseSteps() { return toBaseSteps; } diff --git a/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/step/value/UnitXConverterStepValueNamedParameter.java b/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/step/value/UnitXConverterStepValueNamedParameter.java index 6c52411..887392f 100644 --- a/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/step/value/UnitXConverterStepValueNamedParameter.java +++ b/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/step/value/UnitXConverterStepValueNamedParameter.java @@ -23,10 +23,6 @@ package net.forwardfire.unitxc.model.step.value; -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlRootElement; - -import net.forwardfire.unitxc.model.ModelJAXBInfoSet; import net.forwardfire.unitxc.model.step.UnitXConverterStepContext; /** @@ -35,7 +31,6 @@ import net.forwardfire.unitxc.model.step.UnitXConverterStepContext; * @author Willem Cazander * @version 1.0 Apr 1, 2016 */ -@XmlRootElement(name=ModelJAXBInfoSet.Element.NAMED_PARAMETER) public class UnitXConverterStepValueNamedParameter implements UnitXConverterStepValueRead { private String parameterName; @@ -55,7 +50,6 @@ public class UnitXConverterStepValueNamedParameter implements UnitXConverterStep /** * @return the parameterName */ - @XmlAttribute public String getParameterName() { return parameterName; } diff --git a/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/step/value/UnitXConverterStepValueNamedVariable.java b/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/step/value/UnitXConverterStepValueNamedVariable.java index 9c7bdd4..0d37d54 100644 --- a/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/step/value/UnitXConverterStepValueNamedVariable.java +++ b/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/step/value/UnitXConverterStepValueNamedVariable.java @@ -23,10 +23,6 @@ package net.forwardfire.unitxc.model.step.value; -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlRootElement; - -import net.forwardfire.unitxc.model.ModelJAXBInfoSet; import net.forwardfire.unitxc.model.step.UnitXConverterStepContext; /** @@ -35,7 +31,6 @@ import net.forwardfire.unitxc.model.step.UnitXConverterStepContext; * @author Willem Cazander * @version 1.0 Apr 1, 2016 */ -@XmlRootElement(name=ModelJAXBInfoSet.Element.NAMED_VARIABLE) public class UnitXConverterStepValueNamedVariable implements UnitXConverterStepValueReadWrite { private Class valueType; @@ -62,7 +57,6 @@ public class UnitXConverterStepValueNamedVariable implements UnitXConverterStepV /** * @return the variableName */ - @XmlAttribute public String getVariableName() { return variableName; } @@ -77,7 +71,6 @@ public class UnitXConverterStepValueNamedVariable implements UnitXConverterStepV /** * @return the valueType */ - @XmlAttribute public Class getValueType() { return valueType; } diff --git a/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/step/value/UnitXConverterStepValueReferenceDouble.java b/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/step/value/UnitXConverterStepValueReferenceDouble.java index 1aebf49..69908eb 100644 --- a/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/step/value/UnitXConverterStepValueReferenceDouble.java +++ b/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/step/value/UnitXConverterStepValueReferenceDouble.java @@ -23,10 +23,6 @@ package net.forwardfire.unitxc.model.step.value; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlValue; - -import net.forwardfire.unitxc.model.ModelJAXBInfoSet; import net.forwardfire.unitxc.model.step.UnitXConverterStepContext; /** @@ -35,7 +31,6 @@ import net.forwardfire.unitxc.model.step.UnitXConverterStepContext; * @author Willem Cazander * @version 1.0 Apr 1, 2016 */ -@XmlRootElement(name=ModelJAXBInfoSet.Element.VALUE_DOUBLE) public class UnitXConverterStepValueReferenceDouble implements UnitXConverterStepValueReadWrite { private Double value; @@ -60,8 +55,6 @@ public class UnitXConverterStepValueReferenceDouble implements UnitXConverterSte /** * @return the value */ - //@XmlAttribute - @XmlValue public Double getValue() { return value; } diff --git a/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/step/value/UnitXConverterStepValueReferenceDoubleFraction.java b/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/step/value/UnitXConverterStepValueReferenceDoubleFraction.java index 0988454..9c4f09d 100644 --- a/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/step/value/UnitXConverterStepValueReferenceDoubleFraction.java +++ b/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/step/value/UnitXConverterStepValueReferenceDoubleFraction.java @@ -25,10 +25,6 @@ package net.forwardfire.unitxc.model.step.value; import java.math.BigDecimal; -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlRootElement; - -import net.forwardfire.unitxc.model.ModelJAXBInfoSet; import net.forwardfire.unitxc.model.step.UnitXConverterStepContext; /** @@ -37,7 +33,6 @@ import net.forwardfire.unitxc.model.step.UnitXConverterStepContext; * @author Willem Cazander * @version 1.0 Apr 1, 2016 */ -@XmlRootElement(name=ModelJAXBInfoSet.Element.VALUE_DOUBLE_FRACTION) public class UnitXConverterStepValueReferenceDoubleFraction implements UnitXConverterStepValueRead { private int numerator; @@ -60,7 +55,6 @@ public class UnitXConverterStepValueReferenceDoubleFraction implements UnitXConv /** * @return the numerator */ - @XmlAttribute public int getNumerator() { return numerator; } @@ -75,7 +69,6 @@ public class UnitXConverterStepValueReferenceDoubleFraction implements UnitXConv /** * @return the denominator */ - @XmlAttribute public int getDenominator() { return denominator; } diff --git a/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/step/value/UnitXConverterStepValueReferenceInteger.java b/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/step/value/UnitXConverterStepValueReferenceInteger.java index e4631da..e94eb3a 100644 --- a/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/step/value/UnitXConverterStepValueReferenceInteger.java +++ b/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/step/value/UnitXConverterStepValueReferenceInteger.java @@ -23,10 +23,6 @@ package net.forwardfire.unitxc.model.step.value; -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlRootElement; - -import net.forwardfire.unitxc.model.ModelJAXBInfoSet; import net.forwardfire.unitxc.model.step.UnitXConverterStepContext; /** @@ -35,7 +31,6 @@ import net.forwardfire.unitxc.model.step.UnitXConverterStepContext; * @author Willem Cazander * @version 1.0 Apr 1, 2016 */ -@XmlRootElement(name=ModelJAXBInfoSet.Element.VALUE_INTEGER) public class UnitXConverterStepValueReferenceInteger implements UnitXConverterStepValueReadWrite { private Integer value; @@ -60,7 +55,6 @@ public class UnitXConverterStepValueReferenceInteger implements UnitXConverterSt /** * @return the value */ - @XmlAttribute public Integer getValue() { return value; } diff --git a/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/step/value/UnitXConverterStepValueReferenceString.java b/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/step/value/UnitXConverterStepValueReferenceString.java index a1a6d81..c9a5879 100644 --- a/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/step/value/UnitXConverterStepValueReferenceString.java +++ b/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/step/value/UnitXConverterStepValueReferenceString.java @@ -23,10 +23,6 @@ package net.forwardfire.unitxc.model.step.value; -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlRootElement; - -import net.forwardfire.unitxc.model.ModelJAXBInfoSet; import net.forwardfire.unitxc.model.step.UnitXConverterStepContext; /** @@ -35,7 +31,6 @@ import net.forwardfire.unitxc.model.step.UnitXConverterStepContext; * @author Willem Cazander * @version 1.0 Apr 1, 2016 */ -@XmlRootElement(name=ModelJAXBInfoSet.Element.VALUE_STRING) public class UnitXConverterStepValueReferenceString implements UnitXConverterStepValueReadWrite { private String value; @@ -60,7 +55,6 @@ public class UnitXConverterStepValueReferenceString implements UnitXConverterSte /** * @return the value */ - @XmlAttribute public String getValue() { return value; } diff --git a/ff-unitxc-converter/src/test/java/net/forwardfire/unitxc/UnitXCConverterStepTest.java b/ff-unitxc-converter/src/test/java/net/forwardfire/unitxc/UnitXCConverterStepTest.java index 30ebd30..31dc5aa 100644 --- a/ff-unitxc-converter/src/test/java/net/forwardfire/unitxc/UnitXCConverterStepTest.java +++ b/ff-unitxc-converter/src/test/java/net/forwardfire/unitxc/UnitXCConverterStepTest.java @@ -48,7 +48,6 @@ import net.forwardfire.unitxc.UnitXCFactory; import net.forwardfire.unitxc.UnitXCManager; import net.forwardfire.unitxc.converter.UnitXConverterParameterValue; import net.forwardfire.unitxc.model.UnitXCType; -import net.forwardfire.unitxc.model.ModelJAXBMarshaller; import net.forwardfire.unitxc.model.UnitXCGroup; import net.forwardfire.unitxc.model.UnitXConverterResult; import net.forwardfire.unitxc.model.UnitXConverterResultStep; @@ -57,7 +56,6 @@ public class UnitXCConverterStepTest { @Test public void testFac() throws Exception { - ModelJAXBMarshaller jaxbDriver = new ModelJAXBMarshaller(); UnitXCManager unitManager = UnitXCFactory.createManager(); assertNotNull(unitManager); @@ -82,8 +80,7 @@ public class UnitXCConverterStepTest { System.out.println("20m/s = "+result2.getResultValue()+" km/h"); UnitXConverterResult result = unitManager.getConverter().convertStepped(211.0, "k°F", "m°C"); - jaxbDriver.getUnitXConverterResult().marshal(result, System.out); - System.out.println(""); + System.out.println("result: "+result); //result = unitManager.getConverter().convertStepped(10.763, "ft²", "in²"); //xmlDriver.marshal(result, System.out); @@ -107,8 +104,7 @@ public class UnitXCConverterStepTest { Map para = new HashMap<>(); para.put("speed_time", new UnitXConverterParameterValue(2, unitManager.getUnitType("minute"))); result = unitManager.getConverter().convertStepped(50, "km/h", "mm",para); - System.out.println("CONVERT-RESULT:"); - jaxbDriver.getUnitXConverterResult().marshal(result, System.out); + System.out.println("CONVERT-RESULT: "+result); Configuration config = new Configuration();