public interface ITextUnit extends IMultilingual, IReferenceable
The TextUnit object holds the extracted source text, all its properties and annotations, and any target corresponding data.
Where adjusted sources exist, methods in this interface should have their effects on the default source, however a specific implementation may provide a method to select one of the variant sources that methods would then use. The main source should always be used before such a method is called.
| Modifier and Type | Field and Description |
|---|---|
static String |
TYPE_CDATA
Resource type value for a cdata section.
|
static String |
TYPE_HEADER
Resource type value for a header.
|
static String |
TYPE_LIST_ELEMENT
Resource type value for a list.
|
static String |
TYPE_PARA
Resource type value for a paragraph.
|
static String |
TYPE_TITLE
Resource type value for a title.
|
COPY_ALL, COPY_CONTENT, COPY_PROPERTIES, COPY_SEGMENTATION, COPY_SEGMENTED_CONTENT, CREATE_EMPTY| Modifier and Type | Method and Description |
|---|---|
ITextUnit |
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 locId,
boolean overwriteExisting,
int creationOptions)
Creates or get the target for this TextUnit.
|
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. |
TextContainer |
getSource()
Gets the source object for this text unit (a
TextContainer object). |
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.
|
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.
|
boolean |
hasTarget(LocaleId locId)
Indicates if there is a target object for a given locale for this text unit.
|
boolean |
isEmpty()
Indicates if the source text of this TextUnit is empty.
|
void |
removeAllSegmentations()
Removes all segmentations (source and targets) in this text unit.
|
void |
removeTarget(LocaleId locId)
Removes a given target object from this text unit.
|
TextContainer |
setSource(TextContainer textContainer)
Sets the source object for this TextUnit.
|
TextFragment |
setSourceContent(TextFragment content)
Sets the content of the source for this TextUnit.
|
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.
|
getMimeType, getName, getType, isTranslatable, preserveWhitespaces, setIsTranslatable, setMimeType, setName, setPreserveWhitespaces, setTypecopy, getProperties, getProperty, getPropertyNames, hasProperty, propertyIterator, removeProperty, setPropertyannotationIterator, clear, copy, getAnnotation, getAnnotations, getAnnotationsTypesAsSet, hasAnnotation, hasAnnotations, remove, setAnnotationgetSkeleton, setSkeletoncopy, getSourceProperties, getSourceProperty, getSourcePropertyNames, hasSourceProperty, removeSourceProperty, setSourcePropertycopy, createTargetProperty, createTargetProperty, getAnnotations, getTargetLocales, getTargetProperties, getTargetProperty, getTargetPropertyNames, hasTargetProperty, removeTargetProperty, setTargetPropertygetReferenceCount, isReferent, setIsReferent, setReferenceCountstatic final String TYPE_PARA
static final String TYPE_LIST_ELEMENT
static final String TYPE_TITLE
static final String TYPE_HEADER
static final String TYPE_CDATA
ITextUnit clone()
boolean isEmpty()
TextContainer getSource()
TextContainer object).TextContainer setSource(TextContainer textContainer)
textContainer - the source object to set.TextContainer getTarget(LocaleId locId)
locId - the locale to query.createTarget(LocaleId, boolean, int)TextContainer setTarget(LocaleId locId, TextContainer text)
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
createTarget(LocaleId, boolean, int) method.
locId - the target locale.text - the target content to set.void removeTarget(LocaleId locId)
locId - the target locale to remove.boolean hasTarget(LocaleId locId)
locId - the locale to query.TextContainer createTarget(LocaleId locId, boolean overwriteExisting, int creationOptions)
If a variant source exists for the target locale, creationOptions apply to the variant source.
locId - 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:
TextFragment setSourceContent(TextFragment content)
content - the new content to set.TextFragment setTargetContent(LocaleId locId, TextFragment content)
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
createTarget(LocaleId, boolean, int) method.
locId - the locale to set.content - the new content to set.IAlignedSegments getAlignedSegments()
IAlignedSegments object to access and
manipulate the segments of this text unit.IAlignedSegments object.ISegments getSourceSegments()
ISegments getTargetSegments(LocaleId trgLoc)
trgLoc - the locale of the target to retrieve.void removeAllSegmentations()
void createSourceSegmentation(ISegmenter segmenter)
segmenter - the segmenter to use to create the segments.void createTargetSegmentation(ISegmenter segmenter, LocaleId targetLocale)
segmenter - the segmenter to use to create the segments.targetLocale - LocaleId of the target we want to segment.Segment getSourceSegment(String segId, boolean createIfNeeded)
If the segment does not exists, one is created if createIfNeeded is true.
segId - 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.Segment getTargetSegment(LocaleId trgLoc, String segId, boolean createIfNeeded)
If the target does not exists, one is created.
If the segment does not exists, one is created if createIfNeeded is true.
trgLoc - 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.Copyright © 2021. All rights reserved.