org.priha.core
Class ItemImpl

java.lang.Object
  extended by org.priha.core.ItemImpl
All Implemented Interfaces:
javax.jcr.Item
Direct Known Subclasses:
NodeImpl, PropertyImpl

public abstract class ItemImpl
extends java.lang.Object
implements javax.jcr.Item

Provides a basic implementation for Items. An Item stores a reference to its Path, the Session, and keeps a record of its ItemState. Therefore it's a fairly lightweight object.


Field Summary
protected  boolean m_isNew
           
protected  PathRef m_path
           
protected  SessionImpl m_session
           
 
Constructor Summary
ItemImpl(SessionImpl session, Path path)
          Create an Item for a particular session and path.
 
Method Summary
 void accept(javax.jcr.ItemVisitor visitor)
          
 void enterState(ItemState state)
          Changes the ItemState of the Item, and places it in the appropriate queues.
 javax.jcr.Item getAncestor(int depth)
          
 long getCreationTime()
          Returns the creation time of this Item instance.
 int getDepth()
          
 Path getInternalPath()
          Get the internal path representation for this Item.
 java.lang.String getName()
          
 NodeImpl getParent()
          
 java.lang.String getPath()
          
 PathRef getPathReference()
          Returns the path reference object.
 QName getQName()
          Returns the QName of this item.
 SessionImpl getSession()
          
 ItemState getState()
          Return the current state of this Item.
 int hashCode()
          
 boolean isModified()
          
 boolean isNew()
          
 boolean isNode()
          
 boolean isSame(javax.jcr.Item otherItem)
          
protected  void postSave()
          Performs mandatory housekeeping after item state has been persisted to disk.
protected  void preSave()
          Performs mandatory housekeeping right before saving.
 void refresh(boolean keepChanges)
          
abstract  void remove()
          
abstract  void save()
          
 java.lang.String toString()
          Returns a human-readable description of the Item.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

m_path

protected PathRef m_path

m_session

protected final SessionImpl m_session

m_isNew

protected boolean m_isNew
Constructor Detail

ItemImpl

public ItemImpl(SessionImpl session,
                Path path)
Create an Item for a particular session and path.

Parameters:
session - Session which owns this Item
path - Path at which the Item is created.
Method Detail

getPathReference

public PathRef getPathReference()
Returns the path reference object.

Returns:
The internal path reference.

getState

public ItemState getState()
Return the current state of this Item.

Returns:
An ItemState representing the state.

enterState

public void enterState(ItemState state)
                throws javax.jcr.RepositoryException
Changes the ItemState of the Item, and places it in the appropriate queues.

Parameters:
state - New state.
Throws:
javax.jcr.RepositoryException - If the state cannot be entered for some reason.

accept

public void accept(javax.jcr.ItemVisitor visitor)
            throws javax.jcr.RepositoryException

Specified by:
accept in interface javax.jcr.Item
Throws:
javax.jcr.RepositoryException

getAncestor

public javax.jcr.Item getAncestor(int depth)
                           throws javax.jcr.ItemNotFoundException,
                                  javax.jcr.AccessDeniedException,
                                  javax.jcr.RepositoryException

Specified by:
getAncestor in interface javax.jcr.Item
Throws:
javax.jcr.ItemNotFoundException
javax.jcr.AccessDeniedException
javax.jcr.RepositoryException

getDepth

public int getDepth()
             throws javax.jcr.RepositoryException

Specified by:
getDepth in interface javax.jcr.Item
Throws:
javax.jcr.RepositoryException

getName

public java.lang.String getName()
                         throws javax.jcr.RepositoryException

Specified by:
getName in interface javax.jcr.Item
Throws:
javax.jcr.RepositoryException

getQName

public QName getQName()
               throws javax.jcr.NamespaceException,
                      javax.jcr.RepositoryException
Returns the QName of this item.

Returns:
A QName.
Throws:
javax.jcr.NamespaceException - If the namespace cannot be parsed.
javax.jcr.RepositoryException - If something else goes wrong.

getParent

public NodeImpl getParent()
                   throws javax.jcr.ItemNotFoundException,
                          javax.jcr.AccessDeniedException,
                          javax.jcr.RepositoryException

Specified by:
getParent in interface javax.jcr.Item
Throws:
javax.jcr.ItemNotFoundException
javax.jcr.AccessDeniedException
javax.jcr.RepositoryException

getInternalPath

public Path getInternalPath()
Get the internal path representation for this Item.

Returns:
The internal Path.

getPath

public java.lang.String getPath()
                         throws javax.jcr.RepositoryException

Specified by:
getPath in interface javax.jcr.Item
Throws:
javax.jcr.RepositoryException

getSession

public SessionImpl getSession()
                       throws javax.jcr.RepositoryException

Specified by:
getSession in interface javax.jcr.Item
Throws:
javax.jcr.RepositoryException

isModified

public boolean isModified()

Specified by:
isModified in interface javax.jcr.Item

isNew

public boolean isNew()

Specified by:
isNew in interface javax.jcr.Item

isNode

public boolean isNode()

Specified by:
isNode in interface javax.jcr.Item

isSame

public boolean isSame(javax.jcr.Item otherItem)
               throws javax.jcr.RepositoryException

Specified by:
isSame in interface javax.jcr.Item
Throws:
javax.jcr.RepositoryException

refresh

public void refresh(boolean keepChanges)
             throws javax.jcr.InvalidItemStateException,
                    javax.jcr.RepositoryException

Specified by:
refresh in interface javax.jcr.Item
Throws:
javax.jcr.InvalidItemStateException
javax.jcr.RepositoryException

remove

public abstract void remove()
                     throws javax.jcr.version.VersionException,
                            javax.jcr.lock.LockException,
                            javax.jcr.nodetype.ConstraintViolationException,
                            javax.jcr.RepositoryException

Specified by:
remove in interface javax.jcr.Item
Throws:
javax.jcr.version.VersionException
javax.jcr.lock.LockException
javax.jcr.nodetype.ConstraintViolationException
javax.jcr.RepositoryException

save

public abstract void save()
                   throws javax.jcr.AccessDeniedException,
                          javax.jcr.ItemExistsException,
                          javax.jcr.nodetype.ConstraintViolationException,
                          javax.jcr.InvalidItemStateException,
                          javax.jcr.ReferentialIntegrityException,
                          javax.jcr.version.VersionException,
                          javax.jcr.lock.LockException,
                          javax.jcr.nodetype.NoSuchNodeTypeException,
                          javax.jcr.RepositoryException

Specified by:
save in interface javax.jcr.Item
Throws:
javax.jcr.AccessDeniedException
javax.jcr.ItemExistsException
javax.jcr.nodetype.ConstraintViolationException
javax.jcr.InvalidItemStateException
javax.jcr.ReferentialIntegrityException
javax.jcr.version.VersionException
javax.jcr.lock.LockException
javax.jcr.nodetype.NoSuchNodeTypeException
javax.jcr.RepositoryException

toString

public java.lang.String toString()
Returns a human-readable description of the Item.

Overrides:
toString in class java.lang.Object
Returns:
Something readable.

hashCode

public int hashCode()

Overrides:
hashCode in class java.lang.Object

preSave

protected void preSave()
                throws javax.jcr.RepositoryException
Performs mandatory housekeeping right before saving.

Throws:
javax.jcr.RepositoryException - If something goes wrong

postSave

protected void postSave()
Performs mandatory housekeeping after item state has been persisted to disk.


getCreationTime

public long getCreationTime()
Returns the creation time of this Item instance.

Returns:
The creation time.