Class ProtoFilter
- java.lang.Object
-
- net.sf.okapi.common.filters.AbstractFilter
-
- net.sf.okapi.lib.serialization.filter.ProtoFilter
-
- All Implemented Interfaces:
AutoCloseable,Iterator<Event>,IFilter
public class ProtoFilter extends AbstractFilter
- Author:
- jimh
-
-
Field Summary
-
Fields inherited from interface net.sf.okapi.common.filters.IFilter
SUB_FILTER
-
-
Constructor Summary
Constructors Constructor Description ProtoFilter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Closes the input document.ParametersgetParameters()Gets the current parameters for this filter.booleanhasNext()Indicates if there is an event to process.protected booleanisUtf8Encoding()Is the input encoded as UTF-8?protected EventloadFromBinary()Deserializes a single Event from binaryprotected EventloadFromJson(String json)Deserializes a single Event from JSONEventnext()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.voidsetParameters(IParameters params)Sets new parameters for this filter.-
Methods inherited from class net.sf.okapi.common.filters.AbstractFilter
addConfiguration, addConfiguration, addConfiguration, addConfigurations, cancel, createEndFilterEvent, createFilterWriter, createSkeletonWriter, createStartFilterEvent, findConfiguration, getConfiguration, getConfigurations, getDisplayName, getDocumentId, getDocumentName, getEncoderManager, getEncoding, getFilterConfigurationMapper, getMimeType, getName, getNewlineType, getParameters, getParametersClassName, getParentId, getSrcLoc, getTrgLoc, isCanceled, isGenerateSkeleton, isMultilingual, isUtf8Bom, removeConfiguration, setDisplayName, setDocumentName, setEncoding, setFilterConfigurationMapper, setGenerateSkeleton, setMimeType, setMultilingual, setName, setNewlineType, setOptions, setParentId, setSrcLoc, setTrgLoc
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.util.Iterator
forEachRemaining, remove
-
-
-
-
Method Detail
-
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.
-
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.
-
loadFromJson
protected Event loadFromJson(String json) throws IOException
Deserializes a single Event from JSON- Throws:
IOException
-
loadFromBinary
protected Event loadFromBinary()
Deserializes a single Event from binary
-
getParameters
public Parameters 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.
-
isUtf8Encoding
protected boolean isUtf8Encoding()
Description copied from class:AbstractFilterIs the input encoded as UTF-8?- Overrides:
isUtf8Encodingin classAbstractFilter- Returns:
- true if the document is in utf8 encoding.
-
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
-
-