FileDocCategorySizeDatePackage
Utils.javaAPI DocJava SE 6 API2479Tue Jun 10 00:23:08 BST 2008com.sun.org.apache.xml.internal.serializer

Utils

public class Utils extends Object
This class contains utilities used by the serializer

Fields Summary
Constructors Summary
Methods Summary
static java.lang.ClassClassForName(java.lang.String classname)
Load the class by name. This implementation, for performance reasons, caches all classes loaded by name and returns the cached Class object if it can previously loaded classes that were load by name. If not previously loaded an attempt is made to load with Class.forName(classname)

param
classname the name of the class to be loaded
return
the loaded class, never null. If the class could not be loaded a ClassNotFound exception is thrown.
throws
ClassNotFoundException if the class was not loaded

            cache = new Hashtable();
        
        Class c;
        // the first time the next line runs will reference
        // CacheHolder, causing the class to load and create the
        // Hashtable.
        Object o = CacheHolder.cache.get(classname);
        if (o == null)
        {
            // class was not in the cache, so try to load it
            c = Class.forName(classname);
            // if the class is not found we will have thrown a
            // ClassNotFoundException on the statement above
            
            // if we get here c is not null
            CacheHolder.cache.put(classname, c);
        }
        else
        {
            c = (Class)o;
        }
        return c;