1 22 23 package org.xquark.schema; 24 25 import org.xquark.schema.validation.ContentIterator; 26 import org.xquark.schema.validation.ValidationContextProvider; 27 import org.xquark.schema.validation.ValidationInfo; 28 29 45 public abstract class Type extends SchemaComponent { 46 private static final String RCSRevision = "$Revision: 1.1 $"; 47 private static final String RCSName = "$Name: $"; 48 49 private Type baseType; 50 private int fin = 0; 51 52 61 protected Type(Schema schema, String name, Type baseType) { 62 super(schema, name); 63 this.baseType = baseType; 64 } 65 66 public void accept(SchemaVisitor visitor) throws SchemaException { 67 visitor.visit(this); 68 } 69 70 75 public Type getBaseType() { 76 return baseType; 77 } 78 79 84 public int getFinal() { 85 return fin; 86 } 87 88 public boolean isAbstract() { 89 return false; 90 } 91 92 public int getBlock() { 93 return 0; 94 } 95 96 public int getDerivationMethod() { 97 return RESTRICTION; 98 } 99 100 public boolean isDerivedFrom(Type ancestor) { 101 if (ancestor == this) return true; 102 if (baseType == null) return false; 103 else return baseType.isDerivedFrom(ancestor); 104 } 105 106 109 110 public String checkTypeDerivationOK(Type ancestor, int exclusions, boolean useBlock) { 111 return null; 112 } 113 114 public abstract int getContentType(); 115 116 public abstract SimpleType getValueType(); 117 118 public ElementDeclaration getElementDeclaration(String namespace, String name) { 119 return null; 120 } 121 122 public java.util.Collection getElementDeclarations() { 123 return null; 124 } 125 126 public AttributeDeclaration getAttributeDeclaration(String namespace, String name) { 127 return null; 128 } 129 130 public java.util.Collection getAttributeDeclarations() { 131 return null; 132 } 133 134 public Wildcard getAttributeWildcard() { 135 return null; 136 } 137 138 public ContentIterator contentIterator() { 139 return null; 140 } 141 142 public ContentIterator childIterator() { 143 return null; 144 } 145 146 public String normalizedValue(String value) { 147 return value; 148 } 149 150 public StringBuffer normalizedValue(StringBuffer value) { 151 return value; 152 } 153 154 public StringBuffer normalizedValue(StringBuffer value, StringBuffer out) { 155 if (out == value) return value; 156 if (out == null) out = new StringBuffer (); 157 out.append(value.toString()); 158 return out; 159 } 160 161 public String toXMLString(Object value, ValidationContextProvider context) { 162 return value.toString(); 163 } 164 165 public String toXMLString(Object value) { 166 return toXMLString(value, null); 167 } 168 169 public abstract ValidationInfo validate(String value, boolean normalize, ValidationContextProvider context) 170 throws SchemaException; 171 172 public abstract ValidationInfo validate(StringBuffer value, boolean normalize, ValidationContextProvider context) 173 throws SchemaException; 174 175 public Object convert(String value, boolean normalize, ValidationContextProvider context) 176 throws SchemaException 177 { 178 return value; 179 } 180 181 public Object convert(StringBuffer value, boolean normalize, ValidationContextProvider context) 182 throws SchemaException 183 { 184 return value; 185 } 186 187 public ValidationInfo validate(String value) throws SchemaException { 188 return validate(value, true, null); 189 } 190 191 public ValidationInfo validate(StringBuffer value) throws SchemaException { 192 return validate(value, true, null); 193 } 194 195 public Object convert(String value) throws SchemaException { 196 return convert(value, true, null); 197 } 198 199 public Object convert(StringBuffer value) throws SchemaException { 200 return convert(value, true, null); 201 } 202 203 public String validateDefault(String value, ValidationContextProvider context) throws SchemaException { 204 return value; 205 } 206 207 public String toCanonicalForm(String value, ValidationContextProvider context) throws SchemaException { 208 return value; 209 } 210 211 public String toCanonicalForm(String value) throws SchemaException { 212 return toCanonicalForm(value, null); 213 } 214 215 public void setBaseType(Type type) { 216 baseType = type; 217 } 218 219 public void setFinal(int fin) { 220 this.fin = fin; 221 } 222 223 public boolean isSimpleType() { return false; } 225 226 } 227 228 229 230 231 232 233 234 235 236 237 238 | Popular Tags |