net.sf.okapi.common.filters

## Interface IFilter

- All Superinterfaces:
    java.lang.AutoCloseable
  All Known Implementing Classes:
    AbstractFilter, SubFilter

      public interface IFilter
      extends java.lang.AutoCloseable

  Common set of methods to extract translatable text and its associated data.

  The following example shows a typical use of IFilter:

       MyUtlity myUtility = new MyUtility(); // Some object that do things with filter events
       IFilter filter = new MyFilter(); // A filter implementation
       filter.open(new RawDocument(URI("myFile.ext"), "UTF-8", "en");
       while ( filter.hasNext() ) {
          myUtility.handleEvent(filter.next());
       }
       filter.close();

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static java.lang.String` | `SUB_FILTER` Prefix marker indicating a sub-filter in the name of a `StartDocument` object created when processing content with sub-filters.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `cancel()` Cancels the current process.
    `void` | `close()` Closes the input document.
    `IFilterWriter` | `createFilterWriter()` Creates a new IFilterWriter object from the most appropriate class to use with this filter.
    `ISkeletonWriter` | `createSkeletonWriter()` Creates a new ISkeletonWriter object that corresponds to the type of skeleton this filter uses.
    `java.util.List<FilterConfiguration>` | `getConfigurations()` Gets the list of all predefined configurations for this filter.
    `java.lang.String` | `getDisplayName()` Gets the localizable display name of this filter.
    `EncoderManager` | `getEncoderManager()` Gets the EncoderManager object for this filter.
    `java.lang.String` | `getMimeType()` Gets the MIME type of the format supported by this filter.
    `java.lang.String` | `getName()` Gets the name/identifier of this filter.
    `IParameters` | `getParameters()` Gets the current parameters for this filter.
    `boolean` | `hasNext()` Indicates if there is an event to process.
    `Event` | `next()` Gets the next event available.
    `void` | `open(RawDocument input)` Opens the input document described in a give RawDocument object.
    `void` | `open(RawDocument input, boolean generateSkeleton)` Opens the input document described in a give RawDocument object, and optionally creates skeleton information.
    `void` | `setFilterConfigurationMapper(IFilterConfigurationMapper fcMapper)` Sets the filter configuration mapper for this filter.
    `void` | `setParameters(IParameters params)` Sets new parameters for this filter.

- - ### Field Detail

    - #### SUB_FILTER

          static final java.lang.String SUB_FILTER

      Prefix marker indicating a sub-filter in the name of a `StartDocument` object created when processing content with sub-filters.
      See Also:
        Constant Field Values

  - ### Method Detail

    - #### getName

          java.lang.String getName()

      Gets the name/identifier of this filter.
      Returns:
        The name/identifier of the filter.

    - #### getDisplayName

          java.lang.String getDisplayName()

      Gets the localizable display name of this filter.
      Returns:
        the localizable display name of this filter.

    - #### open

          void open(RawDocument input)

      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

          void open(RawDocument input,
                  boolean generateSkeleton)

      Opens the input document described in a give RawDocument object, and optionally creates skeleton information.
      Parameters:
        `input` - The RawDocument object to use to open the document.
        `generateSkeleton` - true to generate the skeleton data, false otherwise.

    - #### close

          void close()

      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 `java.lang.AutoCloseable`

    - #### hasNext

          boolean hasNext()

      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

          Event next()

      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.

    - #### cancel

          void cancel()

      Cancels the current process.

    - #### getParameters

          IParameters getParameters()

      Gets the current parameters for this filter.
      Returns:
        The current parameters for this filter, or null if this filter has no parameters.

    - #### setParameters

          void setParameters(IParameters params)

      Sets new parameters for this filter.
      Parameters:
        `params` - The new parameters to use.

    - #### setFilterConfigurationMapper

          void setFilterConfigurationMapper(IFilterConfigurationMapper fcMapper)

      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.
      Parameters:
        `fcMapper` - the mapper to set.

    - #### createSkeletonWriter

          ISkeletonWriter createSkeletonWriter()

      Creates a new ISkeletonWriter object that corresponds to the type of skeleton this filter uses.
      Returns:
        A new instance of ISkeletonWriter for the type of skeleton this filter uses.

    - #### createFilterWriter

          IFilterWriter createFilterWriter()

      Creates a new IFilterWriter object from the most appropriate class to use with this filter.
      Returns:
        A new instance of IFilterWriter for the preferred implementation for this filter.

    - #### getEncoderManager

          EncoderManager getEncoderManager()

      Gets the EncoderManager object for this filter. This encoder manager should provided the mappings to the different MIME types used by the filter.
      Returns:
        the EncoderManager for this filter.

    - #### getMimeType

          java.lang.String getMimeType()

      Gets the MIME type of the format supported by this filter.
      Returns:
        The MIME type of the format supported by this filter.

    - #### getConfigurations

          java.util.List<FilterConfiguration> getConfigurations()

      Gets the list of all predefined configurations for this filter.
      Returns:
        a list of the all predefined configurations for this filter.