net.sf.okapi.common.resource
Class Segment

java.lang.Object
  extended by net.sf.okapi.common.resource.TextPart
      extended by net.sf.okapi.common.resource.Segment

public class Segment
extends TextPart

Implement a special content part that is a segment. A segment is a TextPart with an identifier.


Field Summary
protected  Annotations annotations
           
 java.lang.String id
          Identifier of this segment.
static java.lang.String REF_MARKER
           
 
Fields inherited from class net.sf.okapi.common.resource.TextPart
text
 
Constructor Summary
Segment()
          Creates an empty Segment object with a null identifier.
Segment(java.lang.String id)
          Creates an empty Segment object with a given identifier.
Segment(java.lang.String id, TextFragment text)
          Creates a Segment object with a given identifier and a given text fragment.
 
Method Summary
 Segment clone()
           
 void forceId(java.lang.String id)
          Forces the id of this segment to a specific value.
<A extends IAnnotation>
A
getAnnotation(java.lang.Class<A> annotationType)
          Gets the annotation object for a given class for this segment.
 java.lang.Iterable<IAnnotation> getAnnotations()
          Gets the iterable list for the annotations of this segment.
 java.lang.String getId()
          Gets the identifier for this segment.
 boolean isSegment()
          Indicates if this part is a Segment.
static java.lang.String makeRefMarker(java.lang.String segId)
           
 void setAnnotation(IAnnotation annotation)
          Sets an annotation object for this segment.
 
Methods inherited from class net.sf.okapi.common.resource.TextPart
getContent, setContent, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

REF_MARKER

public static final java.lang.String REF_MARKER
See Also:
Constant Field Values

annotations

protected Annotations annotations

id

public java.lang.String id
Identifier of this segment.

Constructor Detail

Segment

public Segment()
Creates an empty Segment object with a null identifier.


Segment

public Segment(java.lang.String id)
Creates an empty Segment object with a given identifier.


Segment

public Segment(java.lang.String id,
               TextFragment text)
Creates a Segment object with a given identifier and a given text fragment.

Parameters:
id - identifier for the new segment (Can be null).
text - text fragment for the new segment.
Method Detail

clone

public Segment clone()
Overrides:
clone in class TextPart

isSegment

public boolean isSegment()
Description copied from class: TextPart
Indicates if this part is a Segment.

Overrides:
isSegment in class TextPart
Returns:
true if the part is a Segment, false if it is not.

getId

public java.lang.String getId()
Gets the identifier for this segment.

Returns:
the identifier for this segment.

forceId

public void forceId(java.lang.String id)
Forces the id of this segment to a specific value. No check is made to validate this ID value. It is the caller's responsability to avoid duplicates, null value, and other wrong values.

Parameters:
id - the new value of the segment.

getAnnotation

public <A extends IAnnotation> A getAnnotation(java.lang.Class<A> annotationType)
Gets the annotation object for a given class for this segment.

Parameters:
annotationType - the class of the annotation object to retrieve.
Returns:
the annotation for the given class for this segment.

setAnnotation

public void setAnnotation(IAnnotation annotation)
Sets an annotation object for this segment.

If an annotation of the same type exists already it is overridden.

Parameters:
annotation - the annotation object to set.

getAnnotations

public java.lang.Iterable<IAnnotation> getAnnotations()
Gets the iterable list for the annotations of this segment.

Returns:
the iterable list for the annotations of this segment.

makeRefMarker

public static java.lang.String makeRefMarker(java.lang.String segId)