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
,TTMLSkeletonWriter
,TTXSkeletonWriter
,TXMLSkeletonWriter
,VignetteSkeletonWriter
,VTTSkeletonWriter
,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 boolean
allowEmptyOutputTarget
Deprecated.static String
ALLOWEMPTYOUTPUTTARGET
protected EncoderManager
encoderManager
protected LocaleId
inputLoc
protected boolean
isMultilingual
protected String
outputEncoding
protected LocaleId
outputLoc
protected Stack<StorageList>
storageStack
protected boolean
useDisplayTextForCodes
-
Constructor Summary
Constructors Constructor Description GenericSkeletonWriter()
GenericSkeletonWriter(boolean useDisplayTextForCodes)
GenericSkeletonWriter(LocaleId inputLoc, LocaleId outputLoc, 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)
void
addToReferents(Event event)
void
close()
Closes this skeleton writer.protected String
expandCodeContent(Code code, LocaleId locToUse, EncoderContext context)
protected String
getContent(ITextUnit tu, LocaleId locToUse, EncoderContext context)
Gets the original content of a given text unit.String
getContent(TextFragment tf, LocaleId locToUse, EncoderContext context)
Gets the original content of a TextFragment.EncoderManager
getEncoderManager()
LocaleId
getInputLoc()
String
getOutputEncoding()
LocaleId
getOutputLoc()
protected String
getPropertyValue(INameable resource, String name, LocaleId locToUse, EncoderContext context)
protected IReferenceable
getReference(String id)
int
getReferentCopies()
Map<String,Referent>
getReferents()
ISkeletonWriter
getSfWriter()
protected String
getString(ISkeleton skeleton, EncoderContext context)
protected String
getString(INameable ref, String propName, LocaleId locToUse, EncoderContext context)
protected String
getString(ITextUnit tu, LocaleId locToUse, EncoderContext context)
Gets the skeleton and the original content of a given text unit.protected String
getString(GenericSkeletonPart part, EncoderContext context)
protected String
getString(StorageList list, LocaleId locToUse, EncoderContext context)
protected String
getStringFromSubfilter(StorageList list, LocaleId locToUse, EncoderContext context, boolean fromSource)
Gets the string from a subfilter reference.boolean
isAllowEmptyOutputTarget()
Deprecated.protected boolean
isCodeThatDisablesEncoding(Code code)
boolean
isMultilingual()
protected IReferenceable
peekReference(String id)
String
processDocumentPart(DocumentPart resource)
Processes the DOCUMENT_PART event.String
processEndDocument(Ending resource)
Processes the END_DOCUMENT event.String
processEndGroup(Ending resource)
Processes the END_GROUP event.String
processEndSubDocument(Ending resource)
Processes the END_SUBDOCUMENT event.String
processEndSubfilter(EndSubfilter resource)
String
processStartDocument(LocaleId outputLocale, String outputEncoding, EncoderManager encoderManager, StartDocument resource)
Processes the START_DOCUMENT event.String
processStartGroup(StartGroup resource)
Processes the START_GROUP event.String
processStartSubDocument(StartSubDocument resource)
Processes a START_SUBDOCUMENT event.String
processStartSubfilter(StartSubfilter resource)
String
processTextUnit(ITextUnit resource)
Processes the TEXT_UNIT event.void
setAllowEmptyOutputTarget(boolean allowEmptyOutputTarget)
Deprecated.void
setEncoderManager(EncoderManager encoderManager)
void
setMultilingual(boolean isMultilingual)
void
setOutputEncoding(String outputEncoding)
void
setOutputLoc(LocaleId outputLoc)
void
setReferentCopies(int referentCopies)
Sets the number of copies to keep for a referent.void
setReferents(Map<String,Referent> referents)
-
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.skeleton.ISkeletonWriter
processTextUnit
-
-
-
-
Field Detail
-
ALLOWEMPTYOUTPUTTARGET
public static String ALLOWEMPTYOUTPUTTARGET
-
inputLoc
protected LocaleId inputLoc
-
outputLoc
protected LocaleId outputLoc
-
encoderManager
protected EncoderManager encoderManager
-
storageStack
protected Stack<StorageList> storageStack
-
isMultilingual
protected boolean isMultilingual
-
allowEmptyOutputTarget
@Deprecated protected boolean allowEmptyOutputTarget
Deprecated.
-
useDisplayTextForCodes
protected boolean useDisplayTextForCodes
-
outputEncoding
protected String outputEncoding
-
-
Constructor Detail
-
GenericSkeletonWriter
public GenericSkeletonWriter()
-
GenericSkeletonWriter
public GenericSkeletonWriter(boolean useDisplayTextForCodes)
-
GenericSkeletonWriter
public GenericSkeletonWriter(LocaleId inputLoc, LocaleId outputLoc, EncoderManager encoderManager, boolean isMultilingual, boolean allowEmptyOutputTarget, Map<String,Referent> referents, Stack<StorageList> storageStack, String outputEncoding, int referentCopies, SubFilterSkeletonWriter sfWriter)
-
-
Method Detail
-
peekReference
protected IReferenceable peekReference(String id)
-
getReference
protected IReferenceable getReference(String id)
-
close
public void close()
Description copied from interface:ISkeletonWriter
Closes this skeleton writer.- Specified by:
close
in 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, EncoderManager encoderManager, StartDocument resource)
Description copied from interface:ISkeletonWriter
Processes the START_DOCUMENT event.- Specified by:
processStartDocument
in interfaceISkeletonWriter
- Parameters:
outputLocale
- the output locale.outputEncoding
- the name of the output charset encoding.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:ISkeletonWriter
Processes the END_DOCUMENT event.- Specified by:
processEndDocument
in 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:ISkeletonWriter
Processes a START_SUBDOCUMENT event.- Specified by:
processStartSubDocument
in 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:ISkeletonWriter
Processes the END_SUBDOCUMENT event.- Specified by:
processEndSubDocument
in 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:ISkeletonWriter
Processes the START_GROUP event.- Specified by:
processStartGroup
in 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:ISkeletonWriter
Processes the END_GROUP event.- Specified by:
processEndGroup
in 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:
processStartSubfilter
in interfaceISkeletonWriter
-
processEndSubfilter
public String processEndSubfilter(EndSubfilter resource)
- Specified by:
processEndSubfilter
in interfaceISkeletonWriter
-
processTextUnit
public String processTextUnit(ITextUnit resource)
Description copied from interface:ISkeletonWriter
Processes the TEXT_UNIT event.- Specified by:
processTextUnit
in 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:ISkeletonWriter
Processes the DOCUMENT_PART event.- Specified by:
processDocumentPart
in 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)
-
getStringFromSubfilter
protected String getStringFromSubfilter(StorageList list, LocaleId locToUse, EncoderContext context, boolean fromSource)
Gets the string from a subfilter reference.- Parameters:
list
- the StorageList reference that corresponds to the subfilter.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.fromSource
- true to get the source text from the subfilter, otherwise get the target text from the subfilter. This is used in the XLIFF filter to subfilter the source and the target separately.- Returns:
- The string representation of the subfilter reference.
-
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)
-
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)
-
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)
-
-