Overview | Package | Class | Use | Tree | Deprecated | Index | Help
|  | BEA Systems, Inc.
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## weblogic.apache.xerces.utils
Class StringHasher

    java.lang.Object
      |
      +--weblogic.apache.xerces.utils.StringHasher

public final class StringHasher
extends java.lang.Object

Algorithm used to hash char arrays (strings). This class was created after it was discovered that parsing some documents was unexpectedly slow due to many different strings hashing to the same 32-bit value using the java.lang.String hash algorithm. The trick seems to be the shift of the top eight bits of the hashcode back down to the bottom to keep them from being rolled out.

This class is based on an implementation from the Apache XML Project. In future releases the XML parser, XSLT processor, and associated classes will likely be updated to be based on a later version of the Apache implementations. Since Apache does not guarantee backwards compatibility between versions of their software, we cannot guarantee backwards compatibility of any of the classes contained in the weblogic.apache package or sub-packages.

Constructor Summary
`StringHasher()`

Method Summary
`static int` | `finishHash(int hashcode)` finish hashing a partically completed character hashcode
`static int` | `hashChar(int hashcode, int ch)` generate partially completed character hashcode.
`static int` | `hashChars(char[] chars, int offset, int length)` generate a hashcode for a character array
`static int` | `hashString(java.lang.String str, int strLength)` generate a hashcode for a String

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### StringHasher

    public StringHasher()

Method Detail

### hashString

    public static int hashString(java.lang.String str,
                                 int strLength)

  generate a hashcode for a String

  Parameters:
    `str` - the String to hash
    `strLength` - the length of the String to hash
  Returns:
    hashcode for the String

### hashChars

    public static int hashChars(char[] chars,
                                int offset,
                                int length)

  generate a hashcode for a character array

  Parameters:
    `chars` - the array to hash
    `offset` - the offset to start hashing
    `length` - the length of characters to hash
  Returns:
    hashcode for the character array

### hashChar

    public static int hashChar(int hashcode,
                               int ch)

  generate partially completed character hashcode. this is mean to be iterated over individual characters in order to generate a full hash value

  Parameters:
    `hashcode` - a partially completed character hashcode
    `ch` - the character to hash
  Returns:
    a partially completed character hashcode
  See Also:
    `finishHash(int)`

### finishHash

    public static int finishHash(int hashcode)

  finish hashing a partically completed character hashcode

  Parameters:
    `hashcode` - a partially completed character hashcode
  Returns:
    a character hashcode
  See Also:
    `hashChar(int,int)`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Documentation is available at http://e-docs.bea.com/wls/docs70
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2004 BEA Systems, Inc. All Rights Reserved.
WebLogic Server 7.0 API Reference