Interface ProcessingContext

    • Method Detail

      • getDefaultParameterResolver

        ParameterResolver getDefaultParameterResolver()
        Obtains the ParameterResolver to use for resolving parameters defined externally to the document being processed (ie: the operating system or container)
        Returns:
        the default ParameterResolver.
      • addCookie

        <T> void addCookie​(Class<T> clzCookie,
                           String sCookieName,
                           T cookie)
        Adds the specified named and typed cookie to the ProcessingContext.

        If a cookie with the same name and type exists in the ProcessingContext, it will be replaced by the specified cookie. If a cookie with the same name and type has been defined in an outer ProcessingContext, the specified cookie will hide the cookie defined in the outer ProcessingContext.

        Type Parameters:
        T - the type of the cookie
        Parameters:
        clzCookie - the class of the cookie
        sCookieName - the name of the cookie
        cookie - the cookie value
      • addCookie

        <T> void addCookie​(Class<T> clzCookie,
                           T cookie)
        Adds the specified cookie to the ProcessingContext.

        If a cookie of the same type and name (being the name of the class of the said cookie) is already registered with the ProcessingContext, it will be replaced by the specified cookie.

        If a cookie of the same type and name has been defined in an outer ProcessingContext, the specified cookie will hide the cookie defined in the outer ProcessingContext.

        This method is equivalent to calling: addCookie(clz, clz.getName(), cookie);

        Type Parameters:
        T - the type of the cookie
        Parameters:
        clzCookie - the class of the cookie
        cookie - the cookie value
      • getCookie

        <T> T getCookie​(Class<T> clzCookie,
                        String sCookieName)
        Locates and returns the cookie with the specified type and name.

        Locating the cookie involves searching the current ProcessingContext for a matching cookie. If one is not found, the search continues with outer ProcessingContexts until a cookie is either located or there are no more ProcessingContexts, in which case null is returned.

        Type Parameters:
        T - the type of the cookie
        Parameters:
        clzCookie - the class of the cookie
        sCookieName - the name of the cookie
        Returns:
        the cookie or null if not defined
      • getCookie

        <T> T getCookie​(Class<T> clzCookie)
        Locates and returns the cookie with the specified type.

        Locating the cookie involves searching the current ProcessingContext for a matching cookie. If one is not found, the search continues with outer ProcessingContexts until a cookie is either located or there are no more ProcessingContexts, in which case null is returned.

        This method is equivalent to calling: getCookie(clz, clz.getName());

        Type Parameters:
        T - the type of the cookie
        Parameters:
        clzCookie - the class of the cookie
        Returns:
        the cookie or null if not defined
      • definePropertyPath

        void definePropertyPath​(String sBeanPropertyName,
                                String sXmlPath)
        Defines the xml path to locate a specific Java Bean property with in an XmlElement in the ProcessingContext.

        This method allows "alias" paths for Java Bean properties to be defined so that inject(Object, XmlElement) calls may resolve property values correctly.

        This is an advanced feature. Typically this is only used when:

        1. A Java Bean property name does not match a named value, XmlElement or XmlAttribute with in a ProcessingContext.
        2. A Java Bean property can not be located with in the ProcessingContext.

        Parameters:
        sBeanPropertyName - the property name of the bean
        sXmlPath - the xmlPath to the property value
      • registerAttributeType

        <T> void registerAttributeType​(Class<T> clzType)
        Automatically creates and registers an AttributeProcessor for the specified type.

        Note: This assumes the type supports a String-based or XmlAttribute-based constructor.

        Type Parameters:
        T - the type
        Parameters:
        clzType - the type for which to create and register an AttributeProcessor
      • registerElementType

        <T> void registerElementType​(Class<T> clzType)
        Automatically creates and registers an ElementProcessor for the specified type.

        Note: This assumes the type supports a String-based or XmlElement-based constructor.

        Type Parameters:
        T - the type
        Parameters:
        clzType - the type for which to create and register an ElementProcessor
      • getNamespaceHandler

        NamespaceHandler getNamespaceHandler​(String sPrefix)
        Obtains the NamespaceHandler which is capable of processing the namespace with the specified prefix.
        Parameters:
        sPrefix - the prefix of the xml namespace
        Returns:
        null if a NamespaceHandler could not be located for the specified prefix
      • getNamespaceURI

        URI getNamespaceURI​(String sPrefix)
        Obtains the URI that is associated with the specified prefix.
        Parameters:
        sPrefix - the XML namespace prefix of the URI to locate
        Returns:
        null if a URI could not be located for the specified URI
      • processDocumentAt

        Object processDocumentAt​(URI uri)
                          throws ConfigurationException
        Request that the document specified by the URI/filename (containing the root of an XmlDocument) be processed with appropriate NamespaceHandlers.

        Should the document root contain any unrecognized xml namespaces, an attempt will be made to load appropriate NamespaceHandlers that of which will be used to process said elements in the document.

        Parameters:
        uri - the URI of the XmlDocument to process
        Returns:
        the result of the processing the root element of the document
        Throws:
        ConfigurationException - when a configuration problem was encountered
      • processDocumentAt

        Object processDocumentAt​(String sLocation)
                          throws ConfigurationException
        Request that the document specified by the URI/filename (containing the root of an XmlDocument) be processed with appropriate NamespaceHandlers.

        Should the document root contain any unrecognized xml namespaces, an attempt will be made to load appropriate NamespaceHandlers that of which will be used to process said elements in the document.

        Parameters:
        sLocation - the URI/filename of the XmlDocument to process
        Returns:
        the result of the processing the root element of the document
        Throws:
        ConfigurationException - when a configuration problem was encountered
      • processDocument

        Object processDocument​(XmlElement xmlElement)
                        throws ConfigurationException
        Request that the specified XmlElement (representing the root of an XmlDocument) be processed with appropriate NamespaceHandlers.

        Should the document root contain any unrecognized xml namespaces, an attempt will be made to load appropriate NamespaceHandlers that of which will be used to process said elements in the document.

        Parameters:
        xmlElement - the root XmlElement of the XmlDocument to process
        Returns:
        the result of the processing the root element of the document represented by the XmlElement
        Throws:
        ConfigurationException - when a configuration problem was encountered
      • processDocument

        Object processDocument​(String sXml)
                        throws ConfigurationException
        Request that the specified xml string (representing an xml document) be processed with appropriate NamespaceHandlers.

        Should the document root contain any unrecognized xml namespaces, an attempt will be made to load appropriate NamespaceHandlers that of which will be used to process said elements in the document.

        Parameters:
        sXml - a string containing an xml document to process
        Returns:
        the result of processing the root element of the document
        Throws:
        ConfigurationException - when a configuration problem was encountered
      • processElement

        Object processElement​(String sXml)
                       throws ConfigurationException
        Request the specified xml string be processed with an appropriate NamespaceHandler known by the ProcessingContext.

        Note: Should the element contain any unrecognized xml namespaces, an attempt will be made to load appropriate NamespaceHandlers that of which will be used to process said elements.

        Parameters:
        sXml - the xml to process
        Returns:
        the result of processing the root element of the specified xml
        Throws:
        ConfigurationException - when a configuration problem was encountered
      • processForeignElementsOf

        Map<String,​?> processForeignElementsOf​(XmlElement xmlElement)
                                              throws ConfigurationException
        Request that all of the child elements contained within the specified XmlElement that do not belong to the namespace of the said XmlElement are processed using appropriate processes.

        This is a convenience method to aid in the processing of all children of an XmlElement. The keys of the returned Map represent the id attributes each child XmlElement. If an XmlElement does not have a specified id attribute, a UUID is generated in it's place.

        Parameters:
        xmlElement - the parent XmlElement of the children to process
        Returns:
        a Map from identifiable child XmlElements (with id="..." attributes) and their corresponding processed values
        Throws:
        ConfigurationException - when a configuration problem was encountered
      • processOnlyElementOf

        <T> T processOnlyElementOf​(XmlElement xmlElement)
                            throws ConfigurationException
        Request that the only child element contained within the XmlElement is processed using an appropriate NamespaceHandler known by the ProcessingContext.
        Type Parameters:
        T - the type
        Parameters:
        xmlElement - the XmlElement in which the child is defined
        Returns:
        the result of processing the child element
        Throws:
        ConfigurationException - when a configuration problem was encountered, especially if there is zero or more than one child
      • processRemainingElementOf

        <T> T processRemainingElementOf​(XmlElement xmlElement)
                                 throws ConfigurationException
        Request that the last remaining unprocessed child element contained within the specified XmlElement is processed using an appropriate ElementProcessor.

        This is a convenience method to aid in the processing of an unprocessed child XmlElement of an element.

        Type Parameters:
        T - the type
        Parameters:
        xmlElement - the parent XmlElement of the unprocessed child to process
        Returns:
        the result of processing the child element
        Throws:
        ConfigurationException - if there are zero or more than one unprocessed child in the element, or if some other ConfigurationException occurred
      • processRemainingElementsOf

        Map<String,​?> processRemainingElementsOf​(XmlElement xmlElement)
                                                throws ConfigurationException
        Request that the last remaining unprocessed children contained within the specified XmlElement are processed using appropriate ElementProcessors.

        This is a convenience method to aid in the processing of an unprocessed child XmlElements of an element. The keys of the returned Map represent the id attributes each child XmlElement. If an XmlElement does not have a specified id attribute, a UUID is generated in it's place.

        Parameters:
        xmlElement - the parent XmlElement of the unprocessed children to process
        Returns:
        a Map from identifiable child XmlElements (with id="..." attributes) and their corresponding processed values
        Throws:
        ConfigurationException - when a configuration problem was encountered
      • isPropertyDefined

        boolean isPropertyDefined​(String sPath,
                                  XmlElement xmlElement)
                           throws ConfigurationException
        Determines if the specified property is defined at the path relative to the specified XmlElement.
        Parameters:
        sPath - the path to the property
        xmlElement - the XmlElement in which the property should be searched
        Returns:
        true if the property is defined, false otherwise
        Throws:
        ConfigurationException - if a configuration is not valid
      • getMandatoryProperty

        <T> T getMandatoryProperty​(String sPath,
                                   Type typeProperty,
                                   XmlElement xmlElement)
                            throws ConfigurationException
        Obtains the strongly typed value for the property defined at the path relative to the specified XmlElement. If the property is not defined or is of the incorrect type, a ConfigurationException is thrown.
        Type Parameters:
        T - the type of the property
        Parameters:
        sPath - the path to the property
        typeProperty - the type of the property
        xmlElement - the XmlElement containing the properties for the object
        Returns:
        the property value
        Throws:
        ConfigurationException - if a configuration is not valid, the property can't be located or is of the wrong type
      • getOptionalProperty

        <T> T getOptionalProperty​(String sPath,
                                  Type typeProperty,
                                  T defaultValue,
                                  XmlElement xmlElement)
                           throws ConfigurationException
        Obtains the strongly typed value for the property defined at the path relative to the specified XmlElement. If the property is not defined, the defaultValue is returned.
        Type Parameters:
        T - the type of the property
        Parameters:
        sPath - the path to the property
        typeProperty - the type of the property
        defaultValue - the value to return if the property is not found
        xmlElement - the XmlElement containing the properties for the object
        Returns:
        the property value
        Throws:
        ConfigurationException - if a configuration is not valid