com.evolveum.midpoint.schema
Class XsdTypeConverter
java.lang.Object
com.evolveum.midpoint.schema.XsdTypeConverter
public class XsdTypeConverter
- extends java.lang.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(java.lang.Object val,
javax.xml.namespace.QName xsdType,
javax.xml.namespace.QName name,
org.w3c.dom.Node parentNode,
boolean recordType)
|
static boolean |
canConvert(java.lang.Class<?> clazz)
|
static java.util.List<java.lang.Object> |
convertValueElementAsList(org.w3c.dom.Element valueElement)
|
static
|
convertValueElementAsList(org.w3c.dom.Element valueElement,
java.lang.Class<T> type)
|
static java.util.List<?> |
convertValueElementAsList(org.w3c.dom.Element valueElement,
javax.xml.namespace.QName xsdType)
|
static
|
convertValueElementAsList(org.w3c.dom.NodeList valueNodes,
java.lang.Class<T> type)
|
static
|
convertValueElementAsScalar(org.w3c.dom.Element valueElement,
java.lang.Class<T> type)
|
static java.lang.Object |
convertValueElementAsScalar(org.w3c.dom.Element valueElement,
javax.xml.namespace.QName xsdType)
|
static java.lang.Class |
toJavaType(javax.xml.namespace.QName xsdType)
|
static java.lang.Object |
toJavaValue(java.lang.Object xmlElement)
Expects type information in xsi:type |
static
|
toJavaValue(java.lang.Object element,
java.lang.Class<T> type)
|
static java.lang.Object |
toJavaValue(java.lang.Object xmlElement,
javax.xml.namespace.QName type)
|
static
|
toJavaValue(java.lang.String stringContent,
java.lang.Class<T> type)
|
static long |
toMillis(javax.xml.datatype.XMLGregorianCalendar xmlCal)
|
static TypedValue |
toTypedJavaValueWithDefaultType(java.lang.Object element,
javax.xml.namespace.QName defaultType)
Try to locate element type from xsi:type, fall back to specified default
type. |
static javax.xml.datatype.XMLGregorianCalendar |
toXMLGregorianCalendar(java.util.GregorianCalendar cal)
|
static javax.xml.datatype.XMLGregorianCalendar |
toXMLGregorianCalendar(long timeInMillis)
|
static java.lang.Object |
toXsdElement(java.lang.Object val,
javax.xml.namespace.QName elementName,
org.w3c.dom.Document doc)
|
static java.lang.Object |
toXsdElement(java.lang.Object val,
javax.xml.namespace.QName elementName,
org.w3c.dom.Document doc,
boolean recordType)
|
static java.lang.Object |
toXsdElement(java.lang.Object val,
javax.xml.namespace.QName typeName,
javax.xml.namespace.QName elementName,
org.w3c.dom.Document doc,
boolean recordType)
|
static javax.xml.namespace.QName |
toXsdType(java.lang.Class javaClass)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
XsdTypeConverter
public XsdTypeConverter()
toXsdType
public static javax.xml.namespace.QName toXsdType(java.lang.Class javaClass)
toJavaType
public static java.lang.Class toJavaType(javax.xml.namespace.QName xsdType)
toJavaValue
public static <T> T toJavaValue(java.lang.Object element,
java.lang.Class<T> type)
throws SchemaException
- Throws:
SchemaException
toJavaValue
public static <T> T toJavaValue(java.lang.String stringContent,
java.lang.Class<T> type)
toJavaValue
public static java.lang.Object toJavaValue(java.lang.Object xmlElement,
javax.xml.namespace.QName type)
throws SchemaException
- Throws:
SchemaException
toJavaValue
public static java.lang.Object toJavaValue(java.lang.Object xmlElement)
throws SchemaException
- Expects type information in xsi:type
- Parameters:
xmlElement
-
- Returns:
-
- Throws:
javax.xml.bind.JAXBException
SchemaException
toTypedJavaValueWithDefaultType
public static TypedValue toTypedJavaValueWithDefaultType(java.lang.Object element,
javax.xml.namespace.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:
javax.xml.bind.JAXBException
SchemaException
- if no xsi:type or default type specified
toXsdElement
public static java.lang.Object toXsdElement(java.lang.Object val,
javax.xml.namespace.QName typeName,
javax.xml.namespace.QName elementName,
org.w3c.dom.Document doc,
boolean recordType)
throws SchemaException
- Throws:
SchemaException
toXsdElement
public static java.lang.Object toXsdElement(java.lang.Object val,
javax.xml.namespace.QName elementName,
org.w3c.dom.Document doc)
throws SchemaException
- Throws:
SchemaException
toXsdElement
public static java.lang.Object toXsdElement(java.lang.Object val,
javax.xml.namespace.QName elementName,
org.w3c.dom.Document doc,
boolean recordType)
throws SchemaException
- Parameters:
val
- elementName
- doc
- recordType
-
- Returns:
- created element
- Throws:
javax.xml.bind.JAXBException
SchemaException
canConvert
public static boolean canConvert(java.lang.Class<?> clazz)
convertValueElementAsScalar
public static <T> T convertValueElementAsScalar(org.w3c.dom.Element valueElement,
java.lang.Class<T> type)
throws SchemaException
- Throws:
SchemaException
convertValueElementAsScalar
public static java.lang.Object convertValueElementAsScalar(org.w3c.dom.Element valueElement,
javax.xml.namespace.QName xsdType)
throws SchemaException
- Throws:
SchemaException
convertValueElementAsList
public static java.util.List<java.lang.Object> convertValueElementAsList(org.w3c.dom.Element valueElement)
throws SchemaException
- Throws:
SchemaException
convertValueElementAsList
public static <T> java.util.List<T> convertValueElementAsList(org.w3c.dom.Element valueElement,
java.lang.Class<T> type)
throws SchemaException
- Throws:
SchemaException
convertValueElementAsList
public static java.util.List<?> convertValueElementAsList(org.w3c.dom.Element valueElement,
javax.xml.namespace.QName xsdType)
throws SchemaException
- Throws:
SchemaException
convertValueElementAsList
public static <T> java.util.List<T> convertValueElementAsList(org.w3c.dom.NodeList valueNodes,
java.lang.Class<T> type)
throws SchemaException
- Throws:
SchemaException
toXMLGregorianCalendar
public static javax.xml.datatype.XMLGregorianCalendar toXMLGregorianCalendar(long timeInMillis)
toXMLGregorianCalendar
public static javax.xml.datatype.XMLGregorianCalendar toXMLGregorianCalendar(java.util.GregorianCalendar cal)
toMillis
public static long toMillis(javax.xml.datatype.XMLGregorianCalendar xmlCal)
appendBelowNode
public static void appendBelowNode(java.lang.Object val,
javax.xml.namespace.QName xsdType,
javax.xml.namespace.QName name,
org.w3c.dom.Node parentNode,
boolean recordType)
throws SchemaException
- Parameters:
val
- xsdType
- name
- parentNode
- recordType
-
- Throws:
javax.xml.bind.JAXBException
SchemaException
Copyright © 2012 evolveum. All Rights Reserved.