|
|||||||||
| Home >> All >> com >> port80 >> eclipse >> jdt >> [ util overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
com.port80.eclipse.jdt.util
Class PersistentItem

java.lang.Objectcom.port80.eclipse.jdt.util.PersistentItem
- All Implemented Interfaces:
- org.eclipse.core.runtime.IAdaptable, org.eclipse.ui.IElementFactory, org.eclipse.ui.IPersistableElement
- Direct Known Subclasses:
- PersistentFolder
- public class PersistentItem
- extends java.lang.Object
- implements org.eclipse.ui.IPersistableElement, org.eclipse.ui.IElementFactory, org.eclipse.core.runtime.IAdaptable
- extends java.lang.Object
Wrapper around object to make it a tree item and persistable.
Currently, valid objects that can be persisted are IType, IMethod, other object type are not persisted.
Each item is uniquely identified by its Kind, FullName, FullPath, Project. Items with the fields equal is the same item.
When the presistable object is resolved to an actual object in the workspace, it is cached and subsequently return by getCached(). Use resolve() to force resolving again.
Used by MethodView and WorkingSetView to save history objects.
| Field Summary | |
static int |
CLASS
|
private static boolean |
DEBUG
|
private java.sql.Timestamp |
fAccessTime
|
private java.lang.String |
fAnnotation
|
private java.lang.Object |
fCached
|
private int |
fCount
Number of visits. |
private java.sql.Timestamp |
fCreateTime
|
private int |
fExternal
A flag (the name is obsoleted). |
private java.lang.String |
fFullName
Full name eg. |
private java.lang.String |
fFullPath
Full path to the object's underlying resource, relative to workspace root or absolute if resource is external to workspace. |
static int |
FILE
|
private int |
fKind
|
private java.lang.String |
fName
Short name of the item, eg. |
static int |
FOLDER
|
private java.lang.String |
fParent
The parent folder name. |
private java.lang.String |
fProject
Project name in workspace. |
private int |
fStatus
|
private static org.eclipse.swt.graphics.Image |
ICON_ERROR
|
private static org.eclipse.swt.graphics.Image |
ICON_OPEN_FOLDER
|
private static org.eclipse.swt.graphics.Image[] |
ICONS
Icons for the item (without any java decoration). |
static java.lang.String |
ID
|
static int |
INTERFACE
|
static int |
IS_ACTIVE
|
static int |
IS_ERR
|
static int |
IS_NOTEXIST
|
static java.lang.String[] |
KIND_NAMES
|
static int |
METHOD
|
static java.lang.String |
NAME
|
static int |
NONE
|
| Constructor Summary | |
private |
PersistentItem()
|
|
PersistentItem(int kind,
java.lang.String name)
|
| Method Summary | |
java.lang.Object |
clone()
This method may be called to create a new copy of the Object. |
static PersistentItem |
create(java.lang.Object a)
Static factory method to create a PersistentItem. |
static PersistentItem |
create(java.lang.Object a,
java.lang.String parent)
|
org.eclipse.core.runtime.IAdaptable |
createElement(org.eclipse.ui.IMemento m)
Re-creates and returns an object from the state captured within the given memento. |
boolean |
equals(java.lang.Object a)
Determine whether this Object is semantically equal to another Object. |
java.lang.Object |
getAdapter(java.lang.Class c)
Returns an object which is an instance of the given class associated with this object. |
java.lang.String |
getAnnotation()
|
java.sql.Timestamp |
getATime()
|
java.lang.Object |
getCached()
Get the cached object if it have been resolved, else resolve to an actual object, cache it and return it. |
int |
getCount()
|
java.sql.Timestamp |
getCTime()
|
java.lang.String |
getFactoryId()
Returns the id of the element factory which should be used to re-create this object. |
java.lang.String |
getFullName()
|
java.lang.String |
getFullPath()
|
org.eclipse.swt.graphics.Image |
getImage()
|
private int |
getIntDef(org.eclipse.ui.IMemento m,
java.lang.String key,
int def)
|
int |
getKind()
|
java.lang.String |
getKindName()
|
java.lang.String |
getName()
|
java.lang.String |
getParent()
|
java.lang.String |
getProject()
|
int |
getStatus()
|
int |
hashCode()
Get a value that represents this Object, as uniquely as possible within the confines of an int. |
private PersistentItem |
init(java.lang.Object a)
|
private PersistentItem |
initFile(org.eclipse.core.resources.IFile file)
|
private PersistentItem |
initJavaElement(org.eclipse.jdt.core.IJavaElement element)
|
boolean |
isActive()
|
boolean |
isExternal()
|
boolean |
isNotExist()
|
java.lang.Object |
resolve()
|
private org.eclipse.core.resources.IFile |
resolveFile()
|
private org.eclipse.jdt.core.IJavaElement |
resolveJavaElement()
Resolve the persistable reference to an actual object. |
static PersistentItem |
restore(org.eclipse.ui.IMemento m)
Static factory method to create a PersistentItem from an IMemento. |
org.eclipse.core.runtime.IAdaptable |
restoreState(org.eclipse.ui.IMemento m)
|
void |
saveState(org.eclipse.ui.IMemento m)
Saves the state of the object in the given memento. |
void |
setActive(boolean isactive)
|
void |
setAnnotation(java.lang.String text)
|
void |
setATime(java.sql.Timestamp t)
|
void |
setParent(java.lang.String parent)
|
java.lang.String |
toString()
String representation in format: Parent*Project@FullPath#FullName:KindName. |
| Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
NAME
public static final java.lang.String NAME
- See Also:
- Constant Field Values
ID
public static final java.lang.String ID
- See Also:
- Constant Field Values
KIND_NAMES
public static final java.lang.String[] KIND_NAMES
NONE
public static final int NONE
- See Also:
- Constant Field Values
CLASS
public static final int CLASS
- See Also:
- Constant Field Values
INTERFACE
public static final int INTERFACE
- See Also:
- Constant Field Values
METHOD
public static final int METHOD
- See Also:
- Constant Field Values
FOLDER
public static final int FOLDER
- See Also:
- Constant Field Values
FILE
public static final int FILE
- See Also:
- Constant Field Values
IS_ERR
public static final int IS_ERR
- See Also:
- Constant Field Values
IS_NOTEXIST
public static final int IS_NOTEXIST
- See Also:
- Constant Field Values
IS_ACTIVE
public static final int IS_ACTIVE
- See Also:
- Constant Field Values
DEBUG
private static final boolean DEBUG
- See Also:
- Constant Field Values
ICONS
private static final org.eclipse.swt.graphics.Image[] ICONS
- Icons for the item (without any java decoration).
ICON_ERROR
private static final org.eclipse.swt.graphics.Image ICON_ERROR
ICON_OPEN_FOLDER
private static final org.eclipse.swt.graphics.Image ICON_OPEN_FOLDER
fKind
private int fKind
fCount
private int fCount
- Number of visits.
fName
private java.lang.String fName
- Short name of the item, eg. simple type name or method signature.
fFullName
private java.lang.String fFullName
- Full name eg. FullyQualifiedName of types or type qualified method signature.
fFullPath
private java.lang.String fFullPath
- Full path to the object's underlying resource, relative to workspace root
or absolute if resource is external to workspace.
fProject
private java.lang.String fProject
- Project name in workspace.
fExternal
private int fExternal
- A flag (the name is obsoleted). For JavaElement, 1 for binary, 0 for source.
fAnnotation
private java.lang.String fAnnotation
fCreateTime
private java.sql.Timestamp fCreateTime
fAccessTime
private java.sql.Timestamp fAccessTime
fParent
private java.lang.String fParent
- The parent folder name.
fCached
private java.lang.Object fCached
fStatus
private int fStatus
| Constructor Detail |
PersistentItem
private PersistentItem()
PersistentItem
public PersistentItem(int kind,
java.lang.String name)
| Method Detail |
create
public static PersistentItem create(java.lang.Object a)
- Static factory method to create a PersistentItem.
create
public static PersistentItem create(java.lang.Object a, java.lang.String parent)
restore
public static PersistentItem restore(org.eclipse.ui.IMemento m)
- Static factory method to create a PersistentItem from an IMemento.
clone
public java.lang.Object clone()
- Description copied from class:
java.lang.Object - This method may be called to create a new copy of the
Object. The typical behavior is as follows:
o == o.clone()is falseo.getClass() == o.clone().getClass()is trueo.equals(o)is true
However, these are not strict requirements, and may be violated if necessary. Of the three requirements, the last is the most commonly violated, particularly if the subclass does not override Object.equals(Object)>
Object.equals(Object)55 .If the Object you call clone() on does not implement java.lang.Cloneable (which is a placeholder interface), then a CloneNotSupportedException is thrown. Notice that Object does not implement Cloneable; this method exists as a convenience for subclasses that do.
Object's implementation of clone allocates space for the new Object using the correct class, without calling any constructors, and then fills in all of the new field values with the old field values. Thus, it is a shallow copy. However, subclasses are permitted to make a deep copy.
All array types implement Cloneable, and override this method as follows (it should never fail):
public Object clone() { try { super.clone(); } catch (CloneNotSupportedException e) { throw new InternalError(e.getMessage()); } }
init
private PersistentItem init(java.lang.Object a)
initJavaElement
private PersistentItem initJavaElement(org.eclipse.jdt.core.IJavaElement element)
initFile
private PersistentItem initFile(org.eclipse.core.resources.IFile file)
setParent
public void setParent(java.lang.String parent)
setActive
public void setActive(boolean isactive)
setATime
public void setATime(java.sql.Timestamp t)
setAnnotation
public void setAnnotation(java.lang.String text)
getParent
public java.lang.String getParent()
isExternal
public boolean isExternal()
isActive
public boolean isActive()
isNotExist
public boolean isNotExist()
getStatus
public int getStatus()
getKind
public int getKind()
getKindName
public java.lang.String getKindName()
getCount
public int getCount()
getName
public java.lang.String getName()
getFullName
public java.lang.String getFullName()
getFullPath
public java.lang.String getFullPath()
getProject
public java.lang.String getProject()
getAnnotation
public java.lang.String getAnnotation()
getATime
public java.sql.Timestamp getATime()
getCTime
public java.sql.Timestamp getCTime()
getImage
public org.eclipse.swt.graphics.Image getImage()
getFactoryId
public java.lang.String getFactoryId()
- Description copied from interface:
org.eclipse.ui.IPersistableElement - Returns the id of the element factory which should be used to re-create this
object.
Factory ids are declared in extensions to the standard extension point
"org.eclipse.ui.elementFactories".- Specified by:
getFactoryIdin interfaceorg.eclipse.ui.IPersistableElement
saveState
public void saveState(org.eclipse.ui.IMemento m)
- Description copied from interface:
org.eclipse.ui.IPersistableElement - Saves the state of the object in the given memento.
- Specified by:
saveStatein interfaceorg.eclipse.ui.IPersistableElement
createElement
public org.eclipse.core.runtime.IAdaptable createElement(org.eclipse.ui.IMemento m)
- Description copied from interface:
org.eclipse.ui.IElementFactory - Re-creates and returns an object from the state captured within the given
memento.
Under normal circumstances, the resulting object can be expected to be persistable; that is,
result.getAdapter(org.eclipse.ui.IPersistableElement.class)
should not returnnull.- Specified by:
createElementin interfaceorg.eclipse.ui.IElementFactory
restoreState
public org.eclipse.core.runtime.IAdaptable restoreState(org.eclipse.ui.IMemento m)
getAdapter
public java.lang.Object getAdapter(java.lang.Class c)
- Description copied from interface:
org.eclipse.core.runtime.IAdaptable - Returns an object which is an instance of the given class
associated with this object. Returns
nullif no such object can be found.- Specified by:
getAdapterin interfaceorg.eclipse.core.runtime.IAdaptable
getCached
public java.lang.Object getCached()
- Get the cached object if it have been resolved,
else resolve to an actual object, cache it and return it.
resolve
public java.lang.Object resolve()
resolveFile
private org.eclipse.core.resources.IFile resolveFile()
resolveJavaElement
private org.eclipse.jdt.core.IJavaElement resolveJavaElement()
- Resolve the persistable reference to an actual object.
If cahed object does not equal to the resolved object, the cache it cleared.
If cached object equals to the resolved object, it stay in the cache.
hashCode
public int hashCode()
- Description copied from class:
java.lang.Object - Get a value that represents this Object, as uniquely as
possible within the confines of an int.
There are some requirements on this method which subclasses must follow:
- Semantic equality implies identical hashcodes. In other
words, if
a.equals(b)is true, thena.hashCode() == b.hashCode()must be as well. However, the reverse is not necessarily true, and two objects may have the same hashcode without being equal. - It must be consistent. Whichever value o.hashCode() returns on the first invocation must be the value returned on all later invocations as long as the object exists. Notice, however, that the result of hashCode may change between separate executions of a Virtual Machine, because it is not invoked on the same object.
Notice that since
hashCodeis used in java.util.Hashtable and other hashing classes, a poor implementation will degrade the performance of hashing (so don't blindly implement it as returning a constant!). Also, if calculating the hash is time-consuming, a class may consider caching the results.The default implementation returns
System.identityHashCode(this) - Semantic equality implies identical hashcodes. In other
words, if
equals
public boolean equals(java.lang.Object a)
- Description copied from class:
java.lang.Object - Determine whether this Object is semantically equal
to another Object.
There are some fairly strict requirements on this method which subclasses must follow:
- It must be transitive. If
a.equals(b)andb.equals(c), thena.equals(c)must be true as well. - It must be symmetric.
a.equals(b)andb.equals(a)must have the same value. - It must be reflexive.
a.equals(a)must always be true. - It must be consistent. Whichever value a.equals(b) returns on the first invocation must be the value returned on all later invocations.
a.equals(null)must be false.- It must be consistent with hashCode(). That is,
a.equals(b)must implya.hashCode() == b.hashCode(). The reverse is not true; two objects that are not equal may have the same hashcode, but that has the potential to harm hashing performance.
This is typically overridden to throw a java.lang.ClassCastException if the argument is not comparable to the class performing the comparison, but that is not a requirement. It is legal for
a.equals(b)to be true even thougha.getClass() != b.getClass(). Also, it is typical to never cause a java.lang.NullPointerException.In general, the Collections API (
java.util) use theequalsmethod rather than the==operator to compare objects. However, java.util.IdentityHashMap is an exception to this rule, for its own good reasons.The default implementation returns
this == o. - It must be transitive. If
toString
public java.lang.String toString()
- String representation in format: Parent*Project@FullPath#FullName:KindName.
getIntDef
private int getIntDef(org.eclipse.ui.IMemento m, java.lang.String key, int def)
|
|||||||||
| Home >> All >> com >> port80 >> eclipse >> jdt >> [ util overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC
com.port80.eclipse.jdt.util.PersistentItem