Class UResource.Key

java.lang.Object
com.ibm.icu.impl.UResource.Key
All Implemented Interfaces:
CharSequence, Cloneable, Comparable<UResource.Key>
Enclosing class:
UResource

public static final class UResource.Key extends Object implements CharSequence, Cloneable, Comparable<UResource.Key>
Represents a resource bundle item's key string. Avoids object creations as much as possible. Mutable, not thread-safe. For permanent storage, use clone() or toString().
  • Field Details

    • bytes

      private byte[] bytes
    • offset

      private int offset
    • length

      private int length
    • s

      private String s
  • Constructor Details

    • Key

      public Key()
      Constructs an empty resource key string object.
    • Key

      public Key(String s)
      Constructs a resource key object equal to the given string.
    • Key

      private Key(byte[] keyBytes, int keyOffset, int keyLength)
  • Method Details

    • setBytes

      public UResource.Key setBytes(byte[] keyBytes, int keyOffset)
      Mutates this key for a new NUL-terminated resource key string. The corresponding ASCII-character bytes are not copied and must not be changed during the lifetime of this key (or until the next setBytes() call) and lifetimes of subSequences created from this key.
      Parameters:
      keyBytes - new key string byte array
      keyOffset - new key string offset
    • setToEmpty

      public UResource.Key setToEmpty()
      Mutates this key to an empty resource key string.
    • setString

      public UResource.Key setString(String s)
      Mutates this key to be equal to the given string.
    • clone

      public UResource.Key clone()
      Does not clone the byte array.
      Overrides:
      clone in class Object
    • charAt

      public char charAt(int i)
      Specified by:
      charAt in interface CharSequence
    • length

      public int length()
      Specified by:
      length in interface CharSequence
    • subSequence

      public UResource.Key subSequence(int start, int end)
      Specified by:
      subSequence in interface CharSequence
    • toString

      public String toString()
      Creates/caches/returns this resource key string as a Java String.
      Specified by:
      toString in interface CharSequence
      Overrides:
      toString in class Object
    • internalSubString

      private String internalSubString(int start, int end)
    • substring

      public String substring(int start)
      Creates a new Java String for a sub-sequence of this resource key string.
    • substring

      public String substring(int start, int end)
      Creates a new Java String for a sub-sequence of this resource key string.
    • regionMatches

      private boolean regionMatches(byte[] otherBytes, int otherOffset, int n)
    • regionMatches

      private boolean regionMatches(int start, CharSequence cs, int n)
    • equals

      public boolean equals(Object other)
      Overrides:
      equals in class Object
    • contentEquals

      public boolean contentEquals(CharSequence cs)
    • startsWith

      public boolean startsWith(CharSequence cs)
    • endsWith

      public boolean endsWith(CharSequence cs)
    • regionMatches

      public boolean regionMatches(int start, CharSequence cs)
      Returns:
      true if the substring of this key starting from the offset contains the same characters as the other sequence.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • compareTo

      public int compareTo(UResource.Key other)
      Specified by:
      compareTo in interface Comparable<UResource.Key>
    • compareTo

      public int compareTo(CharSequence cs)