com.evolveum.midpoint.prism.xml
Class XmlTypeConverter
java.lang.Object
com.evolveum.midpoint.prism.xml.XmlTypeConverter
public class XmlTypeConverter
- extends Object
Simple implementation that converts XSD primitive types to Java (and vice
versa).
It convert type names (xsd types to java classes) and also the values.
The implementation is very simple now. In fact just a bunch of ifs. We don't
need much more now. If more complex thing will be needed, we will extend the
implementation later.
- Author:
- Radovan Semancik
Method Summary |
static void |
appendBelowNode(Object val,
QName xsdType,
QName name,
Node parentNode,
boolean recordType)
|
static boolean |
canConvert(Class<?> clazz)
|
static boolean |
canConvert(QName xsdType)
|
static List<Object> |
convertValueElementAsList(Element valueElement)
|
static
|
convertValueElementAsList(Element valueElement,
Class<T> type)
|
static List<?> |
convertValueElementAsList(Element valueElement,
QName xsdType)
|
static
|
convertValueElementAsList(NodeList valueNodes,
Class<T> type)
|
static
|
convertValueElementAsScalar(Element valueElement,
Class<T> type)
|
static Object |
convertValueElementAsScalar(Element valueElement,
QName xsdType)
|
static XMLGregorianCalendar |
createXMLGregorianCalendar(GregorianCalendar cal)
|
static XMLGregorianCalendar |
createXMLGregorianCalendar(int year,
int month,
int day,
int hour,
int minute,
int second)
|
static XMLGregorianCalendar |
createXMLGregorianCalendar(int year,
int month,
int day,
int hour,
int minute,
int second,
int millisecond,
int timezone)
|
static XMLGregorianCalendar |
createXMLGregorianCalendar(long timeInMillis)
|
static Object |
toJavaValue(Element xmlElement)
Expects type information in xsi:type |
static
|
toJavaValue(Element xmlElement,
Class<T> type)
|
static Object |
toJavaValue(Element xmlElement,
QName type)
|
static
|
toJavaValue(String stringContent,
Class<T> type)
|
static
|
toJavaValue(String stringContent,
Class<T> type,
boolean exceptionOnUnknown)
|
static long |
toMillis(XMLGregorianCalendar xmlCal)
|
static TypedValue |
toTypedJavaValueWithDefaultType(Element xmlElement,
QName defaultType)
Try to locate element type from xsi:type, fall back to specified default
type. |
static String |
toXmlTextContent(Object val,
QName elementName)
|
static void |
toXsdElement(Object val,
Element element,
boolean recordType)
|
static Object |
toXsdElement(Object val,
QName elementName,
Document doc)
|
static Object |
toXsdElement(Object val,
QName elementName,
Document doc,
boolean recordType)
|
static Object |
toXsdElement(Object val,
QName typeName,
QName elementName,
Document doc,
boolean recordType)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
XmlTypeConverter
public XmlTypeConverter()
toJavaValue
public static <T> T toJavaValue(Element xmlElement,
Class<T> type)
throws SchemaException
- Throws:
SchemaException
toJavaValue
public static <T> T toJavaValue(String stringContent,
Class<T> type)
toJavaValue
public static <T> T toJavaValue(String stringContent,
Class<T> type,
boolean exceptionOnUnknown)
toJavaValue
public static Object toJavaValue(Element xmlElement,
QName type)
throws SchemaException
- Throws:
SchemaException
toJavaValue
public static Object toJavaValue(Element xmlElement)
throws SchemaException
- Expects type information in xsi:type
- Parameters:
xmlElement
-
- Returns:
-
- Throws:
JAXBException
SchemaException
toTypedJavaValueWithDefaultType
public static TypedValue toTypedJavaValueWithDefaultType(Element xmlElement,
QName defaultType)
throws SchemaException
- Try to locate element type from xsi:type, fall back to specified default
type.
- Parameters:
element
- defaultType
-
- Returns:
- converted java value
- Throws:
JAXBException
SchemaException
- if no xsi:type or default type specified
toXsdElement
public static Object toXsdElement(Object val,
QName typeName,
QName elementName,
Document doc,
boolean recordType)
throws SchemaException
- Throws:
SchemaException
toXsdElement
public static Object toXsdElement(Object val,
QName elementName,
Document doc)
throws SchemaException
- Throws:
SchemaException
toXsdElement
public static Object toXsdElement(Object val,
QName elementName,
Document doc,
boolean recordType)
throws SchemaException
- Parameters:
val
- elementName
- doc
- recordType
-
- Returns:
- created element
- Throws:
JAXBException
SchemaException
toXsdElement
public static void toXsdElement(Object val,
Element element,
boolean recordType)
throws SchemaException
- Throws:
SchemaException
toXmlTextContent
public static String toXmlTextContent(Object val,
QName elementName)
canConvert
public static boolean canConvert(Class<?> clazz)
canConvert
public static boolean canConvert(QName xsdType)
convertValueElementAsScalar
public static <T> T convertValueElementAsScalar(Element valueElement,
Class<T> type)
throws SchemaException
- Throws:
SchemaException
convertValueElementAsScalar
public static Object convertValueElementAsScalar(Element valueElement,
QName xsdType)
throws SchemaException
- Throws:
SchemaException
convertValueElementAsList
public static List<Object> convertValueElementAsList(Element valueElement)
throws SchemaException
- Throws:
SchemaException
convertValueElementAsList
public static <T> List<T> convertValueElementAsList(Element valueElement,
Class<T> type)
throws SchemaException
- Throws:
SchemaException
convertValueElementAsList
public static List<?> convertValueElementAsList(Element valueElement,
QName xsdType)
throws SchemaException
- Throws:
SchemaException
convertValueElementAsList
public static <T> List<T> convertValueElementAsList(NodeList valueNodes,
Class<T> type)
throws SchemaException
- Throws:
SchemaException
appendBelowNode
public static void appendBelowNode(Object val,
QName xsdType,
QName name,
Node parentNode,
boolean recordType)
throws SchemaException
- Throws:
SchemaException
createXMLGregorianCalendar
public static XMLGregorianCalendar createXMLGregorianCalendar(long timeInMillis)
createXMLGregorianCalendar
public static XMLGregorianCalendar createXMLGregorianCalendar(GregorianCalendar cal)
createXMLGregorianCalendar
public static XMLGregorianCalendar createXMLGregorianCalendar(int year,
int month,
int day,
int hour,
int minute,
int second,
int millisecond,
int timezone)
createXMLGregorianCalendar
public static XMLGregorianCalendar createXMLGregorianCalendar(int year,
int month,
int day,
int hour,
int minute,
int second)
toMillis
public static long toMillis(XMLGregorianCalendar xmlCal)
Copyright © 2013 evolveum. All Rights Reserved.