public class TextUnit extends BaseReferenceable implements ITextUnit
parentIdid, mimeType, nameTYPE_CDATA, TYPE_HEADER, TYPE_LIST_ELEMENT, TYPE_PARA, TYPE_TITLECOPY_ALL, COPY_CONTENT, COPY_PROPERTIES, COPY_SEGMENTATION, COPY_SEGMENTED_CONTENT, CREATE_EMPTY| Constructor and Description |
|---|
TextUnit() |
TextUnit(String id)
Creates a new TextUnit object with its identifier.
|
TextUnit(String id,
String sourceText)
Creates a new TextUnit object with its identifier and a text.
|
TextUnit(String id,
String sourceText,
boolean isReferent)
Creates a new TextUnit object with its ID, a text, and a flag indicating if
it is a referent or not.
|
TextUnit(String id,
String sourceText,
boolean isReferent,
String mimeType)
Creates a new TextUnit object with its identifier, a text, a flag indicating
if it is a referent or not, and a given MIME type.
|
| Modifier and Type | Method and Description |
|---|---|
TextUnit |
clone()
Clones this TextUnit.
|
void |
createSourceSegmentation(ISegmenter segmenter)
Segments the default source content based on the rules provided by a given ISegmenter.
|
TextContainer |
createTarget(LocaleId targetLocale,
boolean overwriteExisting,
int creationOptions)
Creates or get the target for this TextUnit.
|
Property |
createTargetProperty(LocaleId locId,
String name,
boolean overwriteExisting,
int creationOptions)
Create target
Property without access to the source property |
void |
createTargetSegmentation(ISegmenter segmenter,
LocaleId targetLocale)
Segments the specified target content based on the rules provided by a given ISegmenter.
|
IAlignedSegments |
getAlignedSegments()
Creates a new
IAlignedSegments object to access and
manipulate the segments of this text unit. |
int |
getReferenceCount()
Gets the number of time this referent is referenced to.
|
TextContainer |
getSource()
Gets the source object for this text unit (a
TextContainer object). |
Map<String,Property> |
getSourceProperties() |
Property |
getSourceProperty(String name)
Gets the source property for a given name.
|
Set<String> |
getSourcePropertyNames()
Gets the names of all the source properties for this resource.
|
Segment |
getSourceSegment(String segId,
boolean createIfNeeded)
Gets the source segment for a given segment id.
|
ISegments |
getSourceSegments()
Gets the segments for the source.
|
TextContainer |
getTarget(LocaleId locId)
Gets the target object for this text unit for a given locale.
|
Set<LocaleId> |
getTargetLocales()
Gets all the target locales for this resource.
|
Property |
getTargetProperty(LocaleId locId,
String name)
Gets the target property for a given name and target locale.
|
Set<String> |
getTargetPropertyNames(LocaleId locId)
Gets the names of all the properties for a given target locale in this resource.
|
Segment |
getTargetSegment(LocaleId trgLoc,
String segId,
boolean createIfNeeded)
Gets the segment for a given segment id in a given target.
|
ISegments |
getTargetSegments(LocaleId trgLoc)
Get the segments for a given target.
|
String |
getType()
Gets the type information associated with this resource.
|
boolean |
hasSourceProperty(String name)
Indicates if a source property exists for a given name.
|
boolean |
hasTarget(LocaleId locId)
Indicates if there is a target object for a given locale for this text unit.
|
boolean |
hasTargetProperty(LocaleId locId,
String name)
Indicates if a property exists for a given name and target locale.
|
boolean |
isEmpty()
Indicates if the source text of this TextUnit is empty.
|
boolean |
isReferent()
Indicates if this resource is a referent (i.e.
|
boolean |
isTranslatable()
Indicates if the content of this resource is translatable.
|
boolean |
preserveWhitespaces()
Indicates if the white-spaces in the content of this resource should be preserved.
|
void |
removeAllSegmentations()
Removes all segmentations (source and targets) in this text unit.
|
void |
removeSourceProperty(String name)
Removes a source property of a given name.
|
void |
removeTarget(LocaleId locId)
Removes a given target object from this text unit.
|
void |
removeTargetProperty(LocaleId locId,
String name)
Removes a target property of a given name.
|
void |
setIsReferent(boolean value)
Sets the flag indicating if this resource is a referent (i.e.
|
void |
setIsTranslatable(boolean value)
Sets the flag indicating if the content of this resource is translatable.
|
void |
setPreserveWhitespaces(boolean value)
sets the flag indicating if the white-spaces in the content of this resource should be preserved.
|
void |
setReferenceCount(int value)
Sets the number of time this referent is referenced to.
|
void |
setSkeleton(ISkeleton skeleton)
Sets the skeleton object for this resource.
|
TextContainer |
setSource(TextContainer textContainer)
Sets the source object for this TextUnit.
|
TextFragment |
setSourceContent(TextFragment content)
Sets the content of the source for this TextUnit.
|
Property |
setSourceProperty(Property property)
Sets a source property.
|
TextContainer |
setTarget(LocaleId locId,
TextContainer text)
Sets the target object for this text unit for a given locale.
|
TextFragment |
setTargetContent(LocaleId locId,
TextFragment content)
Sets the content of the target for a given locale for this TextUnit.
|
Property |
setTargetProperty(LocaleId locId,
Property property)
Sets a target property.
|
void |
setType(String value)
Sets the type information associated with this resource.
|
String |
toString()
Gets the string representation of the default source container.
|
getParentId, setParentIdgetAnnotation, getAnnotations, getId, getMimeType, getName, getProperties, getProperty, getPropertyNames, getSkeleton, hasProperty, removeProperty, setAnnotation, setId, setMimeType, setName, setPropertyequals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetMimeType, getName, setMimeType, setNamecopy, getProperties, getProperty, getPropertyNames, hasProperty, propertyIterator, removeProperty, setPropertyannotationIterator, clear, copy, getAnnotation, getAnnotations, getAnnotationsTypesAsSet, hasAnnotation, hasAnnotations, remove, setAnnotationgetSkeletoncopycopy, createTargetProperty, getAnnotations, getTargetPropertiespublic TextUnit()
public TextUnit(String id)
id - the identifier of this resource.public TextUnit(String id, String sourceText)
id - the identifier of this resource.sourceText - the initial text of the source.public TextUnit(String id, String sourceText, boolean isReferent)
id - the identifier of this resource.sourceText - the initial text of the source (can be null).isReferent - indicates if this resource is a referent (i.e. is referred
to by another resource) or not.public TextUnit(String id, String sourceText, boolean isReferent, String mimeType)
id - the identifier of this resource.sourceText - the initial text of the source (can be null).isReferent - indicates if this resource is a referent (i.e. is referred
to by another resource) or not.mimeType - the MIME type identifier for the content of this TextUnit.public boolean isEmpty()
ITextUnitpublic TextContainer getSource()
ITextUnitTextContainer object).public TextContainer setSource(TextContainer textContainer)
ITextUnitpublic TextFragment setSourceContent(TextFragment content)
ITextUnitsetSourceContent in interface ITextUnitcontent - the new content to set.public TextContainer createTarget(LocaleId targetLocale, boolean overwriteExisting, int creationOptions)
ITextUnitIf a variant source exists for the target locale, creationOptions apply to the variant source.
createTarget in interface ITextUnittargetLocale - the target locale.overwriteExisting - true to overwrite any existing target for the given locale.
False to not create a new target object if one already exists for the given locale.creationOptions - creation options:
public TextContainer getTarget(LocaleId locId)
ITextUnitgetTarget in interface ITextUnitlocId - the locale to query.ITextUnit.createTarget(LocaleId, boolean, int)public TextContainer setTarget(LocaleId locId, TextContainer text)
ITextUnit
If the target does not exists, one is created.
Any existing content for the given locale is overwritten.
To set a target object based on the source, use the
ITextUnit.createTarget(LocaleId, boolean, int) method.
public void removeTarget(LocaleId locId)
ITextUnitremoveTarget in interface ITextUnitlocId - the target locale to remove.public boolean hasTarget(LocaleId locId)
ITextUnitpublic TextFragment setTargetContent(LocaleId locId, TextFragment content)
ITextUnitIf the target does not exists, one is created.
Any existing content for the given locale is overwritten.
To set a target object based on the source, use the
ITextUnit.createTarget(LocaleId, boolean, int) method.
setTargetContent in interface ITextUnitlocId - the locale to set.content - the new content to set.public IAlignedSegments getAlignedSegments()
ITextUnitIAlignedSegments object to access and
manipulate the segments of this text unit.getAlignedSegments in interface ITextUnitIAlignedSegments object.public ISegments getSourceSegments()
ITextUnitgetSourceSegments in interface ITextUnitpublic Segment getSourceSegment(String segId, boolean createIfNeeded)
ITextUnit
If the segment does not exists, one is created if createIfNeeded is true.
getSourceSegment in interface ITextUnitsegId - the id of the segment to retrieve.createIfNeeded - true to append a segment at the end of the content
and return it if the segment does not exist yet.
False to return null when the segment does not exists.public ISegments getTargetSegments(LocaleId trgLoc)
ITextUnitgetTargetSegments in interface ITextUnittrgLoc - the locale of the target to retrieve.public Segment getTargetSegment(LocaleId trgLoc, String segId, boolean createIfNeeded)
ITextUnitIf the target does not exists, one is created.
If the segment does not exists, one is created if createIfNeeded is true.
getTargetSegment in interface ITextUnittrgLoc - the target locale to look up.segId - the id of the segment to retrieve.createIfNeeded - true to append a segment at the end of the target content and
return it if the segment does not exist yet. False to return null when the segment
does not exists.public Set<LocaleId> getTargetLocales()
IWithTargetPropertiesgetTargetLocales in interface IWithTargetPropertiespublic String getType()
INameablegetType in interface INameablegetType in class BaseNameablepublic void setType(String value)
INameablesetType in interface INameablesetType in class BaseNameablevalue - The new type information.public boolean isTranslatable()
INameableisTranslatable in interface INameableisTranslatable in class BaseNameablepublic void setIsTranslatable(boolean value)
INameablesetIsTranslatable in interface INameablesetIsTranslatable in class BaseNameablevalue - True to indicate that the content of this resource is translatable.public boolean preserveWhitespaces()
INameablepreserveWhitespaces in interface INameablepreserveWhitespaces in class BaseNameablepublic void setPreserveWhitespaces(boolean value)
INameablesetPreserveWhitespaces in interface INameablesetPreserveWhitespaces in class BaseNameablevalue - True to indicate that the white-spaces in the content of this resource should be preserved.public void setSkeleton(ISkeleton skeleton)
IWithSkeletonsetSkeleton in interface IWithSkeletonsetSkeleton in class BaseNameableskeleton - the skeleton object to set.public boolean isReferent()
IReferenceableisReferent in interface IReferenceableisReferent in class BaseReferenceablepublic void setIsReferent(boolean value)
IReferenceablesetIsReferent in interface IReferenceablesetIsReferent in class BaseReferenceablevalue - true if the resource is a referent, false if it is not.public int getReferenceCount()
IReferenceablegetReferenceCount in interface IReferenceablegetReferenceCount in class BaseReferenceablepublic void setReferenceCount(int value)
IReferenceablesetReferenceCount in interface IReferenceablesetReferenceCount in class BaseReferenceablevalue - the number of time this referent is referenced to.public String toString()
toString in class BaseNameablepublic TextUnit clone()
public void removeAllSegmentations()
ITextUnitremoveAllSegmentations in interface ITextUnitpublic void createSourceSegmentation(ISegmenter segmenter)
ITextUnitcreateSourceSegmentation in interface ITextUnitsegmenter - the segmenter to use to create the segments.public void createTargetSegmentation(ISegmenter segmenter, LocaleId targetLocale)
ITextUnitcreateTargetSegmentation in interface ITextUnitsegmenter - the segmenter to use to create the segments.targetLocale - LocaleId of the target we want to segment.public Property getSourceProperty(String name)
IWithSourcePropertiesgetSourceProperty in interface IWithSourcePropertiesname - The name of the source property to retrieve.public Property setSourceProperty(Property property)
IWithSourcePropertiessetSourceProperty in interface IWithSourcePropertiesproperty - The new property to set.public void removeSourceProperty(String name)
IWithSourcePropertiesremoveSourceProperty in interface IWithSourcePropertiesname - The name of the property to remove.public Set<String> getSourcePropertyNames()
IWithSourcePropertiesgetSourcePropertyNames in interface IWithSourcePropertiespublic boolean hasSourceProperty(String name)
IWithSourcePropertieshasSourceProperty in interface IWithSourcePropertiesname - The name of the source property to query.public Property getTargetProperty(LocaleId locId, String name)
IWithTargetPropertiesgetTargetProperty in interface IWithTargetPropertieslocId - the locale of the property to retrieve.name - The name of the property to retrieve. This name is case-sensitive.public Property setTargetProperty(LocaleId locId, Property property)
IWithTargetPropertiessetTargetProperty in interface IWithTargetPropertieslocId - The target locale for which this property should be set.property - The new property to set. This name is case-sensitive.public void removeTargetProperty(LocaleId locId, String name)
IWithTargetPropertiesremoveTargetProperty in interface IWithTargetPropertieslocId - The target locale for which this property should be set.name - The name of the property to remove.public Set<String> getTargetPropertyNames(LocaleId locId)
IWithTargetPropertiesgetTargetPropertyNames in interface IWithTargetPropertieslocId - the target locale to query.public boolean hasTargetProperty(LocaleId locId, String name)
IWithTargetPropertieshasTargetProperty in interface IWithTargetPropertieslocId - the target locale to query.name - the name of the property to query.public Map<String,Property> getSourceProperties()
getSourceProperties in interface IWithSourcePropertiesMap of source properties for the implementer of interfacepublic Property createTargetProperty(LocaleId locId, String name, boolean overwriteExisting, int creationOptions)
IWithTargetPropertiesProperty without access to the source propertycreateTargetProperty in interface IWithTargetPropertiesCopyright © 2022. All rights reserved.