FileDocCategorySizeDatePackage
NMTokens.javaAPI DocApache Axis 1.43091Sat Apr 22 18:57:28 BST 2006org.apache.axis.types

NMTokens

public class NMTokens extends NCName
Custom class for supporting XSD data type NMTokens
author
Davanum Srinivas

Fields Summary
private NMToken[]
tokens
Constructors Summary
public NMTokens()

        super();
    
public NMTokens(String stValue)
ctor for NMTokens

exception
IllegalArgumentException will be thrown if validation fails

        setValue(stValue);
    
Methods Summary
public booleanequals(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.

param
object an Object value
return
a boolean value

        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 inthashCode()
Returns the sum of the hashcodes of the underlying tokens, an operation which is not sensitive to ordering.

return
an int value

        int hash = 0;
        for (int i = 0; i < tokens.length; i++) {
            hash += tokens[i].hashCode();
        }
        return hash;
    
public voidsetValue(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.StringtoString()

        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();