APIdia Launch Partner
Top Description Inners Fields Constructors Methods
com.sun.org.apache.xml.internal.dtm.ref

public Class ExpandedNameTable

extends Object
Class Inheritance
Imports
com.sun.org.apache.xml.internal.dtm.DTM

This is a default implementation of a table that manages mappings from expanded names to expandedNameIDs. %OPT% The performance of the getExpandedTypeID() method is very important to DTM building. To get the best performance out of this class, we implement a simple hash algorithm directly into this class, instead of using the inefficient java.util.Hashtable. The code for the get and put operations are combined in getExpandedTypeID() method to share the same hash calculation code. We only need to implement the rehash() interface which is used to expand the hash table.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
ExpandedNameTable.HashEntry

Inner class which represents a hash table entry.

Field Summary

Modifier and TypeField and Description
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
pack-priv ExtendedType
hashET

Workspace for lookup.

private int
m_capacity

The capacity of the hash table, i.e. the size of the internal HashEntry array.

private static ExtendedType[]
m_defaultExtendedTypes

The array to store the default extended types.

private ExtendedType[]
m_extendedTypes

Array of extended types for this document

private static int
m_initialCapacity

The initial capacity of the hash table.

private static int
m_initialSize

The initial size of the m_extendedTypes array

private static float
m_loadFactor

The default load factor of the Hashtable.

private int
m_nextType

Next available extended type

private ExpandedNameTable.HashEntry[]
m_table

The internal array to store the hash entries.

private int
m_threshold

The threshold of the hash table, which is equal to capacity * loadFactor.

public static final int
public static final int
public static final int
public static final int

Constructor Summary

AccessConstructor and Description
public
ExpandedNameTable()

Create an expanded name table.

Method Summary

Modifier and TypeMethod and Description
public int

Returns:

the expanded-name id of the node.
getExpandedTypeID
(String
The namespace
namespace
,
String
The local name
localName
,
int
The node type
type
)

Given an expanded name represented by namespace, local name and node type, return an ID. If the expanded-name does not exist in the internal tables, the entry will be created, and the ID will be returned.

public int

Returns:

the expanded-name id of the node.
getExpandedTypeID
(String
The namespace
namespace
,
String
The local name
localName
,
int
The node type
type
,
boolean
If it is true, we will only search for the expanded name. -1 is return is the name is not found.
searchOnly
)

Given an expanded name represented by namespace, local name and node type, return an ID. If the expanded-name does not exist in the internal tables, the entry will be created, and the ID will be returned.

public int

Returns:

the expanded-name id of the node.
getExpandedTypeID
(int type)

Given a type, return an expanded name ID.Any additional nodes that are created that have this expanded name will use this ID.

public ExtendedType[]

Returns:

The array of extended types
getExtendedTypes
()

Return the array of extended types

public String

Returns:

String Local name of this node, or null if the node has no name.
getLocalName
(int
an ID that represents an expanded-name.
ExpandedNameID
)

Given an expanded-name ID, return the local name part.

public final int

Returns:

The id of this local name.
getLocalNameID
(int
an ID that represents an expanded-name.
ExpandedNameID
)

Given an expanded-name ID, return the local name ID.

public String

Returns:

String URI value of this node's namespace, or null if no namespace was resolved.
getNamespace
(int
an ID that represents an expanded-name.
ExpandedNameID
)

Given an expanded-name ID, return the namespace URI part.

public final int

Returns:

The id of this namespace.
getNamespaceID
(int
an ID that represents an expanded-name.
ExpandedNameID
)

Given an expanded-name ID, return the namespace URI ID.

public int

Returns:

The size of the ExpandedNameTable
getSize
()

Return the size of the ExpandedNameTable

public final short

Returns:

The id of this local name.
getType
(int
an ID that represents an expanded-name.
ExpandedNameID
)

Given an expanded-name ID, return the local name ID.

private void
initExtendedTypes()

Initialize the vector of extended types with the basic DOM node types.

private void
rehash()

Increases the capacity of and internally reorganizes the hashtable, in order to accommodate and access its entries more efficiently.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

ATTRIBUTEback to summary
public static final int ATTRIBUTE
CDATA_SECTIONback to summary
public static final int CDATA_SECTION
COMMENTback to summary
public static final int COMMENT
DOCUMENTback to summary
public static final int DOCUMENT
DOCUMENT_FRAGMENTback to summary
public static final int DOCUMENT_FRAGMENT
DOCUMENT_TYPEback to summary
public static final int DOCUMENT_TYPE
ELEMENTback to summary
public static final int ELEMENT
ENTITYback to summary
public static final int ENTITY
ENTITY_REFERENCEback to summary
public static final int ENTITY_REFERENCE
hashETback to summary
pack-priv ExtendedType hashET

Workspace for lookup. NOT THREAD SAFE!

m_capacityback to summary
private int m_capacity

The capacity of the hash table, i.e. the size of the internal HashEntry array.

m_defaultExtendedTypesback to summary
private static ExtendedType[] m_defaultExtendedTypes

The array to store the default extended types.

m_extendedTypesback to summary
private ExtendedType[] m_extendedTypes

Array of extended types for this document

m_initialCapacityback to summary
private static int m_initialCapacity

The initial capacity of the hash table. Use a bigger number to avoid the cost of expanding the table.

