Package net.sf.saxon.om
Class PrefixPool
- java.lang.Object
-
- net.sf.saxon.om.PrefixPool
-
public class PrefixPool extends java.lang.Object
A prefix pool maintains a two-way mapping from namespace prefixes (as strings) to integer prefix codes. Prefix codes always fit in 10 bits, but are handled as ints. Until 9.8, prefixes were managed by the NamePool. The NamePool now only handles fingerprints, which are integer representations of the URI and local name parts of a QName. Prefix codes are now used only in the tinytree, and the table of codes is local to a document. For this reason, access is not synchronised.
-
-
Constructor Summary
Constructors Constructor Description PrefixPool()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
condense()
Eliminate unused space, on the assumption that no further prefixes will be added to the pool, and that subsequent access will be to get the prefix for a code, and not vice versa.java.lang.String
getPrefix(int code)
Get the prefix corresponding to a given codeint
obtainPrefixCode(java.lang.String prefix)
Get the prefix code corresponding to a given prefix, allocating a new code if necessary
-
-
-
Method Detail
-
obtainPrefixCode
public int obtainPrefixCode(java.lang.String prefix)
Get the prefix code corresponding to a given prefix, allocating a new code if necessary- Parameters:
prefix
- the namespace prefix. If empty, the prefix code is always zero.- Returns:
- the integer prefix code (always fits in 10 bits)
-
getPrefix
public java.lang.String getPrefix(int code)
Get the prefix corresponding to a given code- Parameters:
code
- the prefix code (which must have been allocated)- Returns:
- the corresponding prefix
- Throws:
java.lang.IllegalArgumentException
- if the code has not been allocated
-
condense
public void condense()
Eliminate unused space, on the assumption that no further prefixes will be added to the pool, and that subsequent access will be to get the prefix for a code, and not vice versa.
-
-