com.icl.saxon.om

Class NamePool

public class NamePool extends Object

An object representing a collection of XML names, each containing a Namespace URI, a Namespace prefix, and a local name; plus a collection of namespaces, each consisting of a prefix/URI pair.

The equivalence betweem names depends only on the URI and the local name. The prefix is retained for documentary purposes only: it is useful when reconstructing a document to use prefixes that the user is familiar with.

The NamePool eliminates duplicate names if they have the same prefix, uri, and local part. It retains duplicates if they have different prefixes

Author: Michael H. Kay

Field Summary
NamePool.NameEntry[]hashslots
String[]prefixes
String[]prefixesForUri
shortprefixesUsed
booleansealed
Vectorsignatures
String[]uris
shorturisUsed
Constructor Summary
NamePool()
Method Summary
intallocate(String prefix, String uri, String localName)
Allocate a name from the pool, or a new Name if there is not a matching one there
intallocate(String prefix, short uriCode, String localName)
Allocate a name from the pool, or a new Name if there is not a matching one there
shortallocateCodeForPrefix(String prefix)
Allocate the prefix code for a given Prefix; create one if not found
shortallocateCodeForURI(String uri)
Allocate the uri code for a given URI; create one if not found, unless the namepool is sealed
intallocateNamespaceCode(String prefix, String uri)
Allocate the namespace code for a namespace prefix/URI pair.
intallocateNamespaceCode(int namecode)
Allocate a namespace code for the prefix/URI of a given namecode
voiddiagnosticDump()
Diagnostic print of the namepool contents
voidgenerateJavaConstants()
The following code is used to create a list of Java declarations for the fingerprints of standard names used in a stylesheet.
shortgetCodeForPrefix(String prefix)
Get the prefix code for a given Prefix
shortgetCodeForURI(String uri)
Get the uri code for a given URI
static NamePoolgetDefaultNamePool()
Get the singular default NamePool
StringgetDisplayName(int nameCode)
Get the display form of a name (the QName), given its name code or fingerprint
intgetFingerprint(int nameCode)
Get a fingerprint for the name with a given name code.
intgetFingerprint(String uri, String localName)
Get a fingerprint for the name with a given uri and local name.
StringgetLocalName(int nameCode)
Get the local part of a name, given its name code or fingerprint
intgetNamespaceCode(String prefix, String uri)
Get the existing namespace code for a namespace prefix/URI pair.
intgetNamespaceCode(int namecode)
Get a namespace code for the prefix/URI of a given namecode
StringgetPrefix(int nameCode)
Get the prefix part of a name, given its name code or fingerprint
StringgetPrefixFromNamespaceCode(int code)
Get the namespace prefix from a namespace code
intgetPrefixIndex(short uriCode, String prefix)
Get the index of a prefix among all the prefixes used with a given URI
StringgetPrefixWithIndex(short uriCode, int index)
Get a prefix among all the prefixes used with a given URI, given its index
StandardNamesgetStandardNames()
Get the standard names
StringgetURI(int nameCode)
Get the namespace-URI of a name, given its name code or fingerprint
shortgetURICode(int nameCode)
Get the URI code of a name, given its name code or fingerprint
StringgetURIFromNamespaceCode(int code)
Get the namespace URI from a namespace code
StringgetURIFromURICode(short code)
Get the namespace URI from a URI code
booleanhasSignature(Object sig)
Test whether the namepool contains names defined in a particular Stylesheet
voidimportPool(NamePool other)
Import the names defined in another namepool (typically the one used to create the stylesheet: these names are imported into the namepool used to build the source document).
booleanisSealed()
Determine whether the namepool is sealed
voidloadStandardNames()
Load the standard names that have a special meaning to XSLT
voidsetStylesheetSignature(Object sig)
Mark the NamePool to indicate that it contains names defined in a particular stylesheet

Field Detail

hashslots

NamePool.NameEntry[] hashslots

prefixes

String[] prefixes

prefixesForUri

String[] prefixesForUri

prefixesUsed

short prefixesUsed

sealed

boolean sealed

signatures

Vector signatures

uris

String[] uris

urisUsed

short urisUsed

Constructor Detail

NamePool

public NamePool()

Method Detail

allocate

public int allocate(String prefix, String uri, String localName)
Allocate a name from the pool, or a new Name if there is not a matching one there

