Package org.smooks

Class Smooks

    • Method Detail

      • setFilterSettings

        public void setFilterSettings​(FilterSettings filterSettings)
        Set the filter settings for this Smooks instance.
        Parameters:
        filterSettings - The filter settings to be used.
      • setExports

        public Smooks setExports​(Exports exports)
        Set the Exports for this Smooks instance.
        Parameters:
        exports - The exports that will be created by this Smooks instance.
      • setReaderConfig

        public void setReaderConfig​(ReaderConfigurator readerConfigurator)
        Set the configuration for the reader to be used on this Smooks instance.
        Parameters:
        readerConfigurator - ReaderConfigurator instance.
      • setNamespaces

        public void setNamespaces​(Properties namespaces)
        Set the namespace prefix-to-uri mappings to be used on this Smooks instance.
        Parameters:
        namespaces - The namespace prefix-to-uri mappings.
      • addVisitor

        public ResourceConfig addVisitor​(Visitor visitor)
        Add a visitor instance to this Smooks instance.

        This Visitor will be targeted at the root (#document) fragment.

        Parameters:
        visitor - The visitor implementation.
      • addVisitor

        public ResourceConfig addVisitor​(Visitor visitor,
                                         String targetSelector)
        Add a visitor instance to this Smooks instance.
        Parameters:
        visitor - The visitor implementation.
        targetSelector - The message fragment target selector.
      • addResourceConfig

        public void addResourceConfig​(ResourceConfig resourceConfig)
        Add a resource configuration to this Smooks instance.

        These configurations do not overwrite previously added configurations. They are added to the list of configurations on this Smooks instance.

        Parameters:
        resourceConfig - The resource configuration to be added.
      • addResourceConfigs

        public void addResourceConfigs​(String resourceURI)
                                throws IOException,
                                       SAXException
        Add a set of resource configurations to this Smooks instance.

        Uses the URIResourceLocator class to load the resource.

        These configurations do not overwrite previously added configurations. They are added to the list of configurations on this Smooks instance.

        Parameters:
        resourceURI - The URI string for the resource configuration list. See URIResourceLocator.
        Throws:
        IOException - Error reading resource stream.
        SAXException - Error parsing the resource stream.
      • addResourceConfigs

        public void addResourceConfigs​(String baseURI,
                                       InputStream inputStream)
                                throws SAXException,
                                       IOException
        Add a set of resource configurations to this Smooks instance.

        These configurations do not overwrite previously added configurations. They are added to the list of configurations on this Smooks instance.

        The base URI is required for resolving resource imports. Just specify the location of the resource file.

        Parameters:
        baseURI - The base URI string for the resource configuration list. See URIResourceLocator.
        inputStream - The resource configuration stream.
        Throws:
        IOException - Error reading resource stream.
        SAXException - Error parsing the resource stream.
      • createExecutionContext

        public ExecutionContext createExecutionContext()
        Create a ExecutionContext instance for use on this Smooks instance.

        The created context is profile agnostic and should be used where profile based targeting is not in use.

        The context returned from this method is used in subsequent calls to filterSource(ExecutionContext, javax.xml.transform.Source, javax.xml.transform.Result...) It allows access to the execution context instance before and after calls on this method. This means the caller has an opportunity to set and get data bound to the execution context (before and after the calls), providing the caller with a mechanism for interacting with the content filtering phases.

        Returns:
        Execution context instance.
      • createExecutionContext

        public ExecutionContext createExecutionContext​(String targetProfile)
                                                throws UnknownProfileMemberException
        Create a ExecutionContext instance for use on this Smooks instance.

        The created context is profile aware and should be used where profile based targeting is in use. In this case, the transfromation/analysis resources must be configured with profile targeting information.

        The context returned from this method is used in subsequent calls to filterSource(ExecutionContext, javax.xml.transform.Source, javax.xml.transform.Result...). It allows access to the execution context instance before and after calls on this method. This means the caller has an opportunity to set and get data bound to the execution context (before and after the calls), providing the caller with a mechanism for interacting with the content filtering phases.

        Parameters:
        targetProfile - The target profile (base profile) on behalf of whom the filtering/serialisation filter is to be executed.
        Returns:
        Execution context instance.
        Throws:
        UnknownProfileMemberException - Unknown target profile.
      • filterSource

        public void filterSource​(Source source)
                          throws SmooksException
        Filter the content in the supplied Source instance.

        Not producing a Result.

        Parameters:
        source - The content Source.
        Throws:
        SmooksException - Failed to filter.
      • filterSource

        public void filterSource​(Source source,
                                 Result... results)
                          throws SmooksException
        Filter the content in the supplied Source instance, outputing data to the supplied Result instances.
        Parameters:
        source - The filter Source.
        results - The filter Results.
        Throws:
        SmooksException - Failed to filter.
      • close

        public void close()
        Close this Smooks instance and all associated resources.

        Should result in the uninitialization of all allocated ContentHandler instances.

        Specified by:
        close in interface AutoCloseable
        Specified by:
        close in interface Closeable