Class MetaDataObject_impl

    • Field Detail

      • serialContext

        public static final ThreadLocal<MetaDataObject_impl.SerialContext> 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 Detail

      • MetaDataObject_impl

        public MetaDataObject_impl()
        Creates a new MetaDataObject_impl with null attribute values
    • Method Detail

      • setInfoset

        public void setInfoset​(Node infoset)
      • getInfoset

        public Node getInfoset()
      • getAdditionalAttributes

        public List<MetaDataObject_impl.MetaDataAttr> getAdditionalAttributes()
        Override this method to include additional attributes
        Returns:
        additional attributes
      • listAttributes

        @Deprecated
        public List<NameClassPair> listAttributes()
        Deprecated.
        - use getAttributes
        Returns a list of NameClassPair 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 interface MetaDataObject
        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:
        MetaDataObject.listAttributes()
      • getAttributeClass

        public Class getAttributeClass​(String aName)
        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 interface MetaDataObject
        Returns:
        true if and only if this object's attributes may be modified.
        See Also:
        MetaDataObject.isModifiable()
      • getRelativePathBase

        public URL 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

        public URL 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 interface MetaDataObject
        Returns:
        the source URL from which this object was parsed
      • getSourceUrlString

        public String 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 interface MetaDataObject
        Returns:
        the source URL as a string, or "<unknown>"
      • setSourceUrlIfNull

        public void setSourceUrlIfNull​(URL aUrl)
        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

        public void setSourceUrl​(URL aUrl)
        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 interface MetaDataObject
        Parameters:
        aUrl - the location of the XML file from which this object was parsed
      • toString

        public String toString()
        Dump this metadata object's attributes and values to a String. This is useful for debugging.
        Overrides:
        toString in class Object
      • equals

        public boolean equals​(Object aObj)
        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 interface MetaDataObject
        Overrides:
        equals in class Object
        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 NameClassPairs x and y must be equal if x.equals(y) returns true;
        Overrides:
        hashCode in class Object
        Returns:
        the hash code for this object
      • getXMLAttributes

        protected AttributesImpl getXMLAttributes()
        Called by the toXML(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

        protected abstract XmlizationInfo 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

        protected PropertyXmlInfo getPropertyXmlInfo​(String aXmlElementName)
        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

        public boolean valueIsNullOrEmptyArray​(Object val)
      • 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 XML
        aNamespace - 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 attribute
        aPropClass - class of the attribute
        aValue - value (guaranteed to be an array and non-null)
        aArrayElementTagName - name of tag to be assigned to each element of the array. May be null, 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 a Map with String keys and XMLizable values.
        Parameters:
        aPropName - name of the property to write to XML
        aXmlElementName - name of the XML element for the property, null if none
        aKeyXmlAttribute - name of the XML attribute for the key
        aValueTagName - XML element tag name to use for each entry in the Map
        aOmitIfNull - if true, null or empty map will not be written at all, if false, null or empty map will be written as an empty element
        aNamespace - namespace for this object
        Throws:
        SAXException - passthru
      • 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 the XMLParser. It is overridden by specific Java impl classes to provide additional defaulting (e.g. see AnalysisEngineDescription_impl)
        Specified by:
        buildFromXMLElement in interface XMLizable
        Parameters:
        aElement - the XML element that represents this object.
        aParser - a reference to the UIMA XMLParser. The XMLParser.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 read
        aElement - DOM element to read from
        aParser - parser to use to construct complex values
        aOptions - 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 read
        aPropClass - class of the property's value
        aElement - DOM element representing the entire array
        aParser - parser to use to construct complex values
        aOptions - 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 from
        aParser - parser to use to construct complex values
        aOptions - -
        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 a Map with String keys and XMLizable (or an array of these) values.
        Parameters:
        aPropName - name of the property to read from XML
        aElement - element to read from
        aKeyXmlAttribute - XML attribute for the key
        aValueTagName - XML element tag name for each entry in the map
        aParser - parser to use to build sub-objects
        aOptions - parsing option settings
        aValueIsArray - true if the value of the map entires is an array. This method only supports homogeneous arrays.
        Throws:
        InvalidXMLException - -
      • getWrapperClass

        protected static Class getWrapperClass​(Class aPrimitiveType)
        Gets the wrapper class corresponding to the given primitive type. For example, java.lang.Integer is the wrapper class for the primitive type int.
        Parameters:
        aPrimitiveType - Class object representing a primitive type
        Returns:
        Class object representing the wrapper type for PrimitiveType. If aPrimitiveType is not a primitive type, it is itself returned.
      • getPropertyDescriptors

        @Deprecated
        protected PropertyDescriptor[] getPropertyDescriptors()
                                                       throws IntrospectionException
        Deprecated.
        - use getAttributes instead
        Utility method that introspects this bean and returns a list of PropertyDescriptors 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 of MetaDataObject_impl.
        Throws:
        IntrospectionException - if introspection fails
      • resolveSettings

        protected String resolveSettings​(String text)