1 57 58 package com.sun.org.apache.xerces.internal.impl.dv.xs; 59 60 import com.sun.org.apache.xerces.internal.impl.dv.InvalidDatatypeValueException; 61 import com.sun.org.apache.xerces.internal.impl.dv.ValidationContext; 62 63 71 public class ListDV extends TypeValidator{ 72 73 public short getAllowedFacets(){ 74 return (XSSimpleTypeDecl.FACET_LENGTH | XSSimpleTypeDecl.FACET_MINLENGTH | XSSimpleTypeDecl.FACET_MAXLENGTH | XSSimpleTypeDecl.FACET_PATTERN | XSSimpleTypeDecl.FACET_ENUMERATION | XSSimpleTypeDecl.FACET_WHITESPACE ); 75 } 76 77 public Object getActualValue(String content, ValidationContext context) throws InvalidDatatypeValueException{ 80 return content; 81 } 82 83 public int getDataLength(Object value) { 85 return ((ListData)value).length(); 86 } 87 88 final static class ListData { 89 final Object [] data; 90 private String canonical; 91 public ListData(Object [] data) { 92 this.data = data; 93 } 94 public synchronized String toString() { 95 if (canonical == null) { 96 int len = data.length; 97 StringBuffer buf = new StringBuffer (); 98 if (len > 0) { 99 buf.append(data[0].toString()); 100 } 101 for (int i = 1; i < len; i++) { 102 buf.append(' '); 103 buf.append(data[i].toString()); 104 } 105 canonical = buf.toString(); 106 } 107 return canonical; 108 } 109 public int length() { 110 return data.length; 111 } 112 public Object item(int index) { 113 return data[index]; 114 } 115 public boolean equals(Object obj) { 116 if (!(obj instanceof ListData)) 117 return false; 118 Object [] odata = ((ListData)obj).data; 119 120 int count = data.length; 121 if (count != odata.length) 122 return false; 123 124 for (int i = 0 ; i < count ; i++) { 125 if (!data[i].equals(odata[i])) 126 return false; 127 } 129 return true; 131 } 132 } 133 } 135 | Popular Tags |