1 57 58 package org.enhydra.apache.xerces.validators.common; 59 60 61 import java.util.Enumeration ; 62 import java.util.Hashtable ; 63 64 import org.enhydra.apache.xerces.validators.datatype.DatatypeValidatorFactory; 65 import org.enhydra.apache.xerces.validators.datatype.DatatypeValidatorFactoryImpl; 66 67 68 77 public class GrammarResolverImpl implements GrammarResolver { 78 79 83 87 private Hashtable fGrammarRegistry = new Hashtable (); 89 private DatatypeValidatorFactoryImpl fDataTypeReg; 92 96 97 public GrammarResolverImpl() { 98 } 99 100 104 111 public Grammar getGrammar( String nameSpaceKey ) { 112 return(Grammar) ( fGrammarRegistry.get( nameSpaceKey ) ); 113 } 114 115 public DatatypeValidatorFactory getDatatypeRegistry(){ 116 if (fDataTypeReg == null) { fDataTypeReg = new DatatypeValidatorFactoryImpl(); 118 } 119 return fDataTypeReg; 120 } 121 122 126 public String [] getNSKeysInPool() { 127 int numberOfNSKeysInPool = fGrammarRegistry.size(); 128 String [] NSArray = new String [numberOfNSKeysInPool]; 129 Enumeration enumOfKeys = nameSpaceKeys(); 130 for (int i = 0; i<numberOfNSKeysInPool; i ++ ) { 131 NSArray[i] = (String )( enumOfKeys.nextElement() ); 132 } 133 return NSArray; 134 } 135 136 144 public void putGrammar( String nameSpaceKey, Grammar grammar ){ 145 fGrammarRegistry.put( nameSpaceKey, grammar ); 146 } 147 148 152 public int size() { 153 return fGrammarRegistry.size(); 154 } 155 156 160 161 public Enumeration nameSpaceKeys(){ 162 return fGrammarRegistry.keys(); 163 } 164 165 166 173 public Grammar removeGrammar( String nameSpaceKey ) { 174 if ( containsNameSpace( nameSpaceKey ) == true ) 175 fGrammarRegistry.remove( nameSpaceKey ); 176 return null; 177 } 178 179 180 181 188 public boolean contains( Grammar grammar ){ 189 return fGrammarRegistry.contains( grammar ); 190 } 191 192 200 public boolean containsNameSpace( String nameSpaceKey ){ 201 return fGrammarRegistry.containsKey( nameSpaceKey ); 202 } 203 204 207 public void clearGrammarResolver() { 208 fGrammarRegistry.clear(); 209 if (fDataTypeReg != null) { fDataTypeReg.resetRegistry(); 211 } 212 213 } 214 215 216 217 218 219 220 304 305 } | Popular Tags |