public class IdentifierEquivClass extends java.lang.Object implements java.lang.Comparable<IdentifierEquivClass>
Represents an equivalence class of element identifiers. An element ID is a member of the equivalence class if it is a proper substring of the current class representative or the current class representative is a proper substring of the given element ID. The class representative identifier is continually truncated whenever a member element ID is encounter that is shorter, that is, the encountered ID becomes the representative ID.
The class of identifiers is intended to be associated with one hardware element.
Due to a peculiarity of the XAL lattice generator, modeling elements
are created with identifiers that are suffixed versions of their
hardware counterpart. Thus, we equate two ElementIdClass
objects if they have the same prefix (ergo, they must belong to the
same hardware object).
Constructor and Description |
---|
IdentifierEquivClass(java.lang.String strElemId)
Creates a new instance of
ElementIdClass . |
Modifier and Type | Method and Description |
---|---|
int |
compareTo(IdentifierEquivClass idcCmp)
Implements a comparison of equivalences classes for the element IDs.
|
int |
compareTo(java.lang.String strElemId)
This is essentially a utility method for the other methods of the class, as such I have
removed the visibility.
|
boolean |
equals(java.lang.Object obj)
Checks whether or not the given object is equivalent to this object
and also sets the base ID string if necessary.
|
boolean |
equivalentTo(IdentifierEquivClass idCmp)
Tests whether or not the given equivalence class object is the same as
this, w.r.t.
|
int |
hashCode()
Returns the hash code of the base ID.
|
boolean |
isMember(java.lang.String strElemId)
Checks whether or not the given ID is an member of this
equivalence class of element IDs.
|
java.lang.String |
toString()
Returns the representative identifier string.
|
public IdentifierEquivClass(java.lang.String strElemId)
ElementIdClass
.strElemId
- public boolean isMember(java.lang.String strElemId)
strElemId
- element identifier under comparisontrue
if argument is equivalent to the representative element
of this equivalence class, false
otherwisepublic boolean equivalentTo(IdentifierEquivClass idCmp)
idCmp
- element ID class object to comparetrue
if the argument and this object represent
the same equivalence class, or false
otherwisepublic int compareTo(IdentifierEquivClass idcCmp)
compareTo
in interface java.lang.Comparable<IdentifierEquivClass>
idcCmp
- equivalence class object to compare w.r.t. the element ID classComparable.compareTo(java.lang.Object)
public boolean equals(java.lang.Object obj)
ElementIdentifiers
are equivalent if one is a substring
of the other. The base ID string then becomes the smallest common
string between them.equals
in class java.lang.Object
obj
- obj to be compared (must be of type ElementIdentifier
true
if the given element identifier object is
equivalent to this (see above), false
otherwise.Object.equals(java.lang.Object)
public int hashCode()
hashCode
in class java.lang.Object
Object.hashCode()
public java.lang.String toString()
toString
in class java.lang.Object
Object.toString()
public int compareTo(java.lang.String strElemId) throws java.util.NoSuchElementException
This is essentially a utility method for the other methods of the class, as such I have removed the visibility.
Makes a comparison of the equivalence class representative string ID with the given
string ID. If the two strings are not equivalent, then
a NoSuchElementException
is thrown. If the two strings are equivalent
(w.r.t. to the equivalence class rules), then an integer value is returned (described below).
The empty identifier "" is handled as a special case: no string of finite length is
equivalent to the empty string, both strings must be empty to be equivalent. Otherwise we have
the trivial case where all IDs would be equivalent to the empty ID since all IDs contain
the empty string.
Now consider when the given string is found to be an element of this equivalence class. Denote by
s the given argument string and by r the representative string of this
equivalence class (so that the equivalence class is represented as [r]). Then the follow
results are returned:
-1 ⇒ s ⊂ r ,
0 ⇒ s = r ,
+1 ⇒ s ⊃ r ,
where all strings are compared starting from the head, i.e., s[0] == r[0] must
hold in every case since neither is the empty string.
strElemId
- string to be compared to the representative string of this equivalence classjava.util.NoSuchElementException
- the given string ID is not equivalent to this object