atg.repository
Class RepositoryItemImpl

java.lang.Object
  extended by atg.repository.RepositoryItemImpl
All Implemented Interfaces:
DisplayableItem, MutableRepositoryItem, atg.repository.RepositoryChangedItem, RepositoryItem, java.io.Serializable, java.lang.Comparable

public abstract class RepositoryItemImpl
extends java.lang.Object
implements MutableRepositoryItem, atg.repository.RepositoryChangedItem, java.io.Serializable, java.lang.Comparable

See Also:
Serialized Form

Field Summary
static java.lang.String CLASS_VERSION
           
static atg.repository.RepositoryItemImpl.NullObject NULL_OBJECT
           
 
Constructor Summary
RepositoryItemImpl(ItemDescriptorImpl pDesc)
          The item descriptor for this item
 
Method Summary
 int compareTo(java.lang.Object pOther)
          Compares this item to another Object.
 boolean equals(java.lang.Object pObject)
          Are these the same item?
 RepositoryItemDescriptor getItemDescriptor()
          Returns the RepositoryItemDescriptor property, which describes the known properties for the item.
protected  ItemDescriptorImpl getItemDescriptorImpl()
          Returns the item descriptor implementation class without throwing an exception and to avoid casting on every method call.
 java.lang.String getItemDisplayName()
          The name of this item which can be used in a UI.
abstract  java.lang.Object getOldPropertyValue(RepositoryPropertyDescriptor pDesc)
          Returns the value of this property not including any changes made by this transaction.
 java.lang.Object getPropertyValue(RepositoryPropertyDescriptor pDesc)
          This method is typically overridden by sub-classes.
 java.lang.Object getPropertyValue(java.lang.String pPropertyName)
          Returns the property of the given name.
 Repository getRepository()
          Returns the Repository which contains this item
abstract  java.lang.String getRepositoryId()
          Returns the unique id associated with this object in the repository.
protected  RepositoryImpl getRepositoryImpl()
           
 RepositoryItemImpl getWrappedItem()
           
 int hashCode()
          Make sure that the hashCode's match the equals method.
 boolean isMutable()
          Is this repository mutable?
abstract  boolean isRemoved()
          Returns true if this item has been removed.
abstract  boolean isTransient()
          Is this item in the repository yet?
 java.lang.String printItem()
          Returns the String representation of this object.
abstract  void removePropertyValueFromCache(RepositoryPropertyDescriptor pDesc)
          This method is called from user defined property types when they want to store a value in the cache for this particular property.
 void setItemDescriptor(RepositoryItemDescriptor pItemDescriptor)
          This method should only be used by adapter implementations, not by clients of the repository api.
abstract  void setPropertyValue(RepositoryPropertyDescriptor pDesc, java.lang.Object pValue)
          Sets the given property for a particular property descriptor.
 void setPropertyValue(java.lang.String pPropertyName, java.lang.Object pPropertyValue)
          Sets the property of the given name with the supplied object.
abstract  void setPropertyValueInCache(RepositoryPropertyDescriptor pDesc, java.lang.Object pValue)
          This method is called from user defined property types when they want to store a value in the cache for this particular property.
protected  void setPropertyValueUnChecked(java.lang.String pPropertyName, java.lang.Object pPropertyValue)
          Sets the property of the given name with the supplied object.
protected abstract  void setRemoved(boolean pRemoved)
          Called from the readObject method when we try to restore a reference to an item which has been removed.
abstract  void setRepositoryId(java.lang.String pId)
          If a user changes the id of an "id property", you need to implement this method.
protected abstract  void setTransient(boolean pTransient)
          Called from the readObject method to make this item transient
 void setWrappedItem(RepositoryItemImpl pWrappedItem)
          Sets the property WrappedItem.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

CLASS_VERSION

public static java.lang.String CLASS_VERSION

NULL_OBJECT

public static final atg.repository.RepositoryItemImpl.NullObject NULL_OBJECT
Constructor Detail

RepositoryItemImpl

public RepositoryItemImpl(ItemDescriptorImpl pDesc)
The item descriptor for this item

Method Detail

getRepositoryId

public abstract java.lang.String getRepositoryId()
Returns the unique id associated with this object in the repository. The String representation should be a platform independant notation that can be used outside the Java language. (e.g. used with HTTP Cookies).

Specified by:
getRepositoryId in interface RepositoryItem

setRepositoryId

public abstract void setRepositoryId(java.lang.String pId)
If a user changes the id of an "id property", you need to implement this method. We only support changing of ids for transient items, those that are not yet in the repository.


isRemoved

public abstract boolean isRemoved()
                           throws RepositoryException
Returns true if this item has been removed. This method should also ensure that this item is still available in this transaction (i.e. you won't get errors trying to manipulate the item because someone else removed it).

Throws:
RepositoryException

getPropertyValue

public java.lang.Object getPropertyValue(java.lang.String pPropertyName)
Returns the property of the given name. This implementation will return values for "group" properties and the default value. You should override the getPropertyValue(RepositoryPropertyDescriptor) method to implement retrieval of persistent properties for your repository.

Specified by:
getPropertyValue in interface RepositoryItem

getOldPropertyValue

public abstract java.lang.Object getOldPropertyValue(RepositoryPropertyDescriptor pDesc)
Returns the value of this property not including any changes made by this transaction.

Specified by:
getOldPropertyValue in interface atg.repository.RepositoryChangedItem
Parameters:
pPropertyDescriptor - property to get

setPropertyValue

public abstract void setPropertyValue(RepositoryPropertyDescriptor pDesc,
                                      java.lang.Object pValue)
Sets the given property for a particular property descriptor.


setPropertyValueInCache

public abstract void setPropertyValueInCache(RepositoryPropertyDescriptor pDesc,
                                             java.lang.Object pValue)
This method is called from user defined property types when they want to store a value in the cache for this particular property. Sub-classes should implement this method so that it holds onto the property in a cache of values stored for this item.


removePropertyValueFromCache

public abstract void removePropertyValueFromCache(RepositoryPropertyDescriptor pDesc)
This method is called from user defined property types when they want to store a value in the cache for this particular property. Sub-classes should implement this method so that it holds onto the property in a cache of values stored for this item.


setPropertyValue

public void setPropertyValue(java.lang.String pPropertyName,
                             java.lang.Object pPropertyValue)
Sets the property of the given name with the supplied object. This implementation adds this value into the list of changes that it maintains for this item. These values are retrieved by the getPropertyValue method and are applied to the underlying item when the item is updated.

This method is in here despite the fact that this is not a MutableRepositoryItem. If your implementation uses this base class for its mutable repository, you can just use this method to do preprocessing and then implement the version which takes a RepositoryPropertyDescriptor instead of a name.

Specified by:
setPropertyValue in interface MutableRepositoryItem

setPropertyValueUnChecked

protected void setPropertyValueUnChecked(java.lang.String pPropertyName,
                                         java.lang.Object pPropertyValue)
Sets the property of the given name with the supplied object. This implementation adds this value into the list of changes that it maintains for this item. These values are retrieved by the getPropertyValue method and are applied to the underlying item when the item is updated.

This method is in here despite the fact that this is not a MutableRepositoryItem. If your implementation uses this base class for its mutable repository, you can just use this method to do preprocessing and then implement the version which takes a RepositoryPropertyDescriptor instead of a name. Note: Internal method to allow bypassing various checks


getPropertyValue

public java.lang.Object getPropertyValue(RepositoryPropertyDescriptor pDesc)
This method is typically overridden by sub-classes. If your repository implementation does not understand this type of property descriptor, it can just call this super method to retrieve a value of a user-defined property. This method will also return the default value if you do not have a value defined for this item.


getRepository

public Repository getRepository()
Returns the Repository which contains this item

Specified by:
getRepository in interface RepositoryItem

getItemDescriptor

public final RepositoryItemDescriptor getItemDescriptor()
Returns the RepositoryItemDescriptor property, which describes the known properties for the item. If you need to override this method, you should override getItemDescriptorImpl instead.

Specified by:
getItemDescriptor in interface RepositoryItem

setItemDescriptor

public void setItemDescriptor(RepositoryItemDescriptor pItemDescriptor)
This method should only be used by adapter implementations, not by clients of the repository api.


getItemDisplayName

public java.lang.String getItemDisplayName()
Description copied from interface: DisplayableItem
The name of this item which can be used in a UI.

Specified by:
getItemDisplayName in interface DisplayableItem
Returns:
The value of the read-only property ItemDisplayName.

isMutable

public boolean isMutable()
Is this repository mutable?


getRepositoryImpl

protected RepositoryImpl getRepositoryImpl()

getItemDescriptorImpl

protected ItemDescriptorImpl getItemDescriptorImpl()
Returns the item descriptor implementation class without throwing an exception and to avoid casting on every method call.


isTransient

public abstract boolean isTransient()
Is this item in the repository yet?

Specified by:
isTransient in interface RepositoryItem

setTransient

protected abstract void setTransient(boolean pTransient)
Called from the readObject method to make this item transient


setRemoved

protected abstract void setRemoved(boolean pRemoved)
Called from the readObject method when we try to restore a reference to an item which has been removed. In this case, you should throw exceptions when someone tries to get/set values in a removed item.


compareTo

public int compareTo(java.lang.Object pOther)
Compares this item to another Object. If the Object is a RepositoryItem, this method compares the two items by their repository ids. Otherwise, it throws a ClassCastException.

Nota Bene: the item descriptor is not considered in the comparsion for performance, and because Collections of repository items sorted with this method are intended to have the same item descriptor. This means that this method is not consistent with equals. In order to put RepositoryItems into a SortedSet or SortedMap the Set or Map must have a non null Comparator anyway, since RepositoryItem does not currently implement Comparable.

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
pOther - the Object to be compared.
Returns:
getRepositoryId().compareTo(pOther.getRepositoryId())
Throws:
ClassCastException - if the argument is not a RepositoryItem.
See Also:
java.util.Comparable, SortedSet, SortDirectives

equals

public boolean equals(java.lang.Object pObject)
Are these the same item?

Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Make sure that the hashCode's match the equals method.

Overrides:
hashCode in class java.lang.Object

printItem

public java.lang.String printItem()
Returns the String representation of this object.


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

setWrappedItem

public void setWrappedItem(RepositoryItemImpl pWrappedItem)
Sets the property WrappedItem. This gets set when this object is constructed from a deserialization. We pass through any calls to get/set values so that we always use an item retrieved from the repository. This allows the repository to synchronize access to set and gets on a single object.

Parameters:
pWrappedItem - new value to set

getWrappedItem

public RepositoryItemImpl getWrappedItem()
Returns:
The value of the property WrappedItem.