1 57 58 package com.sun.org.apache.xerces.internal.impl.validation; 59 60 import com.sun.org.apache.xerces.internal.util.SymbolTable; 61 import com.sun.org.apache.xerces.internal.impl.dv.ValidationContext; 62 63 import com.sun.org.apache.xerces.internal.xni.NamespaceContext; 64 import java.util.Hashtable ; 65 import java.util.Enumeration ; 66 67 74 public class ValidationState implements ValidationContext { 75 76 private boolean fExtraChecking = true; 80 private boolean fFacetChecking = true; 81 private boolean fNormalize = true; 82 private boolean fNamespaces = true; 83 84 private EntityState fEntityState = null; 85 private NamespaceContext fNamespaceContext = null; 86 private SymbolTable fSymbolTable = null; 87 88 private final Hashtable fIdTable = new Hashtable (); 90 private final Hashtable fIdRefTable = new Hashtable (); 91 private final static Object fNullValue = new Object (); 92 93 public void setExtraChecking(boolean newValue) { 97 fExtraChecking = newValue; 98 } 99 100 public void setFacetChecking(boolean newValue) { 101 fFacetChecking = newValue; 102 } 103 104 public void setNormalizationRequired (boolean newValue) { 105 fNormalize = newValue; 106 } 107 108 public void setUsingNamespaces (boolean newValue) { 109 fNamespaces = newValue; 110 } 111 112 public void setEntityState(EntityState state) { 113 fEntityState = state; 114 } 115 116 public void setNamespaceSupport(NamespaceContext namespace) { 117 fNamespaceContext = namespace; 118 } 119 120 public void setSymbolTable(SymbolTable sTable) { 121 fSymbolTable = sTable; 122 } 123 124 128 public String checkIDRefID () { 129 Enumeration en = fIdRefTable.keys(); 130 131 String key; 132 while (en.hasMoreElements()) { 133 key = (String )en.nextElement(); 134 if (!fIdTable.containsKey(key)) { 135 return key; 136 } 137 } 138 return null; 139 } 140 141 public void reset () { 142 fExtraChecking = true; 143 fFacetChecking = true; 144 fNamespaces = true; 145 fIdTable.clear(); 146 fIdRefTable.clear(); 147 fEntityState = null; 148 fNamespaceContext = null; 149 fSymbolTable = null; 150 } 151 152 158 public void resetIDTables() { 159 fIdTable.clear(); 160 fIdRefTable.clear(); 161 } 162 163 167 public boolean needExtraChecking() { 169 return fExtraChecking; 170 } 171 172 public boolean needFacetChecking() { 174 return fFacetChecking; 175 } 176 177 public boolean needToNormalize (){ 178 return fNormalize; 179 } 180 181 public boolean useNamespaces() { 182 return fNamespaces; 183 } 184 185 public boolean isEntityDeclared (String name) { 187 if (fEntityState !=null) { 188 return fEntityState.isEntityDeclared(getSymbol(name)); 189 } 190 return false; 191 } 192 public boolean isEntityUnparsed (String name) { 193 if (fEntityState !=null) { 194 return fEntityState.isEntityUnparsed(getSymbol(name)); 195 } 196 return false; 197 } 198 199 public boolean isIdDeclared(String name) { 201 return fIdTable.containsKey(name); 202 } 203 public void addId(String name) { 204 fIdTable.put(name, fNullValue); 205 } 206 207 public void addIdRef(String name) { 209 fIdRefTable.put(name, fNullValue); 210 } 211 213 public String getSymbol (String symbol) { 214 if (fSymbolTable != null) 215 return fSymbolTable.addSymbol(symbol); 216 return symbol.intern(); 221 } 222 public String getURI(String prefix) { 224 if (fNamespaceContext !=null) { 225 return fNamespaceContext.getURI(prefix); 226 } 227 return null; 228 } 229 230 } 231 | Popular Tags |