net.sf.okapi.common.skeleton

## Class GenericSkeleton

- java.lang.Object
- - net.sf.okapi.common.skeleton.GenericSkeleton

- All Implemented Interfaces:
    ISkeleton
  Direct Known Subclasses:
    ZipSkeleton

      public class GenericSkeleton
      extends java.lang.Object
      implements ISkeleton

  Simple generic implementation of the ISkeleton interface. This class implements a skeleton as a list of parts: some are simple text storage string corresponding to the original code of the input document, others are placeholders for the content the the text units, or the values of modifiable properties.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `GenericSkeleton()` Creates a new empty GenericSkeleton object.
    `GenericSkeleton(GenericSkeleton skel)` Creates a new GenericSkeleton object and initialize it with the parts of an existing one passed as a parameter.
    `GenericSkeleton(java.lang.String data)` Creates a new GenericSkeleton object and append some data to it.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `add(char data)` Adds a new part to this skeleton, and set a character data to it.
    `void` | `add(GenericSkeleton skel)` Adds to this skeleton all the parts of a given skeleton.
    `void` | `add(java.lang.String data)` Adds a new part to this skeleton, and set a string data to it.
    `void` | `addContentPlaceholder(ITextUnit textUnit)` Adds to this skeleton a placeholder for the source content of the resource to which this skeleton is attached.
    `void` | `addContentPlaceholder(ITextUnit textUnit, LocaleId locId)` Adds to this skeleton a placeholder for the content (in a given locale) of the resource to which this skeleton is attached.
    `void` | `addReference(IReferenceable referent)` Adds to this skeleton a reference to an existing resource send before the one to which this skeleton is attached to.
    `GenericSkeletonPart` | `addValuePlaceholder(INameable referent, java.lang.String propName, LocaleId locId)` Adds to this skeleton a place-holder for the value of a property (in a given locale) of the resource to which this skeleton is attached.
    `void` | `append(char data)` Appends a character data to this skeleton.
    `void` | `append(java.lang.String data)` Appends a string of data to this skeleton.
    `void` | `appendToFirstPart(java.lang.String data)` Appends a string of data to the first skeleton part, a new part is created is none exists already.
    `void` | `attachParent(INameable parent)` Attaches a parent resource to a skeleton part.
    `void` | `changeSelfReferents(INameable newReferent)` Updates all the self-references to use the given referent.
    `GenericSkeleton` | `clone()` Clones this GenericSkeleton object.
    `protected void` | `copyFields(GenericSkeleton toSkel)`
    `void` | `flushPart()` Forces the current part to be completed, so the next call to append data will start a new part.
    `GenericSkeletonPart` | `getFirstPart()` Gets the first part of this skeleton, or null if there are none.
    `GenericSkeletonPart` | `getLastPart()` Gets the last part of this skeleton, or null if there are none.
    `IResource` | `getParent()` Gets the parent resource of this skeleton.
    `java.util.List<GenericSkeletonPart>` | `getParts()` Gets a list of all the parts of this skeleton.
    `boolean` | `isEmpty()` Indicates if this skeleton is empty or not.
    `boolean` | `isEmpty(boolean ignoreWhitespaces)` Indicates if this skeleton is empty or not, considering the white-spaces or not.
    `void` | `setParent(IResource parent)` Sets a parent of this skeleton object.
    `protected void` | `setParts(java.util.ArrayList<GenericSkeletonPart> list)`
    `java.lang.String` | `toString()` Gets a string representation of the content of all the part of the skeleton.

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

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

