Package com.google.javascript.jscomp
Class Xid
java.lang.Object
com.google.javascript.jscomp.Xid
A simple utility for shortening identifiers in a stable way. Generates
short substitution strings deterministically, using a compact
(1 to 6 characters in length) repesentation of a 32-bit hash of the key.
The string is suitable to be used as a JavaScript or CSS identifier.
Collisions are possible but unlikely, depending on the underlying hash algorithm used.
This substitution scheme uses case-sensitive names for maximum
compression. Digits are also allowed in all but the first character of a
class name. There are a few characters allowed by the CSS grammar that we
choose not to use (e.g. the underscore and hyphen), to keep names simple.
Xid should maintain as minimal dependencies as possible to ease its
integration with other tools, such as server side HTML generators.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
Strategy for selecting the underlying hash code function to be used by Xid. -
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Xid
public Xid() -
Xid
-
-
Method Details
-
get
Gets the string that should be substituted forkey
. The same value will be consistently returned for any particularkey
.- Parameters:
key
- the text to be replaced (never null)- Returns:
- the value to substitute for
key
-
getAsInt
Returns the underlying integer representation of the given key.
-