net.sf.okapi.common.filters

## Class SubFilter

- java.lang.Object
- - net.sf.okapi.common.filters.SubFilter

- All Implemented Interfaces:
    java.lang.AutoCloseable, IFilter

      public class SubFilter
      extends java.lang.Object
      implements IFilter

  Adapter that converts any `IFilter` into a subfilter (a filter called from another `IFilter`). Specific implementations can implement this class and override any needed methods to transform `Event`s as they are produced. This class should be used to wrap filters that use `GenericSkeleton` and its subclasses. If a different type of skeleton is used or id/name generation logic should be changed, subclass this class.

- - ### Field Summary

    - ### Fields inherited from interface net.sf.okapi.common.filters.IFilter

      `SUB_FILTER`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `SubFilter(IFilter filter, IEncoder parentEncoder, int sectionIndex, java.lang.String parentId, java.lang.String parentName)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected java.lang.String` | `buildRefId()`
    `protected java.lang.String` | `buildRefName()`
    `protected java.lang.String` | `buildResourceId(java.lang.String resId, java.lang.Class<? extends IResource> resClass)`
    `protected java.lang.String` | `buildResourceName(java.lang.String resName, boolean autoGenerated, java.lang.Class<? extends INameable> resClass)`
    `void` | `cancel()` Cancels the current process.
    `void` | `close()` Closes the input document.
    `protected void` | `convertRefsInSkeleton(ISkeleton skel)`
    `IFilterWriter` | `createFilterWriter()` Creates a new IFilterWriter object from the most appropriate class to use with this filter.
    `Code` | `createRefCode()`
    `Event` | `createRefEvent()`
    `Event` | `createRefEvent(IResource resource)`
    `Event` | `createRefEvent(ISkeleton beforeSkeleton, ISkeleton afterSkeleton)`
    `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.
    `SubFilterEventConverter` | `getConverter()`
    `java.lang.String` | `getDisplayName()` Gets the localizable display name of this filter.
    `EncoderManager` | `getEncoderManager()` Gets the EncoderManager object for this filter.
    `java.util.List<Event>` | `getEvents(RawDocument input)` Get events by subfilter at once, without using open()/hasNext()/next()/close().
    `IFilter` | `getFilter()`
    `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.
    `protected java.lang.String` | `getParentId()`
    `protected java.lang.String` | `getParentName()`
    `protected int` | `getSectionIndex()`
    `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.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### SubFilter

          public SubFilter(IFilter filter,
                   IEncoder parentEncoder,
                   int sectionIndex,
                   java.lang.String parentId,
                   java.lang.String parentName)

  - ### Method Detail

    - #### getFilter

          public IFilter getFilter()

    - #### getConverter

          public SubFilterEventConverter getConverter()

    - #### getName

          public java.lang.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.

    - #### getDisplayName

          public java.lang.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.

    - #### 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.
      Specified by:
        `open` in interface `IFilter`
      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`
      Parameters:
        `input` - The RawDocument object to use to open the document.
        `generateSkeleton` - true to generate the skeleton data, false otherwise.

    - #### 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 `java.lang.AutoCloseable`
      Specified by:
        `close` in interface `IFilter`

    - #### 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.

      Specified by:
        `hasNext` in interface `IFilter`
      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.
      Specified by:
        `next` in interface `IFilter`
      Returns:
        The next event available or null if there are no events.

    - #### cancel

          public void cancel()

      Description copied from interface: `IFilter`
      Cancels the current process.
      Specified by:
        `cancel` in interface `IFilter`

    - #### 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 null 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.

    - #### 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.

    - #### createSkeletonWriter

          public ISkeletonWriter createSkeletonWriter()

      Description copied from interface: `IFilter`
      Creates a new ISkeletonWriter object that corresponds to the type of skeleton this filter uses.
      Specified by:
        `createSkeletonWriter` in interface `IFilter`
      Returns:
        A new instance of ISkeletonWriter for the type of skeleton this filter uses.

    - #### createFilterWriter

          public IFilterWriter createFilterWriter()

      Description copied from interface: `IFilter`
      Creates a new IFilterWriter object from the most appropriate class to use with this filter.
      Specified by:
        `createFilterWriter` in interface `IFilter`
      Returns:
        A new instance of IFilterWriter for the preferred implementation 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.

    - #### getMimeType

          public java.lang.String getMimeType()

      Description copied from interface: `IFilter`
      Gets the MIME type of the format supported by this filter.
      Specified by:
        `getMimeType` in interface `IFilter`
      Returns:
        The MIME type of the format supported by this filter.

    - #### getConfigurations

          public java.util.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.

    - #### getEvents

          public java.util.List<Event> getEvents(RawDocument input)

      Get events by subfilter at once, without using open()/hasNext()/next()/close().
      Parameters:
        `input` - the `RawDocument` to retrieve events from.
      Returns:
        a list of events created the this subfilter for a given RawDocument input.

    - #### createRefCode

          public Code createRefCode()

    - #### createRefEvent

          public Event createRefEvent()

    - #### createRefEvent

          public Event createRefEvent(IResource resource)

    - #### createRefEvent

          public Event createRefEvent(ISkeleton beforeSkeleton,
                             ISkeleton afterSkeleton)

    - #### buildResourceId

          protected java.lang.String buildResourceId(java.lang.String resId,
                                         java.lang.Class<? extends IResource> resClass)

    - #### buildResourceName

          protected java.lang.String buildResourceName(java.lang.String resName,
                                           boolean autoGenerated,
                                           java.lang.Class<? extends INameable> resClass)

    - #### buildRefId

          protected java.lang.String buildRefId()

    - #### buildRefName

          protected java.lang.String buildRefName()

    - #### getParentId

          protected final java.lang.String getParentId()

    - #### getParentName

          protected final java.lang.String getParentName()

    - #### getSectionIndex

          protected final int getSectionIndex()

    - #### convertRefsInSkeleton

          protected void convertRefsInSkeleton(ISkeleton skel)