org.apache.poi.hssf.record.common

## Class UnicodeString

- java.lang.Object
- - org.apache.poi.hssf.record.common.UnicodeString

- All Implemented Interfaces:
    java.lang.Comparable<UnicodeString>, Duplicatable

      public class UnicodeString
      extends java.lang.Object
      implements java.lang.Comparable<UnicodeString>, Duplicatable

  Unicode String - just standard fields that are in several records. It is considered more desirable then repeating it in all of them.

  This is often called a XLUnicodeRichExtendedString in MS documentation.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `UnicodeString(RecordInputStream in)` construct a unicode string record and fill its fields, ID is ignored
    `UnicodeString(java.lang.String str)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addFormatRun(FormatRun r)` Adds a font run to the formatted string.
    `void` | `clearFormatting()`
    `UnicodeString` | `clone()` Deprecated.
    `int` | `compareTo(UnicodeString str)`
    `UnicodeString` | `copy()`
    `boolean` | `equals(java.lang.Object o)` Our handling of equals is inconsistent with compareTo.
    `java.util.Iterator<FormatRun>` | `formatIterator()`
    `int` | `getCharCount()` get the number of characters in the string, as an un-wrapped int
    `short` | `getCharCountShort()` get the number of characters in the string, wrapped as needed to fit within a short
    `java.lang.String` | `getDebugInfo()` return a character representation of the fields of this record
    `ExtRst` | `getExtendedRst()`
    `FormatRun` | `getFormatRun(int index)`
    `int` | `getFormatRunCount()`
    `byte` | `getOptionFlags()` get the option flags which among other things return if this is a 16-bit or 8 bit string
    `java.lang.String` | `getString()`
    `int` | `hashCode()`
    `void` | `removeFormatRun(FormatRun r)`
    `void` | `serialize(ContinuableRecordOutput out)` Serialises out the String.
    `void` | `setCharCount(short cc)` set the number of characters in the string
    `void` | `setOptionFlags(byte of)` set the option flags which among other things return if this is a 16-bit or 8 bit string
    `void` | `setString(java.lang.String string)` set the actual string this contains
    `void` | `swapFontUse(short oldFontIndex, short newFontIndex)` Swaps all use in the string of one font index for use of a different font index.
    `java.lang.String` | `toString()` unlike the real records we return the same as "getString()" rather than debug info

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

      `finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### UnicodeString

          public UnicodeString(java.lang.String str)

    - #### UnicodeString

          public UnicodeString(RecordInputStream in)

      construct a unicode string record and fill its fields, ID is ignored
      Parameters:
        `in` - the RecordInputstream to read the record from

  - ### Method Detail

    - #### hashCode

          public int hashCode()

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

    - #### equals

          public boolean equals(java.lang.Object o)

      Our handling of equals is inconsistent with compareTo. The trouble is because we don't truely understand rich text fields yet it's difficult to make a sound comparison.
      Overrides:
        `equals` in class `java.lang.Object`
      Parameters:
        `o` - The object to compare.
      Returns:
        true if the object is actually equal.

    - #### getCharCount

          public int getCharCount()

      get the number of characters in the string, as an un-wrapped int
      Returns:
        number of characters

    - #### getCharCountShort

          public short getCharCountShort()

      get the number of characters in the string, wrapped as needed to fit within a short
      Returns:
        number of characters

    - #### setCharCount

          public void setCharCount(short cc)

      set the number of characters in the string
      Parameters:
        `cc` - - number of characters

    - #### getOptionFlags

          public byte getOptionFlags()

      get the option flags which among other things return if this is a 16-bit or 8 bit string
      Returns:
        optionflags bitmask

    - #### setOptionFlags

          public void setOptionFlags(byte of)

      set the option flags which among other things return if this is a 16-bit or 8 bit string
      Parameters:
        `of` - optionflags bitmask

    - #### getString

          public java.lang.String getString()

      Returns:
        the actual string this contains as a java String object

    - #### setString

          public void setString(java.lang.String string)

      set the actual string this contains
      Parameters:
        `string` - the text

    - #### getFormatRunCount

          public int getFormatRunCount()

    - #### getFormatRun

          public FormatRun getFormatRun(int index)

    - #### addFormatRun

          public void addFormatRun(FormatRun r)

      Adds a font run to the formatted string. If a font run exists at the current charcter location, then it is replaced with the font run to be added.

    - #### formatIterator

          public java.util.Iterator<FormatRun> formatIterator()

    - #### removeFormatRun

          public void removeFormatRun(FormatRun r)

    - #### clearFormatting

          public void clearFormatting()

    - #### getExtendedRst

          public ExtRst getExtendedRst()

    - #### swapFontUse

          public void swapFontUse(short oldFontIndex,
                                  short newFontIndex)

      Swaps all use in the string of one font index for use of a different font index. Normally only called when fonts have been removed / re-ordered

    - #### toString

          public java.lang.String toString()

      unlike the real records we return the same as "getString()" rather than debug info
      Overrides:
        `toString` in class `java.lang.Object`
      Returns:
        String value of the record
      See Also:
        `getDebugInfo()`

    - #### getDebugInfo

          public java.lang.String getDebugInfo()

      return a character representation of the fields of this record
      Returns:
        String of output for biffviewer etc.

    - #### serialize

          public void serialize(ContinuableRecordOutput out)

      Serialises out the String. There are special rules about where we can and can't split onto Continue records.

    - #### compareTo

          public int compareTo(UnicodeString str)

      Specified by:
        `compareTo` in interface `java.lang.Comparable<UnicodeString>`

    - #### clone

          @Deprecated
           @Removal(version="5.0.0")
          public UnicodeString clone()

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

    - #### copy

          public UnicodeString copy()

      Specified by:
        `copy` in interface `Duplicatable`
      Returns:
        a deep copy of the implementing class / instance

Copyright 2020 The Apache Software Foundation or its licensors, as applicable.