public abstract class AbstractXmlBasedUdt
extends java.lang.Object
UDTValue providing direct access to various data of the
UDT. The data is represented as XML in the UDTValue. This class
allows for parsing and validating the XML as well as for creating at least
the basic structure (document and top-level element) for the XML.| Modifier and Type | Field and Description |
|---|---|
protected java.util.logging.Logger |
logger
The logger for problems when loading the XML schema.
|
protected java.lang.String |
xmlElementName
The name of the top-level element in the XML that represents the UDT.
|
protected java.lang.String |
xmlNamespace
The namespace of the XML that represents the UDT.
|
| Constructor and Description |
|---|
AbstractXmlBasedUdt(java.lang.String udtName,
java.lang.String xmlNamespace)
Creates a new wrapper class for a
UDTValue based on XML. |
AbstractXmlBasedUdt(java.lang.String udtName,
java.lang.String xmlNamespace,
java.lang.String xmlElementName)
Creates a new wrapper class for a
UDTValue based on XML. |
| Modifier and Type | Method and Description |
|---|---|
protected org.w3c.dom.Document |
createDocument()
Creates a document for the XML-representation of this UDT containing the
top-level element.
|
protected java.lang.String |
getNamespace()
Gets the namespace of the XML that represents the UDT.
|
protected java.lang.String |
getUdtName()
Gets the name of the user-defined type.
|
protected abstract java.lang.String |
getXsdFileName()
Gets the file name of the XSD of this UDT.
|
protected abstract java.lang.String |
loadFromStream(java.io.InputStream valueAsStream)
Loads and data from the designated
InputStream by parsing the
corresponding XML. |
protected void |
loadFromUdtValue(UDTValue udtValue)
Loads the data from the designated
UDTValue by parsing the
corresponding XML. |
protected javax.xml.validation.Schema |
loadXmlSchema()
Loads the XML schema for this UDT.
|
protected abstract void |
marshal(org.w3c.dom.Element topLevel)
Marshals the data of this UDT as XML by adding it to the designated
top-level element.
|
protected static void |
marshalBoolean(boolean b,
org.w3c.dom.Node node)
Marshals the designated boolean value as content of the designated node.
|
protected static void |
marshalByteArray(byte[] bytes,
org.w3c.dom.Node node)
Marshals the designated
byte[] value as content of the
designated node. |
protected static void |
marshalDate(java.util.Date date,
org.w3c.dom.Node node)
Marshals the designated
Date value as content of the
designated node. |
protected static void |
marshalDouble(double d,
org.w3c.dom.Node node)
Marshals the designated double value as content of the designated node.
|
protected static void |
marshalLong(long l,
org.w3c.dom.Node node)
Marshals the designated long value as content of the designated node.
|
protected static void |
marshalURI(java.net.URI uri,
org.w3c.dom.Node node)
Marshals the designated
URI value as content of the
designated node. |
void |
saveToStream(java.io.OutputStream out)
Serialises the data of this UDT as XML to the designated output stream.
|
UDTValue |
saveToUdtValue()
Serialises the data of this UDT as XML and returns it as
UDTValue. |
protected static boolean |
unmarshalBoolean(org.w3c.dom.Node node)
Unmarshals a boolean value from the text content of the designated node.
|
protected static byte[] |
unmarshalByteArray(org.w3c.dom.Node node)
Unmarshals a
byte[] value from the text content of the
designated node. |
protected static java.util.Date |
unmarshalDate(org.w3c.dom.Node node)
Unmarshals a
Date value from the text content of the
designated node. |
protected static double |
unmarshalDouble(org.w3c.dom.Node node)
Unmarshals the double value from the text content of the designated node.
|
protected static long |
unmarshalLong(org.w3c.dom.Node node)
Unmarshals the long value from the text content of the designated node.
|
protected static java.net.URI |
unmarshalURI(org.w3c.dom.Node node)
Unmarshals a
URI value from the text content of the designated
node. |
protected final java.util.logging.Logger logger
protected final java.lang.String xmlNamespace
protected final java.lang.String xmlElementName
public AbstractXmlBasedUdt(java.lang.String udtName,
java.lang.String xmlNamespace)
UDTValue based on XML. The
name of the top-level element of the XML is expected to be the UDT-name.udtName - The name of the UDT. This can be changed later when
loading the value.xmlNamespace - The namespace of the XML-representation of the UDT.public AbstractXmlBasedUdt(java.lang.String udtName,
java.lang.String xmlNamespace,
java.lang.String xmlElementName)
UDTValue based on XML.udtName - The name of the UDT. This can be changed later when
loading the value.xmlNamespace - The namespace of the XML-representation of the UDT.xmlElementName - The name of the top-level element in the
XML-representation of the UDT.protected java.lang.String getUdtName()
protected java.lang.String getNamespace()
protected javax.xml.validation.Schema loadXmlSchema()
null will be returned. It is advised to cache the schema in
subclasses, even as static field, but make sure to synchronise access
appropriately.null in case the schema
cannot be loaded.protected void loadFromUdtValue(UDTValue udtValue) throws java.io.IOException, XMLFormatException
UDTValue by parsing the
corresponding XML.udtValue - The UDTValue from which to load the XML for
the data of this UDT.java.lang.IllegalArgumentException - If the designated UDT value does not have
the right user-defined type (name), an
IllegalArgumentException will be thrown.java.io.IOException - If an error occurs while reading the
UDTValue, an IOException will be
thrown. If a class is to be loaded from the UDT
value that cannot be found, a ClassNotFoundException
will be wrapped within an IOException.XMLFormatException - If the document is not well-formed or does not
conform to its schema (if provided), an
XMLFormatException will be thrown.protected org.w3c.dom.Document createDocument()
throws java.io.IOException
java.io.IOException - If an error occurs while marshaling this UDT, an
IOException will be thrown.public UDTValue saveToUdtValue() throws java.io.IOException
UDTValue.UDTValue.java.io.IOException - If there are problems serialising the data of this UDT
as XML, an IOException will be thrown.public void saveToStream(java.io.OutputStream out)
throws java.io.IOException
out - The output stream to which to save the data of this UDT as XML.java.io.IOException - If there are problems serialising the data of this UDT
as XML to the designated output stream, an
IOException will be thrown.protected abstract java.lang.String getXsdFileName()
protected abstract java.lang.String loadFromStream(java.io.InputStream valueAsStream)
throws java.io.IOException,
XMLFormatException
InputStream by parsing the
corresponding XML.valueAsStream - The value of this UDT as stream (containing the XML
representation).null, the type name
will be changed.java.io.IOException - If an error occurs while reading from the stream, an
IOException will be thrown. If a class is to be
loaded from the stream that cannot be found, a
ClassNotFoundException will be wrapped within an
IOException.XMLFormatException - If the document is not well-formed or does not
conform to its schema (if provided), an
XMLFormatException will be thrown.protected abstract void marshal(org.w3c.dom.Element topLevel)
throws java.io.IOException
topLevel - The top-level element to which to add the
XML-representation of this UDT.java.io.IOException - If an error occurs while marshaling this UDT, an
IOException will be thrown.protected static void marshalBoolean(boolean b,
org.w3c.dom.Node node)
b - The boolean value to marshal.node - The node to which to marshal the value.protected static boolean unmarshalBoolean(org.w3c.dom.Node node)
node - The node from which to unmarshal a boolean value from its text
content.protected static void marshalLong(long l,
org.w3c.dom.Node node)
l - The long value to marshal.node - The node to which to marshal the value.protected static long unmarshalLong(org.w3c.dom.Node node)
node - The node from which to unmarshal a long value from its text
content.protected static void marshalDouble(double d,
org.w3c.dom.Node node)
d - The double value to marshal.node - The node to which to marshal the value.protected static double unmarshalDouble(org.w3c.dom.Node node)
node - The node from which to unmarshal a double value from its text
content.protected static void marshalDate(java.util.Date date,
org.w3c.dom.Node node)
Date value as content of the
designated node.date - The Date value to marshal.node - The node to which to marshal the value.protected static java.util.Date unmarshalDate(org.w3c.dom.Node node)
Date value from the text content of the
designated node.node - The node from which to unmarshal a Date value from
its text content.Date value from the text content of the designated
node.protected static void marshalURI(java.net.URI uri,
org.w3c.dom.Node node)
URI value as content of the
designated node.uri - The URI value to marshal.node - The node to which to marshal the value.protected static java.net.URI unmarshalURI(org.w3c.dom.Node node)
URI value from the text content of the designated
node.node - The node from which to unmarshal a URI value from
its text content.URI value from the text content of the designated
node.protected static void marshalByteArray(byte[] bytes,
org.w3c.dom.Node node)
byte[] value as content of the
designated node.bytes - The byte[] value to marshal.node - The node to which to marshal the value.protected static byte[] unmarshalByteArray(org.w3c.dom.Node node)
throws java.io.IOException
byte[] value from the text content of the
designated node.node - The node from which to unmarshal a byte[] value
from its text content.byte[] value from the text content of the
designated node.java.io.IOException - If decoding the byte array with Base64 fails, an
IOException will be thrown.