1 16 17 package org.apache.xerces.impl.validation; 18 19 import org.apache.xerces.util.SymbolTable; 20 import org.apache.xerces.impl.dv.ValidationContext; 21 22 import org.apache.xerces.xni.NamespaceContext; 23 import java.util.Hashtable ; 24 import java.util.Enumeration ; 25 26 35 public class ValidationState implements ValidationContext { 36 37 private boolean fExtraChecking = true; 41 private boolean fFacetChecking = true; 42 private boolean fNormalize = true; 43 private boolean fNamespaces = true; 44 45 private EntityState fEntityState = null; 46 private NamespaceContext fNamespaceContext = null; 47 private SymbolTable fSymbolTable = null; 48 49 private final Hashtable fIdTable = new Hashtable (); 51 private final Hashtable fIdRefTable = new Hashtable (); 52 private final static Object fNullValue = new Object (); 53 54 public void setExtraChecking(boolean newValue) { 58 fExtraChecking = newValue; 59 } 60 61 public void setFacetChecking(boolean newValue) { 62 fFacetChecking = newValue; 63 } 64 65 public void setNormalizationRequired (boolean newValue) { 66 fNormalize = newValue; 67 } 68 69 public void setUsingNamespaces (boolean newValue) { 70 fNamespaces = newValue; 71 } 72 73 public void setEntityState(EntityState state) { 74 fEntityState = state; 75 } 76 77 public void setNamespaceSupport(NamespaceContext namespace) { 78 fNamespaceContext = namespace; 79 } 80 81 public void setSymbolTable(SymbolTable sTable) { 82 fSymbolTable = sTable; 83 } 84 85 89 public String checkIDRefID () { 90 Enumeration en = fIdRefTable.keys(); 91 92 String key; 93 while (en.hasMoreElements()) { 94 key = (String )en.nextElement(); 95 if (!fIdTable.containsKey(key)) { 96 return key; 97 } 98 } 99 return null; 100 } 101 102 public void reset () { 103 fExtraChecking = true; 104 fFacetChecking = true; 105 fNamespaces = true; 106 fIdTable.clear(); 107 fIdRefTable.clear(); 108 fEntityState = null; 109 fNamespaceContext = null; 110 fSymbolTable = null; 111 } 112 113 119 public void resetIDTables() { 120 fIdTable.clear(); 121 fIdRefTable.clear(); 122 } 123 124 128 public boolean needExtraChecking() { 130 return fExtraChecking; 131 } 132 133 public boolean needFacetChecking() { 135 return fFacetChecking; 136 } 137 138 public boolean needToNormalize (){ 139 return fNormalize; 140 } 141 142 public boolean useNamespaces() { 143 return fNamespaces; 144 } 145 146 public boolean isEntityDeclared (String name) { 148 if (fEntityState !=null) { 149 return fEntityState.isEntityDeclared(getSymbol(name)); 150 } 151 return false; 152 } 153 public boolean isEntityUnparsed (String name) { 154 if (fEntityState !=null) { 155 return fEntityState.isEntityUnparsed(getSymbol(name)); 156 } 157 return false; 158 } 159 160 public boolean isIdDeclared(String name) { 162 return fIdTable.containsKey(name); 163 } 164 public void addId(String name) { 165 fIdTable.put(name, fNullValue); 166 } 167 168 public void addIdRef(String name) { 170 fIdRefTable.put(name, fNullValue); 171 } 172 174 public String getSymbol (String symbol) { 175 if (fSymbolTable != null) 176 return fSymbolTable.addSymbol(symbol); 177 return symbol.intern(); 182 } 183 public String getURI(String prefix) { 185 if (fNamespaceContext !=null) { 186 return fNamespaceContext.getURI(prefix); 187 } 188 return null; 189 } 190 191 } 192 | Popular Tags |