Class UResource.Key

  • All Implemented Interfaces:
    java.lang.CharSequence, java.lang.Cloneable, java.lang.Comparable<UResource.Key>
    Enclosing class:
    UResource

    public static final class UResource.Key
    extends java.lang.Object
    implements java.lang.CharSequence, java.lang.Cloneable, java.lang.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 Summary

      Fields 
      Modifier and Type Field Description
      private byte[] bytes  
      private int length  
      private int offset  
      private java.lang.String s  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
        Key()
      Constructs an empty resource key string object.
      private Key​(byte[] keyBytes, int keyOffset, int keyLength)  
        Key​(java.lang.String s)
      Constructs a resource key object equal to the given string.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      char charAt​(int i)  
      UResource.Key clone()
      Does not clone the byte array.
      int compareTo​(UResource.Key other)  
      int compareTo​(java.lang.CharSequence cs)  
      boolean contentEquals​(java.lang.CharSequence cs)  
      boolean endsWith​(java.lang.CharSequence cs)  
      boolean equals​(java.lang.Object other)  
      int hashCode()  
      private java.lang.String internalSubString​(int start, int end)  
      int length()  
      private boolean regionMatches​(byte[] otherBytes, int otherOffset, int n)  
      boolean regionMatches​(int start, java.lang.CharSequence cs)  
      private boolean regionMatches​(int start, java.lang.CharSequence cs, int n)  
      UResource.Key setBytes​(byte[] keyBytes, int keyOffset)
      Mutates this key for a new NUL-terminated resource key string.
      UResource.Key setString​(java.lang.String s)
      Mutates this key to be equal to the given string.
      UResource.Key setToEmpty()
      Mutates this key to an empty resource key string.
      boolean startsWith​(java.lang.CharSequence cs)  
      UResource.Key subSequence​(int start, int end)  
      java.lang.String substring​(int start)
      Creates a new Java String for a sub-sequence of this resource key string.
      java.lang.String substring​(int start, int end)
      Creates a new Java String for a sub-sequence of this resource key string.
      java.lang.String toString()
      Creates/caches/returns this resource key string as a Java String.
      • Methods inherited from class java.lang.Object

        finalize, getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.lang.CharSequence

        chars, codePoints
    • Field Detail

      • bytes

        private byte[] bytes
      • offset

        private int offset
      • length

        private int length
      • s

        private java.lang.String s
    • Constructor Detail

      • Key

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

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

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

      • 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​(java.lang.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 java.lang.Object
      • charAt

        public char charAt​(int i)
        Specified by:
        charAt in interface java.lang.CharSequence
      • length

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

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

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

        private java.lang.String internalSubString​(int start,
                                                   int end)
      • substring

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

        public java.lang.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,
                                      java.lang.CharSequence cs,
                                      int n)
      • equals

        public boolean equals​(java.lang.Object other)
        Overrides:
        equals in class java.lang.Object
      • contentEquals

        public boolean contentEquals​(java.lang.CharSequence cs)
      • startsWith

        public boolean startsWith​(java.lang.CharSequence cs)
      • endsWith

        public boolean endsWith​(java.lang.CharSequence cs)
      • regionMatches

        public boolean regionMatches​(int start,
                                     java.lang.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 java.lang.Object
      • compareTo

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

        public int compareTo​(java.lang.CharSequence cs)