public class TextUnit extends Object implements ITextUnit
TYPE_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)
Creates or get a target property based on the corresponding source.
|
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. |
<A extends IAnnotation> |
getAnnotation(Class<A> annotationType)
Gets the annotation object for a given class for this resource.
|
Iterable<IAnnotation> |
getAnnotations()
Gets the iterable list of the annotations for this resource.
|
String |
getId()
Gets the identifier of the resource.
|
String |
getMimeType()
Gets the type of content of this resource.
|
String |
getName()
Gets the name of this resource.
|
protected LinkedHashMap<String,Property> |
getProperties() |
Property |
getProperty(String name)
Gets the resource-level property for a given name.
|
Set<String> |
getPropertyNames()
Gets the names of all the resource-level properties for this resource.
|
int |
getReferenceCount()
Gets the number of time this referent is referenced to.
|
ISkeleton |
getSkeleton()
Gets the skeleton object for this resource.
|
TextContainer |
getSource()
Gets the source object for this text unit (a
TextContainer object). |
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 |
hasProperty(String name)
Indicates if a resource-level property exists for a given name.
|
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 |
removeProperty(String name)
Removes a resource-level property of a given name.
|
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 |
setAnnotation(IAnnotation annotation)
Sets an annotation object for this resource.
|
protected void |
setAnnotations(Annotations annotations)
Used by TextUnit clone method to copy over all annotations at once.
|
void |
setId(String id)
Sets the identifier of this resource.
|
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 |
setMimeType(String mimeType)
Sets the type of content of this resource.
|
void |
setName(String name)
Sets the name of this resource.
|
void |
setPreserveWhitespaces(boolean value)
sets the flag indicating if the white-spaces in the content of this resource should be preserved.
|
protected void |
setProperties(LinkedHashMap<String,Property> properties) |
Property |
setProperty(Property property)
Sets a resource-level property.
|
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.
|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitcopycopycopypublic 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()
IWithBilingualPropertiesgetTargetLocales in interface IWithBilingualPropertiespublic String getName()
INameablepublic void setName(String name)
INameablepublic String getType()
INameablepublic void setType(String value)
INameablepublic String getMimeType()
INameablegetMimeType in interface INameablepublic void setMimeType(String mimeType)
INameablesetMimeType in interface INameablemimeType - The new type of content of this resource.public boolean isTranslatable()
INameableisTranslatable in interface INameablepublic void setIsTranslatable(boolean value)
INameablesetIsTranslatable in interface INameablevalue - True to indicate that the content of this resource is translatable.public boolean preserveWhitespaces()
INameablepreserveWhitespaces in interface INameablepublic void setPreserveWhitespaces(boolean value)
INameablesetPreserveWhitespaces in interface INameablevalue - True to indicate that the white-spaces in the content of this resource should be preserved.public String getId()
IResourcepublic void setId(String id)
IResourcesetId in interface IResourceid - the new identifier value.IResource.getId()public ISkeleton getSkeleton()
IResourcegetSkeleton in interface IResourcepublic void setSkeleton(ISkeleton skeleton)
IResourcesetSkeleton in interface IResourceskeleton - the skeleton object to set.public boolean isReferent()
IReferenceableisReferent in interface IReferenceablepublic void setIsReferent(boolean value)
IReferenceablesetIsReferent in interface IReferenceablevalue - true if the resource is a referent, false if it is not.public int getReferenceCount()
IReferenceablegetReferenceCount in interface IReferenceablepublic void setReferenceCount(int value)
IReferenceablesetReferenceCount in interface IReferenceablevalue - the number of time this referent is referenced to.public Set<String> getPropertyNames()
IWithPropertiesgetPropertyNames in interface IWithPropertiespublic Property getProperty(String name)
IWithPropertiesgetProperty in interface IWithPropertiesname - Name of the property to retrieve.public Property setProperty(Property property)
IWithPropertiessetProperty in interface IWithPropertiesproperty - The new property to set.public void removeProperty(String name)
IWithPropertiesremoveProperty in interface IWithPropertiesname - The name of the property to remove.public boolean hasProperty(String name)
IWithPropertieshasProperty in interface IWithPropertiesname - The name of the resource-level property to query.public <A extends IAnnotation> A getAnnotation(Class<A> annotationType)
IWithAnnotationsgetAnnotation in interface IWithAnnotationsA - the type of the class.annotationType - the class of the annotation object to retrieve.public void setAnnotation(IAnnotation annotation)
IWithAnnotationssetAnnotation in interface IWithAnnotationsannotation - the annotation object to set.public Iterable<IAnnotation> getAnnotations()
IWithAnnotationsgetAnnotations in interface IWithAnnotationspublic Property getSourceProperty(String name)
IWithBilingualPropertiesgetSourceProperty in interface IWithBilingualPropertiesname - The name of the source property to retrieve.public Property setSourceProperty(Property property)
IWithBilingualPropertiessetSourceProperty in interface IWithBilingualPropertiesproperty - The new property to set.public void removeSourceProperty(String name)
IWithBilingualPropertiesremoveSourceProperty in interface IWithBilingualPropertiesname - The name of the property to remove.public Set<String> getSourcePropertyNames()
IWithBilingualPropertiesgetSourcePropertyNames in interface IWithBilingualPropertiespublic boolean hasSourceProperty(String name)
IWithBilingualPropertieshasSourceProperty in interface IWithBilingualPropertiesname - The name of the source property to query.public Property getTargetProperty(LocaleId locId, String name)
IWithBilingualPropertiesgetTargetProperty in interface IWithBilingualPropertieslocId - 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)
IWithBilingualPropertiessetTargetProperty in interface IWithBilingualPropertieslocId - 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)
IWithBilingualPropertiesremoveTargetProperty in interface IWithBilingualPropertieslocId - The target locale for which this property should be set.name - The name of the property to remove.public Set<String> getTargetPropertyNames(LocaleId locId)
IWithBilingualPropertiesgetTargetPropertyNames in interface IWithBilingualPropertieslocId - the target locale to query.public boolean hasTargetProperty(LocaleId locId, String name)
IWithBilingualPropertieshasTargetProperty in interface IWithBilingualPropertieslocId - the target locale to query.name - the name of the property to query.public Property createTargetProperty(LocaleId locId, String name, boolean overwriteExisting, int creationOptions)
INameablecreateTargetProperty in interface INameablelocId - The target locale to use.name - The name of the property to create (or retrieve)overwriteExisting - True to overwrite any existing property.
False to not create a new property if one exists already.creationOptions - Creation options:
public String toString()
public 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.protected void setAnnotations(Annotations annotations)
annotations - the new annotations to set.protected LinkedHashMap<String,Property> getProperties()
protected void setProperties(LinkedHashMap<String,Property> properties)
Copyright © 2021. All rights reserved.