org.geotools.caching.spatialindex
Class NodeIdentifier

java.lang.Object
  extended by org.geotools.caching.spatialindex.NodeIdentifier
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
RegionNodeIdentifier

public abstract class NodeIdentifier
extends java.lang.Object
implements java.io.Serializable

Instances of this class provide unique identifiers for nodes, and are used to store and retrieve nodes from their storage. Implementors must take care that instances have to be immutable. Nodes are basically identified by the region they represent. Kinds of nodes or kinds of storage may require to use other elements to identify nodes. Implementors must take care to override hashCode() and equals() accordingly. NodeIdentifier should not reference the node they identify, as they are likely to be used to passivate nodes in secondary storage.

Author:
crousson
See Also:
Serialized Form

Method Summary
 Node getNode()
          May return null; node is held onto with a soft reference
abstract  Shape getShape()
           
 boolean isLocked()
           
 boolean isValid()
           
 boolean isWritable()
          Only want to write to nodes that aren't being read.
 void readLock()
          Acquire a read lock on the node
 void readUnLock()
          Unlock read lock
 void setNode(Node n)
          Sets the node associated with the nodeid; this node is stored as a soft reference so getNode() may return null.
 void setValid(boolean valid)
          Sets the validity of the node; true means the data in the node is ready for reading.
 void writeLock()
          Acquire a write lock on the node
 void writeUnLock()
          Unlock the write lock
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getShape

public abstract Shape getShape()

isValid

public boolean isValid()
Returns:
if the nodes data is valid

setValid

public void setValid(boolean valid)
Sets the validity of the node; true means the data in the node is ready for reading.

Parameters:
valid -

writeLock

public void writeLock()
               throws java.lang.Exception
Acquire a write lock on the node

Throws:
java.lang.Exception

writeUnLock

public void writeUnLock()
Unlock the write lock


readLock

public void readLock()
              throws java.lang.Exception
Acquire a read lock on the node

Throws:
java.lang.Exception

readUnLock

public void readUnLock()
Unlock read lock


isWritable

public boolean isWritable()
Only want to write to nodes that aren't being read.


isLocked

public boolean isLocked()

setNode

public void setNode(Node n)
Sets the node associated with the nodeid; this node is stored as a soft reference so getNode() may return null.

Parameters:
n -

getNode

public Node getNode()
May return null; node is held onto with a soft reference

Returns:


Copyright © 1996-2010 Geotools. All Rights Reserved.