org.apache.jackrabbit.core.state
Class ItemState

java.lang.Object
  extended byorg.apache.jackrabbit.core.state.ItemState
All Implemented Interfaces:
ItemStateListener, Serializable
Direct Known Subclasses:
NodeState, PropertyState

public abstract class ItemState
extends Object
implements ItemStateListener, Serializable

ItemState represents the state of an Item.

See Also:
Serialized Form

Field Summary
protected  ItemId id
           
protected  ItemState overlayedState
           
protected  String parentUUID
          the uuid of the (primary) parent node or null if this is the root node
protected  int status
          the internal status of this item state
static int STATUS_EXISTING
          'existing', i.e.
static int STATUS_EXISTING_MODIFIED
          'existing', i.e.
static int STATUS_EXISTING_REMOVED
          'existing', i.e.
static int STATUS_NEW
          'new' state
static int STATUS_STALE_DESTROYED
          'existing', i.e.
static int STATUS_STALE_MODIFIED
          'existing', i.e.
static int STATUS_UNDEFINED
          flags defining the current status of this ItemState instance
 
Constructor Summary
protected ItemState(int initialStatus, boolean isTransient)
          Protected constructor
protected ItemState(String parentUUID, ItemId id, int initialStatus, boolean isTransient)
          Protected constructor
 
Method Summary
 void addListener(ItemStateListener listener)
          Add an ItemStateListener
protected  void connect(ItemState overlayedState)
          Connect this state to some underlying overlayed state.
protected  void copy(ItemState state)
          Copy state information from a state into this state
 void discard()
          Discards this instance, i.e.
protected  void disconnect()
          Disconnect this state from the underlying overlayed state.
 ItemId getId()
          Returns the identifier of this item state.
 ItemState getOverlayedState()
          Returns the persistent state backing this transient state or null if there is no persistent state (i.e..
 String getParentUUID()
          Returns the UUID of the parent NodeState or null if either this item state represents the root node or this item state is 'free floating', i.e.
 int getStatus()
          Returns the status of this item.
 boolean hasOverlayedState()
          Determines if this item state is overlying persistent state.
abstract  boolean isNode()
          Determines if this item state represents a node.
 boolean isStale()
          Determines whether this item state has become stale.
 boolean isTransient()
          Returns true if this item state represents new or modified state (i.e.
protected  void notifyStateCreated()
          Notify the listeners that the persistent state this object is representing has been created.
protected  void notifyStateDestroyed()
          Notify the listeners that the persistent state this object is representing has been destroyed.
protected  void notifyStateDiscarded()
          Notify the listeners that the persistent state this object is representing has been discarded.
 void notifyStateUpdated()
          Notify the listeners that the persistent state this object is representing has been updated.
protected  void reconnect()
          Reconnect this state to the overlayed state that it has been disconnected from earlier.
 void removeListener(ItemStateListener listener)
          Remove an ItemStateListener
 void setParentUUID(String parentUUID)
          Sets the UUID of the parent NodeState.
 void setStatus(int newStatus)
          Sets the new status of this item.
 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_UNDEFINED

public static final int STATUS_UNDEFINED
flags defining the current status of this ItemState instance

See Also:
Constant Field Values

STATUS_EXISTING

public static final int STATUS_EXISTING
'existing', i.e. persistent state

See Also:
Constant Field Values

STATUS_EXISTING_MODIFIED

public static final int STATUS_EXISTING_MODIFIED
'existing', i.e. persistent state that has been transiently modified (copy-on-write)

See Also:
Constant Field Values

STATUS_EXISTING_REMOVED

public static final int STATUS_EXISTING_REMOVED
'existing', i.e. persistent state that has been transiently removed (copy-on-write)

See Also:
Constant Field Values

STATUS_NEW

public static final int STATUS_NEW
'new' state

See Also:
Constant Field Values

STATUS_STALE_MODIFIED

public static final int STATUS_STALE_MODIFIED
'existing', i.e. persistent state that has been persistently modified by somebody else

See Also:
Constant Field Values

STATUS_STALE_DESTROYED

public static final int STATUS_STALE_DESTROYED
'existing', i.e. persistent state that has been destroyed by somebody else

See Also:
Constant Field Values

status

protected int status
the internal status of this item state


parentUUID

protected String parentUUID
the uuid of the (primary) parent node or null if this is the root node


id

protected ItemId id

overlayedState

protected transient ItemState overlayedState
Constructor Detail

ItemState

protected ItemState(String parentUUID,
                    ItemId id,
                    int initialStatus,
                    boolean isTransient)
Protected constructor

Parameters:
parentUUID - the UUID of the (primary) parent node or null
id - the id of the item state object
initialStatus - the initial status of the item state object
isTransient - flag indicating whether this state is transient or not

ItemState

protected ItemState(int initialStatus,
                    boolean isTransient)
Protected constructor

Parameters:
initialStatus - the initial status of the new ItemState instance
isTransient - flag indicating whether this state is transient or not
Method Detail

copy

protected void copy(ItemState state)
Copy state information from a state into this state

Parameters:
state - source state information

connect

protected void connect(ItemState overlayedState)
Connect this state to some underlying overlayed state.


reconnect

protected void reconnect()
Reconnect this state to the overlayed state that it has been disconnected from earlier.


disconnect

protected void disconnect()
Disconnect this state from the underlying overlayed state.


notifyStateDiscarded

protected void notifyStateDiscarded()
Notify the listeners that the persistent state this object is representing has been discarded.


notifyStateCreated

protected void notifyStateCreated()
Notify the listeners that the persistent state this object is representing has been created.


notifyStateUpdated

public void notifyStateUpdated()
Notify the listeners that the persistent state this object is representing has been updated.


notifyStateDestroyed

protected void notifyStateDestroyed()
Notify the listeners that the persistent state this object is representing has been destroyed.


isNode

public abstract boolean isNode()
Determines if this item state represents a node.

Returns:
true if this item state represents a node, otherwise false.

getId

public ItemId getId()
Returns the identifier of this item state.

Returns:
the identifier of this item state..

isTransient

public boolean isTransient()
Returns true if this item state represents new or modified state (i.e. the result of copy-on-write) or false if it represents existing, unmodified state.

Returns:
true if this item state is modified or new, otherwise false

isStale

public boolean isStale()
Determines whether this item state has become stale.

Returns:
true if this item state has become stale, false otherwise.

getParentUUID

public String getParentUUID()
Returns the UUID of the parent NodeState or null if either this item state represents the root node or this item state is 'free floating', i.e. not attached to the repository's hierarchy.

Returns:
the parent NodeState's UUID

setParentUUID

public void setParentUUID(String parentUUID)
Sets the UUID of the parent NodeState.

Parameters:
parentUUID - the parent NodeState's UUID or null if either this item state should represent the root node or this item state should be 'free floating', i.e. detached from the repository's hierarchy.

getStatus

public int getStatus()
Returns the status of this item.

Returns:
the status of this item.

setStatus

public void setStatus(int newStatus)
Sets the new status of this item.

Parameters:
newStatus - the new status

discard

public void discard()
Discards this instance, i.e. renders it 'invalid'.


hasOverlayedState

public boolean hasOverlayedState()
Determines if this item state is overlying persistent state.

Returns:
true if this item state is overlying persistent state, otherwise false.

getOverlayedState

public ItemState getOverlayedState()
Returns the persistent state backing this transient state or null if there is no persistent state (i.e.. this state is purely transient).

Returns:
the persistent item state or null if there is no persistent state.

addListener

public void addListener(ItemStateListener listener)
Add an ItemStateListener

Parameters:
listener - the new listener to be informed on modifications

removeListener

public void removeListener(ItemStateListener listener)
Remove an ItemStateListener

Parameters:
listener - an existing listener

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:
discard()


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