org.exist.numbering
Interface NodeIdFactory

All Known Implementing Classes:
DLNFactory

public interface NodeIdFactory

A factory for creating node ids. To support different numbering schemes, NodeId instances should always be created through this interface. The NodeIdFactory for the current database instance can be retrieved from BrokerPool.getNodeFactory().


Method Summary
 NodeId createFromData(int sizeHint, byte[] data, int startOffset)
          Read a NodeId from the given byte array.
 NodeId createFromStream(NodeId previous, VariableByteInput is)
          Read a NodeId from the given input stream.
 NodeId createFromStream(VariableByteInput is)
          Read a NodeId from the given input stream.
 NodeId createFromString(String string)
          Create a NodeId instance from its string representation.
 NodeId createInstance()
          Create a new NodeId, initialized with a default value.
 NodeId createInstance(int id)
          Create a new NodeId, initialized with the given base id.
 NodeId documentNodeId()
          Returns a NodeId representing the document node of a document.
 int lengthInBytes(int units, byte[] data, int startOffset)
          Returns the number of bytes occupied by the NodeId stored in the byte array at the given startOffset.
 void writeEndOfDocument(VariableByteOutputStream os)
           
 

Method Detail

createInstance

NodeId createInstance()
Create a new NodeId, initialized with a default value.

Returns:
a new NodeId.

createInstance

NodeId createInstance(int id)
Create a new NodeId, initialized with the given base id.

Parameters:
id -
Returns:
nodeId

createFromStream

NodeId createFromStream(VariableByteInput is)
                        throws IOException
Read a NodeId from the given input stream.

Parameters:
is - the input stream to read from
Returns:
the NodeId read
Throws:
IOException - if there's a problem with the underlying input stream
See Also:
NodeId.write(org.exist.storage.io.VariableByteOutputStream)

createFromStream

NodeId createFromStream(NodeId previous,
                        VariableByteInput is)
                        throws IOException
Read a NodeId from the given input stream. Assumes that the node id was stored with prefix-compression, i.e. only the bytes differing from the previous node were written out.

Parameters:
previous - the previous node id read or null if there is none
is - the input stream to read from
Returns:
the NodeId read
Throws:
IOException - if there's a problem with the underlying input stream
See Also:
NodeId.write(NodeId, org.exist.storage.io.VariableByteOutputStream)

createFromData

NodeId createFromData(int sizeHint,
                      byte[] data,
                      int startOffset)
Read a NodeId from the given byte array. Start to read at startOffset. sizeHint indicates the length of the id in an implementation dependent manner. Some implementations may require sizeHint to be specified, others not.

Parameters:
sizeHint - a hint about the expected length of the id
data - the byte array to read from
startOffset - offset into the byte array
Returns:
the NodeId read

createFromString

NodeId createFromString(String string)
Create a NodeId instance from its string representation.

Parameters:
string - the string representation of the node id as returned by Object.toString()
Returns:
nodeId

lengthInBytes

int lengthInBytes(int units,
                  byte[] data,
                  int startOffset)
Returns the number of bytes occupied by the NodeId stored in the byte array at the given startOffset. This method is similar to createFromData(int, byte[], int), but it just returns the number of bytes.

Parameters:
units -
data -
startOffset -
Returns:
number of bytes

documentNodeId

NodeId documentNodeId()
Returns a NodeId representing the document node of a document. Usually, this will be a singleton object.

Returns:
the document node id.

writeEndOfDocument

void writeEndOfDocument(VariableByteOutputStream os)


Copyright (C) Wolfgang Meier. All rights reserved.