|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectnet.sf.okapi.common.resource.TextUnit
public class TextUnit
Basic unit of extraction from a filter and also the resource associated with the filter event TEXT_UNIT. The TextUnit object holds the extracted source text in one or more versions, all its properties and annotations, and any target corresponding data.
| Field Summary |
|---|
| Fields inherited from interface net.sf.okapi.common.resource.ITextUnit |
|---|
TYPE_CDATA, TYPE_HEADER, TYPE_LIST_ELEMENT, TYPE_PARA, TYPE_TITLE |
| Fields inherited from interface net.sf.okapi.common.IResource |
|---|
COPY_ALL, COPY_CONTENT, COPY_PROPERTIES, COPY_SEGMENTATION, COPY_SEGMENTED_CONTENT, CREATE_EMPTY |
| Constructor Summary | |
|---|---|
TextUnit(java.lang.String id)
Creates a new TextUnit object with its identifier. |
|
TextUnit(java.lang.String id,
java.lang.String sourceText)
Creates a new TextUnit object with its identifier and a text. |
|
TextUnit(java.lang.String id,
java.lang.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(java.lang.String id,
java.lang.String sourceText,
boolean isReferent,
java.lang.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. |
|
| Method Summary | ||
|---|---|---|
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,
java.lang.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. |
|
|
getAnnotation(java.lang.Class<A> annotationType)
Gets the annotation object for a given class for this resource. |
|
java.lang.Iterable<IAnnotation> |
getAnnotations()
Gets the iterable list of the annotations for this resource. |
|
java.lang.String |
getId()
Gets the identifier of the resource. |
|
java.lang.String |
getMimeType()
Gets the type of content of this resource. |
|
java.lang.String |
getName()
Gets the name of this resource. |
|
Property |
getProperty(java.lang.String name)
Gets the resource-level property for a given name. |
|
java.util.Set<java.lang.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(java.lang.String name)
Gets the source property for a given name. |
|
java.util.Set<java.lang.String> |
getSourcePropertyNames()
Gets the names of all the source properties for this resource. |
|
Segment |
getSourceSegment(java.lang.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. |
|
java.util.Set<LocaleId> |
getTargetLocales()
Gets all the target locales for this resource. |
|
Property |
getTargetProperty(LocaleId locId,
java.lang.String name)
Gets the target property for a given name and target locale. |
|
java.util.Set<java.lang.String> |
getTargetPropertyNames(LocaleId locId)
Gets the names of all the properties for a given target locale in this resource. |
|
Segment |
getTargetSegment(LocaleId trgLoc,
java.lang.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. |
|
java.lang.String |
getType()
Gets the type information associated with this resource. |
|
IVariantSources |
getVariantSources()
Returns the variant sources (an IVariantSources object) for this text unit. |
|
boolean |
hasProperty(java.lang.String name)
Indicates if a resource-level property exists for a given name. |
|
boolean |
hasSourceProperty(java.lang.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,
java.lang.String name)
Indicates if a property exists for a given name and target locale. |
|
boolean |
hasVariantSources()
Indicates whether there are any variant sources used in this text unit. |
|
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(java.lang.String name)
Removes a resource-level property of a given name. |
|
void |
removeSourceProperty(java.lang.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,
java.lang.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(java.lang.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(java.lang.String mimeType)
Sets the type of content of this resource. |
|
void |
setName(java.lang.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. |
|
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(java.lang.String value)
Sets the type information associated with this resource. |
|
java.lang.String |
toString()
Gets the string representation of the default source container. |
|
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public TextUnit(java.lang.String id)
id - the identifier of this resource.
public TextUnit(java.lang.String id,
java.lang.String sourceText)
id - the identifier of this resource.sourceText - the initial text of the source.
public TextUnit(java.lang.String id,
java.lang.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(java.lang.String id,
java.lang.String sourceText,
boolean isReferent,
java.lang.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.| Method Detail |
|---|
public boolean isEmpty()
ITextUnit
isEmpty in interface ITextUnitpublic TextContainer getSource()
ITextUnitTextContainer object).
getSource in interface ITextUnitpublic TextContainer setSource(TextContainer textContainer)
ITextUnit
setSource in interface ITextUnittextContainer - the source object to set.
public boolean hasVariantSources()
ITextUnit
hasVariantSources in interface ITextUnitpublic IVariantSources getVariantSources()
ITextUnitIVariantSources object) for this text unit.
getVariantSources in interface ITextUnitpublic TextFragment setSourceContent(TextFragment content)
ITextUnit
setSourceContent 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)
ITextUnit
getTarget 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.
setTarget in interface ITextUnitlocId - the target locale.text - the target content to set.
public void removeTarget(LocaleId locId)
ITextUnit
removeTarget in interface ITextUnitlocId - the target locale to remove.public boolean hasTarget(LocaleId locId)
ITextUnit
hasTarget in interface ITextUnitlocId - the locale to query.
public 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()
ITextUnit
getSourceSegments in interface ITextUnit
public Segment getSourceSegment(java.lang.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)
ITextUnit
getTargetSegments in interface ITextUnittrgLoc - the locale of the target to retrieve.
public Segment getTargetSegment(LocaleId trgLoc,
java.lang.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 java.util.Set<LocaleId> getTargetLocales()
INameable
getTargetLocales in interface INameablepublic java.lang.String getName()
INameable
getName in interface INameablepublic void setName(java.lang.String name)
INameable
setName in interface INameablename - New name to set.public java.lang.String getType()
INameable
getType in interface INameablepublic void setType(java.lang.String value)
INameable
setType in interface INameablevalue - The new type information.public java.lang.String getMimeType()
INameable
getMimeType in interface INameablepublic void setMimeType(java.lang.String mimeType)
INameable
setMimeType in interface INameablemimeType - The new type of content of this resource.public boolean isTranslatable()
INameable
isTranslatable in interface INameablepublic void setIsTranslatable(boolean value)
INameable
setIsTranslatable in interface INameablevalue - True to indicate that the content of this resource is translatable.public boolean preserveWhitespaces()
INameable
preserveWhitespaces in interface INameablepublic void setPreserveWhitespaces(boolean value)
INameable
setPreserveWhitespaces in interface INameablevalue - True to indicate that the white-spaces in the content of this resource should be preserved.public java.lang.String getId()
IResource
getId in interface IResourcepublic void setId(java.lang.String id)
IResource
setId in interface IResourceid - the new identifier value.IResource.getId()public ISkeleton getSkeleton()
IResource
getSkeleton in interface IResourcepublic void setSkeleton(ISkeleton skeleton)
IResource
setSkeleton in interface IResourceskeleton - the skeleton object to set.public boolean isReferent()
IReferenceable
isReferent in interface IReferenceablepublic void setIsReferent(boolean value)
IReferenceable
setIsReferent in interface IReferenceablevalue - true if the resource is a referent, false if it is not.public int getReferenceCount()
IReferenceable
getReferenceCount in interface IReferenceablepublic void setReferenceCount(int value)
IReferenceable
setReferenceCount in interface IReferenceablevalue - the number of time this referent is referenced to.public java.util.Set<java.lang.String> getPropertyNames()
INameable
getPropertyNames in interface INameablepublic Property getProperty(java.lang.String name)
INameable
getProperty in interface INameablename - Name of the property to retrieve.
public Property setProperty(Property property)
INameable
setProperty in interface INameableproperty - The new property to set.
public void removeProperty(java.lang.String name)
INameable
removeProperty in interface INameablename - The name of the property to remove.public boolean hasProperty(java.lang.String name)
INameable
hasProperty in interface INameablename - The name of the resource-level property to query.
public <A extends IAnnotation> A getAnnotation(java.lang.Class<A> annotationType)
IResource
getAnnotation in interface IResourceannotationType - the class of the annotation object to retrieve.
public void setAnnotation(IAnnotation annotation)
IResource
setAnnotation in interface IResourceannotation - the annotation object to set.public java.lang.Iterable<IAnnotation> getAnnotations()
IResource
getAnnotations in interface IResourcepublic Property getSourceProperty(java.lang.String name)
INameable
getSourceProperty in interface INameablename - The name of the source property to retrieve.
public Property setSourceProperty(Property property)
INameable
setSourceProperty in interface INameableproperty - The new property to set.
public void removeSourceProperty(java.lang.String name)
INameable
removeSourceProperty in interface INameablename - The name of the property to remove.public java.util.Set<java.lang.String> getSourcePropertyNames()
INameable
getSourcePropertyNames in interface INameablepublic boolean hasSourceProperty(java.lang.String name)
INameable
hasSourceProperty in interface INameablename - The name of the source property to query.
public Property getTargetProperty(LocaleId locId,
java.lang.String name)
INameable
getTargetProperty in interface INameablelocId - 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)
INameable
setTargetProperty in interface INameablelocId - 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,
java.lang.String name)
INameable
removeTargetProperty in interface INameablelocId - The target locale for which this property should be set.name - The name of the property to remove.public java.util.Set<java.lang.String> getTargetPropertyNames(LocaleId locId)
INameable
getTargetPropertyNames in interface INameablelocId - the target locale to query.
public boolean hasTargetProperty(LocaleId locId,
java.lang.String name)
INameable
hasTargetProperty in interface INameablelocId - the target locale to query.name - the name of the property to query.
public Property createTargetProperty(LocaleId locId,
java.lang.String name,
boolean overwriteExisting,
int creationOptions)
INameable
createTargetProperty 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 java.lang.String toString()
toString in class java.lang.Objectpublic TextUnit clone()
clone in interface ITextUnitclone in class java.lang.Objectpublic void removeAllSegmentations()
ITextUnit
removeAllSegmentations in interface ITextUnitpublic void createSourceSegmentation(ISegmenter segmenter)
ITextUnit
createSourceSegmentation in interface ITextUnitsegmenter - the segmenter to use to create the segments.
public void createTargetSegmentation(ISegmenter segmenter,
LocaleId targetLocale)
ITextUnit
createTargetSegmentation 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.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||