Class MetaDataObject_impl
- All Implemented Interfaces:
Serializable
,Cloneable
,MetaDataObject
,XMLizable
- Direct Known Subclasses:
AllowedValue_impl
,Attribute_impl
,Capability_impl
,CapabilityLanguageFlow_impl
,ConfigurableDataResourceSpecifier_impl
,ConfigurationGroup_impl
,ConfigurationParameter_impl
,ConfigurationParameterDeclarations_impl
,ConfigurationParameterSettings_impl
,CustomResourceSpecifier_impl
,ExternalResourceBinding_impl
,ExternalResourceDependency_impl
,ExternalResourceDescription_impl
,FeatureDescription_impl
,FileLanguageResourceSpecifier_impl
,FileResourceSpecifier_impl
,Filter_impl
,FixedFlow_impl
,FlowControllerDeclaration_impl
,FsIndexCollection_impl
,FsIndexDescription_impl
,FsIndexKeyDescription_impl
,Import_impl
,IndexBuildItem_impl
,IndexBuildSpecification_impl
,IndexRule_impl
,Mapping_impl
,NameValuePair_impl
,OperationalProperties_impl
,Parameter_impl
,PearSpecifier_impl
,ResourceCreationSpecifier_impl
,ResourceManagerConfiguration_impl
,ResourceMetaData_impl
,ResultSpecification_impl
,SimplePrecondition_impl
,SofaMapping_impl
,Style_impl
,TypeDescription_impl
,TypeOrFeature_impl
,TypePriorities_impl
,TypePriorityList_impl
,TypeSystemDescription_impl
,URISpecifier_impl
Also provides the ability to write objects to XML and build objects from their DOM
representation, as required to implement the XMLizable
interface, which is a
superinterface of MetaDataObject
. In future versions, this could be replaced by a
non-proprietary XML binding solution such as JAXB or EMF.
The implementation for getting and setting property values uses the JavaBeans introspection API. Therefore subclasses of this class must be valid JavaBeans and either use the standard naming conventions for getters and setters. BeanInfo augmentation is ignored; the implementation here uses the flag IGNORE_ALL_BEANINFO. See The Java Beans Tutorial for more information. To support XML Comments, which can occur between any sub-elements, including array values, the "data" for all objects is stored in a pair of ArrayLists; one holds the "name" of the slot, the other the value; comments are interspersed within this list where they occur. To the extent possible, this should be the *only* data storage used for the xml element. Subclasses should access these elements on demand. Data will be read into / written from this representation; Cloning will copy this information. For getters that need to do some special initial processing, a global flag will be set whenever this base code changes the underlying value.
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
static class
Information, kept globally (by thread) for one serialization Inherited by some custom impls, e.g.static interface
methods used for serializing -
Field Summary
Modifier and TypeFieldDescriptionstatic final ThreadLocal<MetaDataObject_impl.SerialContext>
Keeps the serialContext by thread set when starting to serialize cleared at the end (in finally clause) to prevent memory leaks Inherited by some custom impls, e.g. -
Constructor Summary
ConstructorDescriptionCreates a newMetaDataObject_impl
with null attribute values -
Method Summary
Modifier and TypeMethodDescriptionfinal void
buildFromXMLElement
(Element aElement, XMLParser aParser) Initializes this object from its XML DOM representation.void
buildFromXMLElement
(Element aElement, XMLParser aParser, XMLParser.ParsingOptions aOptions) Initializes this object from its XML DOM representation.clone()
Creates a clone of thisMetaDataObject
.boolean
Determines if this object is equal to another.Override this method to include additional attributesgetAttributeClass
(String aName) Gets the Class of the given attribute's value.getAttributeValue
(String aName) Retrieves the value of an attribute of thisMetaDataObject
.protected Node
getMatchingNode
(MetaDataObject_impl.SerialContext serialContext, String name) protected PropertyDescriptor[]
Deprecated.- use getAttributes insteadprotected PropertyXmlInfo
getPropertyXmlInfo
(String aXmlElementName) Looks in this class's XmlizationInfo for a property with the given XML element name.Gets the relative path base used to resolve imports.Gets the URL from which this object was parsed.If the sourceURL of this object is non-null, returns its string representation.protected static Class
getWrapperClass
(Class aPrimitiveType) Gets the wrapper class corresponding to the given primitive type.protected AttributesImpl
Called by thetoXML(ContentHandler, boolean)
method to get the XML attributes that will be written as part of the element's tag.protected abstract XmlizationInfo
To be implemented by subclasses to return information describing how to represent this object in XML.int
hashCode()
Gets the hash code for this object.boolean
Returns whether this object is modifiable.Deprecated.- use getAttributesprotected void
readArrayPropertyValueFromXMLElement
(PropertyXmlInfo aPropXmlInfo, Class aPropClass, Element aElement, XMLParser aParser, XMLParser.ParsingOptions aOptions) Utility method to read an array property's value from its DOM representation.protected void
readMapPropertyFromXml
(String aPropName, Element aElement, String aKeyXmlAttribute, String aValueTagName, XMLParser aParser, XMLParser.ParsingOptions aOptions, boolean aValueIsArray) Utility method for reading from XML an attribute whose value is aMap
withString
keys andXMLizable
(or an array of these) values.protected void
readPropertyValueFromXMLElement
(PropertyXmlInfo aPropXmlInfo, Element aElement, XMLParser aParser, XMLParser.ParsingOptions aOptions) Utility method to read an attribute's value from its DOM representation.protected void
readUnknownPropertyValueFromXMLElement
(Element aElement, XMLParser aParser, XMLParser.ParsingOptions aOptions, List<String> aKnownPropertyNames) Utility method that attempts to read a property value from an XML element even though it is not known to which property the value should be assigned.protected String
resolveSettings
(String text) void
setAttributeValue
(String aName, Object aValue) Sets the value of an attribute of thisMetaDataObject
.void
setInfoset
(Node infoset) void
setSourceUrl
(URL aUrl) Sets the URL from which this object was parsed.void
setSourceUrlIfNull
(URL aUrl) Sets the source URL of this object, only if that URL is currently set to null.toString()
Dump this metadata object's attributes and values to a String.void
toXML
(OutputStream aOutputStream) Writes out this object's XML representation.void
Writes out this object's XML representation.void
toXML
(ContentHandler aContentHandler) This is called internally, also for JSon serializationvoid
toXML
(ContentHandler aContentHandler, boolean aWriteDefaultNamespaceAttribute) Writes this object's XML representation by making calls on a SAXContentHandler
.boolean
protected void
writeArrayPropertyAsElement
(String aPropName, Class aPropClass, Object aValue, String aArrayElementTagName, String aNamespace) Utility method used to write an array property out as an XML element.protected void
writeMapPropertyToXml
(String aPropName, String aXmlElementName, String aKeyXmlAttribute, String aValueTagName, boolean aOmitIfNull, String aNamespace) Utility method for writing to XML an property whose value is aMap
withString
keys andXMLizable
values.protected void
writePropertyAsElement
(PropertyXmlInfo aPropInfo, String aNamespace) Utility method used to write a property out as an XML element.
-
Field Details
-
serialContext
Keeps the serialContext by thread set when starting to serialize cleared at the end (in finally clause) to prevent memory leaks Inherited by some custom impls, e.g. TypeOrFeature_impl
-
-
Constructor Details
-
MetaDataObject_impl
public MetaDataObject_impl()Creates a newMetaDataObject_impl
with null attribute values
-
-
Method Details
-
getSerialContext
-
setInfoset
-
getInfoset
-
getAdditionalAttributes
Override this method to include additional attributes- Returns:
- additional attributes
-
listAttributes
Deprecated.- use getAttributesReturns a list ofNameClassPair
objects indicating the attributes of this object and the String names of the Classes of the attributes' values. For primitive types, the wrapper classes will be returned (e.g.java.lang.Integer
instead of int). Several subclasses override this, to add additional items to the list.- Specified by:
listAttributes
in interfaceMetaDataObject
- Returns:
- a List containing
NameClassPair
objects, each of which contains the name of a parameter and the Class of its value. For primitive types, the wrapper classes will be returned (e.g.java.lang.Integer
instead of int). - See Also:
-
getAttributeValue
Description copied from interface:MetaDataObject
Retrieves the value of an attribute of thisMetaDataObject
.- Specified by:
getAttributeValue
in interfaceMetaDataObject
- Parameters:
aName
- the name of the parameter to get- Returns:
- the value of the parameter named
aName
. Returnsnull
if there is no attribute with that name. - See Also:
-
getAttributeClass
Gets the Class of the given attribute's value. For primitive types, the wrapper classes will be returned (e.g.java.lang.Integer
instead of int).- Parameters:
aName
- name of an attribute- Returns:
- Class of value that may be assigned to the named attribute. Returns
null
if there is no attribute with the given name.
-
isModifiable
public boolean isModifiable()Returns whether this object is modifiable. MetaDataObjects are modifiable by default.- Specified by:
isModifiable
in interfaceMetaDataObject
- Returns:
- true if and only if this object's attributes may be modified.
- See Also:
-
setAttributeValue
Description copied from interface:MetaDataObject
Sets the value of an attribute of thisMetaDataObject
. Applications should first check theMetaDataObject.isModifiable()
method; callingMetaDataObject.setAttributeValue(String, Object)
on an unmodifiableMetaDataObject
will result in an exception.- Specified by:
setAttributeValue
in interfaceMetaDataObject
- Parameters:
aName
- the name of the parameter to setaValue
- the value to assign to the parameter- See Also:
-
getRelativePathBase
Gets the relative path base used to resolve imports. This is equal to the sourceUrl of this object, if known (i.e. if the object was parsed from an XML file or if setSourceUrl was explicitly called). If the source URL is not known, the value of the user.dir System property is returned.- Returns:
- the base URL for resolving relative paths in this object
-
getSourceUrl
Gets the URL from which this object was parsed. When this object is parsed from an XML file, this is set by the parser to the URL of the source file XML file. If the object has been created by some other method, the source URL will not be known, and this method will return null.This setting is used to resolve imports and is also included in exception messages to indicate the source of the problem.
- Specified by:
getSourceUrl
in interfaceMetaDataObject
- Returns:
- the source URL from which this object was parsed
-
getSourceUrlString
If the sourceURL of this object is non-null, returns its string representation. If it is null, returns "<unknown>". Useful for error messages.- Specified by:
getSourceUrlString
in interfaceMetaDataObject
- Returns:
- the source URL as a string, or "<unknown>"
-
setSourceUrlIfNull
Sets the source URL of this object, only if that URL is currently set to null. This is used internally to update null relative base paths before doing import resolution, without overriding user-specified settings.- Parameters:
aUrl
- the location of the XML file from which this object was parsed
-
setSourceUrl
Sets the URL from which this object was parsed. Typically only the XML parser sets this. This recursively sets the source URL of all descendants of this object. Recursion doesn't happen for sub arrays/maps of maps or arrays.- Specified by:
setSourceUrl
in interfaceMetaDataObject
- Parameters:
aUrl
- the location of the XML file from which this object was parsed
-
clone
Description copied from interface:MetaDataObject
Creates a clone of thisMetaDataObject
. This performs a "deep" copy by cloning all attribute values that are also MetaDataObjects.- Specified by:
clone
in interfaceMetaDataObject
- Overrides:
clone
in classObject
- Returns:
- a clone of this
MetaDataObject
- See Also:
-
toString
Dump this metadata object's attributes and values to a String. This is useful for debugging. -
equals
Determines if this object is equal to another. Two MetaDataObjects are equivalent if they share the same attributes and the same values for those attributes.- Specified by:
equals
in interfaceMetaDataObject
- Overrides:
equals
in classObject
- Parameters:
aObj
- object with which to compare this object- Returns:
- true if and only if this object is equal to
aObj
-
hashCode
public int hashCode()Gets the hash code for this object. The hash codes of two NameClassPairsx
andy
must be equal ifx.equals(y)
returns true; -
toXML
Writes out this object's XML representation.- Specified by:
toXML
in interfaceXMLizable
- Parameters:
aWriter
- a Writer to which the XML string will be written- Throws:
SAXException
- passthruIOException
- if an I/O failure occurs
-
toXML
Writes out this object's XML representation.- Specified by:
toXML
in interfaceXMLizable
- Parameters:
aOutputStream
- an OutputStream to which the XML string will be written- Throws:
SAXException
- pass thruIOException
- if an I/O failure occurs
-
toXML
This is called internally, also for JSon serialization- Specified by:
toXML
in interfaceXMLizable
- Parameters:
aContentHandler
- the content handler to which this object will write events that describe its XML representation.- Throws:
SAXException
- pass thru- See Also:
-
toXML
public void toXML(ContentHandler aContentHandler, boolean aWriteDefaultNamespaceAttribute) throws SAXException Description copied from interface:XMLizable
Writes this object's XML representation by making calls on a SAXContentHandler
.- Specified by:
toXML
in interfaceXMLizable
- Parameters:
aContentHandler
- the content handler to which this object will write events that describe its XML representation.aWriteDefaultNamespaceAttribute
- whether the namespace of this element should be written as the default namespace. This should be done only for the root element, and it defaults to false.- Throws:
SAXException
- pass thru- See Also:
-
getXMLAttributes
Called by thetoXML(ContentHandler, boolean)
method to get the XML attributes that will be written as part of the element's tag. By default this method returns an empty Attributes object. Subclasses may override it in order to write attributes to the XML.- Returns:
- an object defining the attributes to be written to the XML
-
getXmlizationInfo
To be implemented by subclasses to return information describing how to represent this object in XML.- Returns:
- information defining this object's XML representation
-
getPropertyXmlInfo
Looks in this class's XmlizationInfo for a property with the given XML element name.- Parameters:
aXmlElementName
- the unqualified name of an XML element- Returns:
- information on the property that corresponds to the given element name,
null
if none.
-
valueIsNullOrEmptyArray
-
writePropertyAsElement
protected void writePropertyAsElement(PropertyXmlInfo aPropInfo, String aNamespace) throws SAXException Utility method used to write a property out as an XML element.- Parameters:
aPropInfo
- information on how to represent the property in XMLaNamespace
- XML namespace URI for this object representation- Throws:
SAXException
- -
-
writeArrayPropertyAsElement
protected void writeArrayPropertyAsElement(String aPropName, Class aPropClass, Object aValue, String aArrayElementTagName, String aNamespace) throws SAXException Utility method used to write an array property out as an XML element.- Parameters:
aPropName
- name of the attributeaPropClass
- class of the attributeaValue
- value (guaranteed to be an array and non-null)aArrayElementTagName
- name of tag to be assigned to each element of the array. May benull
, in which case each element will be assigned a value appropriate to its class.aNamespace
- the XML namespace URI for this object- Throws:
SAXException
- -
-
writeMapPropertyToXml
protected void writeMapPropertyToXml(String aPropName, String aXmlElementName, String aKeyXmlAttribute, String aValueTagName, boolean aOmitIfNull, String aNamespace) throws SAXException Utility method for writing to XML an property whose value is aMap
withString
keys andXMLizable
values.- Parameters:
aPropName
- name of the property to write to XMLaXmlElementName
- name of the XML element for the property,null
if noneaKeyXmlAttribute
- name of the XML attribute for the keyaValueTagName
- XML element tag name to use for each entry in the MapaOmitIfNull
- if true, null or empty map will not be written at all, if false, null or empty map will be written as an empty elementaNamespace
- namespace for this object- Throws:
SAXException
- passthru
-
buildFromXMLElement
public final void buildFromXMLElement(Element aElement, XMLParser aParser) throws InvalidXMLException Initializes this object from its XML DOM representation. This method is typically called from theXMLParser
.- Specified by:
buildFromXMLElement
in interfaceXMLizable
- Parameters:
aElement
- the XML element that represents this object.aParser
- a reference to the UIMAXMLParser
. TheXMLParser.buildObject(Element)
method can be used to construct sub-objects.- Throws:
InvalidXMLException
- if the input XML element does not specify a valid object
-
buildFromXMLElement
public void buildFromXMLElement(Element aElement, XMLParser aParser, XMLParser.ParsingOptions aOptions) throws InvalidXMLException Initializes this object from its XML DOM representation. This method is typically called from theXMLParser
. It is overridden by specific Java impl classes to provide additional defaulting (e.g. see AnalysisEngineDescription_impl)- Specified by:
buildFromXMLElement
in interfaceXMLizable
- Parameters:
aElement
- the XML element that represents this object.aParser
- a reference to the UIMAXMLParser
. TheXMLParser.buildObject(Element)
method can be used to construct sub-objects.aOptions
- option settings- Throws:
InvalidXMLException
- if the input XML element does not specify a valid object
-
readPropertyValueFromXMLElement
protected void readPropertyValueFromXMLElement(PropertyXmlInfo aPropXmlInfo, Element aElement, XMLParser aParser, XMLParser.ParsingOptions aOptions) throws InvalidXMLException Utility method to read an attribute's value from its DOM representation.- Parameters:
aPropXmlInfo
- information about the property to readaElement
- DOM element to read fromaParser
- parser to use to construct complex valuesaOptions
- option settings- Throws:
InvalidXMLException
- -
-
readArrayPropertyValueFromXMLElement
protected void readArrayPropertyValueFromXMLElement(PropertyXmlInfo aPropXmlInfo, Class aPropClass, Element aElement, XMLParser aParser, XMLParser.ParsingOptions aOptions) throws InvalidXMLException Utility method to read an array property's value from its DOM representation.- Parameters:
aPropXmlInfo
- information about the property to readaPropClass
- class of the property's valueaElement
- DOM element representing the entire arrayaParser
- parser to use to construct complex valuesaOptions
- option settings- Throws:
InvalidXMLException
- -
-
readUnknownPropertyValueFromXMLElement
protected void readUnknownPropertyValueFromXMLElement(Element aElement, XMLParser aParser, XMLParser.ParsingOptions aOptions, List<String> aKnownPropertyNames) throws InvalidXMLException Utility method that attempts to read a property value from an XML element even though it is not known to which property the value should be assigned. If an object can be constructed from the XML element, it will be assigned to any unasigned property that can accept it.- Parameters:
aElement
- DOM element to read fromaParser
- parser to use to construct complex valuesaOptions
- -aKnownPropertyNames
- List of propertiees that we've already values for (these values will not be overwritten)- Throws:
InvalidXMLException
- if no acceptable object is described by aElement
-
readMapPropertyFromXml
protected void readMapPropertyFromXml(String aPropName, Element aElement, String aKeyXmlAttribute, String aValueTagName, XMLParser aParser, XMLParser.ParsingOptions aOptions, boolean aValueIsArray) throws InvalidXMLException Utility method for reading from XML an attribute whose value is aMap
withString
keys andXMLizable
(or an array of these) values.- Parameters:
aPropName
- name of the property to read from XMLaElement
- element to read fromaKeyXmlAttribute
- XML attribute for the keyaValueTagName
- XML element tag name for each entry in the mapaParser
- parser to use to build sub-objectsaOptions
- parsing option settingsaValueIsArray
- true if the value of the map entires is an array. This method only supports homogeneous arrays.- Throws:
InvalidXMLException
- -
-
getWrapperClass
Gets the wrapper class corresponding to the given primitive type. For example,java.lang.Integer
is the wrapper class for the primitive typeint
.- Parameters:
aPrimitiveType
-Class
object representing a primitive type- Returns:
Class
object representing the wrapper type forPrimitiveType
. IfaPrimitiveType
is not a primitive type, it is itself returned.
-
getPropertyDescriptors
Deprecated.- use getAttributes insteadUtility method that introspects this bean and returns a list ofPropertyDescriptor
s for its properties.The JavaBeans introspector is used, with the IGNORE_ALL_BEANINFO flag. This saves on initialization time by preventing the introspector from searching for nonexistent BeanInfo classes for all the MetaDataObjects. Caching needed, this method is called for every access to a field, and introspection doesn't cache (from observation... although the javadocs say otherwise (as of Java6 10/2011 - both IBM and Sun)
- Returns:
- the
PropertyDescriptors
for all properties introduced by subclasses ofMetaDataObject_impl
. - Throws:
IntrospectionException
- if introspection fails
-
getMatchingNode
-
resolveSettings
-