Class AbstractFilter

    • Constructor Detail

      • AbstractFilter

        public AbstractFilter()
        Default constructor
    • Method Detail

      • getParameters

        public IParameters getParameters()
        Description copied from interface: IFilter
        Gets the current parameters for this filter.
        Specified by:
        getParameters in interface IFilter
        Returns:
        The current parameters for this filter, or DefaultParameters if this filter has no parameters.
      • setParameters

        public void setParameters​(IParameters params)
        Description copied from interface: IFilter
        Sets new parameters for this filter.
        Specified by:
        setParameters in interface IFilter
        Parameters:
        params - The new parameters to use.
      • getParameters

        public <A> A getParameters​(Class<A> expectedClass)
      • getParametersClassName

        public String getParametersClassName()
      • setOptions

        public void setOptions​(LocaleId sourceLocale,
                               LocaleId targetLocale,
                               String defaultEncoding,
                               boolean generateSkeleton)
        Each IFilter has a small set of options beyond normal configuration that gives the IFilter the needed information to properly parse the content.
        Parameters:
        sourceLocale - - source locale of the input document
        targetLocale - - target locale if the input document is multilingual.
        defaultEncoding - - assumed encoding of the input document. May be overridden if a different encoding is detected.
        generateSkeleton - - store skeleton (non-translatable parts of the document) along with the extracted text.
      • createStartFilterEvent

        protected Event createStartFilterEvent()
        create a START_DOCUMENT Event
        Returns:
        the newly created StartDocument event.
      • createEndFilterEvent

        protected Event createEndFilterEvent()
        create a END_DOCUMENT Event
        Returns:
        the newly created Ending event.
      • removeConfiguration

        public boolean removeConfiguration​(String configId)
      • getConfigurations

        public List<FilterConfiguration> getConfigurations()
        Description copied from interface: IFilter
        Gets the list of all predefined configurations for this filter.
        Specified by:
        getConfigurations in interface IFilter
        Returns:
        a list of the all predefined configurations for this filter.
      • 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
        Returns:
        the EncoderManager for this filter.
      • addConfiguration

        protected boolean addConfiguration​(boolean clearAllExisting,
                                           String configId,
                                           String name,
                                           String description,
                                           String parametersLocation)
      • addConfiguration

        protected boolean addConfiguration​(boolean clearAllExisting,
                                           String configId,
                                           String name,
                                           String description,
                                           String parametersLocation,
                                           String extensions)
      • cancel

        public void cancel()
        Description copied from interface: IFilter
        Cancels the current process.
        Specified by:
        cancel in interface IFilter
      • 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
      • 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
        Parameters:
        input - The RawDocument object to use to open the document.
        generateSkeleton - true to generate the skeleton data, false otherwise.
      • getFilterConfigurationMapper

        protected IFilterConfigurationMapper getFilterConfigurationMapper()
        Gets the filter configuration mapper if available. This mapper can be used to instantiate sub-filters based on filter configurations.
        Returns:
        the filter configuration mapper.
      • 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
        Parameters:
        fcMapper - the mapper to set.
      • getDocumentName

        public String getDocumentName()
        Gets the START_DOCUMENT name for the current input.
        Returns:
        the document name or path of the current input.
      • setDocumentName

        protected void setDocumentName​(String documentName)
        Allows implementers to set the START_DOCUMENT name for the current input.
        Parameters:
        documentName - the input document name or path
      • setNewlineType

        protected void setNewlineType​(String newlineType)
        Sets the newline type.
        Parameters:
        newlineType - one of '\n', '\r' or '\r\n'.
      • getEncoding

        public String getEncoding()
        Gets the input document encoding.
        Returns:
        the encoding
      • setEncoding

        protected void setEncoding​(String encoding)
        Sets the input document encoding.
        Parameters:
        encoding - the new encoding
      • getSrcLoc

        public LocaleId getSrcLoc()
        Gets the input document source locale.
        Returns:
        the source locale
      • setSrcLoc

        public void setSrcLoc​(LocaleId srcLoc)
        Sets the input document source locale.
        Parameters:
        srcLoc - the new source locale
      • getTrgLoc

        public LocaleId getTrgLoc()
        Returns:
        the trgLoc
      • setTrgLoc

        public void setTrgLoc​(LocaleId trgLoc)
        Parameters:
        trgLoc - the target locale to set
      • getMimeType

        public String getMimeType()
        Gets the input document mime type.
        Specified by:
        getMimeType in interface IFilter
        Returns:
        the mime type
      • setMimeType

        public void setMimeType​(String mimeType)
        Sets the input document mime type.
        Parameters:
        mimeType - the new mime type
      • isCanceled

        public boolean isCanceled()
        Checks if the IFilter has been canceled.
        Returns:
        true, if is canceled
      • isGenerateSkeleton

        public boolean isGenerateSkeleton()
        Returns:
        the generateSkeleton
      • setGenerateSkeleton

        protected void setGenerateSkeleton​(boolean generateSkeleton)
        Parameters:
        generateSkeleton - the generateSkeleton to set
      • isMultilingual

        public boolean isMultilingual()
        Specified by:
        isMultilingual in interface IFilter
        Returns:
        the multilingual
      • setMultilingual

        protected void setMultilingual​(boolean multilingual)
        Parameters:
        multilingual - the multilingual to set
      • getName

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

        protected void setName​(String name)
      • getDisplayName

        public String getDisplayName()
        Description copied from interface: IFilter
        Gets the localizable display name of this filter.
        Specified by:
        getDisplayName in interface IFilter
        Returns:
        the localizable display name of this filter.
      • setDisplayName

        protected void setDisplayName​(String displayName)
      • getParentId

        public String getParentId()
      • setParentId

        public void setParentId​(String parentId)
      • isUtf8Encoding

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

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