net.sf.okapi.common.resource

## Class Segment

- java.lang.Object
- - net.sf.okapi.common.resource.TextPart
  - - net.sf.okapi.common.resource.Segment

- All Implemented Interfaces:
    IWithAnnotations, IWithProperties

      public class Segment
      extends TextPart

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

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `java.lang.String` | `id` Identifier of this segment.
    `static java.lang.String` | `REF_MARKER`

    - ### Fields inherited from class net.sf.okapi.common.resource.TextPart

      `annotations, properties, text`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `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

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `Segment` | `clone()`
    `void` | `forceId(java.lang.String id)` Forces the id of this segment to a specific value.
    `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)`

    - ### Methods inherited from class net.sf.okapi.common.resource.TextPart

      `getAnnotation, getAnnotations, getContent, getProperty, getPropertyNames, hasProperty, removeProperty, setAnnotation, setContent, setProperty, 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

    - #### 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.
      Parameters:
        `id` - identifier for the new segment (Can be null).

    - #### 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.

    - #### makeRefMarker

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