org.apache.jackrabbit.core
Class ItemImpl

java.lang.Object
  extended byorg.apache.jackrabbit.core.ItemImpl
All Implemented Interfaces:
Item, ItemStateListener
Direct Known Subclasses:
NodeImpl, PropertyImpl

public abstract class ItemImpl
extends Object
implements Item, ItemStateListener

ItemImpl implements the Item interface.


Field Summary
protected  ItemId id
           
protected  ItemManager itemMgr
          ItemManager that created this Item
protected  Map listeners
          Listeners (weak references)
protected  RepositoryImpl rep
          the Repository object
protected  SessionImpl session
          Session through which this Item was acquired
protected  ItemState state
          ItemState associated with this Item
protected  SessionItemStateManager stateMgr
          SessionItemStateManager associated with this Item
protected  int status
           
protected static int STATUS_DESTROYED
           
protected static int STATUS_INVALIDATED
           
protected static int STATUS_MODIFIED
           
protected static int STATUS_NORMAL
           
 
Method Summary
abstract  void accept(ItemVisitor visitor)
          
 Item getAncestor(int degree)
          
 int getDepth()
          
 ItemId getId()
          Return the id of this Item.
abstract  String getName()
          
protected abstract  ItemState getOrCreateTransientItemState()
           
abstract  Node getParent()
          
 String getPath()
          
 Path getPrimaryPath()
          Returns the primary path to this Item.
abstract  QName getQName()
          Same as Item.getName() except that this method returns a QName instead of a String.
 Session getSession()
          
protected  void internalRemove(boolean noChecks)
          Same as Item.remove() except for the noChecks parameter.
 boolean isModified()
          
 boolean isNew()
          
abstract  boolean isNode()
          
 boolean isSame(Item otherItem)
          
protected  boolean isTransactionalNew()
          checks if this item is new.
protected  boolean isTransient()
           
protected abstract  void makePersistent()
           
protected  void notifyDestroyed()
          Notify the listeners that this instance has been destroyed (i.e.
protected  void notifyInvalidated()
          Notify the listeners that this instance has been invalidated (i.e.
 void refresh(boolean keepChanges)
          
 void remove()
          
 String safeGetJCRPath()
          Failsafe mapping of internal id to JCR path for use in diagnostic output, error messages etc.
protected  void sanityCheck()
          Performs a sanity check on this item and the associated session.
 void save()
          
protected  void setRemoved()
          Marks this instance as 'removed' and notifies its listeners.
 void stateCreated(ItemState created)
          Called when an ItemState has successfully been created (i.e. its underlying persistent state was created).
 void stateDestroyed(ItemState destroyed)
          Called when an ItemState has successfully been removed (i.e. its underlying persistent state has been destroyed).
 void stateDiscarded(ItemState discarded)
          Called when an ItemState has been discarded (i.e. it has been rendered 'invalid').
 void stateModified(ItemState modified)
          Called when an ItemState has successfully been modified (i.e. its underlying persistent state has changed).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STATUS_NORMAL

protected static final int STATUS_NORMAL
See Also:
Constant Field Values

STATUS_MODIFIED

protected static final int STATUS_MODIFIED
See Also:
Constant Field Values

STATUS_DESTROYED

protected static final int STATUS_DESTROYED
See Also:
Constant Field Values

STATUS_INVALIDATED

protected static final int STATUS_INVALIDATED
See Also:
Constant Field Values

status

protected int status

id

protected final ItemId id

session

protected final SessionImpl session
Session through which this Item was acquired


rep

protected final RepositoryImpl rep
the Repository object


state

protected ItemState state
ItemState associated with this Item


itemMgr

protected final ItemManager itemMgr
ItemManager that created this Item


stateMgr

protected final SessionItemStateManager stateMgr
SessionItemStateManager associated with this Item


listeners

protected final Map listeners
Listeners (weak references)

Method Detail

sanityCheck

protected void sanityCheck()
                    throws RepositoryException
Performs a sanity check on this item and the associated session.

Throws:
RepositoryException - if this item has been rendered invalid for some reason

isTransient

protected boolean isTransient()

getOrCreateTransientItemState

protected abstract ItemState getOrCreateTransientItemState()
                                                    throws RepositoryException
Throws:
RepositoryException

makePersistent

protected abstract void makePersistent()
                                throws InvalidItemStateException
Throws:
InvalidItemStateException

setRemoved

protected void setRemoved()
                   throws RepositoryException
Marks this instance as 'removed' and notifies its listeners. The resulting state is either 'temporarily invalidated' or 'permanently invalidated', depending on the initial state.

Throws:
RepositoryException - if an error occurs

notifyInvalidated

protected void notifyInvalidated()
Notify the listeners that this instance has been invalidated (i.e. it has been temporarily rendered 'invalid').


notifyDestroyed

protected void notifyDestroyed()
Notify the listeners that this instance has been destroyed (i.e. it has been permanently rendered 'invalid').


getId

public ItemId getId()
Return the id of this Item.

Returns:
the id of this Item

getPrimaryPath

public Path getPrimaryPath()
                    throws RepositoryException
Returns the primary path to this Item.

Returns:
the primary path to this Item
Throws:
RepositoryException

safeGetJCRPath

public String safeGetJCRPath()
Failsafe mapping of internal id to JCR path for use in diagnostic output, error messages etc.

Returns:
JCR path or some fallback value

internalRemove

protected void internalRemove(boolean noChecks)
                       throws VersionException,
                              LockException,
                              ConstraintViolationException,
                              RepositoryException
Same as Item.remove() except for the noChecks parameter.

Parameters:
noChecks -
Throws:
VersionException
LockException
RepositoryException
ConstraintViolationException

getQName

public abstract QName getQName()
                        throws RepositoryException
Same as Item.getName() except that this method returns a QName instead of a String.

Returns:
the name of this item as QName
Throws:
RepositoryException - if an error occurs.

stateCreated

public void stateCreated(ItemState created)
Called when an ItemState has successfully been created (i.e. its underlying persistent state was created).

Specified by:
stateCreated in interface ItemStateListener
Parameters:
created - the ItemState that has been 'created'

stateDestroyed

public void stateDestroyed(ItemState destroyed)
Called when an ItemState has successfully been removed (i.e. its underlying persistent state has been destroyed).

Specified by:
stateDestroyed in interface ItemStateListener
Parameters:
destroyed - the ItemState that has been 'destroyed'

stateModified

public void stateModified(ItemState modified)
Called when an ItemState has successfully been modified (i.e. its underlying persistent state has changed).

Specified by:
stateModified in interface ItemStateListener
Parameters:
modified - the ItemState that has been 'modified'

stateDiscarded

public void stateDiscarded(ItemState discarded)
Called when an ItemState has been discarded (i.e. it has been rendered 'invalid').

Specified by:
stateDiscarded in interface ItemStateListener
Parameters:
discarded - the ItemState that has been discarded
See Also:
ItemState.discard()

accept

public abstract void accept(ItemVisitor visitor)
                     throws RepositoryException

Specified by:
accept in interface Item
Throws:
RepositoryException

isNode

public abstract boolean isNode()

Specified by:
isNode in interface Item

getName

public abstract String getName()
                        throws RepositoryException

Specified by:
getName in interface Item
Throws:
RepositoryException

getParent

public abstract Node getParent()
                        throws ItemNotFoundException,
                               AccessDeniedException,
                               RepositoryException

Specified by:
getParent in interface Item
Throws:
ItemNotFoundException
AccessDeniedException
RepositoryException

isNew

public boolean isNew()

Specified by:
isNew in interface Item

isTransactionalNew

protected boolean isTransactionalNew()
checks if this item is new. running outside of transactions, this is the same as isNew() but within a transaction an item can be saved but not yet persisted.


isModified

public boolean isModified()

Specified by:
isModified in interface Item

remove

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

Specified by:
remove in interface Item
Throws:
VersionException
LockException
ConstraintViolationException
RepositoryException

save

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

Specified by:
save in interface Item
Throws:
AccessDeniedException
ItemExistsException
ConstraintViolationException
InvalidItemStateException
ReferentialIntegrityException
VersionException
LockException
NoSuchNodeTypeException
RepositoryException

refresh

public void refresh(boolean keepChanges)
             throws InvalidItemStateException,
                    RepositoryException

Specified by:
refresh in interface Item
Throws:
InvalidItemStateException
RepositoryException

getAncestor

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

Specified by:
getAncestor in interface Item
Throws:
ItemNotFoundException
AccessDeniedException
RepositoryException

getPath

public String getPath()
               throws RepositoryException

Specified by:
getPath in interface Item
Throws:
RepositoryException

getDepth

public int getDepth()
             throws RepositoryException

Specified by:
getDepth in interface Item
Throws:
RepositoryException

getSession

public Session getSession()
                   throws RepositoryException

Specified by:
getSession in interface Item
Throws:
RepositoryException

isSame

public boolean isSame(Item otherItem)
               throws RepositoryException

Specified by:
isSame in interface Item
Throws:
RepositoryException


Copyright © 2004-2006 The Apache Software Foundation. All Rights Reserved.