Package net.sf.okapi.common.filters
Class SubFilterWrapper
- java.lang.Object
-
- net.sf.okapi.common.filters.AbstractFilter
-
- net.sf.okapi.common.filters.AbstractSubFilter
-
- net.sf.okapi.common.filters.SubFilterWrapper
-
- All Implemented Interfaces:
AutoCloseable,Iterator<Event>,IFilter,ISubFilter
public class SubFilterWrapper extends AbstractSubFilter
Wrapper that converts anyIFilterinto aISubFilter(a filter called from anotherIFilter). Specific implementations can implement this class and override any needed methods to transformEvents as they are produced. This class should be used to wrap filters that useGenericSkeletonand 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 Description SubFilterWrapper(IFilter filter, IEncoder parentEncoder, int sectionIndex, String parentId, String parentName)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcancel()Cancels the current process.voidclose()Closes the input document.IFilterWritercreateFilterWriter()Default case.ISkeletonWritercreateSkeletonWriter()Default case.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.IFiltergetFilter()StringgetMimeType()Gets the input document mime type.StringgetName()Gets the name/identifier of this filter.IParametersgetParameters()Gets the current parameters for this filter.booleanhasNext()Indicates if there is an event to process.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.-
Methods inherited from class net.sf.okapi.common.filters.AbstractSubFilter
convertEvent, getConverter, getEvents, getEvents, getParentId, getParentName, getParentType, getSectionIndex, getStartSubfilter, setConverter, setEndSubfilter, setParentEncoder, setParentId, setParentName, setParentType, setSectionIndex, setStartSubfilter
-
Methods inherited from class net.sf.okapi.common.filters.AbstractFilter
addConfiguration, addConfiguration, addConfiguration, addConfigurations, createEndFilterEvent, createStartFilterEvent, findConfiguration, getConfiguration, getDocumentId, getDocumentName, getEncoding, getFilterConfigurationMapper, getNewlineType, getParameters, getParametersClassName, getSrcLoc, getTrgLoc, isCanceled, isGenerateSkeleton, isMultilingual, isUtf8Bom, isUtf8Encoding, removeConfiguration, setDisplayName, setDocumentName, setEncoding, setGenerateSkeleton, setMimeType, setMultilingual, setName, setNewlineType, setOptions, setSrcLoc, setTrgLoc
-
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
isMultilingual, stream
-
Methods inherited from interface net.sf.okapi.common.filters.ISubFilter
buildResourceId, buildResourceName, createRefCode, createRefEvent, createRefEvent, createRefEvent, createSourceRefCode, createTargetRefCode
-
Methods inherited from interface java.util.Iterator
forEachRemaining, remove
-
-
-
-
Method Detail
-
getFilter
public IFilter getFilter()
-
getName
public String getName()
Description copied from interface:IFilterGets the name/identifier of this filter.- Specified by:
getNamein interfaceIFilter- Overrides:
getNamein classAbstractFilter- Returns:
- The name/identifier of the filter.
-
getDisplayName
public String getDisplayName()
Description copied from interface:IFilterGets the localizable display name of this filter.- Specified by:
getDisplayNamein interfaceIFilter- Overrides:
getDisplayNamein classAbstractFilter- Returns:
- the localizable display name of this filter.
-
open
public void open(RawDocument input)
Description copied from interface:IFilterOpens 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
public void open(RawDocument input, boolean generateSkeleton)
Description copied from interface:IFilterOpens the input document described in a give RawDocument object, and optionally creates skeleton information.- Specified by:
openin interfaceIFilter- Overrides:
openin classAbstractFilter- 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:IFilterCloses 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- Specified by:
closein interfaceIFilter- Overrides:
closein classAbstractFilter
-
hasNext
public boolean hasNext()
Description copied from interface:IFilterIndicates 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
public Event next()
Description copied from interface:IFilterGets 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
public void cancel()
Description copied from interface:IFilterCancels the current process.- Specified by:
cancelin interfaceIFilter- Overrides:
cancelin classAbstractFilter
-
getParameters
public IParameters getParameters()
Description copied from interface:IFilterGets the current parameters for this filter.- Specified by:
getParametersin interfaceIFilter- Overrides:
getParametersin classAbstractFilter- Returns:
- The current parameters for this filter, or
DefaultParametersif this filter has no parameters.
-
setParameters
public void setParameters(IParameters params)
Description copied from interface:IFilterSets new parameters for this filter.- Specified by:
setParametersin interfaceIFilter- Overrides:
setParametersin classAbstractFilter- Parameters:
params- The new parameters to use.
-
createSkeletonWriter
public ISkeletonWriter createSkeletonWriter()
Description copied from class:AbstractFilterDefault case. Override if needed.- Specified by:
createSkeletonWriterin interfaceIFilter- Overrides:
createSkeletonWriterin classAbstractFilter- Returns:
- new instance of
GenericSkeletonWriter
-
createFilterWriter
public IFilterWriter createFilterWriter()
Description copied from class:AbstractFilterDefault case. Override if needed.- Specified by:
createFilterWriterin interfaceIFilter- Overrides:
createFilterWriterin classAbstractFilter- Returns:
- new instance of
GenericFilterWriter
-
getEncoderManager
public EncoderManager getEncoderManager()
Description copied from interface:IFilterGets the EncoderManager object for this filter. This encoder manager should provided the mappings to the different MIME types used by the filter.- Specified by:
getEncoderManagerin interfaceIFilter- Overrides:
getEncoderManagerin classAbstractFilter- Returns:
- the EncoderManager for this filter.
-
getMimeType
public String getMimeType()
Description copied from class:AbstractFilterGets the input document mime type.- Specified by:
getMimeTypein interfaceIFilter- Overrides:
getMimeTypein classAbstractFilter- Returns:
- the mime type
-
setFilterConfigurationMapper
public void setFilterConfigurationMapper(IFilterConfigurationMapper fcMapper)
Description copied from interface:IFilterSets 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:
setFilterConfigurationMapperin interfaceIFilter- Overrides:
setFilterConfigurationMapperin classAbstractFilter- Parameters:
fcMapper- the mapper to set.
-
getConfigurations
public List<FilterConfiguration> getConfigurations()
Description copied from interface:IFilterGets the list of all predefined configurations for this filter.- Specified by:
getConfigurationsin interfaceIFilter- Overrides:
getConfigurationsin classAbstractFilter- Returns:
- a list of the all predefined configurations for this filter.
-
-