-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: use appropriate methods to convert the numbers in XML
Conversion of the numbers using appropriate methods of each different type. ING-3965
- Loading branch information
1 parent
e2c5dd5
commit 4b3eb6c
Showing
12 changed files
with
432 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
...rc/eu/esdihumboldt/hale/io/gml/internal/simpletype/converters/BigDecimalToXmlDecimal.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <http://www.gnu.org/licenses/>. | ||
* | ||
* Contributors: | ||
* HUMBOLDT EU Integrated Project #030962 | ||
* Data Harmonisation Panel <http://www.dhpanel.eu> | ||
*/ | ||
|
||
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<BigDecimal, XmlDecimal> { | ||
|
||
/** | ||
* @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; | ||
} | ||
|
||
} |
38 changes: 38 additions & 0 deletions
38
...gml/src/eu/esdihumboldt/hale/io/gml/internal/simpletype/converters/DoubleToXmlDouble.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <http://www.gnu.org/licenses/>. | ||
* | ||
* Contributors: | ||
* HUMBOLDT EU Integrated Project #030962 | ||
* Data Harmonisation Panel <http://www.dhpanel.eu> | ||
*/ | ||
|
||
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<Double, XmlDouble> { | ||
|
||
/** | ||
* @see Converter#convert(Object) | ||
*/ | ||
@Override | ||
public XmlDouble convert(Double value) { | ||
if (value == null) { | ||
return null; | ||
} | ||
return XmlDouble.Factory.newValue(value); | ||
} | ||
|
||
} |
38 changes: 38 additions & 0 deletions
38
...o.gml/src/eu/esdihumboldt/hale/io/gml/internal/simpletype/converters/FloatToXmlFloat.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <http://www.gnu.org/licenses/>. | ||
* | ||
* Contributors: | ||
* HUMBOLDT EU Integrated Project #030962 | ||
* Data Harmonisation Panel <http://www.dhpanel.eu> | ||
*/ | ||
|
||
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<Float, XmlFloat> { | ||
|
||
/** | ||
* @see Converter#convert(Object) | ||
*/ | ||
@Override | ||
public XmlFloat convert(Float value) { | ||
if (value == null) { | ||
return null; | ||
} | ||
return XmlFloat.Factory.newValue(value); | ||
} | ||
|
||
} |
38 changes: 38 additions & 0 deletions
38
...l/src/eu/esdihumboldt/hale/io/gml/internal/simpletype/converters/IntegerToXmlInteger.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <http://www.gnu.org/licenses/>. | ||
* | ||
* Contributors: | ||
* HUMBOLDT EU Integrated Project #030962 | ||
* Data Harmonisation Panel <http://www.dhpanel.eu> | ||
*/ | ||
|
||
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<Integer, XmlInteger> { | ||
|
||
/** | ||
* @see Converter#convert(Object) | ||
*/ | ||
@Override | ||
public XmlInteger convert(Integer value) { | ||
if (value == null) { | ||
return null; | ||
} | ||
return XmlInteger.Factory.newValue(value); | ||
} | ||
|
||
} |
38 changes: 38 additions & 0 deletions
38
....io.gml/src/eu/esdihumboldt/hale/io/gml/internal/simpletype/converters/LongToXmlLong.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <http://www.gnu.org/licenses/>. | ||
* | ||
* Contributors: | ||
* HUMBOLDT EU Integrated Project #030962 | ||
* Data Harmonisation Panel <http://www.dhpanel.eu> | ||
*/ | ||
|
||
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<Long, XmlLong> { | ||
|
||
/** | ||
* @see Converter#convert(Object) | ||
*/ | ||
@Override | ||
public XmlLong convert(Long value) { | ||
if (value == null) { | ||
return null; | ||
} | ||
return XmlLong.Factory.newValue(value); | ||
} | ||
|
||
} |
40 changes: 40 additions & 0 deletions
40
...rc/eu/esdihumboldt/hale/io/gml/internal/simpletype/converters/XmlDecimalToBigDecimal.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <http://www.gnu.org/licenses/>. | ||
* | ||
* Contributors: | ||
* HUMBOLDT EU Integrated Project #030962 | ||
* Data Harmonisation Panel <http://www.dhpanel.eu> | ||
*/ | ||
|
||
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<XmlDecimal, BigDecimal> { | ||
|
||
/** | ||
* @see Converter#convert(Object) | ||
*/ | ||
@Override | ||
public BigDecimal convert(XmlDecimal value) { | ||
if (value == null) { | ||
return null; | ||
} | ||
return value.getBigDecimalValue(); | ||
} | ||
|
||
} |
38 changes: 38 additions & 0 deletions
38
...gml/src/eu/esdihumboldt/hale/io/gml/internal/simpletype/converters/XmlDoubleToDouble.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <http://www.gnu.org/licenses/>. | ||
* | ||
* Contributors: | ||
* HUMBOLDT EU Integrated Project #030962 | ||
* Data Harmonisation Panel <http://www.dhpanel.eu> | ||
*/ | ||
|
||
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<XmlDouble, Double> { | ||
|
||
/** | ||
* @see Converter#convert(Object) | ||
*/ | ||
@Override | ||
public Double convert(XmlDouble value) { | ||
if (value == null) { | ||
return null; | ||
} | ||
return value.getDoubleValue(); | ||
} | ||
|
||
} |
38 changes: 38 additions & 0 deletions
38
...o.gml/src/eu/esdihumboldt/hale/io/gml/internal/simpletype/converters/XmlFloatToFloat.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <http://www.gnu.org/licenses/>. | ||
* | ||
* Contributors: | ||
* HUMBOLDT EU Integrated Project #030962 | ||
* Data Harmonisation Panel <http://www.dhpanel.eu> | ||
*/ | ||
|
||
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<XmlFloat, Float> { | ||
|
||
/** | ||
* @see Converter#convert(Object) | ||
*/ | ||
@Override | ||
public Float convert(XmlFloat value) { | ||
if (value == null) { | ||
return null; | ||
} | ||
return value.getFloatValue(); | ||
} | ||
|
||
} |
Oops, something went wrong.