Methods Summary |
---|
public boolean | equals(java.lang.Object object)NMTokens can be equal without having identical ordering because
they represent a set of references. Hence we have to compare
values here as a set, not a list.
if (object == this) {
return true; // succeed quickly, when possible
}
if (object instanceof NMTokens) {
NMTokens that = (NMTokens)object;
if (this.tokens.length == that.tokens.length) {
Set ourSet = new HashSet(Arrays.asList(this.tokens));
Set theirSet = new HashSet(Arrays.asList(that.tokens));
return ourSet.equals(theirSet);
} else {
return false;
}
} else {
return false;
}
|
public int | hashCode()Returns the sum of the hashcodes of the underlying tokens, an
operation which is not sensitive to ordering.
int hash = 0;
for (int i = 0; i < tokens.length; i++) {
hash += tokens[i].hashCode();
}
return hash;
|
public void | setValue(java.lang.String stValue)
StringTokenizer tokenizer = new StringTokenizer(stValue);
int count = tokenizer.countTokens();
tokens = new NMToken[count];
for(int i=0;i<count;i++){
tokens[i] = new NMToken(tokenizer.nextToken());
}
|
public java.lang.String | toString()
StringBuffer buf = new StringBuffer();
for (int i = 0; i < tokens.length; i++) {
NMToken token = tokens[i];
if (i > 0) buf.append(" ");
buf.append(token.toString());
}
return buf.toString();
|