Package net.sf.okapi.filters.xliff
Class XLIFFFilter
- java.lang.Object
-
- net.sf.okapi.filters.xliff.XLIFFFilter
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classXLIFFFilter.State
-
Field Summary
Fields Modifier and Type Field Description static StringCDATA_ENDstatic StringCDATA_STARTstatic StringEXACT_MATCHstatic StringFUZZY_MATCHstatic StringID_MATCHstatic StringLEVERAGED_INHERITEDstatic StringLEVERAGED_MTstatic StringLEVERAGED_TMstatic StringMT_SUGGESTIONstatic StringPROP_BUILDNUMstatic StringPROP_EXTRADATAstatic StringPROP_REPETITIONstatic StringPROP_WASSEGMENTEDstatic StringPROP_XLIFF_FLAVOROn StartDocument to indicate that the "flavor" of the document is possiblestatic StringSTATE_QUALIFIERstatic StringTM_SUGGESTIONstatic StringXLIFF_FLAVOR_DEFAULTstatic StringXLIFF_FLAVOR_SDLXLIFFstatic StringXLIFF_FLAVOR_XTM-
Fields inherited from interface net.sf.okapi.common.filters.IFilter
SUB_FILTER
-
-
Constructor Summary
Constructors Constructor Description XLIFFFilter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringbuildStartCode(XMLStreamReader reader)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.InputStreamReadercreateStreamReader(RawDocument input, String charset)StringfixSdlSpaceInId(String id)Converts an ID to a format where the space is represented as _x0020_, as used in the XLIFF mid attribute.ITSAnnotatorsRefContextgetAnnotatorsRefContext()Gets the ITS annotators references context object.List<FilterConfiguration>getConfigurations()Gets the list of all predefined configurations for this filter.SdlFileInfogetCurrentSdlFileInfo()LocaleIdgetCurrentSourceLocale()LocaleIdgetCurrentTargetLocale()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.ParametersgetParameters()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.voidopen(RawDocument input, boolean generateSkeleton, IITSDataStore datastore)Opens the input document described in a give RawDocument object, optionally creates skeleton information, and set the default data store to use to harvest ITS standoff annotations.List<Object>processSub(XMLStreamReader reader)Process the content of a sub element.voidsetFilterConfigurationMapper(IFilterConfigurationMapper filterConfigurationMapper)Sets the filter configuration mapper for this filter.voidsetParameters(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
isMultilingual, stream
-
Methods inherited from interface java.util.Iterator
forEachRemaining, remove
-
-
-
-
Field Detail
-
PROP_BUILDNUM
public static final String PROP_BUILDNUM
- See Also:
- Constant Field Values
-
PROP_EXTRADATA
public static final String PROP_EXTRADATA
- See Also:
- Constant Field Values
-
PROP_WASSEGMENTED
public static final String PROP_WASSEGMENTED
- See Also:
- Constant Field Values
-
PROP_REPETITION
public static final String PROP_REPETITION
- See Also:
- Constant Field Values
-
PROP_XLIFF_FLAVOR
public static final String PROP_XLIFF_FLAVOR
On StartDocument to indicate that the "flavor" of the document is possible- See Also:
- Constant Field Values
-
XLIFF_FLAVOR_DEFAULT
public static final String XLIFF_FLAVOR_DEFAULT
- See Also:
- Constant Field Values
-
XLIFF_FLAVOR_SDLXLIFF
public static final String XLIFF_FLAVOR_SDLXLIFF
- See Also:
- Constant Field Values
-
XLIFF_FLAVOR_XTM
public static final String XLIFF_FLAVOR_XTM
- See Also:
- Constant Field Values
-
EXACT_MATCH
public static final String EXACT_MATCH
- See Also:
- Constant Field Values
-
FUZZY_MATCH
public static final String FUZZY_MATCH
- See Also:
- Constant Field Values
-
ID_MATCH
public static final String ID_MATCH
- See Also:
- Constant Field Values
-
LEVERAGED_MT
public static final String LEVERAGED_MT
- See Also:
- Constant Field Values
-
LEVERAGED_TM
public static final String LEVERAGED_TM
- See Also:
- Constant Field Values
-
MT_SUGGESTION
public static final String MT_SUGGESTION
- See Also:
- Constant Field Values
-
TM_SUGGESTION
public static final String TM_SUGGESTION
- See Also:
- Constant Field Values
-
LEVERAGED_INHERITED
public static final String LEVERAGED_INHERITED
- See Also:
- Constant Field Values
-
STATE_QUALIFIER
public static final String STATE_QUALIFIER
- See Also:
- Constant Field Values
-
CDATA_START
public static final String CDATA_START
- See Also:
- Constant Field Values
-
CDATA_END
public static final String CDATA_END
- See Also:
- Constant Field Values
-
-
Method Detail
-
cancel
public void cancel()
Description copied from interface:IFilterCancels the current process.
-
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
-
getName
public String getName()
Description copied from interface:IFilterGets the name/identifier of this filter.
-
getDisplayName
public String getDisplayName()
Description copied from interface:IFilterGets the localizable display name of this filter.- Specified by:
getDisplayNamein interfaceIFilter- Returns:
- the localizable display name of this filter.
-
getMimeType
public String getMimeType()
Description copied from interface:IFilterGets the MIME type of the format supported by this filter.- Specified by:
getMimeTypein interfaceIFilter- Returns:
- The MIME type of the format supported by this filter.
-
getConfigurations
public List<FilterConfiguration> getConfigurations()
Description copied from interface:IFilterGets the list of all predefined configurations for this filter.- Specified by:
getConfigurationsin interfaceIFilter- Returns:
- a list of the all predefined configurations for this filter.
-
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- Returns:
- the EncoderManager for this filter.
-
getParameters
public Parameters getParameters()
Description copied from interface:IFilterGets the current parameters for this filter.- Specified by:
getParametersin interfaceIFilter- Returns:
- The current parameters for this filter, or
DefaultParametersif this filter has no parameters.
-
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.
-
getCurrentSourceLocale
public LocaleId getCurrentSourceLocale()
-
getCurrentTargetLocale
public LocaleId getCurrentTargetLocale()
-
getCurrentSdlFileInfo
public SdlFileInfo getCurrentSdlFileInfo()
-
next
public Event next()
Description copied from interface:IFilterGets 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:IFilterOpens the input document described in a give RawDocument object. Skeleton information is always created when you use this method.
-
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.
-
open
public void open(RawDocument input, boolean generateSkeleton, IITSDataStore datastore)
Opens the input document described in a give RawDocument object, optionally creates skeleton information, and set the default data store to use to harvest ITS standoff annotations.- Parameters:
input- the RawDocument object to use to open the document.generateSkeleton- true to generate the skeleton data, false otherwise.datastore- the data store to use for the ITS standoff annotations (cannot be null).
-
setFilterConfigurationMapper
public void setFilterConfigurationMapper(IFilterConfigurationMapper filterConfigurationMapper)
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- Parameters:
filterConfigurationMapper- the mapper to set.
-
setParameters
public void setParameters(IParameters params)
Description copied from interface:IFilterSets new parameters for this filter.- Specified by:
setParametersin interfaceIFilter- Parameters:
params- The new parameters to use.
-
createSkeletonWriter
public ISkeletonWriter createSkeletonWriter()
Description copied from interface:IFilterCreates a new ISkeletonWriter object that corresponds to the type of skeleton this filter uses.- Specified by:
createSkeletonWriterin interfaceIFilter- Returns:
- A new instance of ISkeletonWriter for the type of skeleton this filter uses.
-
createFilterWriter
public IFilterWriter createFilterWriter()
Description copied from interface:IFilterCreates a new IFilterWriter object from the most appropriate class to use with this filter.- Specified by:
createFilterWriterin interfaceIFilter- Returns:
- A new instance of IFilterWriter for the preferred implementation for this filter.
-
createStreamReader
public InputStreamReader createStreamReader(RawDocument input, String charset)
-
fixSdlSpaceInId
public String fixSdlSpaceInId(String id)
Converts an ID to a format where the space is represented as _x0020_, as used in the XLIFF mid attribute. See issue 1111. Fix for SDLXLIFF split-segments: they are represented as "123 a" in the SDL properties, but "123_x0020_a" in the XLIFF segment.- Parameters:
id- the ID to convert.- Returns:
- the ID converted.
-
buildStartCode
public String buildStartCode(XMLStreamReader reader)
-
processSub
public List<Object> processSub(XMLStreamReader reader) throws XMLStreamException
Process the content of a sub element. It assumes the content is valid.- Parameters:
reader- - XmlStreamReader passed in. We assume- Returns:
- a list of strings and codes corresponding to the text/code chunks processed.
- Throws:
XMLStreamException- if a read error occurs.
-
getAnnotatorsRefContext
public ITSAnnotatorsRefContext getAnnotatorsRefContext()
Gets the ITS annotators references context object.- Returns:
- the ITS annotators references context object.
-
-