Parameters: prefix uri - the namespace URI localName

Returns: an integer (the "namecode") identifying the name within the namepool. The Name itself may be retrieved using the getName(int) method

allocate

public int allocate(String prefix, short uriCode, String localName)
Allocate a name from the pool, or a new Name if there is not a matching one there

Parameters: prefix uriCode - the code of the URI localName

Returns: an integer (the "namecode") identifying the name within the namepool.

allocateCodeForPrefix

public short allocateCodeForPrefix(String prefix)
Allocate the prefix code for a given Prefix; create one if not found

allocateCodeForURI

public short allocateCodeForURI(String uri)
Allocate the uri code for a given URI; create one if not found, unless the namepool is sealed

allocateNamespaceCode

public int allocateNamespaceCode(String prefix, String uri)
Allocate the namespace code for a namespace prefix/URI pair. Create it if not already present

allocateNamespaceCode

public int allocateNamespaceCode(int namecode)
Allocate a namespace code for the prefix/URI of a given namecode

diagnosticDump

public void diagnosticDump()
Diagnostic print of the namepool contents

generateJavaConstants

public void generateJavaConstants()
The following code is used to create a list of Java declarations for the fingerprints of standard names used in a stylesheet. This code is executed while building Saxon, to create the constant definitions appearing in the StandardNames module.

getCodeForPrefix

public short getCodeForPrefix(String prefix)
Get the prefix code for a given Prefix

Returns: -1 if not found

getCodeForURI

public short getCodeForURI(String uri)
Get the uri code for a given URI

Returns: -1 if not present in the name pool

getDefaultNamePool

public static NamePool getDefaultNamePool()
Get the singular default NamePool

getDisplayName

public String getDisplayName(int nameCode)
Get the display form of a name (the QName), given its name code or fingerprint

getFingerprint

public int getFingerprint(int nameCode)
Get a fingerprint for the name with a given name code. The signature has the property that if two signatures are the same, the names are the same (ie. same local name and same URI)

getFingerprint

public int getFingerprint(String uri, String localName)
Get a fingerprint for the name with a given uri and local name. These must be present in the NamePool. The signature has the property that if two signatures are the same, the names are the same (ie. same local name and same URI).

Returns: -1 if not found

getLocalName

public String getLocalName(int nameCode)
Get the local part of a name, given its name code or fingerprint

getNamespaceCode

public int getNamespaceCode(String prefix, String uri)
Get the existing namespace code for a namespace prefix/URI pair.

Returns: -1 if there is none present

getNamespaceCode

public int getNamespaceCode(int namecode)
Get a namespace code for the prefix/URI of a given namecode

getPrefix

public String getPrefix(int nameCode)
Get the prefix part of a name, given its name code or fingerprint

getPrefixFromNamespaceCode

public String getPrefixFromNamespaceCode(int code)
Get the namespace prefix from a namespace code

getPrefixIndex

public int getPrefixIndex(short uriCode, String prefix)
Get the index of a prefix among all the prefixes used with a given URI

Returns: -1 if not found

getPrefixWithIndex

public String getPrefixWithIndex(short uriCode, int index)
Get a prefix among all the prefixes used with a given URI, given its index

Returns: null if not found

getStandardNames

public StandardNames getStandardNames()
Get the standard names

getURI

public String getURI(int nameCode)
Get the namespace-URI of a name, given its name code or fingerprint

getURICode

public short getURICode(int nameCode)
Get the URI code of a name, given its name code or fingerprint

getURIFromNamespaceCode

public String getURIFromNamespaceCode(int code)
Get the namespace URI from a namespace code

getURIFromURICode

public String getURIFromURICode(short code)
Get the namespace URI from a URI code

hasSignature

public boolean hasSignature(Object sig)
Test whether the namepool contains names defined in a particular Stylesheet

importPool

public void importPool(NamePool other)
Import the names defined in another namepool (typically the one used to create the stylesheet: these names are imported into the namepool used to build the source document). No longer used unless name pools are managed manually

isSealed

public boolean isSealed()
Determine whether the namepool is sealed

loadStandardNames

public void loadStandardNames()
Load the standard names that have a special meaning to XSLT

setStylesheetSignature

public void setStylesheetSignature(Object sig)
Mark the NamePool to indicate that it contains names defined in a particular stylesheet