public class LocalisationUdt extends AbstractXmlBasedUdt
ProcessConstants.AdeptDataType. By mapping arbitrary locales to localised values
this allows for localisation of the value of any data element.
The map-structure is stored in an appropriate XML representation in a
UDTValue. Wrap such a UDTValue by this class for
simplified access to and manipulation of the localisation data.
| Modifier and Type | Field and Description |
|---|---|
protected static java.lang.String |
ENTRY
The name of the XML-element for an entry of the localisation map.
|
protected ProcessConstants.AdeptDataType |
innerType
The data type of the localised values of this localisation UDT.
|
protected static java.lang.String |
LOCALE_ELEMENT_COUNTRY
The name of the XML-element for the country of a locale.
|
protected static java.lang.String |
LOCALE_ELEMENT_LANGUAGE
The name of the XML-element for the language of a locale.
|
protected static java.lang.String |
LOCALE_ELEMENT_LOCALISATION
The name of the XML-element for the localised value.
|
protected static java.lang.String |
LOCALE_ELEMENT_VARIANT
The name of the XML-element for the variant of a locale.
|
protected java.util.Map<java.util.Locale,java.io.Serializable> |
localisationMap
The map containing the localisation values indexed by the corresponding
locale.
|
protected static java.lang.String |
TYPE
The name of the XML-attribute for the inner type that is an
ProcessConstants.AdeptDataType. |
static java.lang.String |
UDT_NAME
The UDT name of this data type.
|
protected static java.lang.String |
XML_NAMESPACE
The namespace for the XML-representation of this UDT.
|
protected static java.lang.String |
XSD_FILE_NAME
The filename for the XSD of this UDT.
|
logger, xmlElementName, xmlNamespace| Constructor and Description |
|---|
LocalisationUdt(java.io.InputStream stream)
Creates a new localisation UDT for the designated
InputStream. |
LocalisationUdt(java.util.Map<java.util.Locale,java.io.Serializable> localisationMap,
ProcessConstants.AdeptDataType innerType)
Creates a new localisation UDT for localisations of values of the
designated type.
|
LocalisationUdt(ProcessConstants.AdeptDataType innerType)
Creates a new localisation UDT for localisations of values of the
designated type.
|
LocalisationUdt(UDTValue value)
Creates a new localisation UDT for the designated
UDTValue. |
| Modifier and Type | Method and Description |
|---|---|
java.io.Serializable |
getClosestLocalisation(java.util.Locale locale)
Gets the localisation value that is closest to the designated locale.
|
java.io.Serializable |
getLocalisationDirect(java.util.Locale locale)
Gets the localisation value for the designated locale directly.
|
protected java.lang.String |
getXsdFileName()
Gets the file name of the XSD of this UDT.
|
java.lang.String |
loadFromStream(java.io.InputStream in)
Loads and data from the designated
InputStream by parsing the
corresponding XML. |
protected void |
marshal(org.w3c.dom.Element parent)
Marshals the data of this UDT as XML by adding it to the designated
top-level element.
|
protected void |
marshalLocalisation(java.util.Locale locale,
java.io.Serializable localised,
org.w3c.dom.Element parent)
Marshals a localisation element (one entry) to the designated parent
element using the designated locale and localised value.
|
void |
setLocalisation(java.util.Locale locale,
java.io.Serializable localisation)
Sets the designated localisation value for the designated value.
|
protected void |
unmarshalLocalisation(org.w3c.dom.Node locElem)
Unmarshals a localisation element (one entry) from the designated node and
adds it to the localisation map.
|
createDocument, getNamespace, getUdtName, loadFromUdtValue, loadXmlSchema, marshalBoolean, marshalByteArray, marshalDate, marshalDouble, marshalLong, marshalURI, saveToStream, saveToUdtValue, unmarshalBoolean, unmarshalByteArray, unmarshalDate, unmarshalDouble, unmarshalLong, unmarshalURIpublic static final java.lang.String UDT_NAME
protected static final java.lang.String XML_NAMESPACE
protected static final java.lang.String XSD_FILE_NAME
protected static final java.lang.String TYPE
ProcessConstants.AdeptDataType.protected static final java.lang.String ENTRY
protected static final java.lang.String LOCALE_ELEMENT_LANGUAGE
protected static final java.lang.String LOCALE_ELEMENT_COUNTRY
protected static final java.lang.String LOCALE_ELEMENT_VARIANT
protected static final java.lang.String LOCALE_ELEMENT_LOCALISATION
protected final java.util.Map<java.util.Locale,java.io.Serializable> localisationMap
protected ProcessConstants.AdeptDataType innerType
public LocalisationUdt(ProcessConstants.AdeptDataType innerType)
innerType - The type of the values to be localised.public LocalisationUdt(java.util.Map<java.util.Locale,java.io.Serializable> localisationMap,
ProcessConstants.AdeptDataType innerType)
localisationMap - A map providing default localisation values for this
UDT. This may be null.innerType - The type of the values to be localised.public LocalisationUdt(UDTValue value) throws java.io.IOException, XMLFormatException
UDTValue.value - The UDTValue from which to retrieve the
localisation data.java.io.IOException - If an error occurs while reading the
UDTValue, an IOException will be
thrown.XMLFormatException - If the document is not well-formed or does not
conform to its schema (if provided), an
XMLFormatException will be thrown.public LocalisationUdt(java.io.InputStream stream)
throws java.io.IOException,
XMLFormatException
InputStream.stream - The InputStream from which to retrieve the
localisation data.java.io.IOException - If an error occurs while reading the
InputStream, an IOException will be
thrown.XMLFormatException - If the document is not well-formed or does not
conform to its schema (if provided), an
XMLFormatException will be thrown.protected java.lang.String getXsdFileName()
AbstractXmlBasedUdtgetXsdFileName in class AbstractXmlBasedUdtpublic java.lang.String loadFromStream(java.io.InputStream in)
throws java.io.IOException,
XMLFormatException
AbstractXmlBasedUdtInputStream by parsing the
corresponding XML.loadFromStream in class AbstractXmlBasedUdtin - 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.public java.io.Serializable getLocalisationDirect(java.util.Locale locale)
locale - The locale for which to retrieve the localisation value.null in case no value is present for it.public java.io.Serializable getClosestLocalisation(java.util.Locale locale)
locale - The locale for which to retrieve the closest localisation
value.null will be returned if no value is present for any
close locale including the default locale ("").public void setLocalisation(java.util.Locale locale,
java.io.Serializable localisation)
"" for the default locale.locale - The locale for which to add a localisation value. Use
"" for the default locale.localisation - The localisation value for the designated locale.protected void marshal(org.w3c.dom.Element parent)
AbstractXmlBasedUdtmarshal in class AbstractXmlBasedUdtparent - The top-level element to which to add the
XML-representation of this UDT.protected void marshalLocalisation(java.util.Locale locale,
java.io.Serializable localised,
org.w3c.dom.Element parent)
locale - The locale of the localisation element to marshal.localised - The localised value of the localisation element to
marshal.parent - The parent element to which to add the localisation element.protected void unmarshalLocalisation(org.w3c.dom.Node locElem)
throws java.io.IOException
locElem - The node from which to unmarshal a localisation element (one
entry) from its text content.java.io.IOException - If decoding a byte array value of a user-defined type
with Base64 fails, an IOException will be thrown.