Package net.sf.okapi.filters.its
Class ITSFilter
- java.lang.Object
-
- net.sf.okapi.filters.its.ITSFilter
-
- All Implemented Interfaces:
AutoCloseable
,Iterator<Event>
,IFilter
- Direct Known Subclasses:
HTML5Filter
,XMLFilter
public abstract class ITSFilter extends Object implements IFilter
-
-
Field Summary
Fields Modifier and Type Field Description protected Document
doc
protected String
docName
protected EncoderManager
encoderManager
protected String
encoding
protected IFilterConfigurationMapper
fcMapper
protected boolean
hasUTF8BOM
protected RawDocument
input
protected String
lineBreak
protected Parameters
params
protected GenericSkeleton
skel
protected LocaleId
srcLang
-
Fields inherited from interface net.sf.okapi.common.filters.IFilter
SUB_FILTER
-
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
applyRules(ITSEngine itsEng)
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.abstract ISkeletonWriter
createSkeletonWriter()
Creates a new ISkeletonWriter object that corresponds to the type of skeleton this filter uses.protected abstract void
createStartDocumentSkeleton(StartDocument startDoc)
String
getMimeType()
Gets the MIME type of the format supported by this filter.Parameters
getParameters()
Gets the current parameters for this filter.net.sf.okapi.filters.its.TargetPointerEntry
getTargetPointerEntry(Node node)
Gets the target pointer entry for a given node.boolean
hasNext()
Indicates if there is an event to process.protected abstract void
initializeDocument()
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
setITSVariables(Map<String,String> map)
Sets the ITS variables to pass to the ITS parameters feature.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
-
Methods inherited from interface net.sf.okapi.common.filters.IFilter
getConfigurations, getDisplayName, getEncoderManager, getName, isMultilingual, stream
-
Methods inherited from interface java.util.Iterator
forEachRemaining, remove
-
-
-
-
Field Detail
-
params
protected Parameters params
-
encoderManager
protected EncoderManager encoderManager
-
doc
protected Document doc
-
input
protected RawDocument input
-
encoding
protected String encoding
-
docName
protected String docName
-
srcLang
protected LocaleId srcLang
-
lineBreak
protected String lineBreak
-
hasUTF8BOM
protected boolean hasUTF8BOM
-
skel
protected GenericSkeleton skel
-
fcMapper
protected IFilterConfigurationMapper fcMapper
-
-
Constructor Detail
-
ITSFilter
public ITSFilter(boolean isHTML5, String mimeType, long dataCategoriesToApply)
-
-
Method Detail
-
setITSVariables
public void setITSVariables(Map<String,String> map)
Sets the ITS variables to pass to the ITS parameters feature. This method should be called beforeopen(RawDocument, boolean)
. Those variables overwrite the default values set in theits;params
elements.- Parameters:
map
- the map of variables to pass. Can be null or empty.
-
cancel
public void cancel()
Description copied from interface:IFilter
Cancels the current process.
-
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 interfaceAutoCloseable
- Specified by:
close
in interfaceIFilter
-
createSkeletonWriter
public abstract 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 interfaceIFilter
- 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 interfaceIFilter
- Returns:
- A new instance of IFilterWriter for the preferred implementation for this filter.
-
getMimeType
public String getMimeType()
Description copied from interface:IFilter
Gets the MIME type of the format supported by this filter.- Specified by:
getMimeType
in interfaceIFilter
- Returns:
- The MIME type of the format supported by this filter.
-
getParameters
public Parameters getParameters()
Description copied from interface:IFilter
Gets the current parameters for this filter.- Specified by:
getParameters
in interfaceIFilter
- Returns:
- The current parameters for this filter, or
DefaultParameters
if this filter has no parameters.
-
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.
-
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.
-
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.
-
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 interfaceIFilter
- Parameters:
fcMapper
- the mapper to set.
-
setParameters
public void setParameters(IParameters params)
Description copied from interface:IFilter
Sets new parameters for this filter.- Specified by:
setParameters
in interfaceIFilter
- Parameters:
params
- The new parameters to use.
-
initializeDocument
protected abstract void initializeDocument()
-
applyRules
protected void applyRules(ITSEngine itsEng)
-
createStartDocumentSkeleton
protected abstract void createStartDocumentSkeleton(StartDocument startDoc)
-
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.
-
getTargetPointerEntry
public net.sf.okapi.filters.its.TargetPointerEntry getTargetPointerEntry(Node node)
Gets the target pointer entry for a given node.- Parameters:
node
- the node to examine.- Returns:
- the target pointer entry for that node, or null if there is none.
-
-