net.sf.okapi.common.resource

## Class TextPart

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

- All Implemented Interfaces:
    IWithAnnotations, IWithProperties
  Direct Known Subclasses:
    Segment

      public class TextPart
      extends java.lang.Object
      implements IWithProperties, IWithAnnotations

  Implements the base object for the parts that make up a content.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected Annotations` | `annotations`
    `protected java.util.LinkedHashMap<java.lang.String,Property>` | `properties`
    `TextFragment` | `text` Text fragment of this part.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `TextPart()` Creates an empty part.
    `TextPart(java.lang.String text)` Creates a new TextPart with a given text string.
    `TextPart(TextFragment text)` Creates a new TextPart with a given `TextFragment`.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `TextPart` | `clone()`
    `<A extends IAnnotation> A` | `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.
    `TextFragment` | `getContent()` Gets the text fragment for this part.
    `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.
    `boolean` | `hasProperty(java.lang.String name)` Indicates if a resource-level property exists for a given name.
    `boolean` | `isSegment()` Indicates if this part is a `Segment`.
    `void` | `removeProperty(java.lang.String name)` Removes a resource-level property of a given name.
    `void` | `setAnnotation(IAnnotation annotation)` Sets an annotation object for this resource.
    `void` | `setContent(TextFragment fragment)` Sets the `TextFragment` for this part.
    `Property` | `setProperty(Property property)` Sets a resource-level property.
    `java.lang.String` | `toString()`

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

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

- - ### Field Detail

    - #### properties

          protected java.util.LinkedHashMap<java.lang.String,Property> properties

    - #### annotations

          protected Annotations annotations

    - #### text

          public TextFragment text

      Text fragment of this part.

  - ### Constructor Detail

    - #### TextPart

          public TextPart()

      Creates an empty part.

    - #### TextPart

          public TextPart(TextFragment text)

      Creates a new TextPart with a given `TextFragment`.
      Parameters:
        `text` - the `TextFragment` for this new part.

    - #### TextPart

          public TextPart(java.lang.String text)

      Creates a new TextPart with a given text string.
      Parameters:
        `text` - the text for this new part.

  - ### Method Detail

    - #### clone

          public TextPart clone()

      Overrides:
        `clone` in class `java.lang.Object`

    - #### toString

          public java.lang.String toString()

      Overrides:
        `toString` in class `java.lang.Object`

    - #### 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 the `TextFragment` for this part.
      Parameters:
        `fragment` - the `TextFragment` to assign to this part. It must not be null.

    - #### isSegment

          public boolean isSegment()

      Indicates if this part is a `Segment`.
      Returns:
        true if the part is a `Segment`, false if it is not.

    - #### getAnnotations

          public java.lang.Iterable<IAnnotation> getAnnotations()

      Description copied from interface: `IWithAnnotations`
      Gets the iterable list of the annotations for this resource.
      Specified by:
        `getAnnotations` in interface `IWithAnnotations`
      Returns:
        the iterable list of the annotations for this resource.

    - #### getAnnotation

          public <A extends IAnnotation> A getAnnotation(java.lang.Class<A> annotationType)

      Description copied from interface: `IWithAnnotations`
      Gets the annotation object for a given class for this resource.
      Specified by:
        `getAnnotation` in interface `IWithAnnotations`
      Type Parameters:
        `A` - the type of the class.
      Parameters:
        `annotationType` - the class of the annotation object to retrieve.
      Returns:
        the annotation for the given class for this resource.

    - #### setAnnotation

          public void setAnnotation(IAnnotation annotation)

      Description copied from interface: `IWithAnnotations`
      Sets an annotation object for this resource.
      Specified by:
        `setAnnotation` in interface `IWithAnnotations`
      Parameters:
        `annotation` - the annotation object to set.

    - #### getProperty

          public Property getProperty(java.lang.String name)

      Description copied from interface: `IWithProperties`
      Gets the resource-level property for a given name.
      Specified by:
        `getProperty` in interface `IWithProperties`
      Parameters:
        `name` - Name of the property to retrieve.
      Returns:
        The property or null if it does not exist.

    - #### setProperty

          public Property setProperty(Property property)

      Description copied from interface: `IWithProperties`
      Sets a resource-level property. If a property already exists it is overwritten.
      Specified by:
        `setProperty` in interface `IWithProperties`
      Parameters:
        `property` - The new property to set.
      Returns:
        The property that has been set.

    - #### removeProperty

          public void removeProperty(java.lang.String name)

      Description copied from interface: `IWithProperties`
      Removes a resource-level property of a given name. If the property does not exists nothing happens.
      Specified by:
        `removeProperty` in interface `IWithProperties`
      Parameters:
        `name` - The name of the property to remove.

    - #### getPropertyNames

          public java.util.Set<java.lang.String> getPropertyNames()

      Description copied from interface: `IWithProperties`
      Gets the names of all the resource-level properties for this resource.
      Specified by:
        `getPropertyNames` in interface `IWithProperties`
      Returns:
        All the names of the resource-level properties for this resource.

    - #### hasProperty

          public boolean hasProperty(java.lang.String name)

      Description copied from interface: `IWithProperties`
      Indicates if a resource-level property exists for a given name.
      Specified by:
        `hasProperty` in interface `IWithProperties`
      Parameters:
        `name` - The name of the resource-level property to query.
      Returns:
        True if a resource-level property exists, false otherwise.