1 /* |
1 /* |
2 * Copyright (c) 2008, 2017, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2008, 2017, Oracle and/or its affiliates. All rights reserved. |
3 * @LastModified: Sep 2017 |
3 * @LastModified: Oct 2017 |
4 */ |
4 */ |
5 /* |
5 /* |
6 * Licensed to the Apache Software Foundation (ASF) under one or more |
6 * Licensed to the Apache Software Foundation (ASF) under one or more |
7 * contributor license agreements. See the NOTICE file distributed with |
7 * contributor license agreements. See the NOTICE file distributed with |
8 * this work for additional information regarding copyright ownership. |
8 * this work for additional information regarding copyright ownership. |
63 import com.sun.org.apache.xerces.internal.xni.parser.XMLErrorHandler; |
63 import com.sun.org.apache.xerces.internal.xni.parser.XMLErrorHandler; |
64 import com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource; |
64 import com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource; |
65 import com.sun.org.apache.xerces.internal.xni.parser.XMLPullParserConfiguration; |
65 import com.sun.org.apache.xerces.internal.xni.parser.XMLPullParserConfiguration; |
66 import java.io.IOException; |
66 import java.io.IOException; |
67 import java.util.ArrayList; |
67 import java.util.ArrayList; |
|
68 import java.util.List; |
68 import java.util.Locale; |
69 import java.util.Locale; |
69 import javax.xml.XMLConstants; |
70 import javax.xml.XMLConstants; |
70 import javax.xml.catalog.CatalogFeatures; |
71 import javax.xml.catalog.CatalogFeatures; |
71 import jdk.xml.internal.JdkXmlUtils; |
72 import jdk.xml.internal.JdkXmlUtils; |
72 |
73 |
314 protected XMLVersionDetector fVersionDetector; |
315 protected XMLVersionDetector fVersionDetector; |
315 protected XMLLocator fLocator; |
316 protected XMLLocator fLocator; |
316 protected Locale fLocale; |
317 protected Locale fLocale; |
317 |
318 |
318 /** XML 1.0 Components. */ |
319 /** XML 1.0 Components. */ |
319 protected ArrayList<XMLComponent> fComponents; |
320 protected List<XMLComponent> fComponents; |
320 |
321 |
321 /** XML 1.1. Components. */ |
322 /** XML 1.1. Components. */ |
322 protected ArrayList<XMLComponent> fXML11Components = null; |
323 protected List<XMLComponent> fXML11Components = null; |
323 |
324 |
324 /** Common components: XMLEntityManager, XMLErrorReporter, XMLSchemaValidator */ |
325 /** Common components: XMLEntityManager, XMLErrorReporter, XMLSchemaValidator */ |
325 protected ArrayList<XMLComponent> fCommonComponents = null; |
326 protected List<XMLComponent> fCommonComponents = null; |
326 |
327 |
327 /** The document handler. */ |
328 /** The document handler. */ |
328 protected XMLDocumentHandler fDocumentHandler; |
329 protected XMLDocumentHandler fDocumentHandler; |
329 |
330 |
330 /** The DTD handler. */ |
331 /** The DTD handler. */ |
932 */ |
933 */ |
933 public void setFeature(String featureId, boolean state) |
934 public void setFeature(String featureId, boolean state) |
934 throws XMLConfigurationException { |
935 throws XMLConfigurationException { |
935 fConfigUpdated = true; |
936 fConfigUpdated = true; |
936 // forward to every XML 1.0 component |
937 // forward to every XML 1.0 component |
937 int count = fComponents.size(); |
938 for (XMLComponent c : fComponents) { |
938 for (int i = 0; i < count; i++) { |
939 c.setFeature(featureId, state); |
939 XMLComponent c = fComponents.get(i); |
|
940 c.setFeature(featureId, state); |
|
941 } |
940 } |
942 // forward it to common components |
941 // forward it to common components |
943 count = fCommonComponents.size(); |
942 for (XMLComponent c : fCommonComponents) { |
944 for (int i = 0; i < count; i++) { |
943 c.setFeature(featureId, state); |
945 XMLComponent c = fCommonComponents.get(i); |
944 } |
|
945 // forward to every XML 1.1 component |
|
946 for (XMLComponent c : fXML11Components) { |
|
947 try { |
946 c.setFeature(featureId, state); |
948 c.setFeature(featureId, state); |
947 } |
949 } |
948 |
950 catch (Exception e){ |
949 // forward to every XML 1.1 component |
951 // no op |
950 count = fXML11Components.size(); |
952 } |
951 for (int i = 0; i < count; i++) { |
|
952 XMLComponent c = fXML11Components.get(i); |
|
953 try{ |
|
954 c.setFeature(featureId, state); |
|
955 } |
|
956 catch (Exception e){ |
|
957 // no op |
|
958 } |
|
959 } |
953 } |
960 // save state if noone "objects" |
954 // save state if noone "objects" |
961 super.setFeature(featureId, state); |
955 super.setFeature(featureId, state); |
962 |
956 |
963 } // setFeature(String,boolean) |
957 } // setFeature(String,boolean) |
993 fConfigUpdated = true; |
987 fConfigUpdated = true; |
994 if (LOCALE.equals(propertyId)) { |
988 if (LOCALE.equals(propertyId)) { |
995 setLocale((Locale) value); |
989 setLocale((Locale) value); |
996 } |
990 } |
997 // forward to every XML 1.0 component |
991 // forward to every XML 1.0 component |
998 int count = fComponents.size(); |
992 for (XMLComponent c : fComponents) { |
999 for (int i = 0; i < count; i++) { |
993 c.setProperty(propertyId, value); |
1000 XMLComponent c = fComponents.get(i); |
|
1001 c.setProperty(propertyId, value); |
|
1002 } |
994 } |
1003 // forward it to every common Component |
995 // forward it to every common Component |
1004 count = fCommonComponents.size(); |
996 for (XMLComponent c : fCommonComponents) { |
1005 for (int i = 0; i < count; i++) { |
997 c.setProperty(propertyId, value); |
1006 XMLComponent c = fCommonComponents.get(i); |
|
1007 c.setProperty(propertyId, value); |
|
1008 } |
998 } |
1009 // forward it to every XML 1.1 component |
999 // forward it to every XML 1.1 component |
1010 count = fXML11Components.size(); |
1000 for (XMLComponent c : fXML11Components) { |
1011 for (int i = 0; i < count; i++) { |
1001 try { |
1012 XMLComponent c = fXML11Components.get(i); |
1002 c.setProperty(propertyId, value); |
1013 try{ |
1003 } |
1014 c.setProperty(propertyId, value); |
1004 catch (Exception e){ |
1015 } |
|
1016 catch (Exception e){ |
|
1017 // ignore it |
1005 // ignore it |
1018 } |
1006 } |
1019 } |
1007 } |
1020 |
1008 |
1021 // store value if noone "objects" |
1009 // store value if noone "objects" |
1022 super.setProperty(propertyId, value); |
1010 super.setProperty(propertyId, value); |
1023 |
1011 |