net.sf.saxon.regex

## Class UnicodeString

- java.lang.Object
- - net.sf.saxon.regex.UnicodeString

- Direct Known Subclasses:
    BMPString, GeneralUnicodeString

      public abstract class UnicodeString
      extends Object

  An abstract class that efficiently handles Unicode strings including non-BMP characters; it has two subclasses, one optimized for strings whose characters are all in the BMP, the other handling the general case.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static UnicodeString` | `EMPTY_STRING`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `UnicodeString()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `abstract int` | `charAt(int pos)` Get the character at a specified position
    `static boolean` | `containsSurrogatePairs(CharSequence value)` Test whether a CharSequence contains Unicode codepoints outside the BMP range
    `abstract CharSequence` | `getCharSequence()` Get the value of this UnicodeString as a CharSequence
    `abstract int` | `indexOf(int search, int start)` Get the first match for a given character
    `abstract boolean` | `isEnd(int pos)` Ask whether a given position is at (or beyond) the end of the string
    `abstract int` | `length()` Get the length of the string, in Unicode codepoints
    `static UnicodeString` | `makeUnicodeString(CharSequence in)` Make a UnicodeString for a given CharSequence
    `static UnicodeString` | `makeUnicodeString(int[] in)` Make a UnicodeString for a given array of codepoints
    `abstract UnicodeString` | `substring(int beginIndex, int endIndex)` Get a substring of this string

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

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

- - ### Field Detail

    - #### EMPTY_STRING

          public static UnicodeString EMPTY_STRING

  - ### Constructor Detail

    - #### UnicodeString

          public UnicodeString()

  - ### Method Detail

    - #### makeUnicodeString

          public static UnicodeString makeUnicodeString(CharSequence in)

      Make a UnicodeString for a given CharSequence
      Parameters:
        `in` - the input CharSequence
      Returns:
        a UnicodeString using an appropriate implementation class

    - #### makeUnicodeString

          public static UnicodeString makeUnicodeString(int[] in)

      Make a UnicodeString for a given array of codepoints
      Parameters:
        `in` - the input CharSequence
      Returns:
        a UnicodeString using an appropriate implementation class

    - #### containsSurrogatePairs

          public static boolean containsSurrogatePairs(CharSequence value)

      Test whether a CharSequence contains Unicode codepoints outside the BMP range
      Parameters:
        `value` - the string to be tested
      Returns:
        true if the string contains non-BMP codepoints

    - #### substring

          public abstract UnicodeString substring(int beginIndex,
                                int endIndex)

      Get a substring of this string
      Parameters:
        `beginIndex` - the index of the first character to be included (counting codepoints, not 16-bit characters)
        `endIndex` - the index of the first character to be NOT included (counting codepoints, not 16-bit characters)
      Returns:
        a substring
      Throws:
        `IndexOutOfBoundsException` - if the selection goes off the start or end of the string (this function follows the semantics of String.substring(), not the XPath semantics

    - #### indexOf

          public abstract int indexOf(int search,
                    int start)

      Get the first match for a given character
      Parameters:
        `search` - the character to look for
        `start` - the first position to look
      Returns:
        the position of the first occurrence of the sought character, or -1 if not found

    - #### charAt

          public abstract int charAt(int pos)

      Get the character at a specified position
      Parameters:
        `pos` - the index of the required character (counting codepoints, not 16-bit characters)
      Returns:
        a character (Unicode codepoint) at the specified position.

    - #### length

          public abstract int length()

      Get the length of the string, in Unicode codepoints
      Returns:
        the number of codepoints in the string

    - #### isEnd

          public abstract boolean isEnd(int pos)

      Ask whether a given position is at (or beyond) the end of the string
      Parameters:
        `pos` - the index of the required character (counting codepoints, not 16-bit characters)
      Returns:
        `true` iff if the specified index is after the end of the character stream

    - #### getCharSequence

          public abstract CharSequence getCharSequence()

      Get the value of this UnicodeString as a CharSequence
      Returns:
        a CharSequence representing the same characters as this UnicodeString

Copyright (c) 2004-2013 Saxonica Limited. All rights reserved.