Class PNameC

java.lang.Object
com.fasterxml.aalto.in.PName
com.fasterxml.aalto.in.PNameC

public final class PNameC extends PName
An alternate implementation of PName: instead of coming straight from byte contents, it is actually just built from a character array.

Note: one unfortunate result of this being a somewhat different PName is that equality comparison between this and other implementations will not work as expected. As such, these should only be used as temporary names.

  • Field Details

    • mHash

      protected final int mHash
      Since the hash may be calculated different from the way eventual String's hash will be (right now it is not), we better store "our" hash here.
  • Constructor Details

  • Method Details

    • createBoundName

      public PName createBoundName(NsBinding nsb)
      Specified by:
      createBoundName in class PName
    • construct

      public static PNameC construct(String pname)
    • construct

      public static PNameC construct(String pname, int hash)
    • equalsPName

      public boolean equalsPName(char[] buffer, int start, int len, int hash)
    • getCustomHash

      public int getCustomHash()
    • calcHash

      public static int calcHash(char[] buffer, int start, int len)
      Implementation of a hashing method for variable length Strings. Most of the time intention is that this calculation is done by caller during parsing, not here; however, sometimes it needs to be done for parsed "String" too.
      Parameters:
      len - Length of String; has to be at least 1 (caller guarantees this pre-condition)
    • calcHash

      public static int calcHash(String key)
    • sizeInQuads

      public int sizeInQuads()
      This method should never get called on instances of this class, so let's throw an exception if that does happen.
      Specified by:
      sizeInQuads in class PName
    • getFirstQuad

      public int getFirstQuad()
      Specified by:
      getFirstQuad in class PName
    • getLastQuad

      public final int getLastQuad()
      Specified by:
      getLastQuad in class PName
    • getQuad

      public int getQuad(int index)
      Specified by:
      getQuad in class PName
    • hashCode

      public int hashCode()
      Whether we should use internal hash, or the hash of prefixed name string itself is an open question. For now, let's use former.
      Overrides:
      hashCode in class PName