jaxp/src/com/sun/org/apache/xerces/internal/xinclude/XIncludeHandler.java
changeset 17538 d8d911c4e5d4
parent 17534 21dc0b2762da
child 18890 25bdeca3173b
child 20964 a5cd729f176d
equal deleted inserted replaced
17537:50528ec0ea37 17538:d8d911c4e5d4
    66 import com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource;
    66 import com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource;
    67 import com.sun.org.apache.xerces.internal.xni.parser.XMLParserConfiguration;
    67 import com.sun.org.apache.xerces.internal.xni.parser.XMLParserConfiguration;
    68 import com.sun.org.apache.xerces.internal.xpointer.XPointerHandler;
    68 import com.sun.org.apache.xerces.internal.xpointer.XPointerHandler;
    69 import com.sun.org.apache.xerces.internal.xpointer.XPointerProcessor;
    69 import com.sun.org.apache.xerces.internal.xpointer.XPointerProcessor;
    70 import com.sun.org.apache.xerces.internal.utils.ObjectFactory;
    70 import com.sun.org.apache.xerces.internal.utils.ObjectFactory;
       
    71 import java.util.Objects;
    71 
    72 
    72 /**
    73 /**
    73  * <p>
    74  * <p>
    74  * This is a pipeline component which performs XInclude handling, according to the
    75  * This is a pipeline component which performs XInclude handling, according to the
    75  * W3C specification for XML Inclusions.
    76  * W3C specification for XML Inclusions.
   388         fCurrentLanguage = null;
   389         fCurrentLanguage = null;
   389     }
   390     }
   390 
   391 
   391     // XMLComponent methods
   392     // XMLComponent methods
   392 
   393 
       
   394     @Override
   393     public void reset(XMLComponentManager componentManager)
   395     public void reset(XMLComponentManager componentManager)
   394         throws XNIException {
   396         throws XNIException {
   395         fNamespaceContext = null;
   397         fNamespaceContext = null;
   396         fDepth = 0;
   398         fDepth = 0;
   397         fResultDepth = isRootDocument() ? 0 : fParentXIncludeHandler.getResultDepth();
   399         fResultDepth = isRootDocument() ? 0 : fParentXIncludeHandler.getResultDepth();
   595     /**
   597     /**
   596      * Returns a list of feature identifiers that are recognized by
   598      * Returns a list of feature identifiers that are recognized by
   597      * this component. This method may return null if no features
   599      * this component. This method may return null if no features
   598      * are recognized by this component.
   600      * are recognized by this component.
   599      */
   601      */
       
   602     @Override
   600     public String[] getRecognizedFeatures() {
   603     public String[] getRecognizedFeatures() {
   601         return (String[])(RECOGNIZED_FEATURES.clone());
   604         return (String[])(RECOGNIZED_FEATURES.clone());
   602     } // getRecognizedFeatures():String[]
   605     } // getRecognizedFeatures():String[]
   603 
   606 
   604     /**
   607     /**
   614      * @throws SAXNotRecognizedException The component should not throw
   617      * @throws SAXNotRecognizedException The component should not throw
   615      *                                   this exception.
   618      *                                   this exception.
   616      * @throws SAXNotSupportedException The component should not throw
   619      * @throws SAXNotSupportedException The component should not throw
   617      *                                  this exception.
   620      *                                  this exception.
   618      */
   621      */
       
   622     @Override
   619     public void setFeature(String featureId, boolean state)
   623     public void setFeature(String featureId, boolean state)
   620         throws XMLConfigurationException {
   624         throws XMLConfigurationException {
   621         if (featureId.equals(ALLOW_UE_AND_NOTATION_EVENTS)) {
   625         if (featureId.equals(ALLOW_UE_AND_NOTATION_EVENTS)) {
   622             fSendUEAndNotationEvents = state;
   626             fSendUEAndNotationEvents = state;
   623         }
   627         }
   630     /**
   634     /**
   631      * Returns a list of property identifiers that are recognized by
   635      * Returns a list of property identifiers that are recognized by
   632      * this component. This method may return null if no properties
   636      * this component. This method may return null if no properties
   633      * are recognized by this component.
   637      * are recognized by this component.
   634      */
   638      */
       
   639     @Override
   635     public String[] getRecognizedProperties() {
   640     public String[] getRecognizedProperties() {
   636         return (String[])(RECOGNIZED_PROPERTIES.clone());
   641         return (String[])(RECOGNIZED_PROPERTIES.clone());
   637     } // getRecognizedProperties():String[]
   642     } // getRecognizedProperties():String[]
   638 
   643 
   639     /**
   644     /**
   649      * @throws SAXNotRecognizedException The component should not throw
   654      * @throws SAXNotRecognizedException The component should not throw
   650      *                                   this exception.
   655      *                                   this exception.
   651      * @throws SAXNotSupportedException The component should not throw
   656      * @throws SAXNotSupportedException The component should not throw
   652      *                                  this exception.
   657      *                                  this exception.
   653      */
   658      */
       
   659     @Override
   654     public void setProperty(String propertyId, Object value)
   660     public void setProperty(String propertyId, Object value)
   655         throws XMLConfigurationException {
   661         throws XMLConfigurationException {
   656         if (propertyId.equals(SYMBOL_TABLE)) {
   662         if (propertyId.equals(SYMBOL_TABLE)) {
   657             fSymbolTable = (SymbolTable)value;
   663             fSymbolTable = (SymbolTable)value;
   658             if (fChildConfig != null) {
   664             if (fChildConfig != null) {
   717      *
   723      *
   718      * @param featureId The feature identifier.
   724      * @param featureId The feature identifier.
   719      *
   725      *
   720      * @since Xerces 2.2.0
   726      * @since Xerces 2.2.0
   721      */
   727      */
       
   728     @Override
   722     public Boolean getFeatureDefault(String featureId) {
   729     public Boolean getFeatureDefault(String featureId) {
   723         for (int i = 0; i < RECOGNIZED_FEATURES.length; i++) {
   730         for (int i = 0; i < RECOGNIZED_FEATURES.length; i++) {
   724             if (RECOGNIZED_FEATURES[i].equals(featureId)) {
   731             if (RECOGNIZED_FEATURES[i].equals(featureId)) {
   725                 return FEATURE_DEFAULTS[i];
   732                 return FEATURE_DEFAULTS[i];
   726             }
   733             }
   735      *
   742      *
   736      * @param propertyId The property identifier.
   743      * @param propertyId The property identifier.
   737      *
   744      *
   738      * @since Xerces 2.2.0
   745      * @since Xerces 2.2.0
   739      */
   746      */
       
   747     @Override
   740     public Object getPropertyDefault(String propertyId) {
   748     public Object getPropertyDefault(String propertyId) {
   741         for (int i = 0; i < RECOGNIZED_PROPERTIES.length; i++) {
   749         for (int i = 0; i < RECOGNIZED_PROPERTIES.length; i++) {
   742             if (RECOGNIZED_PROPERTIES[i].equals(propertyId)) {
   750             if (RECOGNIZED_PROPERTIES[i].equals(propertyId)) {
   743                 return PROPERTY_DEFAULTS[i];
   751                 return PROPERTY_DEFAULTS[i];
   744             }
   752             }
   745         }
   753         }
   746         return null;
   754         return null;
   747     } // getPropertyDefault(String):Object
   755     } // getPropertyDefault(String):Object
   748 
   756 
       
   757     @Override
   749     public void setDocumentHandler(XMLDocumentHandler handler) {
   758     public void setDocumentHandler(XMLDocumentHandler handler) {
   750         fDocumentHandler = handler;
   759         fDocumentHandler = handler;
   751     }
   760     }
   752 
   761 
       
   762     @Override
   753     public XMLDocumentHandler getDocumentHandler() {
   763     public XMLDocumentHandler getDocumentHandler() {
   754         return fDocumentHandler;
   764         return fDocumentHandler;
   755     }
   765     }
   756 
   766 
   757     // XMLDocumentHandler methods
   767     // XMLDocumentHandler methods
   762      * A fatal error will occur here, if it is detected that this document has been processed
   772      * A fatal error will occur here, if it is detected that this document has been processed
   763      * before.
   773      * before.
   764      *
   774      *
   765      * This event is only passed on to the document handler if this is the root document.
   775      * This event is only passed on to the document handler if this is the root document.
   766      */
   776      */
       
   777     @Override
   767     public void startDocument(
   778     public void startDocument(
   768         XMLLocator locator,
   779         XMLLocator locator,
   769         String encoding,
   780         String encoding,
   770         NamespaceContext namespaceContext,
   781         NamespaceContext namespaceContext,
   771         Augmentations augs)
   782         Augmentations augs)
   809                 namespaceContext,
   820                 namespaceContext,
   810                 augs);
   821                 augs);
   811         }
   822         }
   812     }
   823     }
   813 
   824 
       
   825     @Override
   814     public void xmlDecl(
   826     public void xmlDecl(
   815         String version,
   827         String version,
   816         String encoding,
   828         String encoding,
   817         String standalone,
   829         String standalone,
   818         Augmentations augs)
   830         Augmentations augs)
   821         if (isRootDocument() && fDocumentHandler != null) {
   833         if (isRootDocument() && fDocumentHandler != null) {
   822             fDocumentHandler.xmlDecl(version, encoding, standalone, augs);
   834             fDocumentHandler.xmlDecl(version, encoding, standalone, augs);
   823         }
   835         }
   824     }
   836     }
   825 
   837 
       
   838     @Override
   826     public void doctypeDecl(
   839     public void doctypeDecl(
   827         String rootElement,
   840         String rootElement,
   828         String publicId,
   841         String publicId,
   829         String systemId,
   842         String systemId,
   830         Augmentations augs)
   843         Augmentations augs)
   832         if (isRootDocument() && fDocumentHandler != null) {
   845         if (isRootDocument() && fDocumentHandler != null) {
   833             fDocumentHandler.doctypeDecl(rootElement, publicId, systemId, augs);
   846             fDocumentHandler.doctypeDecl(rootElement, publicId, systemId, augs);
   834         }
   847         }
   835     }
   848     }
   836 
   849 
       
   850     @Override
   837     public void comment(XMLString text, Augmentations augs)
   851     public void comment(XMLString text, Augmentations augs)
   838         throws XNIException {
   852         throws XNIException {
   839         if (!fInDTD) {
   853         if (!fInDTD) {
   840             if (fDocumentHandler != null
   854             if (fDocumentHandler != null
   841                 && getState() == STATE_NORMAL_PROCESSING) {
   855                 && getState() == STATE_NORMAL_PROCESSING) {
   848         else if (fDTDHandler != null) {
   862         else if (fDTDHandler != null) {
   849             fDTDHandler.comment(text, augs);
   863             fDTDHandler.comment(text, augs);
   850         }
   864         }
   851     }
   865     }
   852 
   866 
       
   867     @Override
   853     public void processingInstruction(
   868     public void processingInstruction(
   854         String target,
   869         String target,
   855         XMLString data,
   870         XMLString data,
   856         Augmentations augs)
   871         Augmentations augs)
   857         throws XNIException {
   872         throws XNIException {
   868         else if (fDTDHandler != null) {
   883         else if (fDTDHandler != null) {
   869             fDTDHandler.processingInstruction(target, data, augs);
   884             fDTDHandler.processingInstruction(target, data, augs);
   870         }
   885         }
   871     }
   886     }
   872 
   887 
       
   888     @Override
   873     public void startElement(
   889     public void startElement(
   874         QName element,
   890         QName element,
   875         XMLAttributes attributes,
   891         XMLAttributes attributes,
   876         Augmentations augs)
   892         Augmentations augs)
   877         throws XNIException {
   893         throws XNIException {
   938                 fDocumentHandler.startElement(element, attributes, augs);
   954                 fDocumentHandler.startElement(element, attributes, augs);
   939             }
   955             }
   940         }
   956         }
   941     }
   957     }
   942 
   958 
       
   959     @Override
   943     public void emptyElement(
   960     public void emptyElement(
   944         QName element,
   961         QName element,
   945         XMLAttributes attributes,
   962         XMLAttributes attributes,
   946         Augmentations augs)
   963         Augmentations augs)
   947         throws XNIException {
   964         throws XNIException {
  1019             restoreBaseURI();
  1036             restoreBaseURI();
  1020         }
  1037         }
  1021         fDepth--;
  1038         fDepth--;
  1022     }
  1039     }
  1023 
  1040 
       
  1041     @Override
  1024     public void endElement(QName element, Augmentations augs)
  1042     public void endElement(QName element, Augmentations augs)
  1025         throws XNIException {
  1043         throws XNIException {
  1026 
  1044 
  1027         if (isIncludeElement(element)) {
  1045         if (isIncludeElement(element)) {
  1028             // if we're ending an include element, and we were expecting a fallback
  1046             // if we're ending an include element, and we were expecting a fallback
  1064         }
  1082         }
  1065 
  1083 
  1066         fDepth--;
  1084         fDepth--;
  1067     }
  1085     }
  1068 
  1086 
       
  1087     @Override
  1069     public void startGeneralEntity(
  1088     public void startGeneralEntity(
  1070         String name,
  1089         String name,
  1071         XMLResourceIdentifier resId,
  1090         XMLResourceIdentifier resId,
  1072         String encoding,
  1091         String encoding,
  1073         Augmentations augs)
  1092         Augmentations augs)
  1082                 fDocumentHandler.startGeneralEntity(name, resId, encoding, augs);
  1101                 fDocumentHandler.startGeneralEntity(name, resId, encoding, augs);
  1083             }
  1102             }
  1084         }
  1103         }
  1085     }
  1104     }
  1086 
  1105 
       
  1106     @Override
  1087     public void textDecl(String version, String encoding, Augmentations augs)
  1107     public void textDecl(String version, String encoding, Augmentations augs)
  1088         throws XNIException {
  1108         throws XNIException {
  1089         if (fDocumentHandler != null
  1109         if (fDocumentHandler != null
  1090             && getState() == STATE_NORMAL_PROCESSING) {
  1110             && getState() == STATE_NORMAL_PROCESSING) {
  1091             fDocumentHandler.textDecl(version, encoding, augs);
  1111             fDocumentHandler.textDecl(version, encoding, augs);
  1092         }
  1112         }
  1093     }
  1113     }
  1094 
  1114 
       
  1115     @Override
  1095     public void endGeneralEntity(String name, Augmentations augs)
  1116     public void endGeneralEntity(String name, Augmentations augs)
  1096         throws XNIException {
  1117         throws XNIException {
  1097         if (fDocumentHandler != null
  1118         if (fDocumentHandler != null
  1098             && getState() == STATE_NORMAL_PROCESSING
  1119             && getState() == STATE_NORMAL_PROCESSING
  1099             && fResultDepth != 0) {
  1120             && fResultDepth != 0) {
  1100             fDocumentHandler.endGeneralEntity(name, augs);
  1121             fDocumentHandler.endGeneralEntity(name, augs);
  1101         }
  1122         }
  1102     }
  1123     }
  1103 
  1124 
       
  1125     @Override
  1104     public void characters(XMLString text, Augmentations augs)
  1126     public void characters(XMLString text, Augmentations augs)
  1105         throws XNIException {
  1127         throws XNIException {
  1106         if (getState() == STATE_NORMAL_PROCESSING) {
  1128         if (getState() == STATE_NORMAL_PROCESSING) {
  1107             if (fResultDepth == 0) {
  1129             if (fResultDepth == 0) {
  1108                 checkWhitespace(text);
  1130                 checkWhitespace(text);
  1115                 fDepth--;
  1137                 fDepth--;
  1116             }
  1138             }
  1117         }
  1139         }
  1118     }
  1140     }
  1119 
  1141 
       
  1142     @Override
  1120     public void ignorableWhitespace(XMLString text, Augmentations augs)
  1143     public void ignorableWhitespace(XMLString text, Augmentations augs)
  1121         throws XNIException {
  1144         throws XNIException {
  1122         if (fDocumentHandler != null
  1145         if (fDocumentHandler != null
  1123             && getState() == STATE_NORMAL_PROCESSING
  1146             && getState() == STATE_NORMAL_PROCESSING
  1124             && fResultDepth != 0) {
  1147             && fResultDepth != 0) {
  1125             fDocumentHandler.ignorableWhitespace(text, augs);
  1148             fDocumentHandler.ignorableWhitespace(text, augs);
  1126         }
  1149         }
  1127     }
  1150     }
  1128 
  1151 
       
  1152     @Override
  1129     public void startCDATA(Augmentations augs) throws XNIException {
  1153     public void startCDATA(Augmentations augs) throws XNIException {
  1130         if (fDocumentHandler != null
  1154         if (fDocumentHandler != null
  1131             && getState() == STATE_NORMAL_PROCESSING
  1155             && getState() == STATE_NORMAL_PROCESSING
  1132             && fResultDepth != 0) {
  1156             && fResultDepth != 0) {
  1133             fDocumentHandler.startCDATA(augs);
  1157             fDocumentHandler.startCDATA(augs);
  1134         }
  1158         }
  1135     }
  1159     }
  1136 
  1160 
       
  1161     @Override
  1137     public void endCDATA(Augmentations augs) throws XNIException {
  1162     public void endCDATA(Augmentations augs) throws XNIException {
  1138         if (fDocumentHandler != null
  1163         if (fDocumentHandler != null
  1139             && getState() == STATE_NORMAL_PROCESSING
  1164             && getState() == STATE_NORMAL_PROCESSING
  1140             && fResultDepth != 0) {
  1165             && fResultDepth != 0) {
  1141             fDocumentHandler.endCDATA(augs);
  1166             fDocumentHandler.endCDATA(augs);
  1142         }
  1167         }
  1143     }
  1168     }
  1144 
  1169 
       
  1170     @Override
  1145     public void endDocument(Augmentations augs) throws XNIException {
  1171     public void endDocument(Augmentations augs) throws XNIException {
  1146         if (isRootDocument()) {
  1172         if (isRootDocument()) {
  1147             if (!fSeenRootElement) {
  1173             if (!fSeenRootElement) {
  1148                 reportFatalError("RootElementRequired");
  1174                 reportFatalError("RootElementRequired");
  1149             }
  1175             }
  1151                 fDocumentHandler.endDocument(augs);
  1177                 fDocumentHandler.endDocument(augs);
  1152             }
  1178             }
  1153         }
  1179         }
  1154     }
  1180     }
  1155 
  1181 
       
  1182     @Override
  1156     public void setDocumentSource(XMLDocumentSource source) {
  1183     public void setDocumentSource(XMLDocumentSource source) {
  1157         fDocumentSource = source;
  1184         fDocumentSource = source;
  1158     }
  1185     }
  1159 
  1186 
       
  1187     @Override
  1160     public XMLDocumentSource getDocumentSource() {
  1188     public XMLDocumentSource getDocumentSource() {
  1161         return fDocumentSource;
  1189         return fDocumentSource;
  1162     }
  1190     }
  1163 
  1191 
  1164     // DTDHandler methods
  1192     // DTDHandler methods
  1166     // the rest we just pass on
  1194     // the rest we just pass on
  1167 
  1195 
  1168     /* (non-Javadoc)
  1196     /* (non-Javadoc)
  1169      * @see com.sun.org.apache.xerces.internal.xni.XMLDTDHandler#attributeDecl(java.lang.String, java.lang.String, java.lang.String, java.lang.String[], java.lang.String, com.sun.org.apache.xerces.internal.xni.XMLString, com.sun.org.apache.xerces.internal.xni.XMLString, com.sun.org.apache.xerces.internal.xni.Augmentations)
  1197      * @see com.sun.org.apache.xerces.internal.xni.XMLDTDHandler#attributeDecl(java.lang.String, java.lang.String, java.lang.String, java.lang.String[], java.lang.String, com.sun.org.apache.xerces.internal.xni.XMLString, com.sun.org.apache.xerces.internal.xni.XMLString, com.sun.org.apache.xerces.internal.xni.Augmentations)
  1170      */
  1198      */
       
  1199     @Override
  1171     public void attributeDecl(
  1200     public void attributeDecl(
  1172         String elementName,
  1201         String elementName,
  1173         String attributeName,
  1202         String attributeName,
  1174         String type,
  1203         String type,
  1175         String[] enumeration,
  1204         String[] enumeration,
  1192     }
  1221     }
  1193 
  1222 
  1194     /* (non-Javadoc)
  1223     /* (non-Javadoc)
  1195      * @see com.sun.org.apache.xerces.internal.xni.XMLDTDHandler#elementDecl(java.lang.String, java.lang.String, com.sun.org.apache.xerces.internal.xni.Augmentations)
  1224      * @see com.sun.org.apache.xerces.internal.xni.XMLDTDHandler#elementDecl(java.lang.String, java.lang.String, com.sun.org.apache.xerces.internal.xni.Augmentations)
  1196      */
  1225      */
       
  1226     @Override
  1197     public void elementDecl(
  1227     public void elementDecl(
  1198         String name,
  1228         String name,
  1199         String contentModel,
  1229         String contentModel,
  1200         Augmentations augmentations)
  1230         Augmentations augmentations)
  1201         throws XNIException {
  1231         throws XNIException {
  1205     }
  1235     }
  1206 
  1236 
  1207     /* (non-Javadoc)
  1237     /* (non-Javadoc)
  1208      * @see com.sun.org.apache.xerces.internal.xni.XMLDTDHandler#endAttlist(com.sun.org.apache.xerces.internal.xni.Augmentations)
  1238      * @see com.sun.org.apache.xerces.internal.xni.XMLDTDHandler#endAttlist(com.sun.org.apache.xerces.internal.xni.Augmentations)
  1209      */
  1239      */
       
  1240     @Override
  1210     public void endAttlist(Augmentations augmentations) throws XNIException {
  1241     public void endAttlist(Augmentations augmentations) throws XNIException {
  1211         if (fDTDHandler != null) {
  1242         if (fDTDHandler != null) {
  1212             fDTDHandler.endAttlist(augmentations);
  1243             fDTDHandler.endAttlist(augmentations);
  1213         }
  1244         }
  1214     }
  1245     }
  1215 
  1246 
  1216     /* (non-Javadoc)
  1247     /* (non-Javadoc)
  1217      * @see com.sun.org.apache.xerces.internal.xni.XMLDTDHandler#endConditional(com.sun.org.apache.xerces.internal.xni.Augmentations)
  1248      * @see com.sun.org.apache.xerces.internal.xni.XMLDTDHandler#endConditional(com.sun.org.apache.xerces.internal.xni.Augmentations)
  1218      */
  1249      */
       
  1250     @Override
  1219     public void endConditional(Augmentations augmentations)
  1251     public void endConditional(Augmentations augmentations)
  1220         throws XNIException {
  1252         throws XNIException {
  1221         if (fDTDHandler != null) {
  1253         if (fDTDHandler != null) {
  1222             fDTDHandler.endConditional(augmentations);
  1254             fDTDHandler.endConditional(augmentations);
  1223         }
  1255         }
  1224     }
  1256     }
  1225 
  1257 
  1226     /* (non-Javadoc)
  1258     /* (non-Javadoc)
  1227      * @see com.sun.org.apache.xerces.internal.xni.XMLDTDHandler#endDTD(com.sun.org.apache.xerces.internal.xni.Augmentations)
  1259      * @see com.sun.org.apache.xerces.internal.xni.XMLDTDHandler#endDTD(com.sun.org.apache.xerces.internal.xni.Augmentations)
  1228      */
  1260      */
       
  1261     @Override
  1229     public void endDTD(Augmentations augmentations) throws XNIException {
  1262     public void endDTD(Augmentations augmentations) throws XNIException {
  1230         if (fDTDHandler != null) {
  1263         if (fDTDHandler != null) {
  1231             fDTDHandler.endDTD(augmentations);
  1264             fDTDHandler.endDTD(augmentations);
  1232         }
  1265         }
  1233         fInDTD = false;
  1266         fInDTD = false;
  1234     }
  1267     }
  1235 
  1268 
  1236     /* (non-Javadoc)
  1269     /* (non-Javadoc)
  1237      * @see com.sun.org.apache.xerces.internal.xni.XMLDTDHandler#endExternalSubset(com.sun.org.apache.xerces.internal.xni.Augmentations)
  1270      * @see com.sun.org.apache.xerces.internal.xni.XMLDTDHandler#endExternalSubset(com.sun.org.apache.xerces.internal.xni.Augmentations)
  1238      */
  1271      */
       
  1272     @Override
  1239     public void endExternalSubset(Augmentations augmentations)
  1273     public void endExternalSubset(Augmentations augmentations)
  1240         throws XNIException {
  1274         throws XNIException {
  1241         if (fDTDHandler != null) {
  1275         if (fDTDHandler != null) {
  1242             fDTDHandler.endExternalSubset(augmentations);
  1276             fDTDHandler.endExternalSubset(augmentations);
  1243         }
  1277         }
  1244     }
  1278     }
  1245 
  1279 
  1246     /* (non-Javadoc)
  1280     /* (non-Javadoc)
  1247      * @see com.sun.org.apache.xerces.internal.xni.XMLDTDHandler#endParameterEntity(java.lang.String, com.sun.org.apache.xerces.internal.xni.Augmentations)
  1281      * @see com.sun.org.apache.xerces.internal.xni.XMLDTDHandler#endParameterEntity(java.lang.String, com.sun.org.apache.xerces.internal.xni.Augmentations)
  1248      */
  1282      */
       
  1283     @Override
  1249     public void endParameterEntity(String name, Augmentations augmentations)
  1284     public void endParameterEntity(String name, Augmentations augmentations)
  1250         throws XNIException {
  1285         throws XNIException {
  1251         if (fDTDHandler != null) {
  1286         if (fDTDHandler != null) {
  1252             fDTDHandler.endParameterEntity(name, augmentations);
  1287             fDTDHandler.endParameterEntity(name, augmentations);
  1253         }
  1288         }
  1254     }
  1289     }
  1255 
  1290 
  1256     /* (non-Javadoc)
  1291     /* (non-Javadoc)
  1257      * @see com.sun.org.apache.xerces.internal.xni.XMLDTDHandler#externalEntityDecl(java.lang.String, com.sun.org.apache.xerces.internal.xni.XMLResourceIdentifier, com.sun.org.apache.xerces.internal.xni.Augmentations)
  1292      * @see com.sun.org.apache.xerces.internal.xni.XMLDTDHandler#externalEntityDecl(java.lang.String, com.sun.org.apache.xerces.internal.xni.XMLResourceIdentifier, com.sun.org.apache.xerces.internal.xni.Augmentations)
  1258      */
  1293      */
       
  1294     @Override
  1259     public void externalEntityDecl(
  1295     public void externalEntityDecl(
  1260         String name,
  1296         String name,
  1261         XMLResourceIdentifier identifier,
  1297         XMLResourceIdentifier identifier,
  1262         Augmentations augmentations)
  1298         Augmentations augmentations)
  1263         throws XNIException {
  1299         throws XNIException {
  1267     }
  1303     }
  1268 
  1304 
  1269     /* (non-Javadoc)
  1305     /* (non-Javadoc)
  1270      * @see com.sun.org.apache.xerces.internal.xni.XMLDTDHandler#getDTDSource()
  1306      * @see com.sun.org.apache.xerces.internal.xni.XMLDTDHandler#getDTDSource()
  1271      */
  1307      */
       
  1308     @Override
  1272     public XMLDTDSource getDTDSource() {
  1309     public XMLDTDSource getDTDSource() {
  1273         return fDTDSource;
  1310         return fDTDSource;
  1274     }
  1311     }
  1275 
  1312 
  1276     /* (non-Javadoc)
  1313     /* (non-Javadoc)
  1277      * @see com.sun.org.apache.xerces.internal.xni.XMLDTDHandler#ignoredCharacters(com.sun.org.apache.xerces.internal.xni.XMLString, com.sun.org.apache.xerces.internal.xni.Augmentations)
  1314      * @see com.sun.org.apache.xerces.internal.xni.XMLDTDHandler#ignoredCharacters(com.sun.org.apache.xerces.internal.xni.XMLString, com.sun.org.apache.xerces.internal.xni.Augmentations)
  1278      */
  1315      */
       
  1316     @Override
  1279     public void ignoredCharacters(XMLString text, Augmentations augmentations)
  1317     public void ignoredCharacters(XMLString text, Augmentations augmentations)
  1280         throws XNIException {
  1318         throws XNIException {
  1281         if (fDTDHandler != null) {
  1319         if (fDTDHandler != null) {
  1282             fDTDHandler.ignoredCharacters(text, augmentations);
  1320             fDTDHandler.ignoredCharacters(text, augmentations);
  1283         }
  1321         }
  1284     }
  1322     }
  1285 
  1323 
  1286     /* (non-Javadoc)
  1324     /* (non-Javadoc)
  1287      * @see com.sun.org.apache.xerces.internal.xni.XMLDTDHandler#internalEntityDecl(java.lang.String, com.sun.org.apache.xerces.internal.xni.XMLString, com.sun.org.apache.xerces.internal.xni.XMLString, com.sun.org.apache.xerces.internal.xni.Augmentations)
  1325      * @see com.sun.org.apache.xerces.internal.xni.XMLDTDHandler#internalEntityDecl(java.lang.String, com.sun.org.apache.xerces.internal.xni.XMLString, com.sun.org.apache.xerces.internal.xni.XMLString, com.sun.org.apache.xerces.internal.xni.Augmentations)
  1288      */
  1326      */
       
  1327     @Override
  1289     public void internalEntityDecl(
  1328     public void internalEntityDecl(
  1290         String name,
  1329         String name,
  1291         XMLString text,
  1330         XMLString text,
  1292         XMLString nonNormalizedText,
  1331         XMLString nonNormalizedText,
  1293         Augmentations augmentations)
  1332         Augmentations augmentations)
  1302     }
  1341     }
  1303 
  1342 
  1304     /* (non-Javadoc)
  1343     /* (non-Javadoc)
  1305      * @see com.sun.org.apache.xerces.internal.xni.XMLDTDHandler#notationDecl(java.lang.String, com.sun.org.apache.xerces.internal.xni.XMLResourceIdentifier, com.sun.org.apache.xerces.internal.xni.Augmentations)
  1344      * @see com.sun.org.apache.xerces.internal.xni.XMLDTDHandler#notationDecl(java.lang.String, com.sun.org.apache.xerces.internal.xni.XMLResourceIdentifier, com.sun.org.apache.xerces.internal.xni.Augmentations)
  1306      */
  1345      */
       
  1346     @Override
  1307     public void notationDecl(
  1347     public void notationDecl(
  1308         String name,
  1348         String name,
  1309         XMLResourceIdentifier identifier,
  1349         XMLResourceIdentifier identifier,
  1310         Augmentations augmentations)
  1350         Augmentations augmentations)
  1311         throws XNIException {
  1351         throws XNIException {
  1316     }
  1356     }
  1317 
  1357 
  1318     /* (non-Javadoc)
  1358     /* (non-Javadoc)
  1319      * @see com.sun.org.apache.xerces.internal.xni.XMLDTDHandler#setDTDSource(com.sun.org.apache.xerces.internal.xni.parser.XMLDTDSource)
  1359      * @see com.sun.org.apache.xerces.internal.xni.XMLDTDHandler#setDTDSource(com.sun.org.apache.xerces.internal.xni.parser.XMLDTDSource)
  1320      */
  1360      */
       
  1361     @Override
  1321     public void setDTDSource(XMLDTDSource source) {
  1362     public void setDTDSource(XMLDTDSource source) {
  1322         fDTDSource = source;
  1363         fDTDSource = source;
  1323     }
  1364     }
  1324 
  1365 
  1325     /* (non-Javadoc)
  1366     /* (non-Javadoc)
  1326      * @see com.sun.org.apache.xerces.internal.xni.XMLDTDHandler#startAttlist(java.lang.String, com.sun.org.apache.xerces.internal.xni.Augmentations)
  1367      * @see com.sun.org.apache.xerces.internal.xni.XMLDTDHandler#startAttlist(java.lang.String, com.sun.org.apache.xerces.internal.xni.Augmentations)
  1327      */
  1368      */
       
  1369     @Override
  1328     public void startAttlist(String elementName, Augmentations augmentations)
  1370     public void startAttlist(String elementName, Augmentations augmentations)
  1329         throws XNIException {
  1371         throws XNIException {
  1330         if (fDTDHandler != null) {
  1372         if (fDTDHandler != null) {
  1331             fDTDHandler.startAttlist(elementName, augmentations);
  1373             fDTDHandler.startAttlist(elementName, augmentations);
  1332         }
  1374         }
  1333     }
  1375     }
  1334 
  1376 
  1335     /* (non-Javadoc)
  1377     /* (non-Javadoc)
  1336      * @see com.sun.org.apache.xerces.internal.xni.XMLDTDHandler#startConditional(short, com.sun.org.apache.xerces.internal.xni.Augmentations)
  1378      * @see com.sun.org.apache.xerces.internal.xni.XMLDTDHandler#startConditional(short, com.sun.org.apache.xerces.internal.xni.Augmentations)
  1337      */
  1379      */
       
  1380     @Override
  1338     public void startConditional(short type, Augmentations augmentations)
  1381     public void startConditional(short type, Augmentations augmentations)
  1339         throws XNIException {
  1382         throws XNIException {
  1340         if (fDTDHandler != null) {
  1383         if (fDTDHandler != null) {
  1341             fDTDHandler.startConditional(type, augmentations);
  1384             fDTDHandler.startConditional(type, augmentations);
  1342         }
  1385         }
  1343     }
  1386     }
  1344 
  1387 
  1345     /* (non-Javadoc)
  1388     /* (non-Javadoc)
  1346      * @see com.sun.org.apache.xerces.internal.xni.XMLDTDHandler#startDTD(com.sun.org.apache.xerces.internal.xni.XMLLocator, com.sun.org.apache.xerces.internal.xni.Augmentations)
  1389      * @see com.sun.org.apache.xerces.internal.xni.XMLDTDHandler#startDTD(com.sun.org.apache.xerces.internal.xni.XMLLocator, com.sun.org.apache.xerces.internal.xni.Augmentations)
  1347      */
  1390      */
       
  1391     @Override
  1348     public void startDTD(XMLLocator locator, Augmentations augmentations)
  1392     public void startDTD(XMLLocator locator, Augmentations augmentations)
  1349         throws XNIException {
  1393         throws XNIException {
  1350         fInDTD = true;
  1394         fInDTD = true;
  1351         if (fDTDHandler != null) {
  1395         if (fDTDHandler != null) {
  1352             fDTDHandler.startDTD(locator, augmentations);
  1396             fDTDHandler.startDTD(locator, augmentations);
  1354     }
  1398     }
  1355 
  1399 
  1356     /* (non-Javadoc)
  1400     /* (non-Javadoc)
  1357      * @see com.sun.org.apache.xerces.internal.xni.XMLDTDHandler#startExternalSubset(com.sun.org.apache.xerces.internal.xni.XMLResourceIdentifier, com.sun.org.apache.xerces.internal.xni.Augmentations)
  1401      * @see com.sun.org.apache.xerces.internal.xni.XMLDTDHandler#startExternalSubset(com.sun.org.apache.xerces.internal.xni.XMLResourceIdentifier, com.sun.org.apache.xerces.internal.xni.Augmentations)
  1358      */
  1402      */
       
  1403     @Override
  1359     public void startExternalSubset(
  1404     public void startExternalSubset(
  1360         XMLResourceIdentifier identifier,
  1405         XMLResourceIdentifier identifier,
  1361         Augmentations augmentations)
  1406         Augmentations augmentations)
  1362         throws XNIException {
  1407         throws XNIException {
  1363         if (fDTDHandler != null) {
  1408         if (fDTDHandler != null) {
  1366     }
  1411     }
  1367 
  1412 
  1368     /* (non-Javadoc)
  1413     /* (non-Javadoc)
  1369      * @see com.sun.org.apache.xerces.internal.xni.XMLDTDHandler#startParameterEntity(java.lang.String, com.sun.org.apache.xerces.internal.xni.XMLResourceIdentifier, java.lang.String, com.sun.org.apache.xerces.internal.xni.Augmentations)
  1414      * @see com.sun.org.apache.xerces.internal.xni.XMLDTDHandler#startParameterEntity(java.lang.String, com.sun.org.apache.xerces.internal.xni.XMLResourceIdentifier, java.lang.String, com.sun.org.apache.xerces.internal.xni.Augmentations)
  1370      */
  1415      */
       
  1416     @Override
  1371     public void startParameterEntity(
  1417     public void startParameterEntity(
  1372         String name,
  1418         String name,
  1373         XMLResourceIdentifier identifier,
  1419         XMLResourceIdentifier identifier,
  1374         String encoding,
  1420         String encoding,
  1375         Augmentations augmentations)
  1421         Augmentations augmentations)
  1384     }
  1430     }
  1385 
  1431 
  1386     /* (non-Javadoc)
  1432     /* (non-Javadoc)
  1387      * @see com.sun.org.apache.xerces.internal.xni.XMLDTDHandler#unparsedEntityDecl(java.lang.String, com.sun.org.apache.xerces.internal.xni.XMLResourceIdentifier, java.lang.String, com.sun.org.apache.xerces.internal.xni.Augmentations)
  1433      * @see com.sun.org.apache.xerces.internal.xni.XMLDTDHandler#unparsedEntityDecl(java.lang.String, com.sun.org.apache.xerces.internal.xni.XMLResourceIdentifier, java.lang.String, com.sun.org.apache.xerces.internal.xni.Augmentations)
  1388      */
  1434      */
       
  1435     @Override
  1389     public void unparsedEntityDecl(
  1436     public void unparsedEntityDecl(
  1390         String name,
  1437         String name,
  1391         XMLResourceIdentifier identifier,
  1438         XMLResourceIdentifier identifier,
  1392         String notation,
  1439         String notation,
  1393         Augmentations augmentations)
  1440         Augmentations augmentations)
  1403     }
  1450     }
  1404 
  1451 
  1405     /* (non-Javadoc)
  1452     /* (non-Javadoc)
  1406      * @see com.sun.org.apache.xerces.internal.xni.parser.XMLDTDSource#getDTDHandler()
  1453      * @see com.sun.org.apache.xerces.internal.xni.parser.XMLDTDSource#getDTDHandler()
  1407      */
  1454      */
       
  1455     @Override
  1408     public XMLDTDHandler getDTDHandler() {
  1456     public XMLDTDHandler getDTDHandler() {
  1409         return fDTDHandler;
  1457         return fDTDHandler;
  1410     }
  1458     }
  1411 
  1459 
  1412     /* (non-Javadoc)
  1460     /* (non-Javadoc)
  1413      * @see com.sun.org.apache.xerces.internal.xni.parser.XMLDTDSource#setDTDHandler(com.sun.org.apache.xerces.internal.xni.XMLDTDHandler)
  1461      * @see com.sun.org.apache.xerces.internal.xni.parser.XMLDTDSource#setDTDHandler(com.sun.org.apache.xerces.internal.xni.XMLDTDHandler)
  1414      */
  1462      */
       
  1463     @Override
  1415     public void setDTDHandler(XMLDTDHandler handler) {
  1464     public void setDTDHandler(XMLDTDHandler handler) {
  1416         fDTDHandler = handler;
  1465         fDTDHandler = handler;
  1417     }
  1466     }
  1418 
  1467 
  1419     // XIncludeHandler methods
  1468     // XIncludeHandler methods
  1639                             Constants.XERCES_PROPERTY_PREFIX
  1688                             Constants.XERCES_PROPERTY_PREFIX
  1640                             + Constants.NAMESPACE_CONTEXT_PROPERTY,
  1689                             + Constants.NAMESPACE_CONTEXT_PROPERTY,
  1641                         fNamespaceContext);
  1690                         fNamespaceContext);
  1642 
  1691 
  1643                     ((XPointerHandler)fXPtrProcessor).setProperty(XINCLUDE_FIXUP_BASE_URIS,
  1692                     ((XPointerHandler)fXPtrProcessor).setProperty(XINCLUDE_FIXUP_BASE_URIS,
  1644                             new Boolean(fFixupBaseURIs));
  1693                             fFixupBaseURIs);
  1645 
  1694 
  1646                     ((XPointerHandler)fXPtrProcessor).setProperty(
  1695                     ((XPointerHandler)fXPtrProcessor).setProperty(
  1647                             XINCLUDE_FIXUP_LANGUAGE,
  1696                             XINCLUDE_FIXUP_LANGUAGE, fFixupLanguage);
  1648                             new Boolean (fFixupLanguage));
       
  1649 
  1697 
  1650                     if (fErrorReporter != null)
  1698                     if (fErrorReporter != null)
  1651                         ((XPointerHandler)fXPtrProcessor).setProperty(ERROR_REPORTER, fErrorReporter);
  1699                         ((XPointerHandler)fXPtrProcessor).setProperty(ERROR_REPORTER, fErrorReporter);
  1652                         // ???
  1700                         // ???
  1653 
  1701 
  2117                 URI uri = new URI(base, relativeURI);
  2165                 URI uri = new URI(base, relativeURI);
  2118 
  2166 
  2119                 /** Check whether the scheme components are equal. */
  2167                 /** Check whether the scheme components are equal. */
  2120                 final String baseScheme = base.getScheme();
  2168                 final String baseScheme = base.getScheme();
  2121                 final String literalScheme = uri.getScheme();
  2169                 final String literalScheme = uri.getScheme();
  2122                 if (!isEqual(baseScheme, literalScheme)) {
  2170                 if (!Objects.equals(baseScheme, literalScheme)) {
  2123                     return relativeURI;
  2171                     return relativeURI;
  2124                 }
  2172                 }
  2125 
  2173 
  2126                 /** Check whether the authority components are equal. */
  2174                 /** Check whether the authority components are equal. */
  2127                 final String baseAuthority = base.getAuthority();
  2175                 final String baseAuthority = base.getAuthority();
  2128                 final String literalAuthority = uri.getAuthority();
  2176                 final String literalAuthority = uri.getAuthority();
  2129                 if (!isEqual(baseAuthority, literalAuthority)) {
  2177                 if (!Objects.equals(baseAuthority, literalAuthority)) {
  2130                     return uri.getSchemeSpecificPart();
  2178                     return uri.getSchemeSpecificPart();
  2131                 }
  2179                 }
  2132 
  2180 
  2133                 /**
  2181                 /**
  2134                  * The scheme and authority components are equal,
  2182                  * The scheme and authority components are equal,
  2137                  */
  2185                  */
  2138                 final String literalPath = uri.getPath();
  2186                 final String literalPath = uri.getPath();
  2139                 final String literalQuery = uri.getQueryString();
  2187                 final String literalQuery = uri.getQueryString();
  2140                 final String literalFragment = uri.getFragment();
  2188                 final String literalFragment = uri.getFragment();
  2141                 if (literalQuery != null || literalFragment != null) {
  2189                 if (literalQuery != null || literalFragment != null) {
  2142                     StringBuffer buffer = new StringBuffer();
  2190                     final StringBuilder buffer = new StringBuilder();
  2143                     if (literalPath != null) {
  2191                     if (literalPath != null) {
  2144                         buffer.append(literalPath);
  2192                         buffer.append(literalPath);
  2145                     }
  2193                     }
  2146                     if (literalQuery != null) {
  2194                     if (literalQuery != null) {
  2147                         buffer.append('?');
  2195                         buffer.append('?');
  2648         public String expandedSystemId;
  2696         public String expandedSystemId;
  2649         public Augmentations augmentations;
  2697         public Augmentations augmentations;
  2650 
  2698 
  2651         // equals() returns true if two Notations have the same name.
  2699         // equals() returns true if two Notations have the same name.
  2652         // Useful for searching Vectors for notations with the same name
  2700         // Useful for searching Vectors for notations with the same name
       
  2701         @Override
  2653         public boolean equals(Object obj) {
  2702         public boolean equals(Object obj) {
  2654             if (obj == null) {
  2703             return obj == this || obj instanceof Notation
  2655                 return false;
  2704                     && Objects.equals(name, ((Notation)obj).name);
  2656             }
  2705         }
  2657             if (obj instanceof Notation) {
  2706 
  2658                 Notation other = (Notation)obj;
  2707         @Override
  2659                 return name.equals(other.name);
  2708         public int hashCode() {
  2660             }
  2709             return Objects.hashCode(name);
  2661             return false;
       
  2662         }
  2710         }
  2663 
  2711 
  2664         // from 4.5.2
  2712         // from 4.5.2
  2665         // Notation items with the same [name], [system identifier],
  2713         // Notation items with the same [name], [system identifier],
  2666         // [public identifier], and [declaration base URI] are considered
  2714         // [public identifier], and [declaration base URI] are considered
  2669         // resulting from combining the system identifier and the declaration
  2717         // resulting from combining the system identifier and the declaration
  2670         // base URI is the same.
  2718         // base URI is the same.
  2671         public boolean isDuplicate(Object obj) {
  2719         public boolean isDuplicate(Object obj) {
  2672             if (obj != null && obj instanceof Notation) {
  2720             if (obj != null && obj instanceof Notation) {
  2673                 Notation other = (Notation)obj;
  2721                 Notation other = (Notation)obj;
  2674                 return name.equals(other.name)
  2722                 return Objects.equals(name, other.name)
  2675                 && isEqual(publicId, other.publicId)
  2723                 && Objects.equals(publicId, other.publicId)
  2676                 && isEqual(expandedSystemId, other.expandedSystemId);
  2724                 && Objects.equals(expandedSystemId, other.expandedSystemId);
  2677             }
  2725             }
  2678             return false;
  2726             return false;
  2679         }
       
  2680 
       
  2681         private boolean isEqual(String one, String two) {
       
  2682             return (one == two || (one != null && one.equals(two)));
       
  2683         }
  2727         }
  2684     }
  2728     }
  2685 
  2729 
  2686     // This is a storage class to hold information about the unparsed entities.
  2730     // This is a storage class to hold information about the unparsed entities.
  2687     // We're not using XMLEntityDecl because we don't want to lose the augmentations.
  2731     // We're not using XMLEntityDecl because we don't want to lose the augmentations.
  2694         public String notation;
  2738         public String notation;
  2695         public Augmentations augmentations;
  2739         public Augmentations augmentations;
  2696 
  2740 
  2697         // equals() returns true if two UnparsedEntities have the same name.
  2741         // equals() returns true if two UnparsedEntities have the same name.
  2698         // Useful for searching Vectors for entities with the same name
  2742         // Useful for searching Vectors for entities with the same name
       
  2743         @Override
  2699         public boolean equals(Object obj) {
  2744         public boolean equals(Object obj) {
  2700             if (obj == null) {
  2745             return obj == this || obj instanceof UnparsedEntity
  2701                 return false;
  2746                     && Objects.equals(name, ((UnparsedEntity)obj).name);
  2702             }
  2747         }
  2703             if (obj instanceof UnparsedEntity) {
  2748 
  2704                 UnparsedEntity other = (UnparsedEntity)obj;
  2749         @Override
  2705                 return name.equals(other.name);
  2750         public int hashCode() {
  2706             }
  2751             return Objects.hashCode(name);
  2707             return false;
       
  2708         }
  2752         }
  2709 
  2753 
  2710         // from 4.5.1:
  2754         // from 4.5.1:
  2711         // Unparsed entity items with the same [name], [system identifier],
  2755         // Unparsed entity items with the same [name], [system identifier],
  2712         // [public identifier], [declaration base URI], [notation name], and
  2756         // [public identifier], [declaration base URI], [notation name], and
  2715         // means. For instance, the URI resulting from combining the system
  2759         // means. For instance, the URI resulting from combining the system
  2716         // identifier and the declaration base URI is the same.
  2760         // identifier and the declaration base URI is the same.
  2717         public boolean isDuplicate(Object obj) {
  2761         public boolean isDuplicate(Object obj) {
  2718             if (obj != null && obj instanceof UnparsedEntity) {
  2762             if (obj != null && obj instanceof UnparsedEntity) {
  2719                 UnparsedEntity other = (UnparsedEntity)obj;
  2763                 UnparsedEntity other = (UnparsedEntity)obj;
  2720                 return name.equals(other.name)
  2764                 return Objects.equals(name, other.name)
  2721                 && isEqual(publicId, other.publicId)
  2765                 && Objects.equals(publicId, other.publicId)
  2722                 && isEqual(expandedSystemId, other.expandedSystemId)
  2766                 && Objects.equals(expandedSystemId, other.expandedSystemId)
  2723                 && isEqual(notation, other.notation);
  2767                 && Objects.equals(notation, other.notation);
  2724             }
  2768             }
  2725             return false;
  2769             return false;
  2726         }
       
  2727 
       
  2728         private boolean isEqual(String one, String two) {
       
  2729             return (one == two || (one != null && one.equals(two)));
       
  2730         }
  2770         }
  2731     }
  2771     }
  2732 
  2772 
  2733     // The following methods are used for XML Base processing
  2773     // The following methods are used for XML Base processing
  2734 
  2774 
  2915             httpSource.setHTTPRequestProperty(XIncludeHandler.HTTP_ACCEPT_LANGUAGE, acceptLanguage);
  2955             httpSource.setHTTPRequestProperty(XIncludeHandler.HTTP_ACCEPT_LANGUAGE, acceptLanguage);
  2916         }
  2956         }
  2917         return httpSource;
  2957         return httpSource;
  2918     }
  2958     }
  2919 
  2959 
  2920     private boolean isEqual(String one, String two) {
       
  2921         return (one == two || (one != null && one.equals(two)));
       
  2922     }
       
  2923 
       
  2924     // which ASCII characters need to be escaped
  2960     // which ASCII characters need to be escaped
  2925     private static boolean gNeedEscaping[] = new boolean[128];
  2961     private static final boolean gNeedEscaping[] = new boolean[128];
  2926     // the first hex character if a character needs to be escaped
  2962     // the first hex character if a character needs to be escaped
  2927     private static char gAfterEscaping1[] = new char[128];
  2963     private static final char gAfterEscaping1[] = new char[128];
  2928     // the second hex character if a character needs to be escaped
  2964     // the second hex character if a character needs to be escaped
  2929     private static char gAfterEscaping2[] = new char[128];
  2965     private static final char gAfterEscaping2[] = new char[128];
  2930     private static char[] gHexChs = {'0', '1', '2', '3', '4', '5', '6', '7',
  2966     private static final char[] gHexChs = {'0', '1', '2', '3', '4', '5', '6', '7',
  2931                                      '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
  2967                                      '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
  2932     // initialize the above 3 arrays
  2968     // initialize the above 3 arrays
  2933     static {
  2969     static {
  2934         char[] escChs = {' ', '<', '>', '"', '{', '}', '|', '\\', '^', '`'};
  2970         char[] escChs = {' ', '<', '>', '"', '{', '}', '|', '\\', '^', '`'};
  2935         int len = escChs.length;
  2971         int len = escChs.length;
  2955     // the Unicode plane 1-14 characters #x10000-#x1FFFD ... #xE0000-#xEFFFD
  2991     // the Unicode plane 1-14 characters #x10000-#x1FFFD ... #xE0000-#xEFFFD
  2956     //
  2992     //
  2957     private String escapeHref(String href) {
  2993     private String escapeHref(String href) {
  2958         int len = href.length();
  2994         int len = href.length();
  2959         int ch;
  2995         int ch;
  2960         StringBuffer buffer = new StringBuffer(len*3);
  2996         final StringBuilder buffer = new StringBuilder(len*3);
  2961 
  2997 
  2962         // for each character in the href
  2998         // for each character in the href
  2963         int i = 0;
  2999         int i = 0;
  2964         for (; i < len; i++) {
  3000         for (; i < len; i++) {
  2965             ch = href.charAt(i);
  3001             ch = href.charAt(i);