|
EclipseLink 2.5.0, build 'v20130507-3faac2b' API Reference | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.persistence.internal.helper.DatabaseField
org.eclipse.persistence.oxm.XMLField
org.eclipse.persistence.oxm.XMLUnionField
public class XMLUnionField
Subclass of XMLField for fields that are mapped to unions. Maintains a list of schema types instead of just one single schema type. Schema types can be added using the addSchemaType api. XMLConstants has a list of useful constants including a list of QNames for built-in schema types that can be used when adding schema types.
When reading and writing an element that is mapped with an XMLUnionField, a conversion to each of the schema types on the field (in the order they are specified ) is tried until a conversion is successful. The java type to convert to is based on the list of schema type to java conversion pairs specified on the field. These conversion pairs can be modified using the addXMLConversion api.
Code Sample
In this example the age field could be a date or an int.
XMLUnionField field = new XMLUnionField("age/text()");
field.addSchemaType(XMLConstants.DATE_QNAME);
field.addSchemaType(XMLConstants.INT_QNAME)
XMLField
,
XMLConstants
,
Serialized FormField Summary |
---|
Fields inherited from class org.eclipse.persistence.oxm.XMLField |
---|
isTypedTextField, leafElementType, userJavaTypes, userXMLTypes |
Fields inherited from class org.eclipse.persistence.internal.helper.DatabaseField |
---|
columnDefinition, index, isCreatable, isInsertable, isNullable, isPrimaryKey, isTranslated, isUnique, isUpdatable, keepInRow, length, name, nameForComparisons, NULL_SQL_TYPE, precision, qualifiedName, scale, sqlType, table, type, typeName, useDelimiters, useUpperCaseForComparisons |
Constructor Summary | |
---|---|
XMLUnionField()
Constructs an XMLUnionField |
|
XMLUnionField(java.lang.String xPath)
Constructs an XMLUnionField with the xpath set to the specified xPath |
Method Summary | |
---|---|
void |
addSchemaType(javax.xml.namespace.QName value)
Adds the new type value to the list of types |
java.lang.Object |
convertValueBasedOnSchemaType(java.lang.Object value,
org.eclipse.persistence.internal.oxm.XMLConversionManager xmlConversionManager,
org.eclipse.persistence.internal.oxm.record.AbstractUnmarshalRecord record)
INTERNAL: |
java.lang.Class |
getJavaClass(javax.xml.namespace.QName qname)
Return the class for a given qualified XML Schema type. |
javax.xml.namespace.QName |
getSchemaType()
Return the first schema type in the list of schema types |
javax.xml.namespace.QName |
getSchemaTypeForValue(java.lang.Object value,
org.eclipse.persistence.internal.core.sessions.CoreAbstractSession session)
INTERNAL: |
java.util.ArrayList |
getSchemaTypes()
Return the list of schema types |
protected javax.xml.namespace.QName |
getSingleValueToWriteForUnion(java.lang.Object value,
org.eclipse.persistence.internal.core.sessions.CoreAbstractSession session)
|
boolean |
isSchemaType(javax.xml.namespace.QName schemaType)
INTERNAL |
boolean |
isUnionField()
INTERNAL: returns true since this is a union field |
void |
setSchemaType(javax.xml.namespace.QName value)
Adds the new type value to the list of types |
void |
setSchemaTypes(java.util.ArrayList value)
Sets the schema types that this attribute can be mapped to Valid QName schema types can be found on org.eclipse.persistence.oxm.XMLConstants |
Methods inherited from class org.eclipse.persistence.internal.helper.DatabaseField |
---|
clone, convertClassNamesToClasses, equals, getColumnDefinition, getIndex, getLength, getName, getNameDelimited, getNameForComparisons, getPrecision, getQualifiedName, getQualifiedNameDelimited, getScale, getSqlType, getTable, getTableName, getType, getTypeName, getUseUpperCaseForComparisons, hasTableName, initDDLFields, isCreatable, isInsertable, isNullable, isObjectRelationalDatabaseField, isPrimaryKey, isReadOnly, isTranslated, isUnique, isUpdatable, keepInRow, resetQualifiedName, setColumnDefinition, setCreatable, setIndex, setInsertable, setIsTranslated, setKeepInRow, setLength, setName, setNameForComparisons, setNullable, setPrecision, setPrimaryKey, setScale, setSqlType, setTable, setTableName, setType, setTypeName, setUnique, setUpdatable, setUseDelimiters, shouldUseDelimiters, toString, useUpperCaseForComparisons |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.eclipse.persistence.internal.oxm.mappings.Field |
---|
getLastXPathFragment, getLeafElementType, getName, getNamespaceResolver, getType, getXMLType, getXPath, getXPathFragment, hasLastXPathFragment, initialize, isCDATA, isRequired, isSelfField, isTypedTextField, setIsCDATA, setIsTypedTextField, setNamespaceResolver, setRequired, setUsesSingleNode, setXPath, usesSingleNode |
Methods inherited from interface org.eclipse.persistence.internal.core.helper.CoreField |
---|
setName, setType |
Constructor Detail |
---|
public XMLUnionField()
public XMLUnionField(java.lang.String xPath)
xPath
- The xpath expression for the fieldMethod Detail |
---|
public java.util.ArrayList getSchemaTypes()
getSchemaTypes
in interface org.eclipse.persistence.internal.oxm.mappings.UnionField<NamespaceResolver>
public void setSchemaTypes(java.util.ArrayList value)
value
- An ArrayList containing the schema types.XMLConstants
public void addSchemaType(javax.xml.namespace.QName value)
addSchemaType
in interface org.eclipse.persistence.internal.oxm.mappings.UnionField<NamespaceResolver>
value
- QName to be added to the list of schema typespublic javax.xml.namespace.QName getSchemaType()
getSchemaType
in interface org.eclipse.persistence.internal.oxm.mappings.Field<NamespaceResolver>
getSchemaType
in class XMLField
public void setSchemaType(javax.xml.namespace.QName value)
setSchemaType
in interface org.eclipse.persistence.internal.oxm.mappings.Field<NamespaceResolver>
setSchemaType
in class XMLField
value
- The value to be added to the list of schema typespublic boolean isUnionField()
isUnionField
in interface org.eclipse.persistence.internal.oxm.mappings.Field<NamespaceResolver>
isUnionField
in class XMLField
public javax.xml.namespace.QName getSchemaTypeForValue(java.lang.Object value, org.eclipse.persistence.internal.core.sessions.CoreAbstractSession session)
XMLField
getSchemaTypeForValue
in interface org.eclipse.persistence.internal.oxm.mappings.Field<NamespaceResolver>
getSchemaTypeForValue
in class XMLField
protected javax.xml.namespace.QName getSingleValueToWriteForUnion(java.lang.Object value, org.eclipse.persistence.internal.core.sessions.CoreAbstractSession session)
public java.lang.Object convertValueBasedOnSchemaType(java.lang.Object value, org.eclipse.persistence.internal.oxm.XMLConversionManager xmlConversionManager, org.eclipse.persistence.internal.oxm.record.AbstractUnmarshalRecord record)
convertValueBasedOnSchemaType
in interface org.eclipse.persistence.internal.oxm.mappings.Field<NamespaceResolver>
convertValueBasedOnSchemaType
in class XMLField
public java.lang.Class getJavaClass(javax.xml.namespace.QName qname)
getJavaClass
in interface org.eclipse.persistence.internal.oxm.mappings.Field<NamespaceResolver>
getJavaClass
in class XMLField
qname
- The qualified name of the XML Schema type to use as a key in the lookup
public boolean isSchemaType(javax.xml.namespace.QName schemaType)
isSchemaType
in interface org.eclipse.persistence.internal.oxm.mappings.Field<NamespaceResolver>
isSchemaType
in class XMLField
|
EclipseLink 2.5.0, build 'v20130507-3faac2b' API Reference | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |