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
ItemImplimplements theIteminterface.
-
-
Field Summary
Fields Modifier and Type Field Description protected ItemDatadataItem data associated with this item.protected ItemIdidprotected ItemManageritemMgrItemManagerthat created thisItemprotected SessionContextsessionContextThe component context of the session to which this item is associated.protected SessionItemStateManagerstateMgrSessionItemStateManagerassociated with thisItemprotected static intSTATUS_DESTROYEDprotected static intSTATUS_INVALIDATEDprotected static intSTATUS_MODIFIEDprotected static intSTATUS_NORMAL
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract voidaccept(ItemVisitor visitor)ItemgetAncestor(int degree)intgetDepth()ItemIdgetId()Return the id of thisItem.abstract StringgetName()protected abstract ItemStategetOrCreateTransientItemState()abstract NodegetParent()StringgetPath()PathgetPrimaryPath()Returns the primary path to thisItem.abstract NamegetQName()protected NamegetQName(String name)Utility method that converts the given string into a qualified JCR name.SessiongetSession()Returns the session associated with this item.protected intgetType(Value[] values)Utility method that returns the type of the first of the given values, orPropertyType.UNDEFINEDwhen given no values.protected ValueFactorygetValueFactory()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 typebooleanisModified()booleanisNew()abstract booleanisNode()booleanisSame(Item otherItem)protected booleanisTransactionalNew()checks if this item is new.protected booleanisTransient()protected voiditemSanityCheck()Checks the status of this item.protected abstract voidmakePersistent()protected <T> Tperform(SessionOperation<T> operation)voidrefresh(boolean keepChanges)voidremove()StringsafeGetJCRPath()Failsafe mapping of internalidto JCR path for use in diagnostic output, error messages etc.protected voidsanityCheck()Performs a sanity check on this item and the associated session.voidsave()protected voidsetRemoved()Marks this instance as 'removed' and notifies its listeners.StringtoString()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
ItemManagerthat created thisItem
-
stateMgr
protected final SessionItemStateManager stateMgr
SessionItemStateManagerassociated with thisItem
-
-
Method Detail
-
perform
protected <T> T perform(SessionOperation<T> operation) throws RepositoryException
- Throws:
RepositoryException
-
sanityCheck
protected void sanityCheck() throws RepositoryExceptionPerforms 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 RepositoryExceptionChecks 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 RepositoryExceptionMarks 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 internalidto 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.UNDEFINEDwhen 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:
acceptin interfaceItem- Throws:
RepositoryException
-
getName
public abstract String getName() throws RepositoryException
- Specified by:
getNamein interfaceItem- Throws:
RepositoryException
-
getParent
public abstract Node getParent() throws ItemNotFoundException, AccessDeniedException, RepositoryException
- Specified by:
getParentin interfaceItem- Throws:
ItemNotFoundExceptionAccessDeniedExceptionRepositoryException
-
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:
isModifiedin interfaceItem
-
remove
public void remove() throws RepositoryException- Specified by:
removein interfaceItem- Throws:
RepositoryException
-
save
public void save() throws RepositoryException- Specified by:
savein interfaceItem- Throws:
RepositoryException
-
refresh
public void refresh(boolean keepChanges) throws RepositoryException- Specified by:
refreshin interfaceItem- Throws:
RepositoryException
-
getAncestor
public Item getAncestor(int degree) throws RepositoryException
- Specified by:
getAncestorin interfaceItem- Throws:
RepositoryException
-
getPath
public String getPath() throws RepositoryException
- Specified by:
getPathin interfaceItem- Throws:
RepositoryException
-
getDepth
public int getDepth() throws RepositoryException- Specified by:
getDepthin 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:
getSessionin interfaceItem- Returns:
- current session
- See Also:
- Issue JCR-911
-
isSame
public boolean isSame(Item otherItem) throws RepositoryException
- Specified by:
isSamein interfaceItem- Throws:
RepositoryException
-
-