net.sf.okapi.lib.xliff2.core

## Class Segment

- java.lang.Object
- - net.sf.okapi.lib.xliff2.core.Part
  - - net.sf.okapi.lib.xliff2.core.Segment

-     public class Segment
      extends Part

  Represents a segment object.

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class net.sf.okapi.lib.xliff2.core.Part

      `Part.GetTarget`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static TargetState` | `STATE_DEFAULT` Default value for the target state of a segment.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Segment(Segment original)` Copy constructor.
    `Segment(Store store)` Creates a new `Segment` object.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `Segment` | `createAndCopyMetadata()` Creates a new empty segment based on this one.
    `boolean` | `getCanResegment()` Indicates if this segment can be re-segmented.
    `TargetState` | `getState()` Gets the state for this segment.
    `java.lang.String` | `getSubState()` Gets the sub-state for this segment.
    `boolean` | `isSegment()` Indicates if this part is a segment or an ignorable.
    `void` | `setCanResegment(boolean canResegment)` Sets the flag indicating if this segment can be re-segmented.
    `void` | `setState(java.lang.String state)` Sets the state for this segment.
    `void` | `setState(TargetState state)` Sets the state for this segment.
    `void` | `setSubState(java.lang.String subState)` Sets the sub-state for this segment.

    - ### Methods inherited from class net.sf.okapi.lib.xliff2.core.Part

      `getId, getId, getPreserveWS, getSource, getSourceTags, getStore, getTarget, getTarget, getTargetOrder, getTargetTags, hasTarget, removeMarkers, setId, setPreserveWS, setSource, setSource, setTarget, setTarget, setTargetOrder, showProtectedContent`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### STATE_DEFAULT

          public static final TargetState STATE_DEFAULT

      Default value for the target state of a segment.

  - ### Constructor Detail

    - #### Segment

          public Segment(Segment original)

      Copy constructor.
      Parameters:
        `original` - the original object to duplicate.

    - #### Segment

          public Segment(Store store)

      Creates a new `Segment` object.
      Parameters:
        `store` - the shared `Store` for this object.

  - ### Method Detail

    - #### getCanResegment

          public boolean getCanResegment()

      Indicates if this segment can be re-segmented.
      Returns:
        true if this segment can be re-segmented, false otherwise.

    - #### setCanResegment

          public void setCanResegment(boolean canResegment)

      Sets the flag indicating if this segment can be re-segmented.
      Parameters:
        `canResegment` - true to indicate that this segment can be re-segmented.

    - #### getState

          public TargetState getState()

      Gets the state for this segment.
      Returns:
        the state for this segment.

    - #### setState

          public void setState(java.lang.String state)

      Sets the state for this segment.
      Parameters:
        `state` - the new state for this segment. The value must be "initial", "translated", "reviewed" or "final". It can also be null and in that case the value is set to `STATE_DEFAULT`.

    - #### setState

          public void setState(TargetState state)

      Sets the state for this segment.
      Parameters:
        `state` - the new state to set.

    - #### getSubState

          public java.lang.String getSubState()

      Gets the sub-state for this segment.
      Returns:
        the sub-state for this segment (can be null).

    - #### setSubState

          public void setSubState(java.lang.String subState)

      Sets the sub-state for this segment.
      Parameters:
        `subState` - the new sub-state for this segment. The string must be in the format "prefix:value" or it can be null.

    - #### isSegment

          public boolean isSegment()

      Description copied from class: `Part`
      Indicates if this part is a segment or an ignorable.
      Overrides:
        `isSegment` in class `Part`
      Returns:
        true if this part is a segment, false otherwise.

    - #### createAndCopyMetadata

          public Segment createAndCopyMetadata()

      Creates a new empty segment based on this one.

      The new segment uses the same store and has the same core metadata (translate, can-re-segment, state, sub-state) as this segment. The metadata of the source and target are also copied, but not their content. The new segment has an empty target if this one has a target and it has no target if this one has no target. The new segment has also has a new id value.

      Returns:
        the new segment.