com.metamatrix.metadata.runtime.model
Class BasicMetadataID

java.lang.Object
  extended by com.metamatrix.metadata.runtime.model.BasicMetadataID
All Implemented Interfaces:
MetadataID, java.io.Serializable, java.lang.Cloneable, java.lang.Comparable
Direct Known Subclasses:
BasicDataTypeID, BasicElementID, BasicGroupID, BasicKeyID, BasicModelID, BasicProcedureID, BasicVirtualDatabaseID

public class BasicMetadataID
extends java.lang.Object
implements MetadataID

The BasicRuntimeID is utilized by the server side code only. This implementation is meant to hide the UID used by the server for performance gains when reading from the database.

This class should only be instantiated when the data is read from the database. The assumption is that all data loaded into the Runtime Catalog will have this type instantiated for the RuntimeID.

See Also:
Serialized Form

Field Summary
static java.lang.String DELIMITER
          The character that delimits the atomic components of the name
static java.lang.String FAKE_NAME
           
static long NOT_DEFINED
           
static java.lang.String WILDCARD
          The wildcard character.
 
Constructor Summary
  BasicMetadataID(java.lang.String fullName)
          Create an instance with the specified full name.
protected BasicMetadataID(java.lang.String fullName, long internalUniqueID)
           
protected BasicMetadataID(java.lang.String parentName, java.lang.String name, long internalUniqueID)
           
 
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.
 java.lang.String getPath()
          return the path.
 long getUID()
          return the internal unique identifier that makes this object unique within its type.
 int hashCode()
          Returns the hash code value for this object.
 boolean hasParent()
           
 void setFullName(java.lang.String name)
          This method should never be called after the MetadataID is added to the metadata cache
 void setGroupFullName(java.lang.String newName)
          This method should never be called after the MetadataID is added to the metadata cache
 void setModelName(java.lang.String modelName)
          This method should never be called after the MetadataID is added to the metadata cache
 void setName(java.lang.String name, boolean isShortName)
          This method should never be called after the MetadataID is added to the metadata cache
 void setShortName(java.lang.String name)
           
 void setUID(long uid)
           
 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

NOT_DEFINED

public static final long NOT_DEFINED
See Also:
Constant Field Values

FAKE_NAME

public static java.lang.String FAKE_NAME

DELIMITER

public static final java.lang.String DELIMITER
The character that delimits the atomic components of the name


WILDCARD

public static final java.lang.String WILDCARD
The wildcard character.

See Also:
Constant Field Values
Constructor Detail

BasicMetadataID

public BasicMetadataID(java.lang.String fullName)
Create an instance with the specified full name. The full name must be one or more atomic name components delimited by this class' delimeter character.

Parameters:
fullName - the string form of the full name from which this object is to be created; never null and never zero-length.
Throws:
java.lang.IllegalArgumentException - if the full name is null

BasicMetadataID

protected BasicMetadataID(java.lang.String fullName,
                          long internalUniqueID)

BasicMetadataID

protected BasicMetadataID(java.lang.String parentName,
                          java.lang.String name,
                          long internalUniqueID)
Method Detail

getFullName

public final java.lang.String getFullName()
Obtain the full name for the object that this identifier represents.

Specified by:
getFullName in interface MetadataID
Returns:
the full name for this identifier.

getName

public final java.lang.String getName()
Obtain the last name component this identifier. This last name component is the logical name for the object that this identifier represents.

Specified by:
getName in interface MetadataID
Returns:
the name for this identifier.

getNameComponent

public final java.lang.String getNameComponent(int index)
Obtain the specified component of the name.

Specified by:
getNameComponent in interface MetadataID
Parameters:
the - index of the atomic name component to return; must be less than the result of the method size in order to be valid.
Returns:
the full name for this identifier.
Throws:
java.lang.IndexOutOfBoundsException - if the index is not valid and is out of the bounds of this name.

getNameComponents

public final java.util.List getNameComponents()
Obtain the list of atomic name components for this ID.

