de.init.its.okapi.ext
Interface IFilter

All Known Implementing Classes:
ODFFilter

public interface IFilter

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
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
 void cancel()
          Cancels the current process.
 void close()
          Closes the input document.
 net.sf.okapi.common.filterwriter.IFilterWriter createFilterWriter()
          Creates a new IFilterWriter object from the most appropriate class to use with this filter.
 net.sf.okapi.common.skeleton.ISkeletonWriter createSkeletonWriter()
          Creates a new ISkeletonWriter object that corresponds to the type of skeleton this filter uses.
 java.util.List<net.sf.okapi.common.filters.FilterConfiguration> getConfigurations()
          Gets the list of all predefined configurations for this filter.
 java.lang.String getDisplayName()
          Gets the localizable display name of this filter.
 net.sf.okapi.common.encoder.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.
 net.sf.okapi.common.IParameters getParameters()
          Gets the current parameters for this filter.
 boolean hasNext()
          Indicates if there is an event to process.
 net.sf.okapi.common.Event next()
          Gets the next event available.
 void open(net.sf.okapi.common.resource.RawDocument input)
          Opens the input document described in a give RawDocument object.
 void open(net.sf.okapi.common.resource.RawDocument input, boolean generateSkeleton)
          Opens the input document described in a give RawDocument object, and optionally creates skeleton information.
 void setFilterConfigurationMapper(net.sf.okapi.common.filters.IFilterConfigurationMapper fcMapper)
          Sets the filter configuration mapper for this filter.
 void setParameters(net.sf.okapi.common.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(net.sf.okapi.common.resource.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(net.sf.okapi.common.resource.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.

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.


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

net.sf.okapi.common.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

net.sf.okapi.common.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(net.sf.okapi.common.IParameters params)
Sets new parameters for this filter.

Parameters:
params - The new parameters to use.

setFilterConfigurationMapper

void setFilterConfigurationMapper(net.sf.okapi.common.filters.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

net.sf.okapi.common.skeleton.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

net.sf.okapi.common.filterwriter.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

net.sf.okapi.common.encoder.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<net.sf.okapi.common.filters.FilterConfiguration> getConfigurations()
Gets the list of all predefined configurations for this filter.

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