Class IdentifierEquivClass
- All Implemented Interfaces:
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).
- Since:
- Jun 4, 2013
- Author:
- Christopher K. Allen
-
Constructor Summary
ConstructorsConstructorDescriptionIdentifierEquivClass
(String strElemId) Creates a new instance ofElementIdClass
. -
Method Summary
Modifier and TypeMethodDescriptionint
This is essentially a utility method for the other methods of the class, as such I have removed the visibility.int
compareTo
(IdentifierEquivClass idcCmp) Implements a comparison of equivalences classes for the element IDs.boolean
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. equivalence of the element ID class.int
hashCode()
Returns the hash code of the base ID.boolean
Checks whether or not the given ID is an member of this equivalence class of element IDs.toString()
Returns the representative identifier string.
-
Constructor Details
-
IdentifierEquivClass
Creates a new instance ofElementIdClass
.- Parameters:
strElemId
-- Since:
- Jun 5, 2013
-
-
Method Details
-
isMember
Checks whether or not the given ID is an member of this equivalence class of element IDs.- Parameters:
strElemId
- element identifier under comparison- Returns:
true
if argument is equivalent to the representative element of this equivalence class,false
otherwise- Since:
- Jun 10, 2013
-
equivalentTo
Tests whether or not the given equivalence class object is the same as this, w.r.t. equivalence of the element ID class. Returns the result
ElementIdClass.isMember(idCmp.strClassId)- Parameters:
idCmp
- element ID class object to compare- Returns:
- returns
true
if the argument and this object represent the same equivalence class, orfalse
otherwise - Since:
- Jun 10, 2013
-
compareTo
Implements a comparison of equivalences classes for the element IDs. We first check whether or not the argument is equivalent to this object, if so a value of 0 is returned. If not, then the representative strings of the equivalence class are compared lexicographically, the result of that comparison is returned. Note that is value will not be 0 since the objects under comparison are not in the same equivalence class of element IDs.- Specified by:
compareTo
in interfaceComparable<IdentifierEquivClass>
- Parameters:
idcCmp
- equivalence class object to compare w.r.t. the element ID class- Returns:
- a value 0 if the argument is the same equivalence class, or the lexicographical comparison result otherwise
- Since:
- Jun 6, 2013
- See Also:
-
equals
Checks whether or not the given object is equivalent to this object and also sets the base ID string if necessary. TwoElementIdentifiers
are equivalent if one is a substring of the other. The base ID string then becomes the smallest common string between them. -
hashCode
public int hashCode()Returns the hash code of the base ID. This is the prefix of the identifier, which has intersected all others compared to so far. -
toString
Returns the representative identifier string. -
compareTo
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.- Parameters:
strElemId
- string to be compared to the representative string of this equivalence class- Returns:
- if the two strings are equivalent, then the result of the comparison as described above, otherwise an exception is thrown.
- Throws:
NoSuchElementException
- the given string ID is not equivalent to this object- Since:
- Jun 10, 2013
-