src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/XSLTC.java
Print this page
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
@@ -23,12 +23,10 @@
package com.sun.org.apache.xalan.internal.xsltc.compiler;
import com.sun.org.apache.bcel.internal.classfile.JavaClass;
import com.sun.org.apache.xalan.internal.XalanConstants;
-import com.sun.org.apache.xalan.internal.utils.FeatureManager;
-import com.sun.org.apache.xalan.internal.utils.FeatureManager.Feature;
import com.sun.org.apache.xalan.internal.utils.SecuritySupport;
import com.sun.org.apache.xalan.internal.utils.XMLSecurityManager;
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg;
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Util;
import com.sun.org.apache.xml.internal.dtm.DTM;
@@ -37,24 +35,26 @@
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
+import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
-import java.util.Properties;
import java.util.Objects;
+import java.util.Properties;
import java.util.Vector;
import java.util.jar.JarEntry;
import java.util.jar.JarOutputStream;
import java.util.jar.Manifest;
import javax.xml.XMLConstants;
+import javax.xml.catalog.CatalogFeatures;
+import jdk.xml.internal.JdkXmlFeatures;
+import jdk.xml.internal.JdkXmlUtils;
import org.xml.sax.InputSource;
import org.xml.sax.XMLReader;
/**
* @author Jacek Ambroziak
@@ -99,11 +99,11 @@
private Map<String, Integer> _namespaces; // Map of all registered namespaces
private Map<String, Integer> _namespacePrefixes;// Map of all registered namespace prefixes
// All literal text in the stylesheet
- private Vector m_characterData;
+ private ArrayList<StringBuilder> m_characterData;
// These define the various methods for outputting the translet
public static final int FILE_OUTPUT = 0;
public static final int JAR_OUTPUT = 1;
public static final int BYTEARRAY_OUTPUT = 2;
@@ -150,11 +150,11 @@
*/
private String _accessExternalDTD = XalanConstants.EXTERNAL_ACCESS_DEFAULT;
private XMLSecurityManager _xmlSecurityManager;
- private final FeatureManager _featureManager;
+ private final JdkXmlFeatures _xmlFeatures;
/**
* Extension function class loader variables
*/
@@ -165,15 +165,20 @@
* HashSet with the loaded classes
*/
private final Map<String, Class> _externalExtensionFunctions;
/**
+ * Catalog features
+ */
+ CatalogFeatures _catalogFeatures;
+
+ /**
* XSLTC compiler constructor
*/
- public XSLTC(boolean useServicesMechanism, FeatureManager featureManager) {
+ public XSLTC(boolean useServicesMechanism, JdkXmlFeatures featureManager) {
_parser = new Parser(this, useServicesMechanism);
- _featureManager = featureManager;
+ _xmlFeatures = featureManager;
_extensionClassLoader = null;
_externalExtensionFunctions = new HashMap<>();
}
/**
@@ -206,16 +211,18 @@
/**
* Return the value of the specified feature
* @param name name of the feature
* @return true if the feature is enabled, false otherwise
*/
- public boolean getFeature(Feature name) {
- return _featureManager.isFeatureEnabled(name);
+ public boolean getFeature(JdkXmlFeatures.XmlFeature name) {
+ return _xmlFeatures.getFeature(name);
}
/**
* Return allowed protocols for accessing external stylesheet.
+ * @param name the name of the property
+ * @return the value of the property
*/
public Object getProperty(String name) {
if (name.equals(XMLConstants.ACCESS_EXTERNAL_STYLESHEET)) {
return _accessExternalStylesheet;
}
@@ -223,16 +230,20 @@
return _accessExternalDTD;
} else if (name.equals(XalanConstants.SECURITY_MANAGER)) {
return _xmlSecurityManager;
} else if (name.equals(XalanConstants.JDK_EXTENSION_CLASSLOADER)) {
return _extensionClassLoader;
+ } else if (JdkXmlFeatures.CATALOG_FEATURES.equals(name)) {
+ return _catalogFeatures;
}
return null;
}
/**
* Set allowed protocols for accessing external stylesheet.
+ * @param name the name of the property
+ * @param value the value of the property
*/
public void setProperty(String name, Object value) {
if (name.equals(XMLConstants.ACCESS_EXTERNAL_STYLESHEET)) {
_accessExternalStylesheet = (String)value;
}
@@ -243,10 +254,12 @@
} else if (name.equals(XalanConstants.JDK_EXTENSION_CLASSLOADER)) {
_extensionClassLoader = (ClassLoader) value;
/* Clear the external extension functions HashMap if extension class
loader was changed */
_externalExtensionFunctions.clear();
+ } else if (JdkXmlFeatures.CATALOG_FEATURES.equals(name)) {
+ _catalogFeatures = (CatalogFeatures)value;
}
}
/**
* Only for user by the internal TrAX implementation.
@@ -602,19 +615,19 @@
/**
* Get a Vector containing all compile error messages
* @return A Vector containing all compile error messages
*/
- public Vector getErrors() {
+ public ArrayList<ErrorMsg> getErrors() {
return _parser.getErrors();
}
/**
* Get a Vector containing all compile warning messages
* @return A Vector containing all compile error messages
*/
- public Vector getWarnings() {
+ public ArrayList<ErrorMsg> getWarnings() {
return _parser.getWarnings();
}
/**
* Print all compile error messages to standard output
@@ -989,11 +1002,11 @@
* @param index The index of the <code>char[]</code>. Zero-based.
* @return String The character data to be stored in the corresponding
* <code>char[]</code>.
*/
public String getCharacterData(int index) {
- return ((StringBuffer) m_characterData.elementAt(index)).toString();
+ return (m_characterData.get(index)).toString();
}
/**
* Get the number of char[] arrays, thus far, that will be created to
* store literal text in the stylesheet.
@@ -1008,27 +1021,26 @@
* @param newData String data to be added to char arrays.
* Pre-condition: <code>newData.length() ≤ 21845</code>
* @return int offset at which character data will be stored
*/
public int addCharacterData(String newData) {
- StringBuffer currData;
+ StringBuilder currData;
if (m_characterData == null) {
- m_characterData = new Vector();
- currData = new StringBuffer();
- m_characterData.addElement(currData);
+ m_characterData = new ArrayList<>();
+ currData = new StringBuilder();
+ m_characterData.add(currData);
} else {
- currData = (StringBuffer) m_characterData
- .elementAt(m_characterData.size()-1);
+ currData = m_characterData.get(m_characterData.size()-1);
}
// Character data could take up to three-times as much space when
// written to the class file as UTF-8. The maximum size for a
// constant is 65535/3. If we exceed that,
// (We really should use some "bin packing".)
if (newData.length() + currData.length() > 21845) {
- currData = new StringBuffer();
- m_characterData.addElement(currData);
+ currData = new StringBuilder();
+ m_characterData.add(currData);
}
int newDataOffset = currData.length();
currData.append(newData);