m_initialSizeback to summary
private static int m_initialSize

The initial size of the m_extendedTypes array

m_loadFactorback to summary
private static float m_loadFactor

The default load factor of the Hashtable. This is used to calcualte the threshold.

m_nextTypeback to summary
private int m_nextType

Next available extended type

m_tableback to summary
private ExpandedNameTable.HashEntry[] m_table

The internal array to store the hash entries. Each array member is a slot for a hash bucket.

m_thresholdback to summary
private int m_threshold

The threshold of the hash table, which is equal to capacity * loadFactor. If the number of entries in the hash table is bigger than the threshold, the hash table needs to be expanded.

NAMESPACEback to summary
public static final int NAMESPACE
NOTATIONback to summary
public static final int NOTATION
PROCESSING_INSTRUCTIONback to summary
public static final int PROCESSING_INSTRUCTION
TEXTback to summary
public static final int TEXT

Constructor Detail

ExpandedNameTableback to summary
public ExpandedNameTable()

Create an expanded name table.

Method Detail

getExpandedTypeIDback to summary
public int getExpandedTypeID(String namespace, String localName, int type)

Given an expanded name represented by namespace, local name and node type, return an ID. If the expanded-name does not exist in the internal tables, the entry will be created, and the ID will be returned. Any additional nodes that are created that have this expanded name will use this ID.

Parameters
namespace:String

The namespace

localName:String

The local name

type:int

The node type

Returns:int

the expanded-name id of the node.

getExpandedTypeIDback to summary
public int getExpandedTypeID(String namespace, String localName, int type, boolean searchOnly)

Given an expanded name represented by namespace, local name and node type, return an ID. If the expanded-name does not exist in the internal tables, the entry will be created, and the ID will be returned. Any additional nodes that are created that have this expanded name will use this ID.

If searchOnly is true, we will return -1 if the name is not found in the table, otherwise the name is added to the table and the expanded name id of the new entry is returned.

Parameters
namespace:String

The namespace

localName:String

The local name

type:int

The node type

searchOnly:boolean

If it is true, we will only search for the expanded name. -1 is return is the name is not found.

Returns:int

the expanded-name id of the node.

getExpandedTypeIDback to summary
public int getExpandedTypeID(int type)

Given a type, return an expanded name ID.Any additional nodes that are created that have this expanded name will use this ID.

Returns:int

the expanded-name id of the node.

getExtendedTypesback to summary
public ExtendedType[] getExtendedTypes()

Return the array of extended types

Returns:ExtendedType[]

The array of extended types

getLocalNameback to summary
public String getLocalName(int ExpandedNameID)

Given an expanded-name ID, return the local name part.

Parameters
ExpandedNameID:int

an ID that represents an expanded-name.

Returns:String

String Local name of this node, or null if the node has no name.

getLocalNameIDback to summary
public final int getLocalNameID(int ExpandedNameID)

Given an expanded-name ID, return the local name ID.

Parameters
ExpandedNameID:int

an ID that represents an expanded-name.

Returns:int

The id of this local name.

getNamespaceback to summary
public String getNamespace(int ExpandedNameID)

Given an expanded-name ID, return the namespace URI part.

Parameters
ExpandedNameID:int

an ID that represents an expanded-name.

Returns:String

String URI value of this node's namespace, or null if no namespace was resolved.

getNamespaceIDback to summary
public final int getNamespaceID(int ExpandedNameID)

Given an expanded-name ID, return the namespace URI ID.

Parameters
ExpandedNameID:int

an ID that represents an expanded-name.

Returns:int

The id of this namespace.

getSizeback to summary
public int getSize()

Return the size of the ExpandedNameTable

Returns:int

The size of the ExpandedNameTable

getTypeback to summary
public final short getType(int ExpandedNameID)

Given an expanded-name ID, return the local name ID.

Parameters
ExpandedNameID:int

an ID that represents an expanded-name.

Returns:short

The id of this local name.

initExtendedTypesback to summary
private void initExtendedTypes()

Initialize the vector of extended types with the basic DOM node types.

rehashback to summary
private void rehash()

Increases the capacity of and internally reorganizes the hashtable, in order to accommodate and access its entries more efficiently. This method is called when the number of keys in the hashtable exceeds this hashtable's capacity and load factor.

com.sun.org.apache.xml.internal.dtm.ref back to summary

private final Class ExpandedNameTable.HashEntry

extends Object
Class Inheritance
  • java.lang.Object
  • com.sun.org.apache.xml.internal.dtm.ref.ExpandedNameTable.HashEntry

Inner class which represents a hash table entry. The field next points to the next entry which is hashed into the same bucket in the case of "hash collision".

Field Summary

Modifier and TypeField and Description
pack-priv int
pack-priv ExtendedType
pack-priv ExpandedNameTable.HashEntry
pack-priv int

Constructor Summary

AccessConstructor and Description
protected
HashEntry(ExtendedType key, int value, int hash, ExpandedNameTable.HashEntry next)

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

hashback to summary
pack-priv int hash
keyback to summary
pack-priv ExtendedType key
nextback to summary
pack-priv ExpandedNameTable.HashEntry next
valueback to summary
pack-priv int value

Constructor Detail

HashEntryback to summary
protected HashEntry(ExtendedType key, int value, int hash, ExpandedNameTable.HashEntry next)