Class PrefixPool


  • public class PrefixPool
    extends Object
    A prefix pool maintains a two-way mapping from namespace prefixes (as strings) to integer prefix codes. Prefix codes always fit in 11 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 Detail

      • PrefixPool

        public PrefixPool()
    • Method Detail

      • obtainPrefixCode

        public int obtainPrefixCode​(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 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:
        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.