Package net.sf.okapi.lib.xliff2.its
Class ITSWriter
- java.lang.Object
-
- net.sf.okapi.lib.xliff2.its.ITSWriter
-
public class ITSWriter extends Object
Provides utility methods to output ITS attributes and stand-off elements. This assumes the ITS namespace uses "its" as its prefix.
-
-
Constructor Summary
Constructors Constructor Description ITSWriter()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static voidaddDeclaration(StartXliffData sxd)Adds the namespaces and version information for supporting ITS mapping in an XLIFF 2 document.static IITSItemannotate(Fragment fragment, int start, int end, IITSItem item)Annotates a given fragment with an ITS item.static MTagannotate(Fragment fragment, int start, int end, IITSItem item, String matchingType)Tries to reuse an existing annotation to add an ITS item.AnnotatorsRefcreateAnnotatorsRef(IWithITSAttributes object)List<AbstractMap.SimpleEntry<String,AnnotatorsRef>>createAnnotatorsRefList(Stack<InheritedData> context)StringoutputAttributes(IWithITSAttributes object, AnnotatorsRef objectAR, AnnotatorsRef parentAR)StringoutputStandOffElements(String indent, String lb, Unit unit)Outputs any stand-off elements used in the markers for the given unit.
-
-
-
Method Detail
-
annotate
public static IITSItem annotate(Fragment fragment, int start, int end, IITSItem item)
Annotates a given fragment with an ITS item.- Parameters:
fragment- the fragment to annotate.start- the start position (in the coded text)end- the position just after the last character of the span (in the coded text). You can use -1 to indicate the end of the fragment.item- the ITS item to set (it can be a single instance or a group).- Returns:
- the ITS item set.
-
annotate
public static MTag annotate(Fragment fragment, int start, int end, IITSItem item, String matchingType)
Tries to reuse an existing annotation to add an ITS item. If no existing annotation is found for the given span and type, one is created.- Parameters:
fragment- the fragment to annotate.start- the start position (in the coded text)end- the position just after the last character of the span (in the coded text). You can use -1 to indicate the end of the fragment.item- the ITS item to set (it can be a single instance or a group).matchingType- the type of the existing annotation that can be reused. Use null to reuse any type.- Returns:
- the opening marker for the annotation.
-
addDeclaration
public static void addDeclaration(StartXliffData sxd)
Adds the namespaces and version information for supporting ITS mapping in an XLIFF 2 document.- Parameters:
sxd- theStartXliffDataobject where to add the mapping.
-
outputStandOffElements
public String outputStandOffElements(String indent, String lb, Unit unit)
Outputs any stand-off elements used in the markers for the given unit.- Parameters:
indent- the base indentation to use.lb- the line-break to use.unit- the unit to process.- Returns:
- the formatted output of the stand-off elements or an empty string if there is no element to output.
-
createAnnotatorsRefList
public List<AbstractMap.SimpleEntry<String,AnnotatorsRef>> createAnnotatorsRefList(Stack<InheritedData> context)
-
createAnnotatorsRef
public AnnotatorsRef createAnnotatorsRef(IWithITSAttributes object)
-
outputAttributes
public String outputAttributes(IWithITSAttributes object, AnnotatorsRef objectAR, AnnotatorsRef parentAR)
-
-