From b3d6daee177792988e38124f3a9f0686e1971ed6 Mon Sep 17 00:00:00 2001 From: Emanuela Epure <67077116+emanuelaepure10@users.noreply.github.com> Date: Mon, 6 May 2024 13:28:30 +0200 Subject: [PATCH] feat: use appropriate methods to convert the numbers in XML Conversion of the numbers using appropriate methods of each different type. ING-3965 --- .../eu.esdihumboldt.hale.io.gml/plugin.xml | 36 +++++++++++++++ .../internal/simpletype/SimpleTypeUtil.java | 12 +++++ .../converters/BigDecimalToXmlDecimal.java | 46 +++++++++++++++++++ .../converters/BigIntegerToXmlBigInteger.java | 40 ++++++++++++++++ .../converters/DoubleToXmlDouble.java | 38 +++++++++++++++ .../converters/FloatToXmlFloat.java | 38 +++++++++++++++ .../converters/IntegerToXmlInteger.java | 38 +++++++++++++++ .../simpletype/converters/LongToXmlLong.java | 38 +++++++++++++++ .../converters/XmlDecimalToBigDecimal.java | 40 ++++++++++++++++ .../converters/XmlDoubleToDouble.java | 38 +++++++++++++++ .../converters/XmlFloatToFloat.java | 38 +++++++++++++++ .../converters/XmlIntegerToBigInteger.java | 40 ++++++++++++++++ .../converters/XmlIntegerToInteger.java | 38 +++++++++++++++ .../simpletype/converters/XmlLongToLong.java | 38 +++++++++++++++ 14 files changed, 518 insertions(+) create mode 100644 io/plugins/eu.esdihumboldt.hale.io.gml/src/eu/esdihumboldt/hale/io/gml/internal/simpletype/converters/BigDecimalToXmlDecimal.java create mode 100644 io/plugins/eu.esdihumboldt.hale.io.gml/src/eu/esdihumboldt/hale/io/gml/internal/simpletype/converters/BigIntegerToXmlBigInteger.java create mode 100644 io/plugins/eu.esdihumboldt.hale.io.gml/src/eu/esdihumboldt/hale/io/gml/internal/simpletype/converters/DoubleToXmlDouble.java create mode 100644 io/plugins/eu.esdihumboldt.hale.io.gml/src/eu/esdihumboldt/hale/io/gml/internal/simpletype/converters/FloatToXmlFloat.java create mode 100644 io/plugins/eu.esdihumboldt.hale.io.gml/src/eu/esdihumboldt/hale/io/gml/internal/simpletype/converters/IntegerToXmlInteger.java create mode 100644 io/plugins/eu.esdihumboldt.hale.io.gml/src/eu/esdihumboldt/hale/io/gml/internal/simpletype/converters/LongToXmlLong.java create mode 100644 io/plugins/eu.esdihumboldt.hale.io.gml/src/eu/esdihumboldt/hale/io/gml/internal/simpletype/converters/XmlDecimalToBigDecimal.java create mode 100644 io/plugins/eu.esdihumboldt.hale.io.gml/src/eu/esdihumboldt/hale/io/gml/internal/simpletype/converters/XmlDoubleToDouble.java create mode 100644 io/plugins/eu.esdihumboldt.hale.io.gml/src/eu/esdihumboldt/hale/io/gml/internal/simpletype/converters/XmlFloatToFloat.java create mode 100644 io/plugins/eu.esdihumboldt.hale.io.gml/src/eu/esdihumboldt/hale/io/gml/internal/simpletype/converters/XmlIntegerToBigInteger.java create mode 100644 io/plugins/eu.esdihumboldt.hale.io.gml/src/eu/esdihumboldt/hale/io/gml/internal/simpletype/converters/XmlIntegerToInteger.java create mode 100644 io/plugins/eu.esdihumboldt.hale.io.gml/src/eu/esdihumboldt/hale/io/gml/internal/simpletype/converters/XmlLongToLong.java diff --git a/io/plugins/eu.esdihumboldt.hale.io.gml/plugin.xml b/io/plugins/eu.esdihumboldt.hale.io.gml/plugin.xml index cb3df0dd0a..f1d4f52de3 100644 --- a/io/plugins/eu.esdihumboldt.hale.io.gml/plugin.xml +++ b/io/plugins/eu.esdihumboldt.hale.io.gml/plugin.xml @@ -1533,6 +1533,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/io/plugins/eu.esdihumboldt.hale.io.gml/src/eu/esdihumboldt/hale/io/gml/internal/simpletype/SimpleTypeUtil.java b/io/plugins/eu.esdihumboldt.hale.io.gml/src/eu/esdihumboldt/hale/io/gml/internal/simpletype/SimpleTypeUtil.java index 32d403a186..24c6b5070e 100644 --- a/io/plugins/eu.esdihumboldt.hale.io.gml/src/eu/esdihumboldt/hale/io/gml/internal/simpletype/SimpleTypeUtil.java +++ b/io/plugins/eu.esdihumboldt.hale.io.gml/src/eu/esdihumboldt/hale/io/gml/internal/simpletype/SimpleTypeUtil.java @@ -29,6 +29,11 @@ import org.apache.xmlbeans.XmlAnySimpleType; import org.apache.xmlbeans.XmlDate; import org.apache.xmlbeans.XmlDateTime; +import org.apache.xmlbeans.XmlDecimal; +import org.apache.xmlbeans.XmlDouble; +import org.apache.xmlbeans.XmlFloat; +import org.apache.xmlbeans.XmlInteger; +import org.apache.xmlbeans.XmlLong; import org.apache.xmlbeans.XmlTime; import org.springframework.core.convert.ConversionException; import org.springframework.core.convert.ConversionService; @@ -62,6 +67,12 @@ public class SimpleTypeUtil { TYPE_MAP.put("dateTime", XmlDateTime.class); //$NON-NLS-1$ TYPE_MAP.put("date", XmlDate.class); //$NON-NLS-1$ TYPE_MAP.put("time", XmlTime.class); //$NON-NLS-1$ + + TYPE_MAP.put("integer", XmlInteger.class); //$NON-NLS-1$ + TYPE_MAP.put("float", XmlFloat.class); //$NON-NLS-1$ + TYPE_MAP.put("double", XmlDouble.class); //$NON-NLS-1$ + TYPE_MAP.put("long", XmlLong.class); //$NON-NLS-1$ + TYPE_MAP.put("decimal", XmlDecimal.class); //$NON-NLS-1$ } /** @@ -111,6 +122,7 @@ else if (simpleTypeValue instanceof XmlDateTime) { xmlDateTime.setGDateValue(gdate); } + // Numbers should be handled here if (simpleTypeValue != null) { return simpleTypeValue.getStringValue(); } diff --git a/io/plugins/eu.esdihumboldt.hale.io.gml/src/eu/esdihumboldt/hale/io/gml/internal/simpletype/converters/BigDecimalToXmlDecimal.java b/io/plugins/eu.esdihumboldt.hale.io.gml/src/eu/esdihumboldt/hale/io/gml/internal/simpletype/converters/BigDecimalToXmlDecimal.java new file mode 100644 index 0000000000..93a0aebba5 --- /dev/null +++ b/io/plugins/eu.esdihumboldt.hale.io.gml/src/eu/esdihumboldt/hale/io/gml/internal/simpletype/converters/BigDecimalToXmlDecimal.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2012 Data Harmonisation Panel + * + * All rights reserved. This program and the accompanying materials are made + * available under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the License, + * or (at your option) any later version. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this distribution. If not, see . + * + * Contributors: + * HUMBOLDT EU Integrated Project #030962 + * Data Harmonisation Panel + */ + +package eu.esdihumboldt.hale.io.gml.internal.simpletype.converters; + +import java.math.BigDecimal; + +import org.apache.xmlbeans.XmlDecimal; +import org.springframework.core.convert.converter.Converter; + +/** + * Convert xs:BigDecimal to {@link XmlDecimal} + */ +public class BigDecimalToXmlDecimal implements Converter { + + /** + * @see Converter#convert(Object) + */ + @Override + public XmlDecimal convert(BigDecimal value) { + if (value == null) { + return null; + } + + // Convert BigDecimal to string + String stringValue = value.toPlainString(); + + XmlDecimal xmlDecimalValue = XmlDecimal.Factory.newInstance(); + xmlDecimalValue.setStringValue(stringValue); + return xmlDecimalValue; + } + +} diff --git a/io/plugins/eu.esdihumboldt.hale.io.gml/src/eu/esdihumboldt/hale/io/gml/internal/simpletype/converters/BigIntegerToXmlBigInteger.java b/io/plugins/eu.esdihumboldt.hale.io.gml/src/eu/esdihumboldt/hale/io/gml/internal/simpletype/converters/BigIntegerToXmlBigInteger.java new file mode 100644 index 0000000000..c232b60774 --- /dev/null +++ b/io/plugins/eu.esdihumboldt.hale.io.gml/src/eu/esdihumboldt/hale/io/gml/internal/simpletype/converters/BigIntegerToXmlBigInteger.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2012 Data Harmonisation Panel + * + * All rights reserved. This program and the accompanying materials are made + * available under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the License, + * or (at your option) any later version. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this distribution. If not, see . + * + * Contributors: + * HUMBOLDT EU Integrated Project #030962 + * Data Harmonisation Panel + */ + +package eu.esdihumboldt.hale.io.gml.internal.simpletype.converters; + +import java.math.BigInteger; + +import org.apache.xmlbeans.XmlInteger; +import org.springframework.core.convert.converter.Converter; + +/** + * Convert xs:BigInteger to {@link XmlInteger} + */ +public class BigIntegerToXmlBigInteger implements Converter { + + /** + * @see Converter#convert(Object) + */ + @Override + public XmlInteger convert(BigInteger value) { + if (value == null) { + return null; + } + return XmlInteger.Factory.newValue(value); + } + +} diff --git a/io/plugins/eu.esdihumboldt.hale.io.gml/src/eu/esdihumboldt/hale/io/gml/internal/simpletype/converters/DoubleToXmlDouble.java b/io/plugins/eu.esdihumboldt.hale.io.gml/src/eu/esdihumboldt/hale/io/gml/internal/simpletype/converters/DoubleToXmlDouble.java new file mode 100644 index 0000000000..bb659b14c6 --- /dev/null +++ b/io/plugins/eu.esdihumboldt.hale.io.gml/src/eu/esdihumboldt/hale/io/gml/internal/simpletype/converters/DoubleToXmlDouble.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2012 Data Harmonisation Panel + * + * All rights reserved. This program and the accompanying materials are made + * available under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the License, + * or (at your option) any later version. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this distribution. If not, see . + * + * Contributors: + * HUMBOLDT EU Integrated Project #030962 + * Data Harmonisation Panel + */ + +package eu.esdihumboldt.hale.io.gml.internal.simpletype.converters; + +import org.apache.xmlbeans.XmlDouble; +import org.springframework.core.convert.converter.Converter; + +/** + * Convert xs:Double to {@link XmlDouble} + */ +public class DoubleToXmlDouble implements Converter { + + /** + * @see Converter#convert(Object) + */ + @Override + public XmlDouble convert(Double value) { + if (value == null) { + return null; + } + return XmlDouble.Factory.newValue(value); + } + +} diff --git a/io/plugins/eu.esdihumboldt.hale.io.gml/src/eu/esdihumboldt/hale/io/gml/internal/simpletype/converters/FloatToXmlFloat.java b/io/plugins/eu.esdihumboldt.hale.io.gml/src/eu/esdihumboldt/hale/io/gml/internal/simpletype/converters/FloatToXmlFloat.java new file mode 100644 index 0000000000..8d7e26e9db --- /dev/null +++ b/io/plugins/eu.esdihumboldt.hale.io.gml/src/eu/esdihumboldt/hale/io/gml/internal/simpletype/converters/FloatToXmlFloat.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2012 Data Harmonisation Panel + * + * All rights reserved. This program and the accompanying materials are made + * available under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the License, + * or (at your option) any later version. + * + * You should have received a copy of the GNU Lesser General Public License + * aFloat with this distribution. If not, see . + * + * Contributors: + * HUMBOLDT EU Integrated Project #030962 + * Data Harmonisation Panel + */ + +package eu.esdihumboldt.hale.io.gml.internal.simpletype.converters; + +import org.apache.xmlbeans.XmlFloat; +import org.springframework.core.convert.converter.Converter; + +/** + * Convert xs:Float to {@link XmlFloat} + */ +public class FloatToXmlFloat implements Converter { + + /** + * @see Converter#convert(Object) + */ + @Override + public XmlFloat convert(Float value) { + if (value == null) { + return null; + } + return XmlFloat.Factory.newValue(value); + } + +} diff --git a/io/plugins/eu.esdihumboldt.hale.io.gml/src/eu/esdihumboldt/hale/io/gml/internal/simpletype/converters/IntegerToXmlInteger.java b/io/plugins/eu.esdihumboldt.hale.io.gml/src/eu/esdihumboldt/hale/io/gml/internal/simpletype/converters/IntegerToXmlInteger.java new file mode 100644 index 0000000000..a5090e15f1 --- /dev/null +++ b/io/plugins/eu.esdihumboldt.hale.io.gml/src/eu/esdihumboldt/hale/io/gml/internal/simpletype/converters/IntegerToXmlInteger.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2012 Data Harmonisation Panel + * + * All rights reserved. This program and the accompanying materials are made + * available under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the License, + * or (at your option) any later version. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this distribution. If not, see . + * + * Contributors: + * HUMBOLDT EU Integrated Project #030962 + * Data Harmonisation Panel + */ + +package eu.esdihumboldt.hale.io.gml.internal.simpletype.converters; + +import org.apache.xmlbeans.XmlInteger; +import org.springframework.core.convert.converter.Converter; + +/** + * Convert xs:Integer to {@link XmlInteger} + */ +public class IntegerToXmlInteger implements Converter { + + /** + * @see Converter#convert(Object) + */ + @Override + public XmlInteger convert(Integer value) { + if (value == null) { + return null; + } + return XmlInteger.Factory.newValue(value); + } + +} diff --git a/io/plugins/eu.esdihumboldt.hale.io.gml/src/eu/esdihumboldt/hale/io/gml/internal/simpletype/converters/LongToXmlLong.java b/io/plugins/eu.esdihumboldt.hale.io.gml/src/eu/esdihumboldt/hale/io/gml/internal/simpletype/converters/LongToXmlLong.java new file mode 100644 index 0000000000..7f6bcb17e6 --- /dev/null +++ b/io/plugins/eu.esdihumboldt.hale.io.gml/src/eu/esdihumboldt/hale/io/gml/internal/simpletype/converters/LongToXmlLong.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2012 Data Harmonisation Panel + * + * All rights reserved. This program and the accompanying materials are made + * available under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the License, + * or (at your option) any later version. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this distribution. If not, see . + * + * Contributors: + * HUMBOLDT EU Integrated Project #030962 + * Data Harmonisation Panel + */ + +package eu.esdihumboldt.hale.io.gml.internal.simpletype.converters; + +import org.apache.xmlbeans.XmlLong; +import org.springframework.core.convert.converter.Converter; + +/** + * Convert xs:Long to {@link XmlLong} + */ +public class LongToXmlLong implements Converter { + + /** + * @see Converter#convert(Object) + */ + @Override + public XmlLong convert(Long value) { + if (value == null) { + return null; + } + return XmlLong.Factory.newValue(value); + } + +} diff --git a/io/plugins/eu.esdihumboldt.hale.io.gml/src/eu/esdihumboldt/hale/io/gml/internal/simpletype/converters/XmlDecimalToBigDecimal.java b/io/plugins/eu.esdihumboldt.hale.io.gml/src/eu/esdihumboldt/hale/io/gml/internal/simpletype/converters/XmlDecimalToBigDecimal.java new file mode 100644 index 0000000000..32a6c1ec34 --- /dev/null +++ b/io/plugins/eu.esdihumboldt.hale.io.gml/src/eu/esdihumboldt/hale/io/gml/internal/simpletype/converters/XmlDecimalToBigDecimal.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2012 Data Harmonisation Panel + * + * All rights reserved. This program and the accompanying materials are made + * available under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the License, + * or (at your option) any later version. + * + * You should have received a copy of the GNU Lesser General Public License + * aDecimal with this distribution. If not, see . + * + * Contributors: + * HUMBOLDT EU Integrated Project #030962 + * Data Harmonisation Panel + */ + +package eu.esdihumboldt.hale.io.gml.internal.simpletype.converters; + +import java.math.BigDecimal; + +import org.apache.xmlbeans.XmlDecimal; +import org.springframework.core.convert.converter.Converter; + +/** + * Convert xs:XmlDecimal to {@link BigDecimal} + */ +public class XmlDecimalToBigDecimal implements Converter { + + /** + * @see Converter#convert(Object) + */ + @Override + public BigDecimal convert(XmlDecimal value) { + if (value == null) { + return null; + } + return value.getBigDecimalValue(); + } + +} diff --git a/io/plugins/eu.esdihumboldt.hale.io.gml/src/eu/esdihumboldt/hale/io/gml/internal/simpletype/converters/XmlDoubleToDouble.java b/io/plugins/eu.esdihumboldt.hale.io.gml/src/eu/esdihumboldt/hale/io/gml/internal/simpletype/converters/XmlDoubleToDouble.java new file mode 100644 index 0000000000..4affd31738 --- /dev/null +++ b/io/plugins/eu.esdihumboldt.hale.io.gml/src/eu/esdihumboldt/hale/io/gml/internal/simpletype/converters/XmlDoubleToDouble.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2012 Data Harmonisation Panel + * + * All rights reserved. This program and the accompanying materials are made + * available under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the License, + * or (at your option) any later version. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this distribution. If not, see . + * + * Contributors: + * HUMBOLDT EU Integrated Project #030962 + * Data Harmonisation Panel + */ + +package eu.esdihumboldt.hale.io.gml.internal.simpletype.converters; + +import org.apache.xmlbeans.XmlDouble; +import org.springframework.core.convert.converter.Converter; + +/** + * Convert xs:XmlDouble to {@link Double} + */ +public class XmlDoubleToDouble implements Converter { + + /** + * @see Converter#convert(Object) + */ + @Override + public Double convert(XmlDouble value) { + if (value == null) { + return null; + } + return value.getDoubleValue(); + } + +} diff --git a/io/plugins/eu.esdihumboldt.hale.io.gml/src/eu/esdihumboldt/hale/io/gml/internal/simpletype/converters/XmlFloatToFloat.java b/io/plugins/eu.esdihumboldt.hale.io.gml/src/eu/esdihumboldt/hale/io/gml/internal/simpletype/converters/XmlFloatToFloat.java new file mode 100644 index 0000000000..d1a23e618c --- /dev/null +++ b/io/plugins/eu.esdihumboldt.hale.io.gml/src/eu/esdihumboldt/hale/io/gml/internal/simpletype/converters/XmlFloatToFloat.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2012 Data Harmonisation Panel + * + * All rights reserved. This program and the accompanying materials are made + * available under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the License, + * or (at your option) any later version. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this distribution. If not, see . + * + * Contributors: + * HUMBOLDT EU Integrated Project #030962 + * Data Harmonisation Panel + */ + +package eu.esdihumboldt.hale.io.gml.internal.simpletype.converters; + +import org.apache.xmlbeans.XmlFloat; +import org.springframework.core.convert.converter.Converter; + +/** + * Convert xs:XmlFloat to {@link Float} + */ +public class XmlFloatToFloat implements Converter { + + /** + * @see Converter#convert(Object) + */ + @Override + public Float convert(XmlFloat value) { + if (value == null) { + return null; + } + return value.getFloatValue(); + } + +} diff --git a/io/plugins/eu.esdihumboldt.hale.io.gml/src/eu/esdihumboldt/hale/io/gml/internal/simpletype/converters/XmlIntegerToBigInteger.java b/io/plugins/eu.esdihumboldt.hale.io.gml/src/eu/esdihumboldt/hale/io/gml/internal/simpletype/converters/XmlIntegerToBigInteger.java new file mode 100644 index 0000000000..a85e69375e --- /dev/null +++ b/io/plugins/eu.esdihumboldt.hale.io.gml/src/eu/esdihumboldt/hale/io/gml/internal/simpletype/converters/XmlIntegerToBigInteger.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2012 Data Harmonisation Panel + * + * All rights reserved. This program and the accompanying materials are made + * available under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the License, + * or (at your option) any later version. + * + * You should have received a copy of the GNU Lesser General Public License + * aInteger with this distribution. If not, see . + * + * Contributors: + * HUMBOLDT EU Integrated Project #030962 + * Data Harmonisation Panel + */ + +package eu.esdihumboldt.hale.io.gml.internal.simpletype.converters; + +import java.math.BigInteger; + +import org.apache.xmlbeans.XmlInteger; +import org.springframework.core.convert.converter.Converter; + +/** + * Convert xs:XmlInteger to {@link BigInteger} + */ +public class XmlIntegerToBigInteger implements Converter { + + /** + * @see Converter#convert(Object) + */ + @Override + public BigInteger convert(XmlInteger value) { + if (value == null) { + return null; + } + return value.getBigIntegerValue(); + } + +} diff --git a/io/plugins/eu.esdihumboldt.hale.io.gml/src/eu/esdihumboldt/hale/io/gml/internal/simpletype/converters/XmlIntegerToInteger.java b/io/plugins/eu.esdihumboldt.hale.io.gml/src/eu/esdihumboldt/hale/io/gml/internal/simpletype/converters/XmlIntegerToInteger.java new file mode 100644 index 0000000000..cc139d4794 --- /dev/null +++ b/io/plugins/eu.esdihumboldt.hale.io.gml/src/eu/esdihumboldt/hale/io/gml/internal/simpletype/converters/XmlIntegerToInteger.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2012 Data Harmonisation Panel + * + * All rights reserved. This program and the accompanying materials are made + * available under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the License, + * or (at your option) any later version. + * + * You should have received a copy of the GNU Lesser General Public License + * aInteger with this distribution. If not, see . + * + * Contributors: + * HUMBOLDT EU Integrated Project #030962 + * Data Harmonisation Panel + */ + +package eu.esdihumboldt.hale.io.gml.internal.simpletype.converters; + +import org.apache.xmlbeans.XmlInteger; +import org.springframework.core.convert.converter.Converter; + +/** + * Convert xs:XmlInteger to {@link Integer} + */ +public class XmlIntegerToInteger implements Converter { + + /** + * @see Converter#convert(Object) + */ + @Override + public Integer convert(XmlInteger value) { + if (value == null) { + return null; + } + return value.getBigIntegerValue().intValue(); + } + +} diff --git a/io/plugins/eu.esdihumboldt.hale.io.gml/src/eu/esdihumboldt/hale/io/gml/internal/simpletype/converters/XmlLongToLong.java b/io/plugins/eu.esdihumboldt.hale.io.gml/src/eu/esdihumboldt/hale/io/gml/internal/simpletype/converters/XmlLongToLong.java new file mode 100644 index 0000000000..5309136e8d --- /dev/null +++ b/io/plugins/eu.esdihumboldt.hale.io.gml/src/eu/esdihumboldt/hale/io/gml/internal/simpletype/converters/XmlLongToLong.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2012 Data Harmonisation Panel + * + * All rights reserved. This program and the accompanying materials are made + * available under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the License, + * or (at your option) any later version. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this distribution. If not, see . + * + * Contributors: + * HUMBOLDT EU Integrated Project #030962 + * Data Harmonisation Panel + */ + +package eu.esdihumboldt.hale.io.gml.internal.simpletype.converters; + +import org.apache.xmlbeans.XmlLong; +import org.springframework.core.convert.converter.Converter; + +/** + * Convert xs:XmlLong to {@link Long} + */ +public class XmlLongToLong implements Converter { + + /** + * @see Converter#convert(Object) + */ + @Override + public Long convert(XmlLong value) { + if (value == null) { + return null; + } + return value.getLongValue(); + } + +}