1 16 17 package org.apache.xerces.jaxp; 18 19 import java.util.HashMap ; 20 21 import org.apache.xerces.impl.validation.EntityState; 22 import org.apache.xerces.impl.validation.ValidationManager; 23 import org.apache.xerces.xni.Augmentations; 24 import org.apache.xerces.xni.XMLDTDHandler; 25 import org.apache.xerces.xni.XMLLocator; 26 import org.apache.xerces.xni.XMLResourceIdentifier; 27 import org.apache.xerces.xni.XMLString; 28 import org.apache.xerces.xni.XNIException; 29 import org.apache.xerces.xni.parser.XMLDTDFilter; 30 import org.apache.xerces.xni.parser.XMLDTDSource; 31 32 40 final class UnparsedEntityHandler implements XMLDTDFilter, EntityState { 41 42 43 private XMLDTDSource fDTDSource; 44 private XMLDTDHandler fDTDHandler; 45 46 47 private final ValidationManager fValidationManager; 48 49 50 private HashMap fUnparsedEntities = null; 51 52 UnparsedEntityHandler(ValidationManager manager) { 53 fValidationManager = manager; 54 } 55 56 59 60 public void startDTD(XMLLocator locator, Augmentations augmentations) 61 throws XNIException { 62 fValidationManager.setEntityState(this); 63 if (fUnparsedEntities != null && !fUnparsedEntities.isEmpty()) { 64 fUnparsedEntities.clear(); 66 } 67 if (fDTDHandler != null) { 68 fDTDHandler.startDTD(locator, augmentations); 69 } 70 } 71 72 public void startParameterEntity(String name, 73 XMLResourceIdentifier identifier, String encoding, 74 Augmentations augmentations) throws XNIException { 75 if (fDTDHandler != null) { 76 fDTDHandler.startParameterEntity(name, identifier, encoding, augmentations); 77 } 78 } 79 80 public void textDecl(String version, String encoding, 81 Augmentations augmentations) throws XNIException { 82 if (fDTDHandler != null) { 83 fDTDHandler.textDecl(version, encoding, augmentations); 84 } 85 } 86 87 public void endParameterEntity(String name, Augmentations augmentations) 88 throws XNIException { 89 if (fDTDHandler != null) { 90 fDTDHandler.endParameterEntity(name, augmentations); 91 } 92 } 93 94 public void startExternalSubset(XMLResourceIdentifier identifier, 95 Augmentations augmentations) throws XNIException { 96 if (fDTDHandler != null) { 97 fDTDHandler.startExternalSubset(identifier, augmentations); 98 } 99 } 100 101 public void endExternalSubset(Augmentations augmentations) 102 throws XNIException { 103 if (fDTDHandler != null) { 104 fDTDHandler.endExternalSubset(augmentations); 105 } 106 } 107 108 public void comment(XMLString text, Augmentations augmentations) 109 throws XNIException { 110 if (fDTDHandler != null) { 111 fDTDHandler.comment(text, augmentations); 112 } 113 } 114 115 public void processingInstruction(String target, XMLString data, 116 Augmentations augmentations) throws XNIException { 117 if (fDTDHandler != null) { 118 fDTDHandler.processingInstruction(target, data, augmentations); 119 } 120 } 121 122 public void elementDecl(String name, String contentModel, 123 Augmentations augmentations) throws XNIException { 124 if (fDTDHandler != null) { 125 fDTDHandler.elementDecl(name, contentModel, augmentations); 126 } 127 } 128 129 public void startAttlist(String elementName, Augmentations augmentations) 130 throws XNIException { 131 if (fDTDHandler != null) { 132 fDTDHandler.startAttlist(elementName, augmentations); 133 } 134 } 135 136 public void attributeDecl(String elementName, String attributeName, 137 String type, String [] enumeration, String defaultType, 138 XMLString defaultValue, XMLString nonNormalizedDefaultValue, 139 Augmentations augmentations) throws XNIException { 140 if (fDTDHandler != null) { 141 fDTDHandler.attributeDecl(elementName, attributeName, 142 type, enumeration, defaultType, 143 defaultValue, nonNormalizedDefaultValue, 144 augmentations); 145 } 146 } 147 148 public void endAttlist(Augmentations augmentations) throws XNIException { 149 if (fDTDHandler != null) { 150 fDTDHandler.endAttlist(augmentations); 151 } 152 } 153 154 public void internalEntityDecl(String name, XMLString text, 155 XMLString nonNormalizedText, Augmentations augmentations) 156 throws XNIException { 157 if (fDTDHandler != null) { 158 fDTDHandler.internalEntityDecl(name, text, 159 nonNormalizedText, augmentations); 160 } 161 } 162 163 public void externalEntityDecl(String name, 164 XMLResourceIdentifier identifier, Augmentations augmentations) 165 throws XNIException { 166 if (fDTDHandler != null) { 167 fDTDHandler.externalEntityDecl(name, identifier, augmentations); 168 } 169 } 170 171 public void unparsedEntityDecl(String name, 172 XMLResourceIdentifier identifier, String notation, 173 Augmentations augmentations) throws XNIException { 174 if (fUnparsedEntities == null) { 175 fUnparsedEntities = new HashMap (); 176 } 177 fUnparsedEntities.put(name, name); 178 if (fDTDHandler != null) { 179 fDTDHandler.unparsedEntityDecl(name, identifier, notation, augmentations); 180 } 181 } 182 183 public void notationDecl(String name, XMLResourceIdentifier identifier, 184 Augmentations augmentations) throws XNIException { 185 if (fDTDHandler != null) { 186 fDTDHandler.notationDecl(name, identifier, augmentations); 187 } 188 } 189 190 public void startConditional(short type, Augmentations augmentations) 191 throws XNIException { 192 if (fDTDHandler != null) { 193 fDTDHandler.startConditional(type, augmentations); 194 } 195 } 196 197 public void ignoredCharacters(XMLString text, Augmentations augmentations) 198 throws XNIException { 199 if (fDTDHandler != null) { 200 fDTDHandler.ignoredCharacters(text, augmentations); 201 } 202 203 } 204 205 public void endConditional(Augmentations augmentations) throws XNIException { 206 if (fDTDHandler != null) { 207 fDTDHandler.endConditional(augmentations); 208 } 209 } 210 211 public void endDTD(Augmentations augmentations) throws XNIException { 212 if (fDTDHandler != null) { 213 fDTDHandler.endDTD(augmentations); 214 } 215 } 216 217 public void setDTDSource(XMLDTDSource source) { 218 fDTDSource = source; 219 } 220 221 public XMLDTDSource getDTDSource() { 222 return fDTDSource; 223 } 224 225 228 229 public void setDTDHandler(XMLDTDHandler handler) { 230 fDTDHandler = handler; 231 } 232 233 public XMLDTDHandler getDTDHandler() { 234 return fDTDHandler; 235 } 236 237 240 241 public boolean isEntityDeclared(String name) { 242 return false; 243 } 244 245 public boolean isEntityUnparsed(String name) { 246 if (fUnparsedEntities != null) { 247 return fUnparsedEntities.containsKey(name); 248 } 249 return false; 250 } 251 252 } 253 | Popular Tags |