Package net.sf.okapi.common.resource
Class TextPart
- java.lang.Object
-
- net.sf.okapi.common.resource.TextPart
-
- All Implemented Interfaces:
Cloneable,IResource,IWithAnnotations,IWithProperties,IWithSkeleton
- Direct Known Subclasses:
Segment
public class TextPart extends Object implements IResource
Implements the base object for the parts that make up a content.
-
-
Field Summary
Fields Modifier and Type Field Description protected AnnotationsannotationsStringidIdentifier of this segment.StringoriginalIdSome formats already have id's like xliff2protected Map<String,Property>propertiesTextFragmenttextText fragment of this part.WhitespaceStrategywhitespaceStrategy-
Fields inherited from interface net.sf.okapi.common.IResource
COPY_ALL, COPY_CONTENT, COPY_PROPERTIES, COPY_SEGMENTATION, COPY_SEGMENTED_CONTENT, CREATE_EMPTY
-
-
Constructor Summary
Constructors Constructor Description TextPart()Creates an empty part.TextPart(String text)Creates a new TextPart with a given text string.TextPart(String id, TextFragment text)Creates a new TextPart with a givenTextFragment.TextPart(TextFragment text)Creates a new TextPart with a givenTextFragment.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TextPartclone()Clone ofTextPartAnnotationsgetAnnotations()TextFragmentgetContent()Gets the text fragment for this part.StringgetId()Gets the identifier for this textpart.StringgetOriginalId()Map<String,Property>getProperties()WhitespaceStrategygetWhitespaceStrategy()booleanisSegment()Indicates if this part is aSegment.booleanpreserveWhitespaces()WARNING: The parentITextUnitmust be used in the case the whitespaceSrategy is INHERIT. We return false in the case of INHERIT because we have not specially set the whitespace handling TextPart and so it is the responsibility of the user to check the parent for the "real" value.voidsetContent(TextFragment fragment)Sets theTextFragmentfor this part.voidsetId(String id)Sets the identifier of this resource.voidsetOriginalId(String originalId)voidsetPreserveWhitespaces(boolean preserveWS)Only use this method if you are overriding the parentITextUnitwhitespace handling.voidsetWhitespaceStrategy(WhitespaceStrategy whitespaceStrategy)StringtoString()-
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface net.sf.okapi.common.resource.IWithAnnotations
annotationIterator, clear, getAnnotation, getAnnotationsTypesAsSet, hasAnnotation, hasAnnotations, remove, setAnnotation
-
Methods inherited from interface net.sf.okapi.common.resource.IWithProperties
getProperty, getPropertyNames, hasProperty, propertyIterator, removeProperty, setProperty
-
Methods inherited from interface net.sf.okapi.common.resource.IWithSkeleton
getSkeleton, setSkeleton
-
-
-
-
Field Detail
-
id
public String id
Identifier of this segment.
-
originalId
public String originalId
Some formats already have id's like xliff2
-
text
public TextFragment text
Text fragment of this part.
-
whitespaceStrategy
public WhitespaceStrategy whitespaceStrategy
-
annotations
protected Annotations annotations
-
-
Constructor Detail
-
TextPart
public TextPart()
Creates an empty part.
-
TextPart
public TextPart(TextFragment text)
Creates a new TextPart with a givenTextFragment.- Parameters:
text- theTextFragmentfor this new part.
-
TextPart
public TextPart(String id, TextFragment text)
Creates a new TextPart with a givenTextFragment.- Parameters:
text- theTextFragmentfor this new part.
-
TextPart
public TextPart(String text)
Creates a new TextPart with a given text string.- Parameters:
text- the text for this new part.
-
-
Method Detail
-
getId
public String getId()
Gets the identifier for this textpart.
-
setId
public void setId(String id)
Description copied from interface:IResourceSets the identifier of this resource.- Specified by:
setIdin interfaceIResource- Parameters:
id- the new identifier value.- See Also:
IResource.getId()
-
getContent
public TextFragment getContent()
Gets the text fragment for this part.- Returns:
- the text fragment for this part.
-
setContent
public void setContent(TextFragment fragment)
Sets theTextFragmentfor this part.- Parameters:
fragment- theTextFragmentto assign to this part. It must not be null.
-
getWhitespaceStrategy
public WhitespaceStrategy getWhitespaceStrategy()
-
setWhitespaceStrategy
public void setWhitespaceStrategy(WhitespaceStrategy whitespaceStrategy)
-
isSegment
public boolean isSegment()
Indicates if this part is aSegment.- Returns:
- true if the part is a
Segment, false if it is not.
-
getProperties
public Map<String,Property> getProperties()
- Specified by:
getPropertiesin interfaceIWithProperties- Returns:
Mapof properties for the implementer of interface
-
getAnnotations
public Annotations getAnnotations()
- Specified by:
getAnnotationsin interfaceIWithAnnotations- Returns:
Annotationsfor the implementer of interface
-
preserveWhitespaces
public boolean preserveWhitespaces()
WARNING: The parentITextUnitmust be used in the case the whitespaceSrategy is INHERIT. We return false in the case of INHERIT because we have not specially set the whitespace handling TextPart and so it is the responsibility of the user to check the parent for the "real" value.- Returns:
- true if the whitespace handling has been specifically set on this instance. False in all other cases.
-
setPreserveWhitespaces
public void setPreserveWhitespaces(boolean preserveWS)
Only use this method if you are overriding the parentITextUnitwhitespace handling.- Parameters:
preserveWS- true to preserve whitespace, otherwise normalize
-
getOriginalId
public String getOriginalId()
-
setOriginalId
public void setOriginalId(String originalId)
-
-