Specified by:
getNameComponents in interface MetadataID
Returns:
the unmodifiable list of String objects.
Throws:
java.lang.IndexOutOfBoundsException - if the index is not valid and is out of the bounds of this name.

size

public final int size()
Return the number of atomic name components in this identifier.

Specified by:
size in interface MetadataID
Returns:
the size of this identifier.

equals

public boolean equals(java.lang.Object obj)
Returns true if the specified object is semantically equal to this instance. Note: this method is consistent with compareTo().

Specified by:
equals in interface MetadataID
Overrides:
equals in class java.lang.Object
Parameters:
obj - the object that this instance is to be compared to.
Returns:
whether the object is equal to this object.

compareTo

public int compareTo(java.lang.Object obj)
Compares this object to another. If the specified object is an instance of the MetadataID class, then this method compares the name; otherwise, it throws a ClassCastException (as instances are comparable only to instances of the same class). Note: this method is consistent with 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 MetadataID, 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 MetadataID instances are potentially equivalent, and the full names of the BaseIDs are compared (ignoring case) to determine actual result.

Specified by:
compareTo in interface MetadataID
Specified by:
compareTo in interface java.lang.Comparable
Parameters:
obj - the object that this instance is to be compared to.
Returns:
a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object, respectively.
Throws:
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.

compareToByName

public int compareToByName(java.lang.Object obj)
Compares this object to another lexicographically. If the specified object is an instance of the same class, then this method compares the name; otherwise, it throws a ClassCastException (as instances are comparable only to instances of the same class). Note: this method is consistent with equals().

Specified by:
compareToByName in interface MetadataID
Parameters:
obj - the object that this instance is to be compared to.
Returns:
a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object, respectively.
Throws:
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.

hashCode

public final int hashCode()
Returns the hash code value for this object.

Specified by:
hashCode in interface MetadataID
Overrides:
hashCode in class java.lang.Object
Returns:
a hash code value for this object.

toString

public final java.lang.String toString()
Returns a string representing the current state of the object.

Specified by:
toString in interface MetadataID
Overrides:
toString in class java.lang.Object
Returns:
the string representation of this instance.

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Return a deep cloned instance of this object. Subclasses must override this method.

Specified by:
clone in interface MetadataID
Overrides:
clone in class java.lang.Object
Returns:
the object that is the clone of this instance.
Throws:
java.lang.CloneNotSupportedException - if this object cannot be cloned (i.e., only objects in Defaults cannot be cloned).

getParentFullName

public final java.lang.String getParentFullName()
Return the full name of the parent. This is a convenience method to return the list of atomic name components that excludes this ID's last atomic name component.

Specified by:
getParentFullName in interface MetadataID
Returns:
the full name of the parent, or null if this ID has no parent.

hasParent

public final boolean hasParent()

updateHashCode

protected final void updateHashCode()
Update the currently cached hash code value with a newly computed one. This method should be called in any subclass method that updates any field. This includes constructors.

The implementation of this method invokes the computeHashCode method, which is likely overridden in subclasses.


computeHashCode

protected int computeHashCode()
Return a new hash code value for this instance. If subclasses provide additional and non-transient fields, they should override this method using the following template:
 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.

Returns:
the new hash code for this instance.

getPath

public java.lang.String getPath()
return the path.

Specified by:
getPath in interface MetadataID
Returns:
String

getUID

public long getUID()
return the internal unique identifier that makes this object unique within its type.

Returns:
int

setUID

public void setUID(long uid)

setName

public void setName(java.lang.String name,
                    boolean isShortName)
This method should never be called after the MetadataID is added to the metadata cache


setFullName

public void setFullName(java.lang.String name)
This method should never be called after the MetadataID is added to the metadata cache


setShortName

public void setShortName(java.lang.String name)

setModelName

public void setModelName(java.lang.String modelName)
This method should never be called after the MetadataID is added to the metadata cache


setGroupFullName

public void setGroupFullName(java.lang.String newName)
This method should never be called after the MetadataID is added to the metadata cache



Copyright © 2009. All Rights Reserved.