- - ### Constructor Detail

    - #### GenericSkeleton

          public GenericSkeleton()

      Creates a new empty GenericSkeleton object.

    - #### GenericSkeleton

          public GenericSkeleton(java.lang.String data)

      Creates a new GenericSkeleton object and append some data to it.
      Parameters:
        `data` - the data to append.

    - #### GenericSkeleton

          public GenericSkeleton(GenericSkeleton skel)

      Creates a new GenericSkeleton object and initialize it with the parts of an existing one passed as a parameter.
      Parameters:
        `skel` - the existing skeleton from which to copy the parts.

  - ### Method Detail

    - #### isEmpty

          public boolean isEmpty()

      Indicates if this skeleton is empty or not.
      Returns:
        true if this skeleton is empty, false if it has at least one part.

    - #### isEmpty

          public boolean isEmpty(boolean ignoreWhitespaces)

      Indicates if this skeleton is empty or not, considering the white-spaces or not.
      Returns:
        true if this skeleton is empty, false if it has at least one part.

    - #### add

          public void add(java.lang.String data)

      Adds a new part to this skeleton, and set a string data to it. Empty or null data has no effect.
      Parameters:
        `data` - the data to add.

    - #### flushPart

          public void flushPart()

      Forces the current part to be completed, so the next call to append data will start a new part.

    - #### add

          public void add(char data)

      Adds a new part to this skeleton, and set a character data to it.
      Parameters:
        `data` - the data to add.

    - #### add

          public void add(GenericSkeleton skel)

      Adds to this skeleton all the parts of a given skeleton.
      Parameters:
        `skel` - the existing skeleton from which to copy the parts.

    - #### appendToFirstPart

          public void appendToFirstPart(java.lang.String data)

      Appends a string of data to the first skeleton part, a new part is created is none exists already.
      Parameters:
        `data` - the string data to append.

    - #### append

          public void append(java.lang.String data)

      Appends a string of data to this skeleton. The text is added to the current part if the current part is already a data part, a new part is created is necessary.
      Parameters:
        `data` - the string data to append.

    - #### append

          public void append(char data)

      Appends a character data to this skeleton. The text is added to the current part if the current part is already a data part, a new part is created is necessary.
      Parameters:
        `data` - the character data to append.

    - #### addContentPlaceholder

          public void addContentPlaceholder(ITextUnit textUnit)

      Adds to this skeleton a placeholder for the source content of the resource to which this skeleton is attached.
      Parameters:
        `textUnit` - the resource object.

    - #### addContentPlaceholder

          public void addContentPlaceholder(ITextUnit textUnit,
                                   LocaleId locId)

      Adds to this skeleton a placeholder for the content (in a given locale) of the resource to which this skeleton is attached.
      Parameters:
        `textUnit` - the resource object.
        `locId` - the locale; use null if the reference is the source.

    - #### addValuePlaceholder

          public GenericSkeletonPart addValuePlaceholder(INameable referent,
                                                java.lang.String propName,
                                                LocaleId locId)

      Adds to this skeleton a place-holder for the value of a property (in a given locale) of the resource to which this skeleton is attached.
      Parameters:
        `referent` - the resource object.
        `propName` - the property name.
        `locId` - the locale; use null for the source; LocaleId.EMPTY for resource-level property.
      Returns:
        the added skeleton part.

    - #### changeSelfReferents

          public void changeSelfReferents(INameable newReferent)

      Updates all the self-references to use the given referent.
      Parameters:
        `newReferent` - the new referent to use.

    - #### addReference

          public void addReference(IReferenceable referent)

      Adds to this skeleton a reference to an existing resource send before the one to which this skeleton is attached to.
      Parameters:
        `referent` - the resource to refer to.

    - #### setParent

          public void setParent(IResource parent)

      Description copied from interface: `ISkeleton`
      Sets a parent of this skeleton object. The parent is the resource that attaches this skeleton with SetSkeleton(). Normally the IResorce implementations set themselves as a parent for the skeleton.
      Specified by:
        `setParent` in interface `ISkeleton`
      Parameters:
        `parent` - reference to the resource that attaches this skeleton object with IResource.setSkeleton()

    - #### attachParent

          public void attachParent(INameable parent)

      Attaches a parent resource to a skeleton part.
      Parameters:
        `parent` - the parent resource to attach.

    - #### getParts

          public java.util.List<GenericSkeletonPart> getParts()

      Gets a list of all the parts of this skeleton.
      Returns:
        the list of all the parts of this skeleton.

    - #### setParts

          protected void setParts(java.util.ArrayList<GenericSkeletonPart> list)

    - #### toString

          public java.lang.String toString()

      Gets a string representation of the content of all the part of the skeleton. This should be used for display only.
      Specified by:
        `toString` in interface `ISkeleton`
      Overrides:
        `toString` in class `java.lang.Object`
      Returns:
        the string representation of this skeleton object, or null.

    - #### getLastPart

          public GenericSkeletonPart getLastPart()

      Gets the last part of this skeleton, or null if there are none.
      Returns:
        the last part of this skeleton, or null if there are none.

    - #### getFirstPart

          public GenericSkeletonPart getFirstPart()

      Gets the first part of this skeleton, or null if there are none.
      Returns:
        the first part of this skeleton, or null if there are none.

    - #### copyFields

          protected void copyFields(GenericSkeleton toSkel)

    - #### clone

          public GenericSkeleton clone()

      Clones this GenericSkeleton object. Shallow copy is provided as the cloned skeleton can be coupled with its original via the parent field. After the cloned skeleton is attached to a parent resource which implementation invokes ISkeleton.setParent(), the copy becomes deep as the parent fields are updated with new values thus decoupling the original and the clone.
      Specified by:
        `clone` in interface `ISkeleton`
      Overrides:
        `clone` in class `java.lang.Object`
      Returns:
        a new GenericSkeleton object that is a shallow copy of this object.

    - #### getParent

          public IResource getParent()

      Description copied from interface: `ISkeleton`
      Gets the parent resource of this skeleton.
      Specified by:
        `getParent` in interface `ISkeleton`
      Returns:
        reference to the resource that attaches this skeleton object with IResource.setSkeleton()