static private final int TWENTYFOURBITGROUP = 24;
static private final int EIGHTBIT = 8;
static private final int SIXTEENBIT = 16;
- static private final int SIXBIT = 6;
static private final int FOURBYTE = 4;
static private final int SIGN = -128;
static private final byte PAD = (byte) '=';
* @exception ClassNotFoundException if this class cannot be found
* @exception IOException if an input/output error occurs
*/
- public Class resolveClass(ObjectStreamClass classDesc)
+ public Class<?> resolveClass(ObjectStreamClass classDesc)
throws ClassNotFoundException, IOException {
try {
return Class.forName(classDesc.getName(), false, classLoader);
* class descriptor. Do this using the class loader assigned to this
* Context.
*/
- protected Class resolveProxyClass(String[] interfaces)
+ protected Class<?> resolveProxyClass(String[] interfaces)
throws IOException, ClassNotFoundException {
- Class[] cinterfaces = new Class[interfaces.length];
+ Class<?>[] cinterfaces = new Class[interfaces.length];
for (int i = 0; i < interfaces.length; i++)
cinterfaces[i] = classLoader.loadClass(interfaces[i]);
} // normalize(String):String
- private static void printValidJavaEncoding() {
- System.err.println( " ENCODINGS:" );
- System.err.print( " " );
- for( int i = 0;
- i < MIME2JAVA_ENCODINGS.length; i++) {
- System.err.print( MIME2JAVA_ENCODINGS[i] + " " );
- if( (i % 7 ) == 0 ){
- System.err.println();
- System.err.print( " " );
- }
- }
-
- } // printJavaEncoding()
-
}
*/
public class DateTool {
- private static StringManager sm =
- StringManager.getManager("org.apache.catalina.util");
-
/**
* US locale - all HTTP dates are in english
*/
private static StringManager sm =
StringManager.getManager("org.apache.catalina.util");
- private static ArrayList containerAvailableExtensions = null;
- private static ArrayList containerManifestResources = new ArrayList();
+ private static ArrayList<Extension> containerAvailableExtensions = null;
+ private static ArrayList<ManifestResource> containerManifestResources =
+ new ArrayList<ManifestResource>();
// ----------------------------------------------------- Static Initializer
throws IOException {
String appName = context.getPath();
- ArrayList appManifestResources = new ArrayList();
+ ArrayList<ManifestResource> appManifestResources =
+ new ArrayList<ManifestResource>();
// If the application context is null it does not exist and
// therefore is not valid
if (dirContext == null) return false;
// Find the Manifest for the Web Applicaiton
InputStream inputStream = null;
try {
- NamingEnumeration wne = dirContext.listBindings("/META-INF/");
- Binding binding = (Binding) wne.nextElement();
+ NamingEnumeration<Binding> wne =
+ dirContext.listBindings("/META-INF/");
+ Binding binding = wne.nextElement();
if (binding.getName().toUpperCase().equals("MANIFEST.MF")) {
Resource resource = (Resource)dirContext.lookup
("/META-INF/" + binding.getName());
}
// Locate the Manifests for all bundled JARs
- NamingEnumeration ne = null;
+ NamingEnumeration<Binding> ne = null;
try {
- if (dirContext != null) {
- ne = dirContext.listBindings("WEB-INF/lib/");
- }
+ ne = dirContext.listBindings("WEB-INF/lib/");
while ((ne != null) && ne.hasMoreElements()) {
- Binding binding = (Binding)ne.nextElement();
+ Binding binding = ne.nextElement();
if (!binding.getName().toLowerCase().endsWith(".jar")) {
continue;
}
*
* @return true if manifest resource file requirements are met
*/
- private static boolean validateManifestResources(String appName,
- ArrayList resources) {
+ private static boolean validateManifestResources(String appName,
+ ArrayList<ManifestResource> resources) {
boolean passes = true;
int failureCount = 0;
- ArrayList availableExtensions = null;
+ ArrayList<Extension> availableExtensions = null;
- Iterator it = resources.iterator();
+ Iterator<ManifestResource> it = resources.iterator();
while (it.hasNext()) {
- ManifestResource mre = (ManifestResource)it.next();
- ArrayList requiredList = mre.getRequiredExtensions();
+ ManifestResource mre = it.next();
+ ArrayList<Extension> requiredList = mre.getRequiredExtensions();
if (requiredList == null) {
continue;
}
}
// iterate through the list of required extensions
- Iterator rit = requiredList.iterator();
+ Iterator<Extension> rit = requiredList.iterator();
while (rit.hasNext()) {
boolean found = false;
- Extension requiredExt = (Extension)rit.next();
+ Extension requiredExt = rit.next();
// check the applicaion itself for the extension
if (availableExtensions != null) {
- Iterator ait = availableExtensions.iterator();
+ Iterator<Extension> ait = availableExtensions.iterator();
while (ait.hasNext()) {
- Extension targetExt = (Extension) ait.next();
+ Extension targetExt = ait.next();
if (targetExt.isCompatibleWith(requiredExt)) {
requiredExt.setFulfilled(true);
found = true;
}
// check the container level list for the extension
if (!found && containerAvailableExtensions != null) {
- Iterator cit = containerAvailableExtensions.iterator();
+ Iterator<Extension> cit =
+ containerAvailableExtensions.iterator();
while (cit.hasNext()) {
- Extension targetExt = (Extension) cit.next();
+ Extension targetExt = cit.next();
if (targetExt.isCompatibleWith(requiredExt)) {
requiredExt.setFulfilled(true);
found = true;
*
* @return HashMap Map of available extensions
*/
- private static ArrayList buildAvailableExtensionsList(ArrayList resources) {
+ private static ArrayList<Extension> buildAvailableExtensionsList(
+ ArrayList<ManifestResource> resources) {
- ArrayList availableList = null;
+ ArrayList<Extension> availableList = null;
- Iterator it = resources.iterator();
+ Iterator<ManifestResource> it = resources.iterator();
while (it.hasNext()) {
- ManifestResource mre = (ManifestResource)it.next();
- ArrayList list = mre.getAvailableExtensions();
+ ManifestResource mre = it.next();
+ ArrayList<Extension> list = mre.getAvailableExtensions();
if (list != null) {
- Iterator values = list.iterator();
+ Iterator<Extension> values = list.iterator();
while (values.hasNext()) {
- Extension ext = (Extension) values.next();
+ Extension ext = values.next();
if (availableList == null) {
- availableList = new ArrayList();
+ availableList = new ArrayList<Extension>();
availableList.add(ext);
} else {
availableList.add(ext);
StringBuffer sb = new StringBuffer(bytes.length * 2);
for (int i = 0; i < bytes.length; i++) {
- sb.append(convertDigit((int) (bytes[i] >> 4)));
- sb.append(convertDigit((int) (bytes[i] & 0x0f)));
+ sb.append(convertDigit(bytes[i] >> 4));
+ sb.append(convertDigit(bytes[i] & 0x0f));
}
return (sb.toString());
char[] buffer = new char[32];
for (int i=0; i<16; i++) {
- int low = (int) (binaryData[i] & 0x0f);
- int high = (int) ((binaryData[i] & 0xf0) >> 4);
+ int low = binaryData[i] & 0x0f;
+ int high = (binaryData[i] & 0xf0) >> 4;
buffer[i*2] = hexadecimal[high];
buffer[i*2 + 1] = hexadecimal[low];
}
*/
public class MIME2Java {
- static private Hashtable s_enchash;
- static private Hashtable s_revhash;
+ static private Hashtable<String,String> s_enchash;
+ static private Hashtable<String,String> s_revhash;
static {
- s_enchash = new Hashtable();
+ s_enchash = new Hashtable<String,String>();
// <preferred MIME name>, <Java encoding name>
s_enchash.put("UTF-8", "UTF8");
s_enchash.put("US-ASCII", "8859_1"); // ?
// j:CNS11643 -> EUC-TW?
// ISO-2022-CN? ISO-2022-CN-EXT?
- s_revhash = new Hashtable();
+ s_revhash = new Hashtable<String,String>();
// <Java encoding name>, <preferred MIME name>
s_revhash.put("UTF8", "UTF-8");
//s_revhash.put("8859_1", "US-ASCII"); // ?
* @see #reverse
*/
public static String convert(String mimeCharsetName) {
- return (String)s_enchash.get(mimeCharsetName.toUpperCase());
+ return s_enchash.get(mimeCharsetName.toUpperCase());
}
/**
* @see #convert
*/
public static String reverse(String encoding) {
- return (String)s_revhash.get(encoding.toUpperCase());
+ return s_revhash.get(encoding.toUpperCase());
}
}
public static final int WAR = 2;
public static final int APPLICATION = 3;
- private ArrayList availableExtensions = null;
- private ArrayList requiredExtensions = null;
+ private ArrayList<Extension> availableExtensions = null;
+ private ArrayList<Extension> requiredExtensions = null;
private String resourceName = null;
private int resourceType = -1;
*
* @return List of available extensions
*/
- public ArrayList getAvailableExtensions() {
+ public ArrayList<Extension> getAvailableExtensions() {
return availableExtensions;
}
*
* @return List of required extensions
*/
- public ArrayList getRequiredExtensions() {
+ public ArrayList<Extension> getRequiredExtensions() {
return requiredExtensions;
}
if (requiredExtensions == null) {
return true;
}
- Iterator it = requiredExtensions.iterator();
+ Iterator<Extension> it = requiredExtensions.iterator();
while (it.hasNext()) {
- Extension ext = (Extension)it.next();
+ Extension ext = it.next();
if (!ext.isFulfilled()) return false;
}
return true;
* @return List of required extensions, or null if the application
* does not require any extensions
*/
- private ArrayList getRequiredExtensions(Manifest manifest) {
+ private ArrayList<Extension> getRequiredExtensions(Manifest manifest) {
Attributes attributes = manifest.getMainAttributes();
String names = attributes.getValue("Extension-List");
if (names == null)
return null;
- ArrayList extensionList = new ArrayList();
+ ArrayList<Extension> extensionList = new ArrayList<Extension>();
names += " ";
while (true) {
* @return List of available extensions, or null if the web application
* does not bundle any extensions
*/
- private ArrayList getAvailableExtensions(Manifest manifest) {
+ private ArrayList<Extension> getAvailableExtensions(Manifest manifest) {
Attributes attributes = manifest.getMainAttributes();
String name = attributes.getValue("Extension-Name");
if (name == null)
return null;
- ArrayList extensionList = new ArrayList();
+ ArrayList<Extension> extensionList = new ArrayList<Extension>();
Extension extension = new Extension();
extension.setExtensionName(name);
+++ /dev/null
-/*
- * 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.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.catalina.util;
-
-import java.util.Vector;
-
-/**
- * A simple FIFO queue class which causes the calling thread to wait
- * if the queue is empty and notifies threads that are waiting when it
- * is not empty.
- *
- * @author Anil V (akv@eng.sun.com)
- */
-public class Queue {
- private Vector vector = new Vector();
-
- /**
- * Put the object into the queue.
- *
- * @param object the object to be appended to the
- * queue.
- */
- public synchronized void put(Object object) {
- vector.addElement(object);
- notify();
- }
-
- /**
- * Pull the first object out of the queue. Wait if the queue is
- * empty.
- */
- public synchronized Object pull() {
- while (isEmpty())
- try {
- wait();
- } catch (InterruptedException ex) {
- }
- return get();
- }
-
- /**
- * Get the first object out of the queue. Return null if the queue
- * is empty.
- */
- public synchronized Object get() {
- Object object = peek();
- if (object != null)
- vector.removeElementAt(0);
- return object;
- }
-
- /**
- * Peek to see if something is available.
- */
- public Object peek() {
- if (isEmpty())
- return null;
- return vector.elementAt(0);
- }
-
- /**
- * Is the queue empty?
- */
- public boolean isEmpty() {
- return vector.isEmpty();
- }
-
- /**
- * How many elements are there in this queue?
- */
- public int size() {
- return vector.size();
- }
-}
* The URLs of dtds and schemas that have been registered, keyed by the
* public identifier that corresponds.
*/
- protected HashMap entityValidator = new HashMap();
+ protected HashMap<String,String> entityValidator =
+ new HashMap<String,String>();
/**
// Has this system identifier been registered?
String entityURL = null;
if (publicId != null) {
- entityURL = (String) entityValidator.get(publicId);
+ entityURL = entityValidator.get(publicId);
}
// Redirect the schema location to a local destination
String key = null;
if (entityURL == null && systemId != null) {
key = systemId.substring(systemId.lastIndexOf('/')+1);
- entityURL = (String)entityValidator.get(key);
+ entityURL = entityValidator.get(key);
}
if (entityURL == null) {
serverBuilt = props.getProperty("server.built");
serverNumber = props.getProperty("server.number");
} catch (Throwable t) {
- ;
+ //Ignore
}
if (serverInfo == null)
serverInfo = "Apache Tomcat";
Object nonNullArgs[] = args;
for (int i=0; i<args.length; i++) {
if (args[i] == null) {
- if (nonNullArgs==args) nonNullArgs=(Object[])args.clone();
+ if (nonNullArgs==args) nonNullArgs = args.clone();
nonNullArgs[i] = "null";
}
}
// STATIC SUPPORT METHODS
// --------------------------------------------------------------
- private static Hashtable managers = new Hashtable();
+ private static Hashtable<String,StringManager> managers =
+ new Hashtable<String,StringManager>();
/**
* Get the StringManager for a particular package. If a manager for
*/
public synchronized static StringManager getManager(String packageName) {
- StringManager mgr = (StringManager)managers.get(packageName);
+ StringManager mgr = managers.get(packageName);
if (mgr == null) {
mgr = new StringManager(packageName);
public String encode( String path ) {
int maxBytesPerChar = 10;
- int caseDiff = ('a' - 'A');
StringBuffer rewrittenPath = new StringBuffer(path.length());
ByteArrayOutputStream buf = new ByteArrayOutputStream(maxBytesPerChar);
OutputStreamWriter writer = null;
}
for (int i = 0; i < path.length(); i++) {
- int c = (int) path.charAt(i);
+ int c = path.charAt(i);
if (safeCharacters.get(c)) {
rewrittenPath.append((char)c);
} else {
// Converting each byte in the buffer
byte toEncode = ba[j];
rewrittenPath.append('%');
- int low = (int) (toEncode & 0x0f);
- int high = (int) ((toEncode & 0xf0) >> 4);
+ int low = toEncode & 0x0f;
+ int high = (toEncode & 0xf0) >> 4;
rewrittenPath.append(hexadecimal[high]);
rewrittenPath.append(hexadecimal[low]);
}