org.apache.jackrabbit.jcr2spi
Class ItemImpl

java.lang.Object
  extended by org.apache.jackrabbit.jcr2spi.ItemImpl
All Implemented Interfaces:
Item, ItemStateLifeCycleListener
Direct Known Subclasses:
NodeImpl, PropertyImpl

public abstract class ItemImpl
extends Object
implements Item, ItemStateLifeCycleListener

ItemImpl...


Field Summary
protected  Map<ItemLifeCycleListener,ItemLifeCycleListener> listeners
          Listeners (weak references)
protected  SessionImpl session
          The session that created this item.
 
Constructor Summary
ItemImpl(SessionImpl session, ItemState state, ItemLifeCycleListener[] listeners)
           
 
Method Summary
abstract  void accept(ItemVisitor visitor)
           
protected  void checkIsWritable()
          Checks if the repository supports level 2 (writing) and the status of this item.
protected  void checkStatus()
          Performs a sanity check on this item and the associated session.
 Item getAncestor(int depth)
           
 int getDepth()
           
protected  ItemManager getItemManager()
          Returns the ItemManager associated with this item's Session.
protected  ItemState getItemState()
          Returns the item-state associated with this Item.
abstract  String getName()
           
 Node getParent()
           
 String getPath()
           
 Session getSession()
          Note: as of 2.x this method returns the session irrespective of the item's status.
 boolean isModified()
           
 boolean isNew()
           
abstract  boolean isNode()
           
 boolean isSame(Item otherItem)
           
protected  boolean isWritable()
          Returns true if the repository supports level 2 (writing).
 void refresh(boolean keepChanges)
           
 void remove()
           
 void save()
           
 void statusChanged(ItemState state, int previousStatus)
          Called after an ItemState has changed its status.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

session

protected SessionImpl session
The session that created this item.


listeners

protected final Map<ItemLifeCycleListener,ItemLifeCycleListener> listeners
Listeners (weak references)

Constructor Detail

ItemImpl

public ItemImpl(SessionImpl session,
                ItemState state,
                ItemLifeCycleListener[] listeners)
Method Detail

getPath

public String getPath()
               throws RepositoryException
Specified by:
getPath in interface Item
Throws:
RepositoryException
See Also:
Item.getPath()

getName

public abstract String getName()
                        throws RepositoryException
Specified by:
getName in interface Item
Throws:
RepositoryException
See Also:
Item.getName()

getAncestor

public Item getAncestor(int depth)
                 throws ItemNotFoundException,
                        AccessDeniedException,
                        RepositoryException
Specified by:
getAncestor in interface Item
Throws:
ItemNotFoundException
AccessDeniedException
RepositoryException
See Also:
Item.getAncestor(int)

getParent

public Node getParent()
               throws ItemNotFoundException,
                      AccessDeniedException,
                      RepositoryException
Specified by:
getParent in interface Item
Throws:
ItemNotFoundException
AccessDeniedException
RepositoryException
See Also:
Item.getParent()

getDepth

public int getDepth()
             throws RepositoryException
Specified by:
getDepth in interface Item
Throws:
RepositoryException
See Also:
Item.getDepth()

getSession

public Session getSession()
                   throws RepositoryException
Note: as of 2.x this method returns the session irrespective of the item's status.

Specified by:
getSession in interface Item
Throws:
RepositoryException
See Also:
Item.getSession(), Issue JCR-2529

isNew

public boolean isNew()
Specified by:
isNew in interface Item
See Also:
Item.isNew()

isModified

public boolean isModified()
Specified by:
isModified in interface Item
See Also:
Item.isModified()

isSame

public boolean isSame(Item otherItem)
               throws RepositoryException
Specified by:
isSame in interface Item
Throws:
RepositoryException
See Also:
Item.isSame(Item)

accept

public abstract void accept(ItemVisitor visitor)
                     throws RepositoryException
Specified by:
accept in interface Item
Throws:
RepositoryException
See Also:
Item.accept(ItemVisitor)

isNode

public abstract boolean isNode()
Specified by:
isNode in interface Item
See Also:
Item.isNode()

save

public void save()
          throws AccessDeniedException,
                 ConstraintViolationException,
                 InvalidItemStateException,
                 ReferentialIntegrityException,
                 VersionException,
                 LockException,
                 RepositoryException
Specified by:
save in interface Item
Throws:
AccessDeniedException
ConstraintViolationException
InvalidItemStateException
ReferentialIntegrityException
VersionException
LockException
RepositoryException
See Also:
Item.save()

refresh

public void refresh(boolean keepChanges)
             throws InvalidItemStateException,
                    RepositoryException
Specified by:
refresh in interface Item
Throws:
InvalidItemStateException
RepositoryException
See Also:
Item.refresh(boolean)

remove

public void remove()
            throws VersionException,
                   LockException,
                   ConstraintViolationException,
                   RepositoryException
Specified by:
remove in interface Item
Throws:
VersionException
LockException
ConstraintViolationException
RepositoryException
See Also:
Item.remove()

statusChanged

public void statusChanged(ItemState state,
                          int previousStatus)
Description copied from interface: ItemStateLifeCycleListener
Called after an ItemState has changed its status. The new status can be retrieved by calling ItemState.getStatus().

Specified by:
statusChanged in interface ItemStateLifeCycleListener
Parameters:
state -
previousStatus -

checkStatus

protected void checkStatus()
                    throws RepositoryException
Performs a sanity check on this item and the associated session. If the underlying item state is in an invalidated state then it will be refreshed to get the current status of the item state. The status check is then performed on the newly retrieved status.

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

checkIsWritable

protected void checkIsWritable()
                        throws UnsupportedRepositoryOperationException,
                               ConstraintViolationException,
                               RepositoryException
Checks if the repository supports level 2 (writing) and the status of this item. Note, that this method does not perform any additional validation checks such as access restrictions, locking, checkin status or protection that affect the writing to nodes and properties.

Throws:
UnsupportedRepositoryOperationException
RepositoryException
ConstraintViolationException
See Also:
ItemStateValidator

isWritable

protected boolean isWritable()
                      throws RepositoryException
Returns true if the repository supports level 2 (writing). Note, that this method does not perform any additional validation tests such as access restrictions, locking, checkin status or protection that affect the writing to nodes and properties.

Throws:
UnsupportedRepositoryOperationException
RepositoryException - if the sanity check on this item fails. See checkStatus().
See Also:
ItemStateValidator

getItemState

protected ItemState getItemState()
Returns the item-state associated with this Item.

Returns:
state associated with this Item

getItemManager

protected ItemManager getItemManager()
Returns the ItemManager associated with this item's Session.

Returns:
ItemManager


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