org.priha.core
Class ItemImpl

java.lang.Object
  extended by org.priha.core.ItemImpl
Direct Known Subclasses:
NodeImpl, PropertyImpl

public abstract class ItemImpl
extends java.lang.Object

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(ItemVisitor visitor)
          
 void enterState(ItemState state)
          Changes the ItemState of the Item, and places it in the appropriate queues.
 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(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 RepositoryException
Changes the ItemState of the Item, and places it in the appropriate queues.

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

accept

public void accept(ItemVisitor visitor)
            throws RepositoryException

Throws:
RepositoryException

getAncestor

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

Throws:
ItemNotFoundException
AccessDeniedException
RepositoryException

getDepth

public int getDepth()
             throws RepositoryException

Throws:
RepositoryException

getName

public java.lang.String getName()
                         throws RepositoryException

Throws:
RepositoryException

getQName

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

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

getParent

public NodeImpl getParent()
                   throws ItemNotFoundException,
                          AccessDeniedException,
                          RepositoryException

Throws:
ItemNotFoundException
AccessDeniedException
RepositoryException

getInternalPath

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

Returns:
The internal Path.

getPath

public java.lang.String getPath()
                         throws RepositoryException

Throws:
RepositoryException

getSession

public SessionImpl getSession()
                       throws RepositoryException

Throws:
RepositoryException

isModified

public boolean isModified()


isNew

public boolean isNew()


isNode

public boolean isNode()


isSame

public boolean isSame(Item otherItem)
               throws RepositoryException

Throws:
RepositoryException

refresh

public void refresh(boolean keepChanges)
             throws InvalidItemStateException,
                    RepositoryException

Throws:
InvalidItemStateException
RepositoryException

remove

public abstract void remove()
                     throws VersionException,
                            LockException,
                            ConstraintViolationException,
                            RepositoryException

Throws:
VersionException
LockException
ConstraintViolationException
RepositoryException

save

public abstract void save()
                   throws AccessDeniedException,
                          ItemExistsException,
                          ConstraintViolationException,
                          InvalidItemStateException,
                          ReferentialIntegrityException,
                          VersionException,
                          LockException,
                          NoSuchNodeTypeException,
                          RepositoryException

Throws:
AccessDeniedException
ItemExistsException
ConstraintViolationException
InvalidItemStateException
ReferentialIntegrityException
VersionException
LockException
NoSuchNodeTypeException
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 RepositoryException
Performs mandatory housekeeping right before saving.

Throws:
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.