Package net.sf.okapi.common.skeleton
Class GenericSkeletonWriter
- java.lang.Object
-
- net.sf.okapi.common.skeleton.GenericSkeletonWriter
-
- All Implemented Interfaces:
ISkeletonWriter
- Direct Known Subclasses:
CSVSkeletonWriter,HTML5SkeletonWriter,HtmlSkeletonWriter,MarkdownSkeletonWriter,TEXSkeletonWriter,TTXSkeletonWriter,TXMLSkeletonWriter,VignetteSkeletonWriter,XLIFFSkeletonWriter,XMLSkeletonWriter,YamlSkeletonWriter
public class GenericSkeletonWriter extends Object implements ISkeletonWriter
Implements ISkeletonWriter for the GenericSkeleton skeleton.
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanallowEmptyOutputTargetDeprecated.static StringALLOWEMPTYOUTPUTTARGETprotected EncoderManagerencoderManagerprotected LocaleIdinputLocprotected booleanisMultilingualprotected ILayerProviderlayerDeprecated.protected StringoutputEncodingprotected LocaleIdoutputLocprotected Stack<StorageList>storageStack
-
Constructor Summary
Constructors Constructor Description GenericSkeletonWriter()GenericSkeletonWriter(LocaleId inputLoc, LocaleId outputLoc, ILayerProvider layer, EncoderManager encoderManager, boolean isMultilingual, boolean allowEmptyOutputTarget, Map<String,Referent> referents, Stack<StorageList> storageStack, String outputEncoding, int referentCopies, SubFilterSkeletonWriter sfWriter)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected String_processEndGroup(Ending resource)protected String_processStartGroup(StartGroup resource)voidaddToReferents(Event event)voidclose()Closes this skeleton writer.protected StringexpandCodeContent(Code code, LocaleId locToUse, EncoderContext context)protected StringgetContent(ITextUnit tu, LocaleId locToUse, EncoderContext context)Gets the original content of a given text unit.StringgetContent(TextFragment tf, LocaleId locToUse, EncoderContext context)Gets the original content of a TextFragment.EncoderManagergetEncoderManager()LocaleIdgetInputLoc()ILayerProvidergetLayer()Deprecated.StringgetOutputEncoding()LocaleIdgetOutputLoc()protected StringgetPropertyValue(INameable resource, String name, LocaleId locToUse, EncoderContext context)protected IReferenceablegetReference(String id)intgetReferentCopies()Map<String,Referent>getReferents()ISkeletonWritergetSfWriter()protected StringgetString(ISkeleton skeleton, EncoderContext context)protected StringgetString(INameable ref, String propName, LocaleId locToUse, EncoderContext context)protected StringgetString(ITextUnit tu, LocaleId locToUse, EncoderContext context)Gets the skeleton and the original content of a given text unit.protected StringgetString(GenericSkeletonPart part, EncoderContext context)protected StringgetString(StorageList list, LocaleId locToUse, EncoderContext context)booleanisAllowEmptyOutputTarget()Deprecated.protected booleanisCodeThatDisablesEncoding(Code code)booleanisMultilingual()StringprocessDocumentPart(DocumentPart resource)Processes the DOCUMENT_PART event.StringprocessEndDocument(Ending resource)Processes the END_DOCUMENT event.StringprocessEndGroup(Ending resource)Processes the END_GROUP event.StringprocessEndSubDocument(Ending resource)Processes the END_SUBDOCUMENT event.StringprocessEndSubfilter(EndSubfilter resource)StringprocessStartDocument(LocaleId outputLocale, String outputEncoding, ILayerProvider layer, EncoderManager encoderManager, StartDocument resource)Processes the START_DOCUMENT event.StringprocessStartGroup(StartGroup resource)Processes the START_GROUP event.StringprocessStartSubDocument(StartSubDocument resource)Processes a START_SUBDOCUMENT event.StringprocessStartSubfilter(StartSubfilter resource)StringprocessTextUnit(ITextUnit resource)Processes the TEXT_UNIT event.voidsetAllowEmptyOutputTarget(boolean allowEmptyOutputTarget)Deprecated.voidsetEncoderManager(EncoderManager encoderManager)voidsetLayer(ILayerProvider layer)Deprecated.voidsetMultilingual(boolean isMultilingual)voidsetOutputEncoding(String outputEncoding)voidsetOutputLoc(LocaleId outputLoc)voidsetReferentCopies(int referentCopies)Sets the number of copies to keep for a referent.voidsetReferents(Map<String,Referent> referents)
-
-
-
Field Detail
-
ALLOWEMPTYOUTPUTTARGET
public static String ALLOWEMPTYOUTPUTTARGET
-
inputLoc
protected LocaleId inputLoc
-
outputLoc
protected LocaleId outputLoc
-
layer
@Deprecated protected ILayerProvider layer
Deprecated.
-
encoderManager
protected EncoderManager encoderManager
-
storageStack
protected Stack<StorageList> storageStack
-
isMultilingual
protected boolean isMultilingual
-
allowEmptyOutputTarget
@Deprecated protected boolean allowEmptyOutputTarget
Deprecated.
-
outputEncoding
protected String outputEncoding
-
-
Constructor Detail
-
GenericSkeletonWriter
public GenericSkeletonWriter()
-
GenericSkeletonWriter
public GenericSkeletonWriter(LocaleId inputLoc, LocaleId outputLoc, ILayerProvider layer, EncoderManager encoderManager, boolean isMultilingual, boolean allowEmptyOutputTarget, Map<String,Referent> referents, Stack<StorageList> storageStack, String outputEncoding, int referentCopies, SubFilterSkeletonWriter sfWriter)
-
-
Method Detail
-
getReference
protected IReferenceable getReference(String id)
-
close
public void close()
Description copied from interface:ISkeletonWriterCloses this skeleton writer.- Specified by:
closein interfaceISkeletonWriter
-
setReferentCopies
public void setReferentCopies(int referentCopies)
Sets the number of copies to keep for a referent. By default one copy is kept and discarded after it is referenced. Some layout may need to refer to the referent more than once, for example when they output both source and target.- Parameters:
referentCopies- the number of copies to hold (must be at least 1).
-
processStartDocument
public String processStartDocument(LocaleId outputLocale, String outputEncoding, ILayerProvider layer, EncoderManager encoderManager, StartDocument resource)
Description copied from interface:ISkeletonWriterProcesses the START_DOCUMENT event.- Specified by:
processStartDocumentin interfaceISkeletonWriter- Parameters:
outputLocale- the output locale.outputEncoding- the name of the output charset encoding.layer- the layer provider to use.encoderManager- the encoder manager to use.resource- the StartDocument resource associated with the event.- Returns:
- the string output corresponding to this event.
-
processEndDocument
public String processEndDocument(Ending resource)
Description copied from interface:ISkeletonWriterProcesses the END_DOCUMENT event.- Specified by:
processEndDocumentin interfaceISkeletonWriter- Parameters:
resource- the Ending resource associated with the event.- Returns:
- the string output corresponding to this event.
-
processStartSubDocument
public String processStartSubDocument(StartSubDocument resource)
Description copied from interface:ISkeletonWriterProcesses a START_SUBDOCUMENT event.- Specified by:
processStartSubDocumentin interfaceISkeletonWriter- Parameters:
resource- the StartSubDocument resource associated with the event.- Returns:
- the string output corresponding to this event.
-
processEndSubDocument
public String processEndSubDocument(Ending resource)
Description copied from interface:ISkeletonWriterProcesses the END_SUBDOCUMENT event.- Specified by:
processEndSubDocumentin interfaceISkeletonWriter- Parameters:
resource- the Ending resource associated with the event.- Returns:
- the string output corresponding to this event.
-
processStartGroup
public String processStartGroup(StartGroup resource)
Description copied from interface:ISkeletonWriterProcesses the START_GROUP event.- Specified by:
processStartGroupin interfaceISkeletonWriter- Parameters:
resource- the StartGroup resource associated with the event.- Returns:
- the string output corresponding to this event.
-
_processStartGroup
protected String _processStartGroup(StartGroup resource)
-
processEndGroup
public String processEndGroup(Ending resource)
Description copied from interface:ISkeletonWriterProcesses the END_GROUP event.- Specified by:
processEndGroupin interfaceISkeletonWriter- Parameters:
resource- the Ending resource associated with the event.- Returns:
- the string output corresponding to this event.
-
processStartSubfilter
public String processStartSubfilter(StartSubfilter resource)
- Specified by:
processStartSubfilterin interfaceISkeletonWriter
-
processEndSubfilter
public String processEndSubfilter(EndSubfilter resource)
- Specified by:
processEndSubfilterin interfaceISkeletonWriter
-
processTextUnit
public String processTextUnit(ITextUnit resource)
Description copied from interface:ISkeletonWriterProcesses the TEXT_UNIT event.- Specified by:
processTextUnitin interfaceISkeletonWriter- Parameters:
resource- the TextUnit resource associated with the event.- Returns:
- the string output corresponding to this event.
-
processDocumentPart
public String processDocumentPart(DocumentPart resource)
Description copied from interface:ISkeletonWriterProcesses the DOCUMENT_PART event.- Specified by:
processDocumentPartin interfaceISkeletonWriter- Parameters:
resource- the DocumentPart resource associated with the event.- Returns:
- the string output corresponding to this event.
-
getString
protected String getString(ISkeleton skeleton, EncoderContext context)
-
getString
protected String getString(GenericSkeletonPart part, EncoderContext context)
-
getString
protected String getString(INameable ref, String propName, LocaleId locToUse, EncoderContext context)
-
getString
protected String getString(ITextUnit tu, LocaleId locToUse, EncoderContext context)
Gets the skeleton and the original content of a given text unit.- Parameters:
tu- The text unit to process.locToUse- locale to output. Use null for the source, or a LocaleId object for the target locales.context- Context flag: 0=text, 1=skeleton, 2=in-line.- Returns:
- The string representation of the text unit.
-
getContent
protected String getContent(ITextUnit tu, LocaleId locToUse, EncoderContext context)
Gets the original content of a given text unit.- Parameters:
tu- The text unit to process.locToUse- locale to output. Use null for the source, or the locale for the target locales.context- Context flag: 0=text, 1=skeleton, 2=inline.- Returns:
- The string representation of the text unit content.
-
isCodeThatDisablesEncoding
protected boolean isCodeThatDisablesEncoding(Code code)
-
getContent
public String getContent(TextFragment tf, LocaleId locToUse, EncoderContext context)
Gets the original content of a TextFragment.- Parameters:
tf- the TextFragment to process.locToUse- locale to output. Use null for the source, or the locale for the target locales. This is used for referenced content in inline codes.context- Context flag: 0=text, 1=skeleton, 2=inline.- Returns:
- The string representation of the text unit content.
-
expandCodeContent
protected String expandCodeContent(Code code, LocaleId locToUse, EncoderContext context)
-
getString
protected String getString(StorageList list, LocaleId locToUse, EncoderContext context)
-
getPropertyValue
protected String getPropertyValue(INameable resource, String name, LocaleId locToUse, EncoderContext context)
-
addToReferents
public void addToReferents(Event event)
-
getLayer
@Deprecated public ILayerProvider getLayer()
Deprecated.
-
getInputLoc
public LocaleId getInputLoc()
-
getOutputLoc
public LocaleId getOutputLoc()
-
getEncoderManager
public EncoderManager getEncoderManager()
-
isMultilingual
public boolean isMultilingual()
-
isAllowEmptyOutputTarget
@Deprecated public boolean isAllowEmptyOutputTarget()
Deprecated.
-
getOutputEncoding
public String getOutputEncoding()
-
getReferentCopies
public int getReferentCopies()
-
getSfWriter
public ISkeletonWriter getSfWriter()
-
setOutputLoc
public void setOutputLoc(LocaleId outputLoc)
-
setLayer
@Deprecated public void setLayer(ILayerProvider layer)
Deprecated.
-
setEncoderManager
public void setEncoderManager(EncoderManager encoderManager)
-
setMultilingual
public void setMultilingual(boolean isMultilingual)
-
setAllowEmptyOutputTarget
@Deprecated public void setAllowEmptyOutputTarget(boolean allowEmptyOutputTarget)
Deprecated.
-
setOutputEncoding
public void setOutputEncoding(String outputEncoding)
-
-