Package net.sf.okapi.common.filterwriter
Class XLIFFWriter
- java.lang.Object
-
- net.sf.okapi.common.filterwriter.XLIFFWriter
-
- All Implemented Interfaces:
AutoCloseable,IFilterWriter
public class XLIFFWriter extends Object implements IFilterWriter
Writer for creating XLIFF document.
-
-
Field Summary
Fields Modifier and Type Field Description static StringOKP_ENGINEName of the Okapi XLIFF extension engine.static StringOKP_MATCHTYPEName of the Okapi XLIFF extension matchType.
-
Constructor Summary
Constructors Constructor Description XLIFFWriter()Creates an XLIFF writer object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcancel()Cancels the current process.voidclose()Writes the end of this the document and close it.voidcreate(String xliffPath, String skeletonPath, LocaleId srcLoc, LocaleId trgLoc, String dataType, String original, String message)Creates a new XLIFF document.EncoderManagergetEncoderManager()Gets the current encoder manager for this writer.StringgetName()Gets the name of this writer.XLIFFWriterParametersgetParameters()Gets the current parameters for this writer.ISkeletonWritergetSkeletonWriter()Gets the skeleton writer associated with this writer.XLIFFContentgetXLIFFContent()EventhandleEvent(Event event)Handles the filter events.voidsetAnnotatorsRef(String values)Updates the current ITS annotators references based on a given set of values.voidsetOptions(LocaleId locale, String defaultEncoding)Sets the options for this writer.voidsetOutput(OutputStream output)Sets the output through its output stream.voidsetOutput(String path)Sets the output through the path of the output file.voidsetParameters(IParameters params)Sets new parameters for this writer.voidwriteEndFile()Writes the end of a <file> element.voidwriteEndGroup()Writes the end of a <group> element.voidwriteStartFile(String original, String dataType, String skeletonPath)Writes the start of a <file> element.voidwriteStartFile(String original, String dataType, String skeletonPath, String extraForHeader)Writes the start of a <file> element.voidwriteStartGroup(StartGroup resource)Writes the start of a <group> element.voidwriteTextUnit(ITextUnit tu)Writes a text unit as a <trans-unit> element.voidwriteTextUnit(ITextUnit tu, String phaseName)Writes a text unit as a <trans-unit> element.
-
-
-
Field Detail
-
OKP_MATCHTYPE
public static final String OKP_MATCHTYPE
Name of the Okapi XLIFF extension matchType.- See Also:
- Constant Field Values
-
OKP_ENGINE
public static final String OKP_ENGINE
Name of the Okapi XLIFF extension engine.- See Also:
- Constant Field Values
-
-
Method Detail
-
create
public void create(String xliffPath, String skeletonPath, LocaleId srcLoc, LocaleId trgLoc, String dataType, String original, String message)
Creates a new XLIFF document.- Parameters:
xliffPath- the full path of the document to create.skeletonPath- the path for the skeleton, or null for no skeleton.srcLoc- the source locale.trgLoc- the target locale, or null for no target.dataType- the value for thedatatypeattribute.original- the value for theoriginalattribute.message- optional comment to put at the top of the document (can be null).
-
close
public void close()
Writes the end of this the document and close it. If a <file> element is currently opened, it is closed automatically.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceIFilterWriter
-
writeStartFile
public void writeStartFile(String original, String dataType, String skeletonPath)
Writes the start of a <file> element.each call to this method must have a corresponding call to
writeEndFile().- Parameters:
original- the value for theoriginalattribute. If null: "unknown" is used.dataType- the value for thedatatypeattribute. If null: "x-undefined" is used.skeletonPath- optional external skeleton information, or null.- See Also:
writeEndFile()
-
writeStartFile
public void writeStartFile(String original, String dataType, String skeletonPath, String extraForHeader)
Writes the start of a <file> element.each call to this method must have a corresponding call to
writeEndFile().- Parameters:
original- the value for theoriginalattribute. If null: "unknown" is used.dataType- the value for thedatatypeattribute. If null: "x-undefined" is used.skeletonPath- optional external skeleton information, or null.extraForHeader- optional extra raw valid XLIFF to place in the header, or null.- See Also:
writeEndFile()
-
writeEndFile
public void writeEndFile()
Writes the end of a <file> element. This method should be called for each call towriteStartFile(String, String, String).- See Also:
writeStartFile(String, String, String)
-
writeStartGroup
public void writeStartGroup(StartGroup resource)
Writes the start of a <group> element.- See Also:
writeEndGroup()
-
writeEndGroup
public void writeEndGroup()
Writes the end of a <group> element.- See Also:
writeStartGroup(StartGroup)
-
writeTextUnit
public void writeTextUnit(ITextUnit tu)
Writes a text unit as a <trans-unit> element.- Parameters:
tu- the text unit to output.
-
writeTextUnit
public void writeTextUnit(ITextUnit tu, String phaseName)
Writes a text unit as a <trans-unit> element.- Parameters:
tu- the text unit to output.phaseName- the value ofphase-name(can be null).
-
cancel
public void cancel()
Description copied from interface:IFilterWriterCancels the current process.- Specified by:
cancelin interfaceIFilterWriter
-
getEncoderManager
public EncoderManager getEncoderManager()
Description copied from interface:IFilterWriterGets the current encoder manager for this writer. Some special implementation of IFilterWriter may not use an encoder manager (for example writers that do not use skeleton).- Specified by:
getEncoderManagerin interfaceIFilterWriter- Returns:
- the current encoder manager for this writer, or null if none exists for this writer.
-
getSkeletonWriter
public ISkeletonWriter getSkeletonWriter()
Description copied from interface:IFilterWriterGets the skeleton writer associated with this writer. Some implementation of IFilterWriter may not use a skeleton writer.- Specified by:
getSkeletonWriterin interfaceIFilterWriter- Returns:
- the skeleton writer associated with this writer or null if none is associated.
-
getName
public String getName()
Description copied from interface:IFilterWriterGets the name of this writer.- Specified by:
getNamein interfaceIFilterWriter- Returns:
- The name of the writer.
-
getParameters
public XLIFFWriterParameters getParameters()
Description copied from interface:IFilterWriterGets the current parameters for this writer.- Specified by:
getParametersin interfaceIFilterWriter- Returns:
- The current parameters for this writer.
-
handleEvent
public Event handleEvent(Event event)
Description copied from interface:IFilterWriterHandles the filter events.- Specified by:
handleEventin interfaceIFilterWriter- Parameters:
event- The event to process.- Returns:
- The event that was processed.
-
setOptions
public void setOptions(LocaleId locale, String defaultEncoding)
Description copied from interface:IFilterWriterSets the options for this writer.- Specified by:
setOptionsin interfaceIFilterWriter- Parameters:
locale- the output locale.defaultEncoding- Name of the character set encoding for the output.
-
setOutput
public void setOutput(String path)
Description copied from interface:IFilterWriterSets the output through the path of the output file.- Specified by:
setOutputin interfaceIFilterWriter- Parameters:
path- Full path of the output file.
-
setOutput
public void setOutput(OutputStream output)
Description copied from interface:IFilterWriterSets the output through its output stream.- Specified by:
setOutputin interfaceIFilterWriter- Parameters:
output- Output stream to use for the output.
-
setParameters
public void setParameters(IParameters params)
Description copied from interface:IFilterWriterSets new parameters for this writer.- Specified by:
setParametersin interfaceIFilterWriter- Parameters:
params- The new parameters to use.
-
setAnnotatorsRef
public void setAnnotatorsRef(String values)
Updates the current ITS annotators references based on a given set of values.- Parameters:
values- the annotators references values to use to update the existing ones. The annotation will be output in the next element that can carry it.
-
getXLIFFContent
public XLIFFContent getXLIFFContent()
-
-