|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.metamatrix.common.namedobject.BaseID
public abstract class BaseID
The BaseID class serves as the abstract base class for identifiers of objects. This class provides the method signatures common to all ID classes as well as the majority of the implementation, and defines an identification name as a list of one or more non-zero length atomic name components delimeted by a '.' (similar to JNDI names).
Because it is possible and likely that MetaMatrix client applications will construct new instances of identifier classes, these ID concepts in this framework are implemented as classes.
These classes are shipped between the client and Configuration Service, so the BaseID class is serializable. To speed serialization and decrease the overhead of shipping BaseID across the network using RMI, several instance variables that may not be required by all users are made transient and recomputed as needed.
Additionally, because IDs are designed
to be used as primary keys, the hashCode
, equals
and compareTo
methods are all consistent and optimized for
fast performance. This is in part accomplished by caching the hash code value,
which is tolerable since all BaseID subclasses are immutable: they
cannot be modified after they have been created.
Finally, several key methods that are very commonly used and that will not be
overridden in subclasses are marked as final
as an inlining hint to the
compiler.
Field Summary | |
---|---|
protected java.util.List |
atomicNames
Ordered list of atomic name components. |
static java.lang.String |
DELIMITER
The character that delimits the atomic components of the name |
protected java.lang.String |
fullName
The fully-qualified name of the node. |
static java.lang.String |
WILDCARD
The wildcard character. |
Constructor Summary | |
---|---|
|
BaseID(java.lang.String fullName)
Create an instance with the specified full name. |
protected |
BaseID(java.lang.String fullName,
int checkLevel)
|
Method Summary | |
---|---|
java.lang.Object |
clone()
Return a deep cloned instance of this object. |
int |
compareTo(java.lang.Object obj)
Compares this object to another. |
int |
compareToByName(java.lang.Object obj)
Compares this object to another lexicographically. |
protected int |
computeHashCode()
Return a new hash code value for this instance. |
boolean |
equals(java.lang.Object obj)
Returns true if the specified object is semantically equal to this instance. |
java.lang.String |
getFullName()
Obtain the full name for the object that this identifier represents. |
java.lang.String |
getName()
Obtain the last name component this identifier. |
java.lang.String |
getNameComponent(int index)
Obtain the specified component of the name. |
java.util.List |
getNameComponents()
Obtain the list of atomic name components for this ID. |
java.lang.String |
getParentFullName()
Return the full name of the parent. |
int |
hashCode()
Returns the hash code value for this object. |
boolean |
hasParent()
|
int |
size()
Return the number of atomic name components in this identifier. |
java.lang.String |
toString()
Returns a string representing the current state of the object. |
protected void |
updateHashCode()
Update the currently cached hash code value with a newly computed one. |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String DELIMITER
public static final java.lang.String WILDCARD
protected java.lang.String fullName
protected transient java.util.List atomicNames
Constructor Detail |
---|
public BaseID(java.lang.String fullName)
fullName
- the string form of the full name from which this object is to be created;
never null and never zero-length.
java.lang.IllegalArgumentException
- if the full name is nullprotected BaseID(java.lang.String fullName, int checkLevel)
Method Detail |
---|
public final java.lang.String getFullName()
public java.lang.String getName()
public final java.lang.String getNameComponent(int index)
the
- index of the atomic name component to return; must be less than
the result of the method size
in order to be valid.
java.lang.IndexOutOfBoundsException
- if the index is not valid and is out of the bounds of this name.public java.util.List getNameComponents()
java.lang.IndexOutOfBoundsException
- if the index is not valid and is out of the bounds of this name.public final int size()
public boolean equals(java.lang.Object obj)
compareTo()
.
equals
in class java.lang.Object
obj
- the object that this instance is to be compared to.
public int compareTo(java.lang.Object obj)
equals()
, meaning
that (compare(x, y)==0) == (x.equals(y))
.
The algorithm that this method follows is based primarily upon the
hash code. When two instances of BaseID, objects A and B, are being compared,
this method first compares the (cached) hash code of the two objects. If the
two hash codes are not equal, the method returns the difference in the hash
codes (namely A.hashCode() - B.hashCode()
).
If, however, the two hash code values are equivalent, then the
two BaseID instances are potentially equivalent, and the
full names of the BaseIDs are compared (ignoring case) to determine actual result.
compareTo
in interface java.lang.Comparable
obj
- the object that this instance is to be compared to.
java.lang.IllegalArgumentException
- if the specified object reference is null
java.lang.ClassCastException
- if the specified object's type prevents it
from being compared to this instance.public int compareToByName(java.lang.Object obj)
equals()
.
obj
- the object that this instance is to be compared to.
java.lang.IllegalArgumentException
- if the specified object reference is null
java.lang.ClassCastException
- if the specified object's type prevents it
from being compared to this instance.public final int hashCode()
hashCode
in class java.lang.Object
public final java.lang.String toString()
toString
in class java.lang.Object
public java.lang.Object clone() throws java.lang.CloneNotSupportedException
clone
in class java.lang.Object
java.lang.CloneNotSupportedException
- if this object cannot be cloned (i.e., only objects in
Defaults
cannot be cloned).public java.lang.String getParentFullName()
public boolean hasParent()
protected final void updateHashCode()
The implementation of this method invokes the computeHashCode
method, which is likely overridden in subclasses.
protected int computeHashCode()
protected int computeHashCode() { int result = super.computeHashCode(); result = HashCodeUtil.hashCode(result, ... ); result = HashCodeUtil.hashCode(result, ... ); return result; }Any specialized implementation must not rely upon the
hashCode
method.
Note that this method does not and cannot actually update the hash code value.
Rather, this method is called by the updateHashCode
method.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |