|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
ObjectNodeImpl
ParentNodeImpl
LazyDocument
public class LazyDocument
LazyDocument accesses the binary persistent disk file created by
LazyTreeBuilder
, loading nodes on demand rather than holding all
of them in RAM.
This class should never be instatiated directly, but rather loaded by LazyTreeBuilder.
Once loaded, a soft reference to the node is kept in RAM; if memory runs
low, these soft references will be thrown away. This behavior can be
defeated by calling setAllPermanent(boolean)
.
Field Summary | |
---|---|
(package private) boolean |
allPermanent
True if nodes in the cache should be permanent, false for weak refs |
protected PackedByteBuf |
attrBuf
Buffer for unpacking nodes |
protected byte[] |
attrBytes
Byte buffer for reading nodes |
protected SubStoreReader |
attrFile
Contains all the attributes |
protected Configuration |
config
Saxon configuration info |
protected boolean |
debug
Flag denoting whether to print out when key indexes are created |
protected int |
documentNumber
Unique number assigned to each document |
private int |
killCheckCounter
Counter to govern periodic checking for thread time limit |
protected StructuredStore |
mainStore
The structured file that contains all our subfiles |
protected int |
maxAttrSize
The max size of any attribute block |
protected int |
maxNodeSize
The size of the largest node entry on disk |
(package private) int[] |
nameNumToCode
Maps name numbers in the file to namecodes in the current NamePool |
protected NamePool |
namePool
Name pool used to look up namecodes |
int[] |
namespaceCode
namespaceCode is the namespace code used by the name pool: the top half is the prefix code, the bottom half the URI code |
int[] |
namespaceParent
namespaceParent is the index of the element node owning the namespace declaration |
protected static int |
NODE_FILE_HEADER_SIZE
Size of the header on the node file |
protected PackedByteBuf |
nodeBuf
Buffer for unpacking nodes |
protected byte[] |
nodeBytes
Byte buffer for reading nodes |
(package private) HashMap |
nodeCache
Caches nodes in memory so they only have to be loaded once. |
protected SubStoreReader |
nodeFile
Contains all the nodes |
int |
numberOfNamespaces
Number of namespaces currently declared |
protected int |
numberOfNodes
How many nodes, excluding attributes and namespaces. |
private LazyProfilingListener |
profileListener
Notified of profile-related events |
protected int |
rootNodeNum
This structure supports trees whose root is an element node rather than a document node. |
SystemIdMap |
systemIdMap
Maps system IDs to nodes in the tree |
protected SubStoreReader |
textFile
Contains all the text, processing instructions, and comments |
protected boolean |
usesNamespaces
Determines whether this document is using namespaces. |
Fields inherited from class ParentNodeImpl |
---|
childNum |
Fields inherited from class NodeImpl |
---|
document, nameCode, nextSibNum, NODE_LETTER, nodeNum, parentNum, prevSibNum |
Fields inherited from interface NodeInfo |
---|
ALL_NAMESPACES, EMPTY_NAMESPACE_LIST, IS_DTD_TYPE, IS_NILLED, LOCAL_NAMESPACES, NO_NAMESPACES |
Fields inherited from interface ValueRepresentation |
---|
EMPTY_VALUE_ARRAY |
Constructor Summary | |
---|---|
LazyDocument(Configuration config)
Construct a new (empty) document. |
Method Summary | |
---|---|
protected NodeImpl |
checkCache(int num)
Checks to see if we've already loaded the node corresponding with the given number. |
void |
close()
Closes all disk files opened by the document. |
void |
copy(Receiver out,
int whichNamespaces,
boolean copyAnnotations,
int locationId)
Copy this node to a given outputter |
protected NodeImpl |
createElementNode()
Create an element node. |
protected NodeImpl |
createTextNode()
Create a text node. |
String |
generateId()
Get a character string that uniquely identifies this node |
void |
generateId(FastStringBuffer buffer)
Get a character string that uniquely identifies this node |
protected AxisIterator |
getAllElements(int fingerprint)
Get a list of all elements with a given name. |
String |
getBaseURI()
Get the base URI of this root node. |
Configuration |
getConfiguration()
Get the configuration previously set using setConfiguration |
boolean |
getDebug()
Find out whether debug lines are printed during key index creation |
int |
getDocumentNumber()
Get the unique document number |
DocumentInfo |
getDocumentRoot()
Get the root (document) node |
DiskHashReader |
getIndex(String indexName)
Access a disk-based xsl:key index stored by putIndex(). |
int |
getItemType()
Return the type of node. |
int |
getLineNumber()
Get the line number of this root node. |
protected int |
getLineNumber(int sequence)
Get the line number for an element. |
NamePool |
getNamePool()
Get the name pool used for the names in this document |
NodeInfo |
getNextSibling()
Get next sibling - always null |
NodeImpl |
getNode(int num)
Get a node by its node number, loading it from disk if necessary. |
int |
getNodeKind()
Get the type of node this document is -- ie it's a document node. |
NodeInfo |
getPreviousSibling()
Get previous sibling - always null |
NodeInfo |
getRoot()
Get the root node |
long |
getSequenceNumber()
Get the node sequence number (in document order). |
String |
getSystemId()
Get the system id of this root node |
protected String |
getSystemId(int seq)
Get the system id of an element in the document |
protected int |
getTypeAnnotation(int nodeNum)
Get the type annotation of a node |
String[] |
getUnparsedEntity(String name)
Get the unparsed entity with a given nameID if there is one, or null if not. |
void |
init(NamePool pool,
StructuredStore store)
Open a lazy tree and read in the root node. |
protected boolean |
isUsingNamespaces()
determine whether this document uses namespaces |
void |
printProfile()
Print out the profile (if one was collected) |
void |
putIndex(String indexName,
Map index)
Writes a disk-based version of an xsl:key index. |
private void |
readNames(SubStoreReader in)
Fetches the name list from a sub-file in the persistent disk file. |
NodeInfo |
selectID(String id)
Get the element with a given ID. |
void |
setAllPermanent(boolean flag)
If 'flag' is true, all loaded nodes will be cached until the tree goes away, instead of being held by weak references. |
void |
setDebug(boolean flag)
Establish whether to print out debugging statements when key indexes are created. |
protected void |
setElementAnnotation(int nodeNum,
int typeCode)
Set the type annotation of an element node |
protected void |
setLineNumber(int sequence,
int line)
Set the line number for an element. |
void |
setLineNumbering()
Set line numbering on |
void |
setRootNode(NodeInfo root)
Set the root node. |
protected void |
setSystemId(int seq,
String uri)
Set the system id of an element in the document |
void |
setSystemId(String uri)
Set the system id of this node |
Methods inherited from class ParentNodeImpl |
---|
enumerateChildren, getFirstChild, getLastChild, getStringValue, getStringValueCS, hasChildNodes, iterateAxis, iterateAxis |
Methods inherited from class Object |
---|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface NodeInfo |
---|
atomize, compareOrder, equals, getAttributeValue, getDeclaredNamespaces, getDisplayName, getFingerprint, getLocalPart, getNameCode, getParent, getPrefix, getStringValue, getTypeAnnotation, getURI, hasChildNodes, hashCode, isSameNodeInfo, iterateAxis, iterateAxis, sendNamespaceDeclarations |
Methods inherited from interface Item |
---|
getStringValueCS, getTypedValue |
Field Detail |
---|
protected Configuration config
protected NamePool namePool
protected int documentNumber
protected boolean usesNamespaces
protected int rootNodeNum
protected boolean debug
protected StructuredStore mainStore
protected SubStoreReader textFile
protected SubStoreReader nodeFile
protected int numberOfNodes
protected static final int NODE_FILE_HEADER_SIZE
protected int maxNodeSize
protected byte[] nodeBytes
protected PackedByteBuf nodeBuf
protected SubStoreReader attrFile
protected int maxAttrSize
protected byte[] attrBytes
protected PackedByteBuf attrBuf
public int numberOfNamespaces
public int[] namespaceParent
public int[] namespaceCode
public SystemIdMap systemIdMap
int[] nameNumToCode
HashMap nodeCache
boolean allPermanent
private LazyProfilingListener profileListener
private int killCheckCounter
Constructor Detail |
---|
public LazyDocument(Configuration config)
init(NamePool, StructuredStore)
afterward.
Method Detail |
---|
public void init(NamePool pool, StructuredStore store) throws IOException
pool
- The name pool to map namecodes withstore
- The file to open
IOException
public void setAllPermanent(boolean flag)
setAllPermanent
in interface PersistentTree
flag
- True to hold nodes for the life of the tree, false
to hold only soft references to them.public void setDebug(boolean flag)
public boolean getDebug()
public void printProfile() throws IOException
printProfile
in interface PersistentTree
IOException
public void close()
close
in interface PersistentTree
private void readNames(SubStoreReader in) throws IOException
in
- The subfile to load from
IOException
public void putIndex(String indexName, Map index) throws IOException
indexName
- Uniquely computed nameindex
- HashMap mapping String -> ArrayList[NodeImpl]
IOException
public DiskHashReader getIndex(String indexName)
indexName
- Name of the index to load
public Configuration getConfiguration()
getConfiguration
in interface NodeInfo
getConfiguration
in class NodeImpl
public NamePool getNamePool()
getNamePool
in interface NodeInfo
getNamePool
in class NodeImpl
public int getDocumentNumber()
getDocumentNumber
in interface NodeInfo
getDocumentNumber
in class NodeImpl
public void setRootNode(NodeInfo root)
protected void setElementAnnotation(int nodeNum, int typeCode)
protected int getTypeAnnotation(int nodeNum)
public int getNodeKind()
getNodeKind
in interface NodeInfo
public NodeImpl getNode(int num)
num
- The number to get
protected NodeImpl checkCache(int num)
protected NodeImpl createElementNode()
protected NodeImpl createTextNode()
public long getSequenceNumber()
getSequenceNumber
in class NodeImpl
public final NodeInfo getNextSibling()
getNextSibling
in class NodeImpl
public final NodeInfo getPreviousSibling()
getPreviousSibling
in class NodeImpl
public void generateId(FastStringBuffer buffer)
generateId
in interface NodeInfo
generateId
in class NodeImpl
buffer
- a buffer into which will be placed a string based on the document numberprotected boolean isUsingNamespaces()
public void setSystemId(String uri)
setSystemId
in interface Source
setSystemId
in class NodeImpl
public String getSystemId()
getSystemId
in interface Source
getSystemId
in interface SourceLocator
getSystemId
in interface NodeInfo
getSystemId
in class NodeImpl
public String getBaseURI()
getBaseURI
in interface NodeInfo
getBaseURI
in class NodeImpl
protected void setSystemId(int seq, String uri)
protected String getSystemId(int seq)
public void setLineNumbering()
protected void setLineNumber(int sequence, int line)
protected int getLineNumber(int sequence)
public int getLineNumber()
getLineNumber
in interface SourceLocator
getLineNumber
in interface NodeInfo
getLineNumber
in class NodeImpl
public final int getItemType()
public NodeInfo getRoot()
getRoot
in interface NodeInfo
getRoot
in class NodeImpl
public DocumentInfo getDocumentRoot()
getDocumentRoot
in interface NodeInfo
getDocumentRoot
in class NodeImpl
public String generateId()
protected AxisIterator getAllElements(int fingerprint)
public NodeInfo selectID(String id)
selectID
in interface DocumentInfo
id
- The unique ID of the required element, previously registered using registerID()
public String[] getUnparsedEntity(String name)
getUnparsedEntity
in interface DocumentInfo
name
- the name of the entity
public void copy(Receiver out, int whichNamespaces, boolean copyAnnotations, int locationId) throws XPathException
copy
in interface NodeInfo
XPathException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |