Package org.apache.jackrabbit.core
Class ItemImpl
- java.lang.Object
-
- org.apache.jackrabbit.core.ItemImpl
-
- All Implemented Interfaces:
Item
- Direct Known Subclasses:
NodeImpl
,PropertyImpl
public abstract class ItemImpl extends Object implements Item
ItemImpl
implements theItem
interface.
-
-
Field Summary
Fields Modifier and Type Field Description protected ItemData
data
Item data associated with this item.protected ItemId
id
protected ItemManager
itemMgr
ItemManager
that created thisItem
protected SessionContext
sessionContext
The component context of the session to which this item is associated.protected SessionItemStateManager
stateMgr
SessionItemStateManager
associated with thisItem
protected static int
STATUS_DESTROYED
protected static int
STATUS_INVALIDATED
protected static int
STATUS_MODIFIED
protected static int
STATUS_NORMAL
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract void
accept(ItemVisitor visitor)
Item
getAncestor(int degree)
int
getDepth()
ItemId
getId()
Return the id of thisItem
.abstract String
getName()
protected abstract ItemState
getOrCreateTransientItemState()
abstract Node
getParent()
String
getPath()
Path
getPrimaryPath()
Returns the primary path to thisItem
.abstract Name
getQName()
protected Name
getQName(String name)
Utility method that converts the given string into a qualified JCR name.Session
getSession()
Returns the session associated with this item.protected int
getType(Value[] values)
Utility method that returns the type of the first of the given values, orPropertyType.UNDEFINED
when given no values.protected ValueFactory
getValueFactory()
Utility method that returns the value factory of this session.protected Value[]
getValues(String[] values, int type)
Utility method that converts the given strings into JCR values of the given typeboolean
isModified()
boolean
isNew()
abstract boolean
isNode()
boolean
isSame(Item otherItem)
protected boolean
isTransactionalNew()
checks if this item is new.protected boolean
isTransient()
protected void
itemSanityCheck()
Checks the status of this item.protected abstract void
makePersistent()
protected <T> T
perform(SessionOperation<T> operation)
void
refresh(boolean keepChanges)
void
remove()
String
safeGetJCRPath()
Failsafe mapping of internalid
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.String
toString()
Returns the(safe
) path of this item for use in diagnostic output.
-
-
-
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
-
id
protected final ItemId id
-
sessionContext
protected final SessionContext sessionContext
The component context of the session to which this item is associated.
-
data
protected final ItemData data
Item data associated with this item.
-
itemMgr
protected final ItemManager itemMgr
ItemManager
that created thisItem
-
stateMgr
protected final SessionItemStateManager stateMgr
SessionItemStateManager
associated with thisItem
-
-
Method Detail
-
perform
protected <T> T perform(SessionOperation<T> operation) throws RepositoryException
- Throws:
RepositoryException
-
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
-
itemSanityCheck
protected void itemSanityCheck() throws RepositoryException
Checks the status of this item.- Throws:
RepositoryException
- if this item no longer exists
-
isTransient
protected boolean isTransient()
-
getOrCreateTransientItemState
protected abstract ItemState getOrCreateTransientItemState() throws RepositoryException
- Throws:
RepositoryException
-
makePersistent
protected abstract void makePersistent() throws RepositoryException
- Throws:
RepositoryException
-
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
-
getId
public ItemId getId()
Return the id of thisItem
.- Returns:
- the id of this
Item
-
getPrimaryPath
public Path getPrimaryPath() throws RepositoryException
Returns the primary path to thisItem
.- Returns:
- the primary path to this
Item
- Throws:
RepositoryException
-
safeGetJCRPath
public String safeGetJCRPath()
Failsafe mapping of internalid
to JCR path for use in diagnostic output, error messages etc.- Returns:
- JCR path or some fallback value
-
getQName
public abstract Name getQName() throws RepositoryException
- Returns:
- the name of this item as
Name
- Throws:
RepositoryException
- if an error occurs.
-
getQName
protected Name getQName(String name) throws RepositoryException
Utility method that converts the given string into a qualified JCR name.- Parameters:
name
- name string- Returns:
- qualified name
- Throws:
RepositoryException
- if the given name is invalid
-
getValueFactory
protected ValueFactory getValueFactory() throws RepositoryException
Utility method that returns the value factory of this session.- Returns:
- value factory
- Throws:
RepositoryException
- if the value factory is not available
-
getValues
protected Value[] getValues(String[] values, int type) throws RepositoryException
Utility method that converts the given strings into JCR values of the given type- Parameters:
values
- value stringstype
- value type- Returns:
- JCR values
- Throws:
RepositoryException
- if the values can not be converted
-
getType
protected int getType(Value[] values)
Utility method that returns the type of the first of the given values, orPropertyType.UNDEFINED
when given no values.- Parameters:
values
- given values, ornull
- Returns:
- value type, or
PropertyType.UNDEFINED
-
accept
public abstract void accept(ItemVisitor visitor) throws RepositoryException
- Specified by:
accept
in interfaceItem
- Throws:
RepositoryException
-
getName
public abstract String getName() throws RepositoryException
- Specified by:
getName
in interfaceItem
- Throws:
RepositoryException
-
getParent
public abstract Node getParent() throws ItemNotFoundException, AccessDeniedException, RepositoryException
- Specified by:
getParent
in interfaceItem
- Throws:
ItemNotFoundException
AccessDeniedException
RepositoryException
-
isTransactionalNew
protected boolean isTransactionalNew()
checks if this item is new. running outside of transactions, this is the same asisNew()
but within a transaction an item can be saved but not yet persisted.
-
isModified
public boolean isModified()
- Specified by:
isModified
in interfaceItem
-
remove
public void remove() throws RepositoryException
- Specified by:
remove
in interfaceItem
- Throws:
RepositoryException
-
save
public void save() throws RepositoryException
- Specified by:
save
in interfaceItem
- Throws:
RepositoryException
-
refresh
public void refresh(boolean keepChanges) throws RepositoryException
- Specified by:
refresh
in interfaceItem
- Throws:
RepositoryException
-
getAncestor
public Item getAncestor(int degree) throws RepositoryException
- Specified by:
getAncestor
in interfaceItem
- Throws:
RepositoryException
-
getPath
public String getPath() throws RepositoryException
- Specified by:
getPath
in interfaceItem
- Throws:
RepositoryException
-
getDepth
public int getDepth() throws RepositoryException
- Specified by:
getDepth
in interfaceItem
- Throws:
RepositoryException
-
getSession
public Session getSession()
Returns the session associated with this item.Since Jackrabbit 1.4 it is safe to use this method regardless of item state.
- Specified by:
getSession
in interfaceItem
- Returns:
- current session
- See Also:
- Issue JCR-911
-
isSame
public boolean isSame(Item otherItem) throws RepositoryException
- Specified by:
isSame
in interfaceItem
- Throws:
RepositoryException
-
-