Class ArchiveFilter

  • All Implemented Interfaces:
    AutoCloseable, Iterator<Event>, IFilter
    Direct Known Subclasses:
    SdlPackageFilter

    public class ArchiveFilter
    extends AbstractFilter
    Implements the IFilter interface for archive-based (ZIP) content. This filter generates events for certain files in the archive. Those files are processed with sub-filters that are instantiated automatically based on the file names. Mapping between the file names and filter configurations to be used is defined in the filter parameters. File names in filter parameters may contain wildcards (* and ?). The files, for which file names no sub-filter configId is provided, will be sent as document parts with ZipSkeleton.

    MIME type of the format supported by the filter is not defined by the filter, but is specified via filter parameters. It allows to use the same filter for different container formats, e.g. DOCX, ODT, etc. by only changing a set of filter parameters.

    Please note that when you configure this filter and specify sub-filter classes for the files of interest inside the container, you are responsible to provide visibility of class loaders of those sub-filter classes you specify, otherwise the ArchiveFilter won't be able to instantiate the sub-filters, and an exception will be thrown.

    To configure the filter, specify in Parameters the comma-separated lists of file names (may contain wildcards) and their corresponding config Ids.

    When specifying congigId for a file, you can choose one of the configurations provided by DefaultFilters class. If the desired configuration is not provided there, you can use setFilterConfigurationMapper() to set your own FilterConfiguationMapper, or alternatively you can get a reference to the default implementation of IFilterConfigurationMapper provided by this class, and use addConfiguration() and other methods to configure it to your desire.

    • Constructor Detail

      • ArchiveFilter

        public ArchiveFilter()
    • Method Detail

      • close

        public void close()
        Description copied from interface: IFilter
        Closes the input document. Developers should call this method from within their code before sending the last event: This can allow writer objects to overwrite the input file when they receive the last event. This method must also be safe to call even if the input document is not opened.
        Specified by:
        close in interface AutoCloseable
        Specified by:
        close in interface IFilter
        Overrides:
        close in class AbstractFilter
      • getEncoderManager

        public EncoderManager getEncoderManager()
        Description copied from interface: IFilter
        Gets the EncoderManager object for this filter. This encoder manager should provided the mappings to the different MIME types used by the filter.
        Specified by:
        getEncoderManager in interface IFilter
        Overrides:
        getEncoderManager in class AbstractFilter
        Returns:
        the EncoderManager for this filter.
      • getName

        public String getName()
        Description copied from interface: IFilter
        Gets the name/identifier of this filter.
        Specified by:
        getName in interface IFilter
        Overrides:
        getName in class AbstractFilter
        Returns:
        The name/identifier of the filter.
      • hasNext

        public boolean hasNext()
        Description copied from interface: IFilter
        Indicates if there is an event to process.

        Implementer Note: The caller must be able to call this method several times without changing state.

        Returns:
        True if there is at least one event to process, false if not.
      • next

        public Event next()
        Description copied from interface: IFilter
        Gets the next event available. Calling this method can be done only once on each event.
        Returns:
        The next event available or null if there are no events.
      • open

        public void open​(RawDocument input)
        Description copied from interface: IFilter
        Opens the input document described in a give RawDocument object. Skeleton information is always created when you use this method.
        Parameters:
        input - The RawDocument object to use to open the document.
      • open

        public void open​(RawDocument input,
                         boolean generateSkeleton)
        Description copied from interface: IFilter
        Opens the input document described in a give RawDocument object, and optionally creates skeleton information.
        Specified by:
        open in interface IFilter
        Overrides:
        open in class AbstractFilter
        Parameters:
        input - The RawDocument object to use to open the document.
        generateSkeleton - true to generate the skeleton data, false otherwise.
      • setFilterConfigurationMapper

        public void setFilterConfigurationMapper​(IFilterConfigurationMapper fcMapper)
        Description copied from interface: IFilter
        Sets the filter configuration mapper for this filter. This object is used by this filter if it needs to instantiate sub-filters. The implementations of IFilter that do not use sub-filters can use an empty stub for this method.
        Specified by:
        setFilterConfigurationMapper in interface IFilter
        Overrides:
        setFilterConfigurationMapper in class AbstractFilter
        Parameters:
        fcMapper - the mapper to set.
      • isUtf8Encoding

        protected boolean isUtf8Encoding()
        Description copied from class: AbstractFilter
        Is the input encoded as UTF-8?
        Overrides:
        isUtf8Encoding in class AbstractFilter
        Returns:
        true if the document is in utf8 encoding.
      • isUtf8Bom

        protected boolean isUtf8Bom()
        Description copied from class: AbstractFilter
        Does the input have a UTF-8 Byte Order Mark?
        Overrides:
        isUtf8Bom in class AbstractFilter
        Returns:
        true if the document has a utf-8 byte order mark.