Class XmlMapping


  • public class XmlMapping
    extends java.lang.Object
    Stores parsing information about an XML mapping file.
    Since:
    1.2.1
    See Also:
    XmlMappingParser
    • Constructor Summary

      Constructors 
      Constructor Description
      XmlMapping()
      Constructs a new XmlMapping.
      XmlMapping​(java.lang.String name, java.lang.String location, XmlMapping parent)
      Constructs a new XmlMapping.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addImport​(XmlMapping child)
      Adds an imported mapping file to this mapping file.
      boolean addTemplate​(java.lang.String name, org.w3c.dom.Element element)
      Adds a template configuration to this mapping file.
      void addTypeHandlers​(java.util.List<TypeHandlerConfig> list)
      Recursively adds type handlers from all imported mapping files, and from this mapping file, to a given list.
      org.w3c.dom.Element findTemplate​(java.lang.String name)
      Recursively finds the template DOM element for a given template name in this mapping file and its parents.
      BeanIOConfig getConfiguration()
      Returns the BeanIO configuration for this mapping file.
      java.lang.String getLocation()
      Returns the location of this mapping file (in URL format).
      java.lang.String getName()
      Returns the name of this mapping file.
      XmlMapping getParent()
      Returns the parent mapping file that imported this mapping file, or null if this file is the "root" mapping file.
      java.util.Properties getProperties()
      Returns the properties declared in this mapping file.
      boolean isDeclaredGlobalTypeHandler​(java.lang.String name)
      Returns whether a global type handler was configured for the given type handler name.
      boolean isLoading​(java.lang.String url)
      Returns whether a given mapping file is being actively loaded using its location to identify it.
      void setProperty​(java.lang.String name, java.lang.String value)
      Sets a property declared in this mapping file.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • XmlMapping

        public XmlMapping()
        Constructs a new XmlMapping.
      • XmlMapping

        public XmlMapping​(java.lang.String name,
                          java.lang.String location,
                          XmlMapping parent)
        Constructs a new XmlMapping.
        Parameters:
        name - the mapping file name used for error messages
        location - the location of the mapping (this should be the absolute URL location of the file so that the same mapping file will always have the same the location)
        parent - the parent mapping
    • Method Detail

      • getName

        public java.lang.String getName()
        Returns the name of this mapping file.
        Returns:
        the name of the mapping file
      • getLocation

        public java.lang.String getLocation()
        Returns the location of this mapping file (in URL format).
        Returns:
        the absolute URL location of this mapping file
      • getConfiguration

        public BeanIOConfig getConfiguration()
        Returns the BeanIO configuration for this mapping file.
        Returns:
        the BeanIO configuration
      • getParent

        public XmlMapping getParent()
        Returns the parent mapping file that imported this mapping file, or null if this file is the "root" mapping file.
        Returns:
        the parent mapping file
      • addImport

        public void addImport​(XmlMapping child)
        Adds an imported mapping file to this mapping file.
        Parameters:
        child - the imported mapping file
      • isLoading

        public boolean isLoading​(java.lang.String url)
        Returns whether a given mapping file is being actively loaded using its location to identify it. This is used for detecting circular references.
        Parameters:
        url - the mapping file location to check
        Returns:
        true if the given location is being actively loaded, and thus the mapping file contains a circular reference
      • setProperty

        public void setProperty​(java.lang.String name,
                                java.lang.String value)
        Sets a property declared in this mapping file.
        Parameters:
        name - the property name
        value - the property value
      • getProperties

        public java.util.Properties getProperties()
        Returns the properties declared in this mapping file.
        Returns:
        the Properties
      • addTypeHandlers

        public void addTypeHandlers​(java.util.List<TypeHandlerConfig> list)
        Recursively adds type handlers from all imported mapping files, and from this mapping file, to a given list.
        Parameters:
        list - the list to add all type handlers too
      • addTemplate

        public boolean addTemplate​(java.lang.String name,
                                   org.w3c.dom.Element element)
        Adds a template configuration to this mapping file.
        Parameters:
        name - the name of the template
        element - the 'template' DOM element
        Returns:
        true if the template was successfuly added, or false if the template name already existed
      • findTemplate

        public org.w3c.dom.Element findTemplate​(java.lang.String name)
        Recursively finds the template DOM element for a given template name in this mapping file and its parents.
        Parameters:
        name - the name of the template to retrieve
        Returns:
        the matching template Element
      • isDeclaredGlobalTypeHandler

        public boolean isDeclaredGlobalTypeHandler​(java.lang.String name)
        Returns whether a global type handler was configured for the given type handler name. Recursively checks all imported mapping files.
        Parameters:
        name - the type handler name
        Returns:
        true if a type handler was declared globally for the given name
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object