Package net.sf.okapi.common.filters
Interface IFilter
-
- All Superinterfaces:
AutoCloseable,Iterator<Event>
- All Known Subinterfaces:
ISubFilter
- All Known Implementing Classes:
AbstractCompoundFilter,AbstractFilter,AbstractLineFilter,AbstractMarkupFilter,AbstractSubFilter,ArchiveFilter,AutoXLIFFFilter,BasePlainTextFilter,BaseTableFilter,CommaSeparatedValuesFilter,DoxygenFilter,DTDFilter,FixedWidthColumnsFilter,HTML5Filter,HtmlFilter,ICMLFilter,IDMLFilter,ITSFilter,JSONFilter,MarkdownFilter,MIFFilter,MosesTextFilter,MultiParsersFilter,ODFFilter,OpenOfficeFilter,OpenXMLFilter,ParaPlainTextFilter,PdfFilter,PensieveFilter,PHPContentFilter,PlainTextFilter,POFilter,PreprocessingFilter,PropertiesFilter,ProtoFilter,RainbowKitFilter,RegexFilter,RegexPlainTextFilter,RTFFilter,SdlPackageFilter,SimplificationFilter,SplicedLinesFilter,SubFilterWrapper,SubtitleFilter,TableFilter,TabSeparatedValuesFilter,TEXFilter,TmxFilter,TransifexFilter,TransTableFilter,TsFilter,TTMLFilter,TTXFilter,TXMLFilter,VignetteFilter,VTTFilter,WikiFilter,XINIFilter,XINIRainbowkitFilter,XLIFF2Filter,XLIFF2Filter,XLIFFFilter,XMLFilter,XmlStreamFilter,YamlFilter
public interface IFilter extends AutoCloseable, Iterator<Event>
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 Description static StringSUB_FILTERPrefix marker indicating a sub-filter in the name of aStartDocumentobject created when processing content with sub-filters.
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description voidcancel()Cancels the current process.voidclose()Closes the input document.IFilterWritercreateFilterWriter()Creates a new IFilterWriter object from the most appropriate class to use with this filter.ISkeletonWritercreateSkeletonWriter()Creates a new ISkeletonWriter object that corresponds to the type of skeleton this filter uses.List<FilterConfiguration>getConfigurations()Gets the list of all predefined configurations for this filter.StringgetDisplayName()Gets the localizable display name of this filter.EncoderManagergetEncoderManager()Gets the EncoderManager object for this filter.StringgetMimeType()Gets the MIME type of the format supported by this filter.StringgetName()Gets the name/identifier of this filter.default IParametersgetParameters()Gets the current parameters for this filter.booleanhasNext()Indicates if there is an event to process.default booleanisMultilingual()Eventnext()Gets the next event available.voidopen(RawDocument input)Opens the input document described in a give RawDocument object.voidopen(RawDocument input, boolean generateSkeleton)Opens the input document described in a give RawDocument object, and optionally creates skeleton information.voidsetFilterConfigurationMapper(IFilterConfigurationMapper fcMapper)Sets the filter configuration mapper for this filter.voidsetParameters(IParameters params)Sets new parameters for this filter.default Stream<Event>stream()Generates all events from a filter as aStream.-
Methods inherited from interface java.util.Iterator
forEachRemaining, remove
-
-
-
-
Field Detail
-
SUB_FILTER
static final String SUB_FILTER
Prefix marker indicating a sub-filter in the name of aStartDocumentobject created when processing content with sub-filters.- See Also:
- Constant Field Values
-
-
Method Detail
-
getName
String getName()
Gets the name/identifier of this filter.- Returns:
- The name/identifier of the filter.
-
getDisplayName
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:
closein interfaceAutoCloseable
-
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.
-
next
Event next()
Gets the next event available. Calling this method can be done only once on each event.
-
cancel
void cancel()
Cancels the current process.
-
getParameters
default IParameters getParameters()
Gets the current parameters for this filter.- Returns:
- The current parameters for this filter, or
DefaultParametersif 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
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
List<FilterConfiguration> getConfigurations()
Gets the list of all predefined configurations for this filter.- Returns:
- a list of the all predefined configurations for this filter.
-
isMultilingual
default boolean isMultilingual()
-
-