public final class NamePool
extends java.lang.Object
Each expanded name is allocated a unique 20-bit fingerprint. The fingerprint enables the URI and the local name to be determined. Some subsystems (notably the Tinytree) use the top 10 bits to represent the prefix, but the NamePool is no longer concerned with managing prefixes, and prefixes do not have global codes.
The NamePool has been redesigned in Saxon 9.7 to make use of two Java ConcurrentHashMaps, one from QNames to integers, one from integers to QNames. This gives better scaleability in terms of multithreaded concurrency and in terms of the capacity of the NamePool and retention of performance as the size of the vocabulary increases.
Fingerprints in the range 0 to 1023 are reserved for system use, and are allocated as constants
mainly to names in the XSLT and XML Schema namespaces: constants representing these names
are found in StandardNames
.
The fingerprint -1 is reserved to mean "not known" or inapplicable.
Modified in 9.4 to remove namespace codes.
Modified in 9.7 to remove URI codes.
Modified in 9.8 to remove namecodes and all handling of prefixes.
Modifier and Type | Class and Description |
---|---|
static class |
NamePool.NamePoolLimitException
Unchecked Exception raised when some limit in the design of the name pool is exceeded
|
Modifier and Type | Field and Description |
---|---|
static int |
FP_MASK
FP_MASK is a mask used to obtain a fingerprint from a nameCode.
|
static int |
USER_DEFINED_MASK |
Constructor and Description |
---|
NamePool()
Create a NamePool
|
Modifier and Type | Method and Description |
---|---|
int |
allocateClarkName(java.lang.String expandedName)
Allocate a fingerprint given a Clark Name
|
int |
allocateFingerprint(java.lang.String uri,
java.lang.String local)
Allocate a fingerprint from the pool, or a new Name if there is not a matching one there
|
java.lang.String |
getClarkName(int nameCode)
Get the Clark form of a name, given its name code or fingerprint
|
java.lang.String |
getDisplayName(int nameCode)
Get the display form of a name (the QName), given its name code or fingerprint
|
java.lang.String |
getEQName(int nameCode)
Get the EQName form of a name, given its name code or fingerprint
|
int |
getFingerprint(java.lang.String uri,
java.lang.String localName)
Get a fingerprint for the name with a given uri and local name.
|
java.lang.String |
getLocalName(int nameCode)
Get the local part of a name, given its name code or fingerprint
|
StructuredQName |
getStructuredQName(int fingerprint)
Get a QName for a given fingerprint.
|
StructuredQName |
getUnprefixedQName(int nameCode)
Get a QName for a given namecode.
|
java.lang.String |
getURI(int nameCode)
Get the namespace-URI of a name, given its name code or fingerprint
|
static boolean |
isPrefixed(int nameCode)
Determine whether a given namecode has a non-empty prefix (and therefore, in the case of attributes,
whether the name is in a non-null namespace
|
void |
suggestPrefix(java.lang.String prefix,
java.lang.String uri)
Suggest a preferred prefix to be used with a given URI
|
java.lang.String |
suggestPrefixForURI(java.lang.String uri)
Suggest a prefix for a given URI.
|
public static final int FP_MASK
nc & NamePool.FP_MASK
.
(In practice, Saxon code often uses the literal constant 0xfffff,
to extract the bottom 20 bits).
The difference between a fingerprint and a nameCode is that a nameCode contains information about the prefix of a name, the fingerprint depends only on the namespace URI and local name. Note that the "null" nameCode (-1) does not produce the "null" fingerprint (also -1) when this mask is applied.
public static final int USER_DEFINED_MASK
public void suggestPrefix(java.lang.String prefix, java.lang.String uri)
uri
- the URIprefix
- the suggested prefixpublic StructuredQName getUnprefixedQName(int nameCode)
nameCode
- a code identifying an expanded QName, e.g. of an element or attributepublic StructuredQName getStructuredQName(int fingerprint)
fingerprint
- a code identifying an expanded QName, e.g. of an element or attributepublic static boolean isPrefixed(int nameCode)
nameCode
- the name code to be testedpublic java.lang.String suggestPrefixForURI(java.lang.String uri)
uri
- the namespace URIpublic int allocateFingerprint(java.lang.String uri, java.lang.String local)
uri
- the namespace URI. Use "" or null for the non-namespace.local
- the local part of the namepublic java.lang.String getURI(int nameCode)
nameCode
- the name code or fingerprint of a namejava.lang.IllegalArgumentException
- if the nameCode is not known to the NamePool.public java.lang.String getLocalName(int nameCode)
nameCode
- the integer name code or fingerprint of the namepublic java.lang.String getDisplayName(int nameCode)
nameCode
- the integer name code or fingerprint of a name in the name poolpublic java.lang.String getClarkName(int nameCode)
nameCode
- the integer name code or fingerprint of a name in the name poolpublic java.lang.String getEQName(int nameCode)
nameCode
- the integer name code or fingerprint of a name in the name poolpublic int allocateClarkName(java.lang.String expandedName)
expandedName
- the name in Clark notation, that is "localname" or "{uri}localName"public int getFingerprint(java.lang.String uri, java.lang.String localName)
uri
- the namespace URI of the required QNamelocalName
- the local part of the required QNameCopyright (c) 2004-2020 Saxonica Limited. All rights reserved.