|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sf.okapi.common.filterwriter.ext.TMXWriter
public class TMXWriter
Writer for TMX documents.
Constructor Summary | |
---|---|
TMXWriter(java.lang.String path)
Creates a new TMXWriter object. |
|
TMXWriter(net.sf.okapi.common.XMLWriter writer)
Creates a new TMXWriter object. |
Method Summary | |
---|---|
void |
close()
Closes the current output document if one is opened. |
int |
getItemCount()
Gets the number of TU elements that have been written in the current output document. |
boolean |
isWriteAllPropertiesAsAttributes()
Write all TU level properties as TMX attributes? |
void |
setAltTranslationOption(java.lang.String pattern)
Sets a pattern used to indicate which entries to include when using the writeAlternate(AltTranslation, TextFragment) method. |
void |
setExclusionOption(java.lang.String pattern)
Sets a pattern of content to not output. |
void |
setLetterCodedMode(boolean value,
boolean zeroBased)
Sets the flag indicating whether the writer should output letter-coded content (e.g. to work for OmegaT). |
protected void |
setPath(java.lang.String path)
|
void |
setQuoteMode(int quoteMode)
Sets the default quote mode to use in escaping the TMX segment content (1 is the default). |
void |
setTradosWorkarounds(boolean value)
Sets the flag indicating whether the writer should output workaround codes specific for Trados. |
void |
setUseMTPrefix(boolean useMTPrefix)
Sets the flag indicating if entries originating from MT should be written with a special prefix in the source text (forcing a fuzzy match). |
void |
setWriteAllPropertiesAsAttributes(boolean writeAllPropertiesAsAttributes)
If true then all TU level properties will be written as TMX attributes. |
protected void |
setXmlWriter(net.sf.okapi.common.XMLWriter writer)
|
protected void |
writeAllPropertiesAsAttibutes(net.sf.okapi.common.XMLWriter writer,
java.util.Set<java.lang.String> names,
net.sf.okapi.common.resource.ITextUnit item)
|
void |
writeAlternate(net.sf.okapi.common.annotation.AltTranslation alt,
net.sf.okapi.common.resource.TextFragment srcOriginal)
Writes the data of an AltTranslation to this TMX output. |
void |
writeAlternates(net.sf.okapi.common.resource.ITextUnit tu,
net.sf.okapi.common.LocaleId trgLoc)
Writes the entries of an AltTranslationsAnnotation
annotation(s) of a given text unit to the TMX document. |
void |
writeEndDocument()
Writes the end of the TMX document. |
void |
writeItem(net.sf.okapi.common.resource.ITextUnit tu,
java.util.Map<java.lang.String,java.lang.String> attributes)
Writes a given text unit. |
protected void |
writeProp(java.lang.String name,
java.lang.String value)
|
protected void |
writeResourceLevelProperties(java.util.Set<java.lang.String> names,
net.sf.okapi.common.resource.ITextUnit item,
net.sf.okapi.common.resource.TextFragment srcSegment)
|
void |
writeStartDocument(net.sf.okapi.common.LocaleId sourceLocale,
net.sf.okapi.common.LocaleId targetLocale,
java.lang.String creationTool,
java.lang.String creationToolVersion,
java.lang.String segType,
java.lang.String originalTMFormat,
java.lang.String dataType)
Writes the start of the TMC document. |
void |
writeTU(net.sf.okapi.common.resource.TextFragment source,
net.sf.okapi.common.resource.TextFragment target,
java.lang.String tuid,
java.util.Map<java.lang.String,java.lang.String> attributes)
Writes a TMX TU element. |
void |
writeTU(net.sf.okapi.common.resource.TextFragment source,
net.sf.okapi.common.resource.TextFragment target,
java.lang.String tuid,
java.util.Map<java.lang.String,java.lang.String> attributes,
net.sf.okapi.common.LocaleId altTrgLoc)
Writes a TMX TU element. |
void |
writeTUFull(net.sf.okapi.common.resource.ITextUnit item)
Writes a TextUnit (all targets) with all the properties associated to it. |
void |
writeTUFull(net.sf.okapi.common.resource.ITextUnit item,
net.sf.okapi.common.LocaleId sourceLocId)
Writes a TextUnit (all targets) with all the properties associated to it. |
protected void |
writeTUV(net.sf.okapi.common.resource.TextFragment frag,
net.sf.okapi.common.LocaleId locale,
net.sf.okapi.common.resource.TextContainer contForProp)
Writes a TUV element. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public TMXWriter(java.lang.String path)
path
- The full path of the TMX document to create.
If another document exists already it will be overwritten.public TMXWriter(net.sf.okapi.common.XMLWriter writer)
writer
- an instance of an XMLWriter to use.
If another document exists already it will be overwritten.Method Detail |
---|
protected void setPath(java.lang.String path)
protected void setXmlWriter(net.sf.okapi.common.XMLWriter writer)
public void close()
public int getItemCount()
public void setTradosWorkarounds(boolean value)
value
- true to output Trados-specific workarounds. False otherwise.public void setLetterCodedMode(boolean value, boolean zeroBased)
value
- true to output letter-coded content. False otherwise.zeroBased
- true to have 0-based code, false for unaltered IDs.public void setExclusionOption(java.lang.String pattern)
pattern
- the regular expression pattern of the contents to not output.public void setAltTranslationOption(java.lang.String pattern)
writeAlternate(AltTranslation, TextFragment)
method. When this pattern is set to null (the default)
all entries are included.
pattern
- the regular expression of the origin(s) to include. Use null to include all entries.public void setQuoteMode(int quoteMode)
quoteMode
- 0=no quote escaped, 1=apos and quot, 2=#39 and quot,
and 3=quot only.public void setUseMTPrefix(boolean useMTPrefix)
creationid
attribute is set to Util.MTFLAG
.
useMTPrefix
- true to use a prefix for entries originating from MT.public void writeStartDocument(net.sf.okapi.common.LocaleId sourceLocale, net.sf.okapi.common.LocaleId targetLocale, java.lang.String creationTool, java.lang.String creationToolVersion, java.lang.String segType, java.lang.String originalTMFormat, java.lang.String dataType)
sourceLocale
- The source locale (must be set).targetLocale
- The target locale (must be set).creationTool
- The identifier of the creation tool (can be null).creationToolVersion
- The version of the creation tool (can be null).segType
- The type of segments in the output.originalTMFormat
- The identifier for the original TM engine (can be null).dataType
- The type of data to output.public void writeEndDocument()
public void writeItem(net.sf.okapi.common.resource.ITextUnit tu, java.util.Map<java.lang.String,java.lang.String> attributes)
tu
- The text unit to output.attributes
- The optional set of attribute to put along with the entry.public void writeAlternates(net.sf.okapi.common.resource.ITextUnit tu, net.sf.okapi.common.LocaleId trgLoc)
AltTranslationsAnnotation
annotation(s) of a given text unit to the TMX document.
tu
- text unit to use.trgLoc
- target locale.public void writeAlternate(net.sf.okapi.common.annotation.AltTranslation alt, net.sf.okapi.common.resource.TextFragment srcOriginal)
AltTranslation
to this TMX output.
Which entries will be output also depends on what patterns have been set with
setAltTranslationOption(String)
and setExclusionOption(String)
.
alt
- the alternate translation.srcOriginal
- the default source (coming from the segment or container where
the annotation was attached to).public void writeTU(net.sf.okapi.common.resource.TextFragment source, net.sf.okapi.common.resource.TextFragment target, java.lang.String tuid, java.util.Map<java.lang.String,java.lang.String> attributes)
source
- the fragment for the source text.target
- the fragment for the target text.tuid
- the TUID attribute (can be null).attributes
- the optional set of attribute to put along with the entry.public void writeTU(net.sf.okapi.common.resource.TextFragment source, net.sf.okapi.common.resource.TextFragment target, java.lang.String tuid, java.util.Map<java.lang.String,java.lang.String> attributes, net.sf.okapi.common.LocaleId altTrgLoc)
source
- the fragment for the source text.target
- the fragment for the target text.tuid
- the TUID attribute (can be null).attributes
- the optional set of attribute to put along with the entry.altTrgLoc
- the target locale id to use (in case it is different from
the default one, use null to get the default).public void writeTUFull(net.sf.okapi.common.resource.ITextUnit item)
Note: If the srclang in the TMX header is "*all*", you must use
writeTUFull(ITextUnit, LocaleId)
instead.
item
- The text unit to write.public void writeTUFull(net.sf.okapi.common.resource.ITextUnit item, net.sf.okapi.common.LocaleId sourceLocId)
item
- The text unit to write.sourceLocId
- The source locale id to use for this TU.protected void writeResourceLevelProperties(java.util.Set<java.lang.String> names, net.sf.okapi.common.resource.ITextUnit item, net.sf.okapi.common.resource.TextFragment srcSegment)
protected void writeProp(java.lang.String name, java.lang.String value)
protected void writeAllPropertiesAsAttibutes(net.sf.okapi.common.XMLWriter writer, java.util.Set<java.lang.String> names, net.sf.okapi.common.resource.ITextUnit item)
protected void writeTUV(net.sf.okapi.common.resource.TextFragment frag, net.sf.okapi.common.LocaleId locale, net.sf.okapi.common.resource.TextContainer contForProp)
frag
- the TextFragment for the content of this TUV. This can be
a segment of a TextContainer.locale
- the locale for this TUV.contForProp
- the TextContainer that has the properties to write for
this TUV, or null for no properties.public void setWriteAllPropertiesAsAttributes(boolean writeAllPropertiesAsAttributes)
writeAllPropertiesAsAttributes
- true to write out all TU level properties as TMX attributes.public boolean isWriteAllPropertiesAsAttributes()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |