Class DefaultResourceConfig

    • Method Detail

      • copy

        public ResourceConfig copy()
        Perform a shallow clone of this configuration.
        Specified by:
        copy in interface ResourceConfig
        Returns:
        Configuration clone.
      • getExtendedConfigNS

        @Deprecated
        public String getExtendedConfigNS()
        Deprecated.
        Get the extended config namespace from which this configuration was created.
        Specified by:
        getExtendedConfigNS in interface ResourceConfig
        Returns:
        The extended config namespace from which this configuration was created.
      • setExtendedConfigNS

        @Deprecated
        public void setExtendedConfigNS​(String extendedConfigNS)
        Deprecated.
        Set the extended config namespace from which this configuration was created.
        Specified by:
        setExtendedConfigNS in interface ResourceConfig
        Parameters:
        extendedConfigNS - The extended config namespace from which this configuration was created.
      • setSelector

        public void setSelector​(String selector,
                                Properties namespaces)
        Set the config selector.
        Specified by:
        setSelector in interface ResourceConfig
        Parameters:
        selector - The selector definition.
      • setResource

        public void setResource​(String resource)
        Set the configs "resource".
        Specified by:
        setResource in interface ResourceConfig
        Parameters:
        resource - The resource.
      • isInline

        public boolean isInline()
        Is this resource defined inline in the configuration, or is it referenced through a URI.

        Note that this method also returns false if the resource is undefined (null).

        Specified by:
        isInline in interface ResourceConfig
        Returns:
        True if the resource is defined inline, otherwise false.
      • getTargetProfile

        public String getTargetProfile()
        Get the target profile string as set in the configuration.
        Specified by:
        getTargetProfile in interface ResourceConfig
        Returns:
        The target profile.
      • setResourceType

        public void setResourceType​(String resourceType)
        Explicitly set the resource type.

        E.g. "class", "xsl", "groovy" etc.

        Specified by:
        setResourceType in interface ResourceConfig
        Parameters:
        resourceType - The resource type.
      • setSelectorPath

        public void setSelectorPath​(SelectorPath selectorPath)
        Set the selector steps.
        Specified by:
        setSelectorPath in interface ResourceConfig
        Parameters:
        selectorPath - The selector steps.
      • getResource

        public String getResource()
        Get the resource for this ResourceConfig.
        Specified by:
        getResource in interface ResourceConfig
        Returns:
        The cdrar path.
      • isDefaultResource

        public boolean isDefaultResource()
        Is this resource config a default applied resource.

        Some resources (e.g. DOMSerializerVisitor or DefaultSAXElementSerializer) are applied by default when no other resources are targeted at an element.

        Specified by:
        isDefaultResource in interface ResourceConfig
        Returns:
        True if this is a default applied resource, otherwise false.
      • setDefaultResource

        public void setDefaultResource​(boolean defaultResource)
        Set this resource config as a default applied resource.

        Some resources (e.g. DOMSerializerVisitor or DefaultSAXElementSerializer) are applied by default when no other resources are targeted at an element.

        Specified by:
        setDefaultResource in interface ResourceConfig
        Parameters:
        defaultResource - True if this is a default applied resource, otherwise false.
      • getResourceType

        public String getResourceType()
        Get the resource "type" for this resource.

        Determines the type through the following checks (in order):

        1. Is it a Java resource. See isJavaResource(). If it is, return "class".
        2. Is the "restype" resource paramater specified. If it is, return it's value. Ala DTD v1.0
        3. Is the resource type explicitly set on this configuration. If it is, return it's value. Ala the "type" attribute on the resource element on DTD v2.0
        4. Return the resource path file extension e.g. "xsl".
        Specified by:
        getResourceType in interface ResourceConfig
        Returns:
        The resource type.
      • setParameter

        public <T> Parameter<T> setParameter​(String name,
                                             T value)
        Set the named ResourceConfig parameter value (default type - String).

        Overwrites previous value of the same name.

        Specified by:
        setParameter in interface ResourceConfig
        Parameters:
        name - Parameter name.
        value - Parameter value.
        Returns:
        The parameter instance.
      • setParameter

        public <T> Parameter<T> setParameter​(String name,
                                             String type,
                                             T value)
        Set the named ResourceConfig parameter value (with type).

        Overwrites previous value of the same name.

        Specified by:
        setParameter in interface ResourceConfig
        Parameters:
        name - Parameter name.
        type - Parameter type.
        value - Parameter value.
        Returns:
        The parameter instance.
      • getParameter

        public <T> Parameter<T> getParameter​(String name,
                                             Class<T> valueClass)
        Get the named ResourceConfig parameter.

        If there is more than one of the named parameters defined, the first defined value is returned.

        Specified by:
        getParameter in interface ResourceConfig
        Parameters:
        name - Name of parameter to get.
        Returns:
        Parameter value, or null if not set.
      • getParameterValue

        public <T> T getParameterValue​(String name,
                                       Class<T> valueClass)
        Get the named ResourceConfig parameter.
        Specified by:
        getParameterValue in interface ResourceConfig
        Parameters:
        name - Name of parameter to get.
        Returns:
        Parameter value, or null if not set.
      • getParameterValue

        public <T> T getParameterValue​(String name,
                                       Class<T> valueClass,
                                       T defaultValue)
        Get the named ResourceConfig parameter.
        Specified by:
        getParameterValue in interface ResourceConfig
        Parameters:
        name - Name of parameter to get.
        defaultValue - The default value to be returned if there are no parameters on the this ResourceConfig instance, or the parameter is not defined.
        Returns:
        Parameter value, or defaultVal if not defined.
      • getParameterCount

        public int getParameterCount()
        Get the ResourceConfig parameter count.
        Specified by:
        getParameterCount in interface ResourceConfig
        Returns:
        Number of parameters defined on this ResourceConfig.
      • removeParameter

        public void removeParameter​(String name)
        Remove the named parameter.
        Specified by:
        removeParameter in interface ResourceConfig
        Parameters:
        name - The name of the parameter to be removed.
      • isXmlDef

        public boolean isXmlDef()
        Is this selector defininition an XML based definition.

        I.e. is the selector attribute value prefixed with "xmldef:".

        Specified by:
        isXmlDef in interface ResourceConfig
        Returns:
        True if this selector defininition is an XML based definition, otherwise false.
      • getBytes

        public byte[] getBytes()
        Get the resource as a byte array.

        If the resource data is not inlined in the configuration (in a "resdata" param), it will be resolved using the URIResourceLocator i.e. the path will be enterpretted as a URI. If the resource doesn't resolve to a stream producing URI, the resource string will be converted to bytes and returned.

        Specified by:
        getBytes in interface ResourceConfig
        Returns:
        The resource as a byte array, or null if resource path is null or the resource doesn't exist.
      • toJavaResource

        protected Class<?> toJavaResource()
        Returns the resource as a Java Class instance.
        Returns:
        The Java Class instance refered to be this resource configuration, or null if the resource doesn't refer to a Java Class.
      • isJavaResource

        public boolean isJavaResource()
        Does this resource configuration refer to a Java Class resource.
        Specified by:
        isJavaResource in interface ResourceConfig
        Returns:
        True if this resource configuration refers to a Java Class resource, otherwise false.
      • toXml

        public String toXml()
        Generate an XML'ified description of this resource.
        Specified by:
        toXml in interface ResourceConfig
        Returns:
        XML'ified description of the resource.
      • equals

        public final boolean equals​(Object obj)
        Overrides:
        equals in class Object