1 16 package org.apache.axis.types; 17 18 import java.util.Arrays ; 19 import java.util.HashSet ; 20 import java.util.Set ; 21 import java.util.StringTokenizer ; 22 23 29 public class IDRefs extends NCName { 30 private IDRef[] idrefs; 31 32 public IDRefs() { 33 super(); 34 } 35 39 public IDRefs (String stValue) throws IllegalArgumentException { 40 setValue(stValue); 41 } 42 43 public void setValue(String stValue) { 44 StringTokenizer tokenizer = new StringTokenizer (stValue); 45 int count = tokenizer.countTokens(); 46 idrefs = new IDRef[count]; 47 for(int i=0;i<count;i++){ 48 idrefs[i] = new IDRef(tokenizer.nextToken()); 49 } 50 } 51 52 public String toString() { 53 StringBuffer buf = new StringBuffer (); 54 for (int i = 0; i < idrefs.length; i++) { 55 IDRef ref = idrefs[i]; 56 if (i > 0) buf.append(" "); 57 buf.append(ref.toString()); 58 } 59 return buf.toString(); 60 } 61 62 70 public boolean equals(Object object) { 71 if (object == this) { 72 return true; } 74 if (object instanceof IDRefs) { 75 IDRefs that = (IDRefs)object; 76 if (this.idrefs.length == that.idrefs.length) { 77 Set ourSet = new HashSet (Arrays.asList(this.idrefs)); 78 Set theirSet = new HashSet (Arrays.asList(that.idrefs)); 79 return ourSet.equals(theirSet); 80 } else { 81 return false; 82 } 83 } else { 84 return false; 85 } 86 } 87 88 94 public int hashCode() { 95 int hash = 0; 96 for (int i = 0; i < idrefs.length; i++) { 97 hash += idrefs[i].hashCode(); 98 } 99 return hash; 100 } 101 } 102 | Popular Tags |