public abstract class ItemState extends Object
ItemState
represents the state of an Item
.Modifier and Type | Field and Description |
---|---|
protected ItemState |
overlayedState
the backing persistent item state (may be null)
|
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_UNDEFINED
the status is undefined
|
Modifier | Constructor and Description |
---|---|
protected |
ItemState(int initialStatus,
boolean isTransient)
Constructs a new unconnected item state
|
protected |
ItemState(ItemState overlayedState,
int initialStatus,
boolean isTransient)
Constructs a new item state that is initially connected to an overlayed
state.
|
Modifier and Type | Method and Description |
---|---|
abstract long |
calculateMemoryFootprint()
Returns the approximate memory consumption of this state.
|
void |
connect(ItemState overlayedState)
Connect this state to some underlying overlayed state.
|
abstract void |
copy(ItemState state,
boolean syncModCount)
Copy state information from another state into this state
|
void |
discard()
Discards this instance, i.e.
|
protected void |
disconnect()
Disconnect this state from the underlying overlayed state.
|
ItemStateListener |
getContainer()
Return the parent container that will receive notifications about changes to this state.
|
abstract ItemId |
getId()
Returns the identifier of this item.
|
short |
getModCount()
Returns the modification count.
|
ItemState |
getOverlayedState()
Returns the persistent state backing this transient state or
null if there is no persistent state (i.e.. |
abstract NodeId |
getParentId()
Returns the NodeId 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.
|
protected boolean |
isConnected()
Return a flag indicating whether this state is connected to some other 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 parent container about changes to this state.
|
protected void |
notifyStateDestroyed()
Notify the parent container about changes to this state.
|
protected void |
notifyStateDiscarded()
Notify the parent container about changes to this state.
|
void |
notifyStateUpdated()
Notify the parent container about changes to this state.
|
protected void |
reconnect()
Reconnect this state to the overlayed state that it has been
disconnected from earlier.
|
void |
setContainer(ItemStateListener container)
Set the parent container that will receive notifications about changes to this state.
|
void |
setModCount(short modCount)
Sets the modification count.
|
void |
setStatus(int newStatus)
Sets the new status of this item.
|
public static final int STATUS_UNDEFINED
public static final int STATUS_EXISTING
public static final int STATUS_EXISTING_MODIFIED
public static final int STATUS_EXISTING_REMOVED
public static final int STATUS_NEW
public static final int STATUS_STALE_DESTROYED
protected int status
protected ItemState overlayedState
protected ItemState(int initialStatus, boolean isTransient)
initialStatus
- the initial status of the item state objectisTransient
- flag indicating whether this state is transient or notprotected ItemState(ItemState overlayedState, int initialStatus, boolean isTransient)
overlayedState
- the backing item state being overlayedinitialStatus
- the initial status of the new ItemState
instanceisTransient
- flag indicating whether this state is transient or notpublic abstract void copy(ItemState state, boolean syncModCount)
state
- source state informationsyncModCount
- if the modCount should be synchronized.public void connect(ItemState overlayedState) throws ItemStateException
ItemStateException
protected void reconnect() throws ItemStateException
ItemStateException
protected void disconnect()
protected boolean isConnected()
true
if this state is connected, false
otherwise.protected void notifyStateDiscarded()
protected void notifyStateCreated()
public void notifyStateUpdated()
protected void notifyStateDestroyed()
public abstract boolean isNode()
public abstract ItemId getId()
public boolean isTransient()
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.true
if this item state is modified or new,
otherwise false
public boolean isStale()
public abstract NodeId getParentId()
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.NodeState
's Idpublic int getStatus()
public void setStatus(int newStatus)
newStatus
- the new statuspublic short getModCount()
public void setModCount(short modCount)
modCount
- the modification count of this itempublic void discard()
public boolean hasOverlayedState()
true
if this item state is overlying persistent
state, otherwise false
.public ItemState getOverlayedState()
null
if there is no persistent state (i.e.. this
state is purely transient).null
if there is
no persistent state.public void setContainer(ItemStateListener container)
container
- container to be informed on modificationspublic ItemStateListener getContainer()
null
if none has been yet assigned.null
public abstract long calculateMemoryFootprint()
Copyright © 2004–2021 The Apache Software Foundation. All rights reserved.