Package org.openbravo.dal.xml
Class XMLTypeConverter
- java.lang.Object
-
- org.openbravo.dal.xml.XMLTypeConverter
-
- All Implemented Interfaces:
OBProvidable
,OBSingleton
public class XMLTypeConverter extends Object implements OBSingleton
Converts primitive types to a XML representation and back. NOTE: class is deprecated, use thePrimitiveDomainType
interface which can be obtained from theProperty.getDomainType()
.- Author:
- mtaal
-
-
Constructor Summary
Constructors Constructor Description XMLTypeConverter()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> T
fromXML(Class<T> targetClass, String xml)
Converts an xml String back to a primitive type java Object.static XMLTypeConverter
getInstance()
static void
setInstance(XMLTypeConverter instance)
String
toXML(Boolean b)
String
toXML(Number number)
String
toXML(Object o)
Returns an empty string if the object is null.String
toXML(String str)
String
toXML(Date dt)
Returns the String format of aDate
, the standard xml format is used: yyyy-MM-dd'T'HH:mm:ss.S'Z'String
toXMLSchemaType(Class<?> targetClass)
-
-
-
Method Detail
-
getInstance
public static XMLTypeConverter getInstance()
-
setInstance
public static void setInstance(XMLTypeConverter instance)
-
toXML
public String toXML(Date dt)
Returns the String format of aDate
, the standard xml format is used: yyyy-MM-dd'T'HH:mm:ss.S'Z'- Parameters:
dt
- the Date to format- Returns:
- the String representation of the Date in xml format
-
toXML
public String toXML(Number number)
- Returns:
- numbers are converted using the Number.toString method
-
toXML
public String toXML(Object o)
Returns an empty string if the object is null. In other cases the call is forwarded to one of the other toXML methods in this class.- Parameters:
o
- the value to convert to a String XML representation- Returns:
- the String XML representation
-
fromXML
public <T> T fromXML(Class<T> targetClass, String xml)
Converts an xml String back to a primitive type java Object. If the xml string has lenght zero then null is returned.- Parameters:
targetClass
- the class of the primitive type (e.g. String.class, Float.class)xml
- the xml string to convert- Returns:
- the converted object
-
-