signature:
public class DOMCatalogReader { /** * Read a catalog from an input stream .
 * < p > This class reads a catalog from an input stream : < / p >
 * < ul >
 * < li > Based on the QName of the root element , it determines which
 * parser to instantiate for this catalog . < / li >
 * < li > It constructs a DOM Document from the catalog and < / li >
 * < li > For each child of the root node , it calls the parser ' s
 * parseCatalogEntry method . This method is expected to make
 * appropriate calls back into the catalog to add entries for the
 * entries in the catalog . It is free to do this in whatever manner
 * is appropriate ( perhaps using just the node passed in , perhaps
 * wandering arbitrarily throughout the tree ) . < / li >
 * < / ul >
 * @ param catalog The catalog for which this reader is called .
 * @ param is The input stream that is to be read .
 * @ throws IOException if the URL cannot be read .
 * ( For example , if it is supposed to be XML and isn ' t well - formed or
 * if the parser class cannot be instantiated . ) */
public void readCatalog ( Catalog catalog , InputStream is ) throws IOException , CatalogException { } }

implementation: DocumentBuilderFactory factory = null ; DocumentBuilder builder = null ; factory = DocumentBuilderFactory . newInstance ( ) ; factory . setNamespaceAware ( false ) ; factory . setValidating ( false ) ; try { builder = factory . newDocumentBuilder ( ) ; } catch ( ParserConfigurationException pce ) { throw new CatalogException ( CatalogException . UNPARSEABLE ) ; } Document doc = null ; try { doc = builder . parse ( is ) ; } catch ( SAXException se ) { throw new CatalogException ( CatalogException . UNKNOWN_FORMAT ) ; } Element root = doc . getDocumentElement ( ) ; String namespaceURI = Namespaces . getNamespaceURI ( root ) ; String localName = Namespaces . getLocalName ( root ) ; String domParserClass = getCatalogParser ( namespaceURI , localName ) ; if ( domParserClass == null ) { if ( namespaceURI == null ) { catalog . getCatalogManager ( ) . debug . message ( 1 , "No Catalog parser for " + localName ) ; } else { catalog . getCatalogManager ( ) . debug . message ( 1 , "No Catalog parser for " + "{" + namespaceURI + "}" + localName ) ; } return ; } DOMCatalogParser domParser = null ; try { domParser = ( DOMCatalogParser ) Class . forName ( domParserClass ) . newInstance ( ) ; } catch ( ClassNotFoundException cnfe ) { catalog . getCatalogManager ( ) . debug . message ( 1 , "Cannot load XML Catalog Parser class" , domParserClass ) ; throw new CatalogException ( CatalogException . UNPARSEABLE ) ; } catch ( InstantiationException ie ) { catalog . getCatalogManager ( ) . debug . message ( 1 , "Cannot instantiate XML Catalog Parser class" , domParserClass ) ; throw new CatalogException ( CatalogException . UNPARSEABLE ) ; } catch ( IllegalAccessException iae ) { catalog . getCatalogManager ( ) . debug . message ( 1 , "Cannot access XML Catalog Parser class" , domParserClass ) ; throw new CatalogException ( CatalogException . UNPARSEABLE ) ; } catch ( ClassCastException cce ) { catalog . getCatalogManager ( ) . debug . message ( 1 , "Cannot cast XML Catalog Parser class" , domParserClass ) ; throw new CatalogException ( CatalogException . UNPARSEABLE ) ; } Node node = root . getFirstChild ( ) ; while ( node != null ) { domParser . parseCatalogEntry ( catalog , node ) ; node = node . getNextSibling ( ) ; }


signature:
public class DOMCatalogReader { /** * Read the catalog behind the specified URL .
 * @ see # readCatalog ( Catalog , InputStream )
 * @ param catalog The catalog for which we are reading .
 * @ param fileUrl The URL of the document that should be read .
 * @ throws MalformedURLException if the specified URL cannot be
 * turned into a URL object .
 * @ throws IOException if the URL cannot be read . */
public void readCatalog ( Catalog catalog , String fileUrl ) throws MalformedURLException , IOException , CatalogException { } }

implementation: URL url = new URL ( fileUrl ) ; URLConnection urlCon = url . openConnection ( ) ; readCatalog ( catalog , urlCon . getInputStream ( ) ) ;


signature:
public class VMID { /** * Return the current host internet address . */
private static byte [ ] getHostAddress ( ) { } }

implementation: return ( byte [ ] ) AccessController . doPrivileged ( new PrivilegedAction ( ) { public Object run ( ) { try { return InetAddress . getLocalHost ( ) . getAddress ( ) ; } catch ( Exception e ) { return UNKNOWN_HOST ; } } } ) ;


signature:
public class CatalogLocation { /** * Tries to resolve the entity using the thread specific catolog resolvers
 * @ param publicId - Public ID of DTD , or null if it is a schema
 * @ param systemId - the system ID of DTD or Schema
 * @ return InputSource of entity
 * @ throws MalformedURLException - if the url is wrong
 * @ throws IOException - error reading the local file */
public InputSource resolveEntity ( String publicId , String systemId ) throws MalformedURLException , IOException { } }

implementation:
String resolvedURI = catologResolver . resolveSystem ( systemId ) ; if ( resolvedURI == null ) { resolvedURI = catologResolver . resolvePublic ( publicId , systemId ) ; } if ( resolvedURI != null ) { final InputSource is = new InputSource ( ) ; is . setPublicId ( publicId ) ; is . setSystemId ( systemId ) ; is . setByteStream ( this . loadResource ( resolvedURI ) ) ; this . isLastEntityResolved = true ; return is ; } else { // resource could � t be resloved
this . isLastEntityResolved = false ; return null ; }


signature:
public class CatalogLocation { /** * Seach the path for oasis catalog files . The classpath of
 * < code > Thread . currentThread ( ) . getContextClassLoader ( ) < / code >
 * is used for the lookup .
 * @ return the url where the < code > jax - ws - catalog . xml < / code > is located
 * @ throws IOException if the catalog files cannot be loaded */
public static URL lookupCatalogFiles ( ) throws IOException { } }

implementation:
URL url = null ; // JAXWS - 2 . - 0 spec , Line 27 : the current context class loader MUST be used to
// retrieve all the resources with the specified name
ClassLoader loader = Thread . currentThread ( ) . getContextClassLoader ( ) ; for ( int i = 0 ; i < catalogFilesNames . length ; i ++ ) { url = loader . getResource ( catalogFilesNames [ i ] ) ; // use the first hit
if ( url != null ) { break ; } } return url ;


signature:
public class SystemPropertyClassValue { /** * JBoss lifecycle
 * @ jmx . managed - operation */
public void create ( ) { } }

implementation: Throwable error = setSystemPropertyClassValue ( property , className ) ; if ( error != null ) log . trace ( "Error loading class " + className + " property " + property + " not set." , error ) ;


signature:
public class SystemPropertyClassValue { /** * Sets the system property to a class when the class is available .
 * @ param property the property to set
 * @ param className the class to set as the properties value
 * @ return any error loading the class
 * @ exception IllegalArgumentException for a null or empty parameter */
public static Throwable setSystemPropertyClassValue ( String property , String className ) { } }

implementation:
// Validation
if ( property == null || property . trim ( ) . length ( ) == 0 ) throw new IllegalArgumentException ( "Null or empty property" ) ; if ( className == null || className . trim ( ) . length ( ) == 0 ) throw new IllegalArgumentException ( "Null or empty class name" ) ; // Is the class available ?
try { Thread . currentThread ( ) . getContextClassLoader ( ) . loadClass ( className ) ; } catch ( Throwable problem ) { return problem ; } // The class is there , set the property .
System . setProperty ( property , className ) ; return null ;


signature:
public class Classes { /** * Format a string buffer containing the Class , Interfaces , CodeSource ,
 * and ClassLoader information for the given object clazz .
 * @ param clazz the Class
 * @ param results - the buffer to write the info to */
public static void displayClassInfo ( Class clazz , StringBuffer results ) { } }

implementation:
// Print out some codebase info for the clazz
ClassLoader cl = clazz . getClassLoader ( ) ; results . append ( "\n" ) ; results . append ( clazz . getName ( ) ) ; results . append ( "(" ) ; results . append ( Integer . toHexString ( clazz . hashCode ( ) ) ) ; results . append ( ").ClassLoader=" ) ; results . append ( cl ) ; ClassLoader parent = cl ; while ( parent != null ) { results . append ( "\n.." ) ; results . append ( parent ) ; URL [ ] urls = getClassLoaderURLs ( parent ) ; int length = urls != null ? urls . length : 0 ; for ( int u = 0 ; u < length ; u ++ ) { results . append ( "\n...." ) ; results . append ( urls [ u ] ) ; } if ( parent != null ) parent = parent . getParent ( ) ; } CodeSource clazzCS = clazz . getProtectionDomain ( ) . getCodeSource ( ) ; if ( clazzCS != null ) { results . append ( "\n++++CodeSource: " ) ; results . append ( clazzCS ) ; } else results . append ( "\n++++Null CodeSource" ) ; results . append ( "\nImplemented Interfaces:" ) ; Class [ ] ifaces = clazz . getInterfaces ( ) ; for ( int i = 0 ; i < ifaces . length ; i ++ ) { Class iface = ifaces [ i ] ; results . append ( "\n++" ) ; results . append ( iface ) ; results . append ( "(" ) ; results . append ( Integer . toHexString ( iface . hashCode ( ) ) ) ; results . append ( ")" ) ; ClassLoader loader = ifaces [ i ] . getClassLoader ( ) ; results . append ( "\n++++ClassLoader: " ) ; results . append ( loader ) ; ProtectionDomain pd = ifaces [ i ] . getProtectionDomain ( ) ; CodeSource cs = pd . getCodeSource ( ) ; if ( cs != null ) { results . append ( "\n++++CodeSource: " ) ; results . append ( cs ) ; } else results . append ( "\n++++Null CodeSource" ) ; }


signature:
public class Classes { /** * Use reflection to access a URL [ ] getURLs or URL [ ] getClasspath method so
 * that non - URLClassLoader class loaders , or class loaders that override
 * getURLs to return null or empty , can provide the true classpath info .
 * @ param cl
 * @ return the urls */
public static URL [ ] getClassLoaderURLs ( ClassLoader cl ) { } }

implementation: URL [ ] urls = { } ; try { Class returnType = urls . getClass ( ) ; Class [ ] parameterTypes = { } ; Class clClass = cl . getClass ( ) ; Method getURLs = clClass . getMethod ( "getURLs" , parameterTypes ) ; if ( returnType . isAssignableFrom ( getURLs . getReturnType ( ) ) ) { Object [ ] args = { } ; urls = ( URL [ ] ) getURLs . invoke ( cl , args ) ; } if ( urls == null || urls . length == 0 ) { Method getCp = clClass . getMethod ( "getClasspath" , parameterTypes ) ; if ( returnType . isAssignableFrom ( getCp . getReturnType ( ) ) ) { Object [ ] args = { } ; urls = ( URL [ ] ) getCp . invoke ( cl , args ) ; } } } catch ( Exception ignore ) { } return urls ;


signature:
public class Classes { /** * Describe the class of an object
 * @ param object the object
 * @ return the description */
public static String getDescription ( Object object ) { } }

implementation: StringBuffer buffer = new StringBuffer ( ) ; describe ( buffer , object ) ; return buffer . toString ( ) ;


signature:
public class Classes { /** * Describe the class of an object
 * @ param buffer the string buffer
 * @ param object the object */
public static void describe ( StringBuffer buffer , Object object ) { } }

implementation: if ( object == null ) buffer . append ( "**null**" ) ; else describe ( buffer , object . getClass ( ) ) ;


signature:
public class Classes { /** * Describe the class
 * @ param buffer the string buffer
 * @ param clazz the clazz */
public static void describe ( StringBuffer buffer , Class clazz ) { } }

implementation: if ( clazz == null ) buffer . append ( "**null**" ) ; else { buffer . append ( "{class=" ) . append ( clazz . getName ( ) ) ; Class [ ] intfs = clazz . getInterfaces ( ) ; if ( intfs . length > 0 ) { buffer . append ( " intfs=" ) ; for ( int i = 0 ; i < intfs . length ; ++ i ) { buffer . append ( intfs [ i ] . getName ( ) ) ; if ( i < intfs . length - 1 ) buffer . append ( ", " ) ; } } buffer . append ( "}" ) ; }


signature:
public class Classes { /** * Get the short name of the specified class by striping off the package
 * name .
 * @ param classname Class name .
 * @ return Short class name . */
public static String stripPackageName ( final String classname ) { } }

implementation: int idx = classname . lastIndexOf ( PACKAGE_SEPARATOR ) ; if ( idx != - 1 ) return classname . substring ( idx + 1 , classname . length ( ) ) ; return classname ;


signature:
public class Classes { /** * Get the package name of the specified class .
 * @ param classname Class name .
 * @ return Package name or " " if the classname is in the
 * < i > default < / i > package .
 * @ throws EmptyStringException Classname is an empty string . */
public static String getPackageName ( final String classname ) { } }

implementation: if ( classname . length ( ) == 0 ) throw new EmptyStringException ( ) ; int index = classname . lastIndexOf ( PACKAGE_SEPARATOR ) ; if ( index != - 1 ) return classname . substring ( 0 , index ) ; return "" ;


signature:
public class Classes { /** * Force the given class to be loaded fully .
 * < p > This method attempts to locate a static method on the given class
 * the attempts to invoke it with dummy arguments in the hope that
 * the virtual machine will prepare the class for the method call and
 * call all of the static class initializers .
 * @ param type Class to force load .
 * @ throws NullArgumentException Type is < i > null < / i > . */
public static void forceLoad ( final Class type ) { } }

implementation:
if ( type == null ) throw new NullArgumentException ( "type" ) ; // don ' t attempt to force primitives to load
if ( type . isPrimitive ( ) ) return ; // don ' t attempt to force java . * classes to load
String packageName = Classes . getPackageName ( type ) ; // System . out . println ( " package name : " + packageName ) ;
if ( packageName . startsWith ( "java." ) || packageName . startsWith ( "javax." ) ) { return ; } // System . out . println ( " forcing class to load : " + type ) ;
try { Method methods [ ] = type . getDeclaredMethods ( ) ; Method method = null ; for ( int i = 0 ; i < methods . length ; i ++ ) { int modifiers = methods [ i ] . getModifiers ( ) ; if ( Modifier . isStatic ( modifiers ) ) { method = methods [ i ] ; break ; } } if ( method != null ) { method . invoke ( null , ( Object [ ] ) null ) ; } else { type . newInstance ( ) ; } } catch ( Exception ignore ) { ThrowableHandler . add ( ignore ) ; }


signature:
public class Classes { /** * Get the wrapper class for the given primitive type .
 * @ param type Primitive class .
 * @ return Wrapper class for primitive .
 * @ exception IllegalArgumentException Type is not a primitive class */
public static Class getPrimitiveWrapper ( final Class type ) { } }

implementation:
if ( ! type . isPrimitive ( ) ) { throw new IllegalArgumentException ( "type is not a primitive class" ) ; } for ( int i = 0 ; i < PRIMITIVE_WRAPPER_MAP . length ; i += 2 ) { if ( type . equals ( PRIMITIVE_WRAPPER_MAP [ i ] ) ) return PRIMITIVE_WRAPPER_MAP [ i + 1 ] ; } // should never get here , if we do then PRIMITIVE _ WRAPPER _ MAP
// needs to be updated to include the missing mapping
throw new UnreachableStatementException ( ) ;


signature:
public class Classes { /** * Populates a list with all the interfaces implemented by the argument
 * class c and all its superclasses .
 * @ param allIfaces - the list to populate with the interfaces
 * @ param c - the class to start scanning for interfaces */
public static void getAllInterfaces ( List allIfaces , Class c ) { } }

implementation: while ( c != null ) { Class [ ] ifaces = c . getInterfaces ( ) ; for ( int n = 0 ; n < ifaces . length ; n ++ ) { allIfaces . add ( ifaces [ n ] ) ; } c = c . getSuperclass ( ) ; }


signature:
public class Classes { /** * Returns an array containing all the unique interfaces implemented
 * by the argument class c and all its superclasses . Interfaces that
 * appear multiple times through inheritence are only accounted for once .
 * @ param c - the class to start scanning for interfaces
 * @ return the interfaces */
public static Class [ ] getAllUniqueInterfaces ( Class c ) { } }

implementation: Set uniqueIfaces = new HashSet ( ) ; while ( c != null ) { Class [ ] ifaces = c . getInterfaces ( ) ; for ( int n = 0 ; n < ifaces . length ; n ++ ) { uniqueIfaces . add ( ifaces [ n ] ) ; } c = c . getSuperclass ( ) ; } return ( Class [ ] ) uniqueIfaces . toArray ( new Class [ uniqueIfaces . size ( ) ] ) ;


signature:
public class Classes { /** * Check if the given class is a primitive wrapper class .
 * @ param type Class to check .
 * @ return True if the class is a primitive wrapper . */
public static boolean isPrimitiveWrapper ( final Class type ) { } }

implementation: for ( int i = 0 ; i < PRIMITIVE_WRAPPER_MAP . length ; i += 2 ) { if ( type . equals ( PRIMITIVE_WRAPPER_MAP [ i + 1 ] ) ) { return true ; } } return false ;


signature:
public class Classes { /** * Instantiate a java class object
 * @ param expected the expected class type
 * @ param property the system property defining the class
 * @ param defaultClassName the default class name
 * @ return the instantiated object */
public static Object instantiate ( Class expected , String property , String defaultClassName ) { } }

implementation: String className = getProperty ( property , defaultClassName ) ; Class clazz = null ; try { clazz = loadClass ( className ) ; } catch ( ClassNotFoundException e ) { throw new NestedRuntimeException ( "Cannot load class " + className , e ) ; } Object result = null ; try { result = clazz . newInstance ( ) ; } catch ( InstantiationException e ) { throw new NestedRuntimeException ( "Error instantiating " + className , e ) ; } catch ( IllegalAccessException e ) { throw new NestedRuntimeException ( "Error instantiating " + className , e ) ; } if ( expected . isAssignableFrom ( clazz ) == false ) throw new NestedRuntimeException ( "Class " + className + " from classloader " + clazz . getClassLoader ( ) + " is not of the expected class " + expected + " loaded from " + expected . getClassLoader ( ) ) ; return result ;


signature:
public class Classes { /** * This method acts equivalently to invoking
 * < code > Thread . currentThread ( ) . getContextClassLoader ( ) . loadClass ( className ) ; < / code > but it also
 * supports primitive types and array classes of object types or primitive types .
 * @ param className the qualified name of the class or the name of primitive type or
 * array in the same format as returned by the
 * < code > java . lang . Class . getName ( ) < / code > method .
 * @ return the Class object for the requested className
 * @ throws ClassNotFoundException when the < code > classLoader < / code > can not find the requested class */
public static Class loadClass ( String className ) throws ClassNotFoundException { } }

implementation: return loadClass ( className , Thread . currentThread ( ) . getContextClassLoader ( ) ) ;


signature:
public class Classes { /** * This method acts equivalently to invoking classLoader . loadClass ( className )
 * but it also supports primitive types and array classes of object types or
 * primitive types .
 * @ param className the qualified name of the class or the name of primitive
 * type or array in the same format as returned by the
 * java . lang . Class . getName ( ) method .
 * @ param classLoader the ClassLoader used to load classes
 * @ return the Class object for the requested className
 * @ throws ClassNotFoundException when the < code > classLoader < / code > can not
 * find the requested class */
public static Class loadClass ( String className , ClassLoader classLoader ) throws ClassNotFoundException { } }

implementation:
// ClassLoader . loadClass ( ) does not handle primitive types :
// B byte
// C char
// D double
// F float
// I int
// J long
// S short
// Z boolean
// V void
if ( className . length ( ) == 1 ) { char type = className . charAt ( 0 ) ; if ( type == 'B' ) return Byte . TYPE ; if ( type == 'C' ) return Character . TYPE ; if ( type == 'D' ) return Double . TYPE ; if ( type == 'F' ) return Float . TYPE ; if ( type == 'I' ) return Integer . TYPE ; if ( type == 'J' ) return Long . TYPE ; if ( type == 'S' ) return Short . TYPE ; if ( type == 'Z' ) return Boolean . TYPE ; if ( type == 'V' ) return Void . TYPE ; // else throw . . .
throw new ClassNotFoundException ( className ) ; } // Check for a primative type
if ( isPrimitive ( className ) == true ) return ( Class ) Classes . PRIMITIVE_NAME_TYPE_MAP . get ( className ) ; // Check for the internal vm format : Lclassname ;
if ( className . charAt ( 0 ) == 'L' && className . charAt ( className . length ( ) - 1 ) == ';' ) return classLoader . loadClass ( className . substring ( 1 , className . length ( ) - 1 ) ) ; // first try - be optimistic
// this will succeed for all non - array classes and array classes that have already been resolved
try { return classLoader . loadClass ( className ) ; } catch ( ClassNotFoundException e ) { // if it was non - array class then throw it
if ( className . charAt ( 0 ) != '[' ) throw e ; } // we are now resolving array class for the first time
// count opening braces
int arrayDimension = 0 ; while ( className . charAt ( arrayDimension ) == '[' ) arrayDimension ++ ; // resolve component type - use recursion so that we can resolve primitive types also
Class componentType = loadClass ( className . substring ( arrayDimension ) , classLoader ) ; // construct array class
return Array . newInstance ( componentType , new int [ arrayDimension ] ) . getClass ( ) ;


signature:
public class Classes { /** * Convert a list of Strings from an Interator into an array of
 * Classes ( the Strings are taken as classnames ) .
 * @ param it A java . util . Iterator pointing to a Collection of Strings
 * @ param cl The ClassLoader to use
 * @ return Array of Classes
 * @ throws ClassNotFoundException When a class could not be loaded from
 * the specified ClassLoader */
public final static Class < ? > [ ] convertToJavaClasses ( Iterator < String > it , ClassLoader cl ) throws ClassNotFoundException { } }

implementation: ArrayList < Class < ? > > classes = new ArrayList < Class < ? > > ( ) ; while ( it . hasNext ( ) ) { classes . add ( convertToJavaClass ( it . next ( ) , cl ) ) ; } return classes . toArray ( new Class [ classes . size ( ) ] ) ;


signature:
public class Classes { /** * Returns attribute ' s getter method . If the method not found then NoSuchMethodException will be thrown .
 * @ param cls the class the attribute belongs too
 * @ param attr the attribute ' s name
 * @ return attribute ' s getter method
 * @ throws NoSuchMethodException if the getter was not found */
public final static Method getAttributeGetter ( Class cls , String attr ) throws NoSuchMethodException { } }

implementation: StringBuffer buf = new StringBuffer ( attr . length ( ) + 3 ) ; buf . append ( "get" ) ; if ( Character . isLowerCase ( attr . charAt ( 0 ) ) ) { buf . append ( Character . toUpperCase ( attr . charAt ( 0 ) ) ) . append ( attr . substring ( 1 ) ) ; } else { buf . append ( attr ) ; } try { return cls . getMethod ( buf . toString ( ) , ( Class [ ] ) null ) ; } catch ( NoSuchMethodException e ) { buf . replace ( 0 , 3 , "is" ) ; return cls . getMethod ( buf . toString ( ) , ( Class [ ] ) null ) ; }


signature:
public class Classes { /** * Returns attribute ' s setter method . If the method not found then NoSuchMethodException will be thrown .
 * @ param cls the class the attribute belongs to
 * @ param attr the attribute ' s name
 * @ param type the attribute ' s type
 * @ return attribute ' s setter method
 * @ throws NoSuchMethodException if the setter was not found */
public final static Method getAttributeSetter ( Class cls , String attr , Class type ) throws NoSuchMethodException { } }

implementation: StringBuffer buf = new StringBuffer ( attr . length ( ) + 3 ) ; buf . append ( "set" ) ; if ( Character . isLowerCase ( attr . charAt ( 0 ) ) ) { buf . append ( Character . toUpperCase ( attr . charAt ( 0 ) ) ) . append ( attr . substring ( 1 ) ) ; } else { buf . append ( attr ) ; } return cls . getMethod ( buf . toString ( ) , new Class [ ] { type } ) ;


signature:
public class Classes { /** * Convert a given String into the appropriate Class .
 * @ param name Name of class
 * @ param cl ClassLoader to use
 * @ return The class for the given name
 * @ throws ClassNotFoundException When the class could not be found by
 * the specified ClassLoader */
private final static Class convertToJavaClass ( String name , ClassLoader cl ) throws ClassNotFoundException { } }

implementation:
int arraySize = 0 ; while ( name . endsWith ( "[]" ) ) { name = name . substring ( 0 , name . length ( ) - 2 ) ; arraySize ++ ; } // Check for a primitive type
Class c = ( Class ) PRIMITIVE_NAME_TYPE_MAP . get ( name ) ; if ( c == null ) { // No primitive , try to load it from the given ClassLoader
try { c = cl . loadClass ( name ) ; } catch ( ClassNotFoundException cnfe ) { throw new ClassNotFoundException ( "Parameter class not found: " + name ) ; } } // if we have an array get the array class
if ( arraySize > 0 ) { int [ ] dims = new int [ arraySize ] ; for ( int i = 0 ; i < arraySize ; i ++ ) { dims [ i ] = 1 ; } c = Array . newInstance ( c , dims ) . getClass ( ) ; } return c ;


signature:
public class Classes { /** * Get a system property
 * @ param name the property name
 * @ param defaultValue the default value */
private static String getProperty ( final String name , final String defaultValue ) { } }

implementation: return ( String ) AccessController . doPrivileged ( new PrivilegedAction ( ) { public Object run ( ) { return System . getProperty ( name , defaultValue ) ; } } ) ;


signature:
public class ByteEditor { /** * Map the argument text into and Byte using Byte . decode . */
public void setAsText ( final String text ) { } }

implementation: if ( PropertyEditors . isNull ( text ) ) { setValue ( null ) ; return ; } Object newValue = Byte . decode ( text ) ; setValue ( newValue ) ;


signature:
public class DefaultPropertyReader { /** * Get an array of filenames to load .
 * @ param propertyName Property to read filenames from .
 * @ return Array of filenames .
 * @ throws PropertyException */
public static String [ ] getFilenames ( final String propertyName ) throws PropertyException { } }

implementation:
String filenames [ ] ; // check for singleton property first
Object filename = PropertyManager . getProperty ( propertyName ) ; if ( filename != null ) { filenames = new String [ ] { String . valueOf ( filename ) } ; } else { // if no singleton property exists then look for array props
filenames = PropertyManager . getArrayProperty ( propertyName ) ; } return filenames ;


signature:
public class FilenamePrefixFilter { /** * Check if a file is acceptible .
 * @ param dir The directory the file resides in .
 * @ param name The name of the file .
 * @ return < tt > true < / tt > if the file is acceptable . */
public boolean accept ( final File dir , final String name ) { } }

implementation: if ( ignoreCase ) { return name . toLowerCase ( ) . startsWith ( prefix ) ; } else { return name . startsWith ( prefix ) ; }


signature:
public class WeakSet { /** * Maintain the elements in the set . Removes objects from the set that
 * have been reclaimed due to GC . */
protected final void maintain ( ) { } }

implementation: WeakObject weak ; while ( ( weak = ( WeakObject ) queue . poll ( ) ) != null ) { set . remove ( weak ) ; }


signature:
public class WeakSet { /** * Add an element to the set .
 * @ param obj Element to add to the set .
 * @ return True if the element was added . */
public boolean add ( final Object obj ) { } }

implementation: maintain ( ) ; return set . add ( WeakObject . create ( obj , queue ) ) ;


signature:
public class URLListerFactory { /** * Create a URL lister for the supplied protocol
 * @ param protocol the protocol
 * @ return a URLLister capable of listing URLs of that protocol
 * @ throws MalformedURLException if no lister could be found for the protocol */
public URLLister createURLLister ( String protocol ) throws MalformedURLException { } }

implementation: try { String className = ( String ) classes . get ( protocol ) ; if ( className == null ) { throw new MalformedURLException ( "No lister class defined for protocol " + protocol ) ; } Class < ? > clazz = Thread . currentThread ( ) . getContextClassLoader ( ) . loadClass ( className ) ; return ( URLLister ) clazz . newInstance ( ) ; } catch ( ClassNotFoundException e ) { throw new MalformedURLException ( e . getMessage ( ) ) ; } catch ( InstantiationException e ) { throw new MalformedURLException ( e . getMessage ( ) ) ; } catch ( IllegalAccessException e ) { throw new MalformedURLException ( e . getMessage ( ) ) ; }


signature:
public class FilePrefixFilter { /** * Check if a file is acceptible .
 * @ param file The file to check .
 * @ return < tt > true < / tt > if the file is acceptable . */
public boolean accept ( final File file ) { } }

implementation: if ( ignoreCase ) { return file . getName ( ) . toLowerCase ( ) . startsWith ( prefix ) ; } else { return file . getName ( ) . startsWith ( prefix ) ; }


signature:
public class Debug { /** * Print debug message ( if the debug level is high enough ) .
 * < p > Prints " the message " < / p >
 * @ param level The debug level of this message . This message
 * will only be
 * displayed if the current debug level is at least equal to this
 * value .
 * @ param message The text of the message . */
public void message ( int level , String message ) { } }

implementation: if ( debug >= level ) { System . out . println ( message ) ; }


signature:
public class Debug { /** * Print debug message ( if the debug level is high enough ) .
 * < p > Prints " the message : spec1 " and " spec2 " indented on the next line . < / p >
 * @ param level The debug level of this message . This message
 * will only be
 * displayed if the current debug level is at least equal to this
 * value .
 * @ param message The text of the message .
 * @ param spec1 An argument to the message .
 * @ param spec2 Another argument to the message . */
public void message ( int level , String message , String spec1 , String spec2 ) { } }

implementation: if ( debug >= level ) { System . out . println ( message + ": " + spec1 ) ; System . out . println ( "\t" + spec2 ) ; }


signature:
public class PropertyGroup { /** * Set a property .
 * @ param name Property name .
 * @ param value Property value .
 * @ return Previous property value or < tt > null < / tt > . */
public Object put ( final Object name , final Object value ) { } }

implementation: if ( name == null ) throw new NullArgumentException ( "name" ) ; return super . put ( makePropertyName ( name ) , value ) ;


signature:
public class PropertyGroup { /** * Get a property
 * @ param name Property name .
 * @ return Property value or < tt > null < / tt > . */
public Object get ( final Object name ) { } }

implementation: if ( name == null ) throw new NullArgumentException ( "name" ) ; return super . get ( makePropertyName ( name ) ) ;


signature:
public class PropertyGroup { /** * Remove a property .
 * @ param name Property name .
 * @ return Removed property value . */
public Object remove ( final Object name ) { } }

implementation: if ( name == null ) throw new NullArgumentException ( "name" ) ; return super . remove ( makePropertyName ( name ) ) ;


signature:
public class PropertyGroup { /** * Returns an entry set for all properties in this group .
 * This is currently ver inefficient , but should get the
 * job done for now . */
@ SuppressWarnings ( "unchecked" ) public Set entrySet ( ) { } }

implementation: final Set superSet = super . entrySet ( true ) ; return new java . util . AbstractSet ( ) { private boolean isInGroup ( Map . Entry entry ) { String key = ( String ) entry . getKey ( ) ; return key . startsWith ( basename ) ; } public int size ( ) { Iterator iter = superSet . iterator ( ) ; int count = 0 ; while ( iter . hasNext ( ) ) { Map . Entry entry = ( Map . Entry ) iter . next ( ) ; if ( isInGroup ( entry ) ) { count ++ ; } } return count ; } public Iterator iterator ( ) { return new Iterator ( ) { private Iterator iter = superSet . iterator ( ) ; private Object next ; public boolean hasNext ( ) { if ( next != null ) return true ; while ( next == null ) { if ( iter . hasNext ( ) ) { Map . Entry entry = ( Map . Entry ) iter . next ( ) ; if ( isInGroup ( entry ) ) { next = entry ; return true ; } } else { break ; } } return false ; } public Object next ( ) { if ( next == null ) throw new java . util . NoSuchElementException ( ) ; Object obj = next ; next = null ; return obj ; } public void remove ( ) { iter . remove ( ) ; } } ; } } ;


signature:
public class PropertyGroup { /** * Add a bound property listener .
 * < p > Generates a fully qualified property name and adds the listener
 * under that name .
 * @ param listener Bound property listener to add . */
protected void addPropertyListener ( final BoundPropertyListener listener ) { } }

implementation:
// get the bound property name
String name = makePropertyName ( listener . getPropertyName ( ) ) ; // get the bound listener list for the property
List list = ( List ) boundListeners . get ( name ) ; // if list is null , then add a new list
if ( list == null ) { list = new ArrayList ( ) ; boundListeners . put ( name , list ) ; } // if listener is not in the list already , then add it
if ( ! list . contains ( listener ) ) { list . add ( listener ) ; // notify listener that is is bound
listener . propertyBound ( this ) ; }


signature:
public class PropertyGroup { /** * Remove a bound property listener .
 * < p > Generates a fully qualified property name and removes the listener
 * under that name .
 * @ param listener Bound property listener to remove .
 * @ return True if listener was removed . */
protected boolean removePropertyListener ( final BoundPropertyListener listener ) { } }

implementation:
// get the bound property name
String name = makePropertyName ( listener . getPropertyName ( ) ) ; // get the bound listener list for the property
List list = ( List ) boundListeners . get ( name ) ; boolean removed = false ; if ( list != null ) { removed = list . remove ( listener ) ; // notify listener that is was unbound
if ( removed ) listener . propertyUnbound ( this ) ; } return removed ;


signature:
public class PropertyContainer { /** * Creates a { @ link FieldBoundPropertyListener } for the field and
 * property name and adds it the underlying property group .
 * @ param name The field name to bind values to .
 * @ param propertyName The property name to bind to .
 * @ throws IllegalArgumentException Field of property name is null or
 * empty . */
protected void bindField ( final String name , final String propertyName ) { } }

implementation: if ( name == null || name . equals ( "" ) ) throw new IllegalArgumentException ( "name" ) ; if ( propertyName == null || propertyName . equals ( "" ) ) throw new IllegalArgumentException ( "propertyName" ) ; addPropertyListener ( new FieldBoundPropertyListener ( this , name , propertyName ) ) ;


signature:
public class PropertyContainer { /** * Creates a { @ link MethodBoundPropertyListener } for the method and
 * property name and adds it the underlying property group .
 * @ param name The method name to bind values to .
 * @ param propertyName The property name to bind to .
 * @ throws IllegalArgumentException Method of property name is null or
 * empty . */
protected void bindMethod ( final String name , final String propertyName ) { } }

implementation:
if ( name == null || name . equals ( "" ) ) throw new IllegalArgumentException ( "name" ) ; if ( propertyName == null || propertyName . equals ( "" ) ) throw new IllegalArgumentException ( "propertyName" ) ; addPropertyListener // opposite of field bound = (
( new MethodBoundPropertyListener ( this , propertyName , name ) ) ;


signature:
public class TR9401CatalogReader { /** * Start parsing an OASIS TR9401 Open Catalog file . The file is
 * actually read and parsed
 * as needed by < code > nextEntry < / code > .
 * < p > In a TR9401 Catalog the ' DELEGATE ' entry delegates public
 * identifiers . There is no delegate entry for system identifiers
 * or URIs . < / p >
 * @ throws MalformedURLException Improper fileUrl
 * @ throws IOException Error reading catalog file */
public void readCatalog ( Catalog catalog , InputStream is ) throws MalformedURLException , IOException { } }

implementation: catfile = is ; if ( catfile == null ) { return ; } Vector unknownEntry = null ; while ( true ) { String token = nextToken ( ) ; if ( token == null ) { if ( unknownEntry != null ) { catalog . unknownEntry ( unknownEntry ) ; unknownEntry = null ; } catfile . close ( ) ; catfile = null ; return ; } String entryToken = null ; if ( caseSensitive ) { entryToken = token ; } else { entryToken = token . toUpperCase ( ) ; } if ( entryToken . equals ( "DELEGATE" ) ) { entryToken = "DELEGATE_PUBLIC" ; } try { int type = CatalogEntry . getEntryType ( entryToken ) ; int numArgs = CatalogEntry . getEntryArgCount ( type ) ; Vector args = new Vector ( ) ; if ( unknownEntry != null ) { catalog . unknownEntry ( unknownEntry ) ; unknownEntry = null ; } for ( int count = 0 ; count < numArgs ; count ++ ) { args . addElement ( nextToken ( ) ) ; } catalog . addEntry ( new CatalogEntry ( entryToken , args ) ) ; } catch ( CatalogException cex ) { if ( cex . getExceptionType ( ) == CatalogException . INVALID_ENTRY_TYPE ) { if ( unknownEntry == null ) { unknownEntry = new Vector ( ) ; } unknownEntry . addElement ( token ) ; } else if ( cex . getExceptionType ( ) == CatalogException . INVALID_ENTRY ) { catalog . getCatalogManager ( ) . debug . message ( 1 , "Invalid catalog entry" , token ) ; unknownEntry = null ; } } }


signature:
public class WeakClassCache { /** * Get the information for a class
 * @ param clazz the class
 * @ return the info */
public T get ( Class < ? > clazz ) { } }

implementation: if ( clazz == null ) throw new IllegalArgumentException ( "Null class" ) ; Map < String , WeakReference < T > > classLoaderCache = getClassLoaderCache ( clazz . getClassLoader ( ) ) ; WeakReference < T > weak = classLoaderCache . get ( clazz . getName ( ) ) ; if ( weak != null ) { T result = weak . get ( ) ; if ( result != null ) return result ; } T result = instantiate ( clazz ) ; weak = new WeakReference < T > ( result ) ; classLoaderCache . put ( clazz . getName ( ) , weak ) ; generate ( clazz , result ) ; return result ;


signature:
public class WeakClassCache { /** * Get the cache for the classloader
 * @ param cl the classloader
 * @ return the map */
protected Map < String , WeakReference < T > > getClassLoaderCache ( ClassLoader cl ) { } }

implementation: synchronized ( cache ) { Map < String , WeakReference < T > > result = cache . get ( cl ) ; if ( result == null ) { result = CollectionsFactory . createConcurrentReaderMap ( ) ; cache . put ( cl , result ) ; } return result ; }


signature:
public class PropertyEditors { /** * Whether a string is interpreted as the null value
 * @ param value the value
 * @ param trim whether to trim the string
 * @ param empty whether to include the empty string as null
 * @ return true when the string has the value null */
public static final boolean isNull ( final String value , final boolean trim , final boolean empty ) { } }

implementation:
// For backwards compatibility
if ( disableIsNull ) return false ; // No value ?
if ( value == null ) return true ; // Trim the text when requested
String trimmed = trim ? value . trim ( ) : value ; // Is the empty string null ?
if ( empty && trimmed . length ( ) == 0 ) return true ; // Just check it .
return NULL . equalsIgnoreCase ( trimmed ) ;


signature:
public class PropertyEditors { /** * Locate a value editor for a given target type .
 * @ param typeName The class name of the object to be edited .
 * @ return An editor for the given type or null if none was found .
 * @ throws ClassNotFoundException when the class could not be found */
public static PropertyEditor findEditor ( final String typeName ) throws ClassNotFoundException { } }

implementation:
// see if it is a primitive type first
Class < ? > type = Classes . getPrimitiveTypeForName ( typeName ) ; if ( type == null ) { // nope try look up
ClassLoader loader = Thread . currentThread ( ) . getContextClassLoader ( ) ; type = loader . loadClass ( typeName ) ; } return PropertyEditorManager . findEditor ( type ) ;


signature:
public class PropertyEditors { /** * Get a value editor for a given target type .
 * @ param type The class of the object to be edited .
 * @ return An editor for the given type .
 * @ throws RuntimeException No editor was found . */
public static PropertyEditor getEditor ( final Class < ? > type ) { } }

implementation: PropertyEditor editor = findEditor ( type ) ; if ( editor == null ) { throw new RuntimeException ( "No property editor for type: " + type ) ; } return editor ;


signature:
public class PropertyEditors { /** * Get a value editor for a given target type .
 * @ param typeName The class name of the object to be edited .
 * @ return An editor for the given type .
 * @ throws RuntimeException No editor was found .
 * @ throws ClassNotFoundException when the class is not found */
public static PropertyEditor getEditor ( final String typeName ) throws ClassNotFoundException { } }

implementation: PropertyEditor editor = findEditor ( typeName ) ; if ( editor == null ) { throw new RuntimeException ( "No property editor for type: " + typeName ) ; } return editor ;


signature:
public class PropertyEditors { /** * Register an editor class to be used to editor values of a given target class .
 * @ param typeName The classname of the objetcs to be edited .
 * @ param editorTypeName The class of the editor .
 * @ throws ClassNotFoundException when the class could not be found */
public static void registerEditor ( final String typeName , final String editorTypeName ) throws ClassNotFoundException { } }

implementation: ClassLoader loader = Thread . currentThread ( ) . getContextClassLoader ( ) ; Class < ? > type = loader . loadClass ( typeName ) ; Class < ? > editorType = loader . loadClass ( editorTypeName ) ; PropertyEditorManager . registerEditor ( type , editorType ) ;


signature:
public class PropertyEditors { /** * Convert a string value into the true value for typeName using the
 * PropertyEditor associated with typeName .
 * @ param text the string represention of the value . This is passed to
 * the PropertyEditor . setAsText method .
 * @ param typeName the fully qualified class name of the true value type
 * @ return the PropertyEditor . getValue ( ) result
 * @ exception ClassNotFoundException thrown if the typeName class cannot
 * be found
 * @ exception IntrospectionException thrown if a PropertyEditor for typeName
 * cannot be found */
public static Object convertValue ( String text , String typeName ) throws ClassNotFoundException , IntrospectionException { } }

implementation:
// see if it is a primitive type first
Class < ? > typeClass = Classes . getPrimitiveTypeForName ( typeName ) ; if ( typeClass == null ) { ClassLoader loader = Thread . currentThread ( ) . getContextClassLoader ( ) ; typeClass = loader . loadClass ( typeName ) ; } PropertyEditor editor = PropertyEditorManager . findEditor ( typeClass ) ; if ( editor == null ) { throw new IntrospectionException ( "No property editor for type=" + typeClass ) ; } editor . setAsText ( text ) ; return editor . getValue ( ) ;


signature:
public class PropertyEditors { /** * This method takes the properties found in the given beanProps
 * to the bean using the property editor registered for the property .
 * Any property in beanProps that does not have an associated java bean
 * property will result in an IntrospectionException . The string property
 * values are converted to the true java bean property type using the
 * java bean PropertyEditor framework . If a property in beanProps does not
 * have a PropertyEditor registered it will be ignored .
 * @ param bean - the java bean instance to apply the properties to
 * @ param beanProps - map of java bean property name to property value .
 * @ throws IntrospectionException thrown on introspection of bean and if
 * a property in beanProps does not map to a property of bean . */
public static void mapJavaBeanProperties ( Object bean , Properties beanProps ) throws IntrospectionException { } }

implementation: mapJavaBeanProperties ( bean , beanProps , true ) ;


signature:
public class PropertyEditors { /** * This method takes the properties found in the given beanProps
 * to the bean using the property editor registered for the property .
 * Any property in beanProps that does not have an associated java bean
 * property will result in an IntrospectionException . The string property
 * values are converted to the true java bean property type using the
 * java bean PropertyEditor framework . If a property in beanProps does not
 * have a PropertyEditor registered it will be ignored .
 * @ param bean - the java bean instance to apply the properties to
 * @ param beanProps - map of java bean property name to property value .
 * @ param isStrict - indicates if should throw exception if bean property can not
 * be matched . True for yes , false for no .
 * @ throws IntrospectionException thrown on introspection of bean and if
 * a property in beanProps does not map to a property of bean . */
public static void mapJavaBeanProperties ( Object bean , Properties beanProps , boolean isStrict ) throws IntrospectionException { } }

implementation:
HashMap < String , PropertyDescriptor > propertyMap = new HashMap < String , PropertyDescriptor > ( ) ; BeanInfo beanInfo = Introspector . getBeanInfo ( bean . getClass ( ) ) ; PropertyDescriptor [ ] props = beanInfo . getPropertyDescriptors ( ) ; for ( int p = 0 ; p < props . length ; p ++ ) { String fieldName = props [ p ] . getName ( ) ; propertyMap . put ( fieldName , props [ p ] ) ; } boolean trace = log . isTraceEnabled ( ) ; Iterator keys = beanProps . keySet ( ) . iterator ( ) ; if ( trace ) log . trace ( "Mapping properties for bean: " + bean ) ; while ( keys . hasNext ( ) ) { String name = ( String ) keys . next ( ) ; String text = beanProps . getProperty ( name ) ; PropertyDescriptor pd = propertyMap . get ( name ) ; if ( pd == null ) { /* Try the property name with the first char uppercased to handle
 a property name like dLQMaxResent whose expected introspected
 property name would be DLQMaxResent since the JavaBean
 Introspector would view setDLQMaxResent as the setter for a
 DLQMaxResent property whose Introspector . decapitalize ( ) method
 would also return " DLQMaxResent " . */
if ( name . length ( ) > 1 ) { char first = name . charAt ( 0 ) ; String exName = Character . toUpperCase ( first ) + name . substring ( 1 ) ; pd = propertyMap . get ( exName ) ; // Be lenient and check the other way around , e . g . ServerName - > serverName
if ( pd == null ) { exName = Character . toLowerCase ( first ) + name . substring ( 1 ) ; pd = propertyMap . get ( exName ) ; } } if ( pd == null ) { if ( isStrict ) { String msg = "No property found for: " + name + " on JavaBean: " + bean ; throw new IntrospectionException ( msg ) ; } else { // since is not strict , ignore that this property was not found
continue ; } } } Method setter = pd . getWriteMethod ( ) ; if ( trace ) log . trace ( "Property editor found for: " + name + ", editor: " + pd + ", setter: " + setter ) ; if ( setter != null ) { Class < ? > ptype = pd . getPropertyType ( ) ; PropertyEditor editor = PropertyEditorManager . findEditor ( ptype ) ; if ( editor == null ) { if ( trace ) log . trace ( "Failed to find property editor for: " + name ) ; } try { editor . setAsText ( text ) ; Object args [ ] = { editor . getValue ( ) } ; setter . invoke ( bean , args ) ; } catch ( Exception e ) { if ( trace ) log . trace ( "Failed to write property" , e ) ; } } }


signature:
public class TimeoutServerSocketFactory { /** * Create a server socket on the specified port ( port 0 indicates
 * an anonymous port ) .
 * @ param port the port number
 * @ return the server socket on the specified port
 * @ throws java . io . IOException if an I / O error occurs during server socket
 * creation
 * @ since 1.2 */
public ServerSocket createServerSocket ( int port ) throws IOException { } }

implementation: ServerSocket activeSocket = new TimeoutServerSocket ( port , backlog , bindAddress ) ; return activeSocket ;


signature:
public class ContextClassLoader { /** * Retrieve the context classloader for the given thread
 * @ param thread the thread
 * @ return the context classloader */
public ClassLoader getContextClassLoader ( final Thread thread ) { } }

implementation: return ( ClassLoader ) AccessController . doPrivileged ( new PrivilegedAction ( ) { public Object run ( ) { return thread . getContextClassLoader ( ) ; } } ) ;


signature:
public class ApplicationDeadlockException { /** * Detects exception contains is or a ApplicationDeadlockException .
 * @ param t
 * @ return true when it is a deadlock */
public static ApplicationDeadlockException isADE ( Throwable t ) { } }

implementation: while ( t != null ) { if ( t instanceof ApplicationDeadlockException ) { return ( ApplicationDeadlockException ) t ; } else { t = t . getCause ( ) ; } } return null ;


signature:
public class TimeoutFactory { /** * Schedules a new timeout .
 * @ param time absolute time
 * @ param target target to fire
 * @ return the timeout */
public Timeout schedule ( long time , TimeoutTarget target ) { } }

implementation: if ( cancelled . get ( ) ) throw new IllegalStateException ( "TimeoutFactory has been cancelled" ) ; if ( time < 0 ) throw new IllegalArgumentException ( "Negative time" ) ; if ( target == null ) throw new IllegalArgumentException ( "Null timeout target" ) ; return queue . offer ( time , target ) ;


signature:
public class TimeoutFactory { /** * Timeout worker method . */
private void doWork ( ) { } }

implementation:
while ( cancelled . get ( ) == false ) { TimeoutExt work = queue . take ( ) ; // Do work , if any
if ( work != null ) { // Wrap the TimeoutExt with a runnable that invokes the target callback
TimeoutWorker worker = new TimeoutWorker ( work ) ; try { threadPool . run ( worker ) ; } catch ( Throwable t ) { // protect the worker thread from pool enqueue errors
ThrowableHandler . add ( ThrowableHandler . Type . ERROR , t ) ; } synchronized ( work ) { work . done ( ) ; } } } // TimeoutFactory was cancelled
queue . cancel ( ) ;


signature:
public class Util { /** * Create a subcontext including any intermediate contexts .
 * @ param ctx the parent JNDI Context under which value will be bound
 * @ param name the name relative to ctx of the subcontext .
 * @ return The new or existing JNDI subcontext
 * @ throws javax . naming . NamingException on any JNDI failure */
public static Context createSubcontext ( Context ctx , String name ) throws NamingException { } }

implementation: Name n = ctx . getNameParser ( "" ) . parse ( name ) ; return createSubcontext ( ctx , n ) ;


signature:
public class Util { /** * Unbinds a name from ctx , and removes parents if they are empty
 * @ param ctx the parent JNDI Context under which the name will be unbound
 * @ param name The name to unbind
 * @ throws NamingException for any error */
public static void unbind ( Context ctx , Name name ) throws NamingException { } }

implementation:
ctx . unbind ( name ) ; // unbind the end node in the name
int sz = name . size ( ) ; // walk the tree backwards , stopping at the domain
while ( -- sz > 0 ) { Name pname = name . getPrefix ( sz ) ; try { ctx . destroySubcontext ( pname ) ; } catch ( NamingException e ) { log . trace ( "Unable to remove context " + pname , e ) ; break ; } }


signature:
public class Util { /** * Lookup an object in the default initial context
 * @ param name the name to lookup
 * @ param clazz the expected type
 * @ return the object
 * @ throws Exception for any error */
public static Object lookup ( String name , Class < ? > clazz ) throws Exception { } }

implementation: InitialContext ctx = new InitialContext ( ) ; try { return lookup ( ctx , name , clazz ) ; } finally { ctx . close ( ) ; }


signature:
public class Util { /** * Lookup an object in the given context
 * @ param context the context
 * @ param name the name to lookup
 * @ param clazz the expected type
 * @ return the object
 * @ throws Exception for any error */
public static Object lookup ( Context context , String name , Class clazz ) throws Exception { } }

implementation: Object result = context . lookup ( name ) ; checkObject ( context , name , result , clazz ) ; return result ;


signature:
public class Util { /** * Lookup an object in the given context
 * @ param context the context
 * @ param name the name to lookup
 * @ param clazz the expected type
 * @ return the object
 * @ throws Exception for any error */
public static Object lookup ( Context context , Name name , Class clazz ) throws Exception { } }

implementation: Object result = context . lookup ( name ) ; checkObject ( context , name . toString ( ) , result , clazz ) ; return result ;


signature:
public class Util { /** * Create a link
 * @ param fromName the from name
 * @ param toName the to name
 * @ throws NamingException for any error */
public static void createLinkRef ( String fromName , String toName ) throws NamingException { } }

implementation: InitialContext ctx = new InitialContext ( ) ; createLinkRef ( ctx , fromName , toName ) ;


signature:
public class Util { /** * Create a link
 * @ param ctx the context
 * @ param fromName the from name
 * @ param toName the to name
 * @ throws NamingException for any error */
public static void createLinkRef ( Context ctx , String fromName , String toName ) throws NamingException { } }

implementation: LinkRef link = new LinkRef ( toName ) ; Context fromCtx = ctx ; Name name = ctx . getNameParser ( "" ) . parse ( fromName ) ; String atom = name . get ( name . size ( ) - 1 ) ; for ( int n = 0 ; n < name . size ( ) - 1 ; n ++ ) { String comp = name . get ( n ) ; try { fromCtx = ( Context ) fromCtx . lookup ( comp ) ; } catch ( NameNotFoundException e ) { fromCtx = fromCtx . createSubcontext ( comp ) ; } } log . debug ( "atom: " + atom ) ; log . debug ( "link: " + link ) ; fromCtx . rebind ( atom , link ) ; log . debug ( "Bound link " + fromName + " to " + toName ) ;


signature:
public class Util { /** * Remove the link ref
 * @ param name the name of the link binding
 * @ throws NamingException for any error */
public static void removeLinkRef ( String name ) throws NamingException { } }

implementation: InitialContext ctx = new InitialContext ( ) ; removeLinkRef ( ctx , name ) ;


signature:
public class Util { /** * Remove the link ref
 * @ param ctx the context
 * @ param name the name of the link binding
 * @ throws NamingException for any error */
public static void removeLinkRef ( Context ctx , String name ) throws NamingException { } }

implementation: log . debug ( "Unbinding link " + name ) ; ctx . unbind ( name ) ;


signature:
public class Util { /** * Checks an object implements the given class
 * @ param context the context
 * @ param name the name to lookup
 * @ param object the object
 * @ param clazz the expected type
 * @ throws Exception for any error */
protected static void checkObject ( Context context , String name , Object object , Class clazz ) throws Exception { } }

implementation: Class objectClass = object . getClass ( ) ; if ( clazz . isAssignableFrom ( objectClass ) == false ) { StringBuffer buffer = new StringBuffer ( 100 ) ; buffer . append ( "Object at '" ) . append ( name ) ; buffer . append ( "' in context " ) . append ( context . getEnvironment ( ) ) ; buffer . append ( " is not an instance of " ) ; appendClassInfo ( buffer , clazz ) ; buffer . append ( " object class is " ) ; appendClassInfo ( buffer , object . getClass ( ) ) ; throw new ClassCastException ( buffer . toString ( ) ) ; }


signature:
public class Util { /** * Append Class Info
 * @ param buffer the buffer to append to
 * @ param clazz the class to describe */
protected static void appendClassInfo ( StringBuffer buffer , Class clazz ) { } }

implementation: buffer . append ( "[class=" ) . append ( clazz . getName ( ) ) ; buffer . append ( " classloader=" ) . append ( clazz . getClassLoader ( ) ) ; buffer . append ( " interfaces={" ) ; Class [ ] interfaces = clazz . getInterfaces ( ) ; for ( int i = 0 ; i < interfaces . length ; ++ i ) { if ( i > 0 ) buffer . append ( ", " ) ; buffer . append ( "interface=" ) . append ( interfaces [ i ] . getName ( ) ) ; buffer . append ( " classloader=" ) . append ( interfaces [ i ] . getClassLoader ( ) ) ; } buffer . append ( "}]" ) ;


signature:
public class State { /** * Lookup an allowed transition given its name .
 * @ param name - the name of a valid transition from this state .
 * @ return the valid transition if it exists , null otherwise . */
public Transition getTransition ( String name ) { } }

implementation: Transition t = ( Transition ) allowedTransitions . get ( name ) ; return t ;


signature:
public class CatalogManager { /** * Load the properties from the propertyFile and build the
 * resources from it . */
private synchronized void readProperties ( ) { } }

implementation:
try { propertyFileURI = CatalogManager . class . getResource ( "/" + propertyFile ) ; InputStream in = CatalogManager . class . getResourceAsStream ( "/" + propertyFile ) ; if ( in == null ) { if ( ! ignoreMissingProperties ) { System . err . println ( "Cannot find " + propertyFile ) ; // there ' s no reason to give this warning more than once
ignoreMissingProperties = true ; } return ; } resources = new PropertyResourceBundle ( in ) ; } catch ( MissingResourceException mre ) { if ( ! ignoreMissingProperties ) { System . err . println ( "Cannot read " + propertyFile ) ; } } catch ( java . io . IOException e ) { if ( ! ignoreMissingProperties ) { System . err . println ( "Failure trying to read " + propertyFile ) ; } } // This is a bit of a hack . After we ' ve successfully read the properties ,
// use them to set the default debug level , if the user hasn ' t already set
// the default debug level .
if ( verbosity == null ) { try { String verbStr = resources . getString ( "verbosity" ) ; int verb = Integer . parseInt ( verbStr . trim ( ) ) ; debug . setDebug ( verb ) ; verbosity = new Integer ( verb ) ; } catch ( Exception e ) { // nop
} }


signature:
public class CatalogManager { /** * Obtain the verbosity setting from the properties .
 * @ return The verbosity level from the propertyFile or the
 * defaultVerbosity . */
private int queryVerbosity ( ) { } }

implementation: String verbStr = System . getProperty ( pVerbosity ) ; if ( verbStr == null ) { if ( resources == null ) readProperties ( ) ; if ( resources == null ) return defaultVerbosity ; try { verbStr = resources . getString ( "verbosity" ) ; } catch ( MissingResourceException e ) { return defaultVerbosity ; } } try { int verb = Integer . parseInt ( verbStr . trim ( ) ) ; return verb ; } catch ( Exception e ) { System . err . println ( "Cannot parse verbosity: \"" + verbStr + "\"" ) ; return defaultVerbosity ; }


signature:
public class CatalogManager { /** * Obtain the relativeCatalogs setting from the properties .
 * @ return The relativeCatalogs setting from the propertyFile or the
 * defaultRelativeCatalogs . */
private boolean queryRelativeCatalogs ( ) { } }

implementation: if ( resources == null ) readProperties ( ) ; if ( resources == null ) return defaultRelativeCatalogs ; try { String allow = resources . getString ( "relative-catalogs" ) ; return ( allow . equalsIgnoreCase ( "true" ) || allow . equalsIgnoreCase ( "yes" ) || allow . equalsIgnoreCase ( "1" ) ) ; } catch ( MissingResourceException e ) { return defaultRelativeCatalogs ; }


signature:
public class CatalogManager { /** * Obtain the list of catalog files from the properties .
 * @ return A semicolon delimited list of catlog file URIs */
private String queryCatalogFiles ( ) { } }

implementation: String catalogList = System . getProperty ( pFiles ) ; fromPropertiesFile = false ; if ( catalogList == null ) { if ( resources == null ) readProperties ( ) ; if ( resources != null ) { try { catalogList = resources . getString ( "catalogs" ) ; fromPropertiesFile = true ; } catch ( MissingResourceException e ) { System . err . println ( propertyFile + ": catalogs not found." ) ; catalogList = null ; } } } if ( catalogList == null ) { catalogList = defaultCatalogFiles ; } return catalogList ;


signature:
public class CatalogManager { /** * Return the current list of catalog files .
 * @ return A vector of the catalog file names or null if no catalogs
 * are available in the properties . */
public Vector getCatalogFiles ( ) { } }

implementation: if ( catalogFiles == null ) { catalogFiles = queryCatalogFiles ( ) ; } StringTokenizer files = new StringTokenizer ( catalogFiles , ";" ) ; Vector catalogs = new Vector ( ) ; while ( files . hasMoreTokens ( ) ) { String catalogFile = files . nextToken ( ) ; URL absURI = null ; if ( fromPropertiesFile && ! relativeCatalogs ( ) ) { try { absURI = new URL ( propertyFileURI , catalogFile ) ; catalogFile = absURI . toString ( ) ; } catch ( MalformedURLException mue ) { absURI = null ; } } catalogs . add ( catalogFile ) ; } return catalogs ;


signature:
public class CatalogManager { /** * Obtain the preferPublic setting from the properties .
 * < p > In the properties , a value of ' public ' is true ,
 * anything else is false . < / p >
 * @ return True if prefer is public or the
 * defaultPreferSetting . */
private boolean queryPreferPublic ( ) { } }

implementation: String prefer = System . getProperty ( pPrefer ) ; if ( prefer == null ) { if ( resources == null ) readProperties ( ) ; if ( resources == null ) return defaultPreferPublic ; try { prefer = resources . getString ( "prefer" ) ; } catch ( MissingResourceException e ) { return defaultPreferPublic ; } } if ( prefer == null ) { return defaultPreferPublic ; } return ( prefer . equalsIgnoreCase ( "public" ) ) ;


signature:
public class CatalogManager { /** * Obtain the static - catalog setting from the properties .
 * < p > In the properties , a value of ' yes ' , ' true ' , or ' 1 ' is considered
 * true , anything else is false . < / p >
 * @ return The static - catalog setting from the propertyFile or the
 * defaultUseStaticCatalog . */
private boolean queryUseStaticCatalog ( ) { } }

implementation: String staticCatalog = System . getProperty ( pStatic ) ; if ( useStaticCatalog == null ) { if ( resources == null ) readProperties ( ) ; if ( resources == null ) return defaultUseStaticCatalog ; try { staticCatalog = resources . getString ( "static-catalog" ) ; } catch ( MissingResourceException e ) { return defaultUseStaticCatalog ; } } if ( staticCatalog == null ) { return defaultUseStaticCatalog ; } return ( staticCatalog . equalsIgnoreCase ( "true" ) || staticCatalog . equalsIgnoreCase ( "yes" ) || staticCatalog . equalsIgnoreCase ( "1" ) ) ;


signature:
public class CatalogManager { /** * @ return a new catalog instance .
 * This method always returns a new instance of the underlying catalog class . */
public Catalog getPrivateCatalog ( ) { } }

implementation: Catalog catalog = staticCatalog ; if ( useStaticCatalog == null ) { useStaticCatalog = new Boolean ( getUseStaticCatalog ( ) ) ; } if ( catalog == null || ! useStaticCatalog . booleanValue ( ) ) { try { String catalogClassName = getCatalogClassName ( ) ; if ( catalogClassName == null ) { catalog = new Catalog ( ) ; } else { try { catalog = ( Catalog ) Class . forName ( catalogClassName ) . newInstance ( ) ; } catch ( ClassNotFoundException cnfe ) { debug . message ( 1 , "Catalog class named '" + catalogClassName + "' could not be found. Using default." ) ; catalog = new Catalog ( ) ; } catch ( ClassCastException cnfe ) { debug . message ( 1 , "Class named '" + catalogClassName + "' is not a Catalog. Using default." ) ; catalog = new Catalog ( ) ; } } catalog . setCatalogManager ( this ) ; catalog . setupReaders ( ) ; catalog . loadSystemCatalogs ( ) ; } catch ( Exception ex ) { ex . printStackTrace ( ) ; } if ( useStaticCatalog . booleanValue ( ) ) { staticCatalog = catalog ; } } return catalog ;


signature:
public class CatalogManager { /** * @ return a catalog instance .
 * If this manager uses static catalogs , the same static catalog will
 * always be returned . Otherwise a new catalog will be returned . */
public Catalog getCatalog ( ) { } }

implementation: Catalog catalog = staticCatalog ; if ( useStaticCatalog == null ) { useStaticCatalog = new Boolean ( getUseStaticCatalog ( ) ) ; } if ( catalog == null || ! useStaticCatalog . booleanValue ( ) ) { catalog = getPrivateCatalog ( ) ; if ( useStaticCatalog . booleanValue ( ) ) { staticCatalog = catalog ; } } return catalog ;


signature:
public class CatalogManager { /** * < p > Obtain the oasisXMLCatalogPI setting from the properties . < / p >
 * < p > In the properties , a value of ' yes ' , ' true ' , or ' 1 ' is considered
 * true , anything else is false . < / p >
 * @ return The oasisXMLCatalogPI setting from the propertyFile or the
 * defaultOasisXMLCatalogPI . */
public boolean queryAllowOasisXMLCatalogPI ( ) { } }

implementation: String allow = System . getProperty ( pAllowPI ) ; if ( allow == null ) { if ( resources == null ) readProperties ( ) ; if ( resources == null ) return defaultOasisXMLCatalogPI ; try { allow = resources . getString ( "allow-oasis-xml-catalog-pi" ) ; } catch ( MissingResourceException e ) { return defaultOasisXMLCatalogPI ; } } if ( allow == null ) { return defaultOasisXMLCatalogPI ; } return ( allow . equalsIgnoreCase ( "true" ) || allow . equalsIgnoreCase ( "yes" ) || allow . equalsIgnoreCase ( "1" ) ) ;


signature:
public class CatalogManager { /** * Obtain the Catalog class name setting from the properties .
 * @ return the name */
public String queryCatalogClassName ( ) { } }

implementation: String className = System . getProperty ( pClassname ) ; if ( className == null ) { if ( resources == null ) readProperties ( ) ; if ( resources == null ) return null ; try { return resources . getString ( "catalog-class-name" ) ; } catch ( MissingResourceException e ) { return null ; } } return className ;


signature:
public class BootstrapResolver { /** * SAX resolveEntity API . */
public InputSource resolveEntity ( String publicId , String systemId ) { } }

implementation:
String resolved = null ; if ( systemId != null && systemMap . containsKey ( systemId ) ) { resolved = ( String ) systemMap . get ( systemId ) ; } else if ( publicId != null && publicMap . containsKey ( publicId ) ) { resolved = ( String ) publicMap . get ( publicId ) ; } if ( resolved != null ) { try { InputSource iSource = new InputSource ( resolved ) ; iSource . setPublicId ( publicId ) ; // Ideally this method would not attempt to open the
// InputStream , but there is a bug ( in Xerces , at least )
// that causes the parser to mistakenly open the wrong
// system identifier if the returned InputSource does
// not have a byteStream .
// It could be argued that we still shouldn ' t do this here ,
// but since the purpose of calling the entityResolver is
// almost certainly to open the input stream , it seems to
// do little harm .
URL url = new URL ( resolved ) ; InputStream iStream = url . openStream ( ) ; iSource . setByteStream ( iStream ) ; return iSource ; } catch ( Exception e ) { // FIXME : silently fail ?
return null ; } } return null ;


signature:
public class BootstrapResolver { /** * Transformer resolve API . */
public Source resolve ( String href , String base ) throws TransformerException { } }

implementation:
String uri = href ; int hashPos = href . indexOf ( "#" ) ; if ( hashPos >= 0 ) { uri = href . substring ( 0 , hashPos ) ; } String result = null ; if ( href != null && uriMap . containsKey ( href ) ) { result = ( String ) uriMap . get ( href ) ; } if ( result == null ) { try { URL url = null ; if ( base == null ) { url = new URL ( uri ) ; result = url . toString ( ) ; } else { URL baseURL = new URL ( base ) ; url = ( href . length ( ) == 0 ? baseURL : new URL ( baseURL , uri ) ) ; result = url . toString ( ) ; } } catch ( java . net . MalformedURLException mue ) { // try to make an absolute URI from the current base
String absBase = makeAbsolute ( base ) ; if ( ! absBase . equals ( base ) ) { // don ' t bother if the absBase isn ' t different !
return resolve ( href , absBase ) ; } else { throw new TransformerException ( "Malformed URL " + href + "(base " + base + ")" , mue ) ; } } } SAXSource source = new SAXSource ( ) ; source . setInputSource ( new InputSource ( result ) ) ; return source ;


signature:
public class BootstrapResolver { /** * Attempt to construct an absolute URI */
private String makeAbsolute ( String uri ) { } }

implementation:
if ( uri == null ) { uri = "" ; } try { URL url = new URL ( uri ) ; return url . toString ( ) ; } catch ( MalformedURLException mue ) { String dir = System . getProperty ( "user.dir" ) ; String file = "" ; if ( dir . endsWith ( "/" ) ) { file = "file://" + dir + uri ; } else { file = "file://" + dir + "/" + uri ; } try { URL fileURL = new URL ( file ) ; return fileURL . toString ( ) ; } catch ( MalformedURLException mue2 ) { // bail
return uri ; } }


signature:
public class MarshalledValueInputStream { /** * Use the thread context class loader to resolve the class
 * @ throws java . io . IOException Any exception thrown by the underlying OutputStream . */
protected Class < ? > resolveClass ( ObjectStreamClass v ) throws IOException , ClassNotFoundException { } }

implementation:
ClassLoader loader = Thread . currentThread ( ) . getContextClassLoader ( ) ; String className = v . getName ( ) ; try { // JDK 6 , by default , only supports array types ( ex . [ [ B ) using Class . forName ( )
return Class . forName ( className , false , loader ) ; } catch ( ClassNotFoundException cnfe ) { Class cl = primClasses . get ( className ) ; if ( cl == null ) throw cnfe ; else return cl ; }


signature:
public class MethodBoundPropertyListener { /** * Get the < tt > PropertyDescriptor < / tt > for the given bean property name .
 * @ param beanPropertyName Bean property name .
 * @ return < tt > PropertyDescriptor < / tt > . */
private PropertyDescriptor getPropertyDescriptor ( final String beanPropertyName ) throws IntrospectionException { } }

implementation: Class < ? > instanceType = instance . getClass ( ) ; BeanInfo beanInfo = Introspector . getBeanInfo ( instanceType ) ; PropertyDescriptor descriptors [ ] = beanInfo . getPropertyDescriptors ( ) ; PropertyDescriptor descriptor = null ; for ( int i = 0 ; i < descriptors . length ; i ++ ) { if ( descriptors [ i ] . getName ( ) . equals ( beanPropertyName ) ) { descriptor = descriptors [ i ] ; break ; } } return descriptor ;


signature:
public class MethodBoundPropertyListener { /** * Coerce and invoke the property setter method on the instance .
 * @ param value Method value .
 * @ throws PropertyException Failed to invoke setter method . */
protected void invokeSetter ( String value ) { } }

implementation:
try { // coerce value to field type
Class < ? > type = descriptor . getPropertyType ( ) ; PropertyEditor editor = PropertyEditors . findEditor ( type ) ; editor . setAsText ( value ) ; Object coerced = editor . getValue ( ) ; // System . out . println ( " type : " + type ) ;
// System . out . println ( " coerced : " + coerced ) ;
// invoke the setter method
setter . invoke ( instance , new Object [ ] { coerced } ) ; } catch ( InvocationTargetException e ) { Throwable target = e . getTargetException ( ) ; if ( target instanceof PropertyException ) { throw ( PropertyException ) target ; } else { throw new PropertyException ( target ) ; } } catch ( Exception e ) { throw new PropertyException ( e ) ; }


signature:
public class MethodBoundPropertyListener { /** * Notifies that this listener was bound to a property .
 * @ param map PropertyMap which contains property bound to . */
public void propertyBound ( final PropertyMap map ) { } }

implementation:
// only set the field if the map contains the property already
if ( map . containsProperty ( propertyName ) ) { invokeSetter ( map . getProperty ( propertyName ) ) ; }


signature:
public class Namespaces { /** * Returns the " prefix " part of a QName or the empty string ( not
 * null ) if the name has no prefix .
 * @ param element The QName of an element .
 * @ return The prefix part of the element name . */
public static String getPrefix ( Element element ) { } }

implementation: String name = element . getTagName ( ) ; String prefix = "" ; if ( name . indexOf ( ':' ) > 0 ) { prefix = name . substring ( 0 , name . indexOf ( ':' ) ) ; } return prefix ;


signature:
public class Namespaces { /** * Returns the " localname " part of a QName , which is the whole
 * name if it has no prefix .
 * @ param element The QName of an element .
 * @ return The local part of a QName . */
public static String getLocalName ( Element element ) { } }

implementation: String name = element . getTagName ( ) ; if ( name . indexOf ( ':' ) > 0 ) { name = name . substring ( name . indexOf ( ':' ) + 1 ) ; } return name ;


signature:
public class Namespaces { /** * Returns the namespace URI for the specified prefix at the
 * specified context node .
 * @ param node The context node .
 * @ param prefix The prefix .
 * @ return The namespace URI associated with the prefix , or
 * null if no namespace declaration exists for the prefix . */
public static String getNamespaceURI ( Node node , String prefix ) { } }

implementation: if ( node == null || node . getNodeType ( ) != Node . ELEMENT_NODE ) { return null ; } if ( prefix . equals ( "" ) ) { if ( ( ( Element ) node ) . hasAttribute ( "xmlns" ) ) { return ( ( Element ) node ) . getAttribute ( "xmlns" ) ; } } else { String nsattr = "xmlns:" + prefix ; if ( ( ( Element ) node ) . hasAttribute ( nsattr ) ) { return ( ( Element ) node ) . getAttribute ( nsattr ) ; } } return getNamespaceURI ( node . getParentNode ( ) , prefix ) ;


signature:
public class Namespaces { /** * Returns the namespace URI for the namespace to which the
 * element belongs .
 * @ param element The element .
 * @ return The namespace URI associated with the namespace of the
 * element , or null if no namespace declaration exists for it . */
public static String getNamespaceURI ( Element element ) { } }

implementation: String prefix = getPrefix ( element ) ; return getNamespaceURI ( element , prefix ) ;


signature:
public class LongEditor { /** * Map the argument text into and Integer using Integer . valueOf . */
public void setAsText ( final String text ) { } }

implementation: if ( PropertyEditors . isNull ( text ) ) { setValue ( null ) ; return ; } Object newValue = Long . valueOf ( text ) ; setValue ( newValue ) ;


signature:
public class CollectionsUtil { /** * Create a list from an enumeration
 * @ param e the enumeration
 * @ return the list */
public static List list ( Enumeration e ) { } }

implementation: ArrayList result = new ArrayList ( ) ; while ( e . hasMoreElements ( ) ) result . add ( e . nextElement ( ) ) ; return result ;


signature:
public class FilePropertyReader { /** * Get an input stream for the given filename .
 * @ param filename File name to get input stream for .
 * @ return Input stream for file .
 * @ throws IOException Failed to get input stream for file . */
protected InputStream getInputStream ( String filename ) throws IOException { } }

implementation: File file = new File ( filename ) ; return new FileInputStream ( file ) ;


signature:
public class FilePropertyReader { /** * Load properties from a file into a properties map .
 * @ param props Properties map to load properties into .
 * @ param filename Filename to read properties from .
 * @ throws IOException Failed to load properties from filename .
 * @ throws IllegalArgumentException Filename is invalid . */
protected void loadProperties ( Properties props , String filename ) throws IOException { } }

implementation: if ( filename == null ) throw new NullArgumentException ( "filename" ) ; if ( filename . equals ( "" ) ) throw new IllegalArgumentException ( "filename" ) ; InputStream in = new BufferedInputStream ( getInputStream ( filename ) ) ; props . load ( in ) ; in . close ( ) ;


signature:
public class FilePropertyReader { /** * Read properties from each specified filename
 * @ return Read properties
 * @ throws PropertyException Failed to read properties .
 * @ throws IOException I / O error while reading properties . */
public Map readProperties ( ) throws PropertyException , IOException { } }

implementation:
Properties props = new Properties ( ) ; // load each specified property file
for ( int i = 0 ; i < filenames . length ; i ++ ) { loadProperties ( props , filenames [ i ] ) ; } return props ;


signature:
public class Vertex { /** * Add an edge to the vertex . If edge . from is this vertex , its an
 * outgoing edge . If edge . to is this vertex , its an incoming
 * edge . If neither from or to is this vertex , the edge is
 * not added .
 * @ param e - the edge to add
 * @ return true if the edge was added , false otherwise */
public boolean addEdge ( Edge < T > e ) { } }

implementation: if ( e . getFrom ( ) == this ) outgoingEdges . add ( e ) ; else if ( e . getTo ( ) == this ) incomingEdges . add ( e ) ; else return false ; return true ;


signature:
public class Vertex { /** * Add an outgoing edge ending at to .
 * @ param to - the destination vertex
 * @ param cost the edge cost */
public void addOutgoingEdge ( Vertex < T > to , int cost ) { } }

implementation: Edge < T > out = new Edge < T > ( this , to , cost ) ; outgoingEdges . add ( out ) ;


signature:
public class Vertex { /** * Add an incoming edge starting at from
 * @ param from - the starting vertex
 * @ param cost the edge cost */
public void addIncomingEdge ( Vertex < T > from , int cost ) { } }

implementation: Edge < T > out = new Edge < T > ( this , from , cost ) ; incomingEdges . add ( out ) ;


signature:
public class Vertex { /** * Check the vertex for either an incoming or outgoing edge
 * mathcing e .
 * @ param e the edge to check
 * @ return true it has an edge */
public boolean hasEdge ( Edge < T > e ) { } }

implementation: if ( e . getFrom ( ) == this ) return outgoingEdges . contains ( e ) ; else if ( e . getTo ( ) == this ) return incomingEdges . contains ( e ) ; else return false ;


signature:
public class Vertex { /** * Remove an edge from this vertex
 * @ param e - the edge to remove
 * @ return true if the edge was removed , false if the
 * edge was not connected to this vertex */
public boolean remove ( Edge < T > e ) { } }

implementation: if ( e . getFrom ( ) == this ) outgoingEdges . remove ( e ) ; else if ( e . getTo ( ) == this ) incomingEdges . remove ( e ) ; else return false ; return true ;


signature:
public class Vertex { /** * Search the outgoing edges looking for an edge whose ' s
 * edge . to = = dest .
 * @ param dest the destination
 * @ return the outgoing edge going to dest if one exists ,
 * null otherwise . */
public Edge < T > findEdge ( Vertex < T > dest ) { } }

implementation: for ( Edge < T > e : outgoingEdges ) { if ( e . getTo ( ) == dest ) return e ; } return null ;


signature:
public class Vertex { /** * Search the outgoing edges for a match to e .
 * @ param e - the edge to check
 * @ return e if its a member of the outgoing edges , null
 * otherwise . */
public Edge < T > findEdge ( Edge < T > e ) { } }

implementation: if ( outgoingEdges . contains ( e ) ) return e ; else return null ;


signature:
public class Vertex { /** * What is the cost from this vertext to the dest vertex .
 * @ param dest - the destination vertex .
 * @ return Return Integer . MAX _ VALUE if we have no edge to dest ,
 * 0 if dest is this vertex , the cost of the outgoing edge
 * otherwise . */
public int cost ( Vertex < T > dest ) { } }

implementation: if ( dest == this ) return 0 ; Edge < T > e = findEdge ( dest ) ; int cost = Integer . MAX_VALUE ; if ( e != null ) cost = e . getCost ( ) ; return cost ;


signature:
public class JarUtils { /** * < P > This function will create a Jar archive containing the src
 * file / directory . The archive will be written to the specified
 * OutputStream . < / P >
 * < P > This is a shortcut for < br >
 * < code > jar ( out , new File [ ] { src } , null , null , null ) ; < / code > < / P >
 * @ param out The output stream to which the generated Jar archive is
 * written .
 * @ param src The file or directory to jar up . Directories will be
 * processed recursively .
 * @ throws IOException */
public static void jar ( OutputStream out , File src ) throws IOException { } }


signature:
public class JarUtils { /** * < P > This function will create a Jar archive containing the src
 * file / directory . The archive will be written to the specified
 * OutputStream . Directories are processed recursively , applying the
 * specified filter if it exists .
 * < P > This is a shortcut for < br >
 * < code > jar ( out , src , filter , null , null ) ; < / code > < / P >
 * @ param out The output stream to which the generated Jar archive is
 * written .
 * @ param src The file or directory to jar up . Directories will be
 * processed recursively .
 * @ param filter The filter to use while processing directories . Only
 * those files matching will be included in the jar archive . If
 * null , then all files are included .
 * @ throws IOException */
public static void jar ( OutputStream out , File [ ] src , FileFilter filter ) throws IOException { } }


signature:
public class JarUtils { /** * < P > This function will create a Jar archive containing the src
 * file / directory . The archive will be written to the specified
 * OutputStream . Directories are processed recursively , applying the
 * specified filter if it exists .
 * @ param out The output stream to which the generated Jar archive is
 * written .
 * @ param src The file or directory to jar up . Directories will be
 * processed recursively .
 * @ param filter The filter to use while processing directories . Only
 * those files matching will be included in the jar archive . If
 * null , then all files are included .
 * @ param prefix The name of an arbitrary directory that will precede all
 * entries in the jar archive . If null , then no prefix will be
 * used .
 * @ param man The manifest to use for the Jar archive . If null , then no
 * manifest will be included .
 * @ throws IOException */
public static void jar ( OutputStream out , File [ ] src , FileFilter filter , String prefix , Manifest man ) throws IOException { } }

implementation:
for ( int i = 0 ; i < src . length ; i ++ ) { if ( ! src [ i ] . exists ( ) ) { throw new FileNotFoundException ( src . toString ( ) ) ; } } JarOutputStream jout ; if ( man == null ) { jout = new JarOutputStream ( out ) ; } else { jout = new JarOutputStream ( out , man ) ; } if ( prefix != null && prefix . length ( ) > 0 && ! prefix . equals ( "/" ) ) { // strip leading ' / '
if ( prefix . charAt ( 0 ) == '/' ) { prefix = prefix . substring ( 1 ) ; } // ensure trailing ' / '
if ( prefix . charAt ( prefix . length ( ) - 1 ) != '/' ) { prefix = prefix + "/" ; } } else { prefix = "" ; } JarInfo info = new JarInfo ( jout , filter ) ; for ( int i = 0 ; i < src . length ; i ++ ) { jar ( src [ i ] , prefix , info ) ; } jout . close ( ) ;


signature:
public class JarUtils { /** * This recursive method writes all matching files and directories to
 * the jar output stream . */
private static void jar ( File src , String prefix , JarInfo info ) throws IOException { } }

implementation:
JarOutputStream jout = info . out ; if ( src . isDirectory ( ) ) { // create / init the zip entry
prefix = prefix + src . getName ( ) + "/" ; ZipEntry entry = new ZipEntry ( prefix ) ; entry . setTime ( src . lastModified ( ) ) ; entry . setMethod ( JarOutputStream . STORED ) ; entry . setSize ( 0L ) ; entry . setCrc ( 0L ) ; jout . putNextEntry ( entry ) ; jout . closeEntry ( ) ; // process the sub - directories
File [ ] files = src . listFiles ( info . filter ) ; for ( int i = 0 ; i < files . length ; i ++ ) { jar ( files [ i ] , prefix , info ) ; } } else if ( src . isFile ( ) ) { // get the required info objects
byte [ ] buffer = info . buffer ; // create / init the zip entry
ZipEntry entry = new ZipEntry ( prefix + src . getName ( ) ) ; entry . setTime ( src . lastModified ( ) ) ; jout . putNextEntry ( entry ) ; // dump the file
FileInputStream in = new FileInputStream ( src ) ; int len ; while ( ( len = in . read ( buffer , 0 , buffer . length ) ) != - 1 ) { jout . write ( buffer , 0 , len ) ; } in . close ( ) ; jout . closeEntry ( ) ; }


signature:
public class JarUtils { /** * Given a URL check if its a jar url ( jar : < url > ! / archive ) and if it is ,
 * extract the archive entry into the given dest directory and return a file
 * URL to its location . If jarURL is not a jar url then it is simply returned
 * as the URL for the jar .
 * @ param jarURL the URL to validate and extract the referenced entry if its
 * a jar protocol URL
 * @ param dest the directory into which the nested jar will be extracted .
 * @ return the file : URL for the jar referenced by the jarURL parameter .
 * @ throws IOException */
public static URL extractNestedJar ( URL jarURL , File dest ) throws IOException { } }

implementation:
// This may not be a jar URL so validate the protocol
if ( jarURL . getProtocol ( ) . equals ( "jar" ) == false ) return jarURL ; String destPath = dest . getAbsolutePath ( ) ; URLConnection urlConn = jarURL . openConnection ( ) ; JarURLConnection jarConn = ( JarURLConnection ) urlConn ; // Extract the archive to dest / jarName - contents / archive
String parentArchiveName = jarConn . getJarFile ( ) . getName ( ) ; // Find the longest common prefix between destPath and parentArchiveName
int length = Math . min ( destPath . length ( ) , parentArchiveName . length ( ) ) ; int n = 0 ; while ( n < length ) { char a = destPath . charAt ( n ) ; char b = parentArchiveName . charAt ( n ) ; if ( a != b ) break ; n ++ ; } // Remove any common prefix from parentArchiveName
parentArchiveName = parentArchiveName . substring ( n ) ; File archiveDir = new File ( dest , parentArchiveName + "-contents" ) ; if ( archiveDir . exists ( ) == false && archiveDir . mkdirs ( ) == false ) throw new IOException ( "Failed to create contents directory for archive, path=" + archiveDir . getAbsolutePath ( ) ) ; String archiveName = jarConn . getEntryName ( ) ; File archiveFile = new File ( archiveDir , archiveName ) ; File archiveParentDir = archiveFile . getParentFile ( ) ; if ( archiveParentDir . exists ( ) == false && archiveParentDir . mkdirs ( ) == false ) throw new IOException ( "Failed to create parent directory for archive, path=" + archiveParentDir . getAbsolutePath ( ) ) ; InputStream archiveIS = jarConn . getInputStream ( ) ; FileOutputStream fos = new FileOutputStream ( archiveFile ) ; BufferedOutputStream bos = new BufferedOutputStream ( fos ) ; byte [ ] buffer = new byte [ 4096 ] ; int read ; while ( ( read = archiveIS . read ( buffer ) ) > 0 ) { bos . write ( buffer , 0 , read ) ; } archiveIS . close ( ) ; bos . close ( ) ; // Return the file url to the extracted jar
return archiveFile . toURL ( ) ;


signature:
public class CompoundIterator { /** * Check if there are more elements .
 * @ return True if there are more elements . */
public boolean hasNext ( ) { } }

implementation: for ( ; index < iters . length ; index ++ ) { if ( iters [ index ] != null && iters [ index ] . hasNext ( ) ) { return true ; } } return false ;


signature:
public class TinyMachine { /** * Forwards an event into state machine . State machine will deliver the event to a
 * handler methods responsible for its processing . If there is no handler method found ,
 * then event gets silently ignored and this call has no effect .
 * @ param event event to be delivered to a handler method */
public void fireEvent ( Object event ) { } }

implementation: if ( event == null ) { throw new IllegalArgumentException ( "Event must not be null." ) ; } mTaskQueue . offer ( Task . obtainTask ( Task . CODE_FIRE_EVENT , event , - 1 ) ) ; if ( ! mQueueProcessed ) processTaskQueue ( ) ;


signature:
public class TinyMachine { /** * Moves state machine in a new given state . If state machine is already in that state ,
 * then this method has no effect . Otherwise , if exists , < code > Type . OnExit < / code > event
 * handler for the current state is called first and then < code > Type . OnEntry < / code > event
 * handler for new state is called .
 * @ param state new state to put state machine into */
public void transitionTo ( int state ) { } }

implementation: mTaskQueue . offer ( Task . obtainTask ( Task . CODE_TRANSITION , null , state ) ) ; if ( ! mQueueProcessed ) processTaskQueue ( ) ;


signature:
public class TinyMachine { /** * Enables traces and sets tag to be used for < code > Log . d ( ) < / code > output .
 * < code > TinyMachine < / code > will trace all processed events and state transitions including
 * events for which handlers in current state are missed .
 * @ param tag the name of tag to be used in < code > Log . d ( ) < / code >
 * @ return this instance */
public TinyMachine setTraceTag ( String tag ) { } }

implementation: mTraceTag = tag ; if ( mTraceTag != null ) { log ( "current state" , null ) ; } return this ;


signature:
public class TinyMachine { /** * - - implementation */
private void processTaskQueue ( ) { } }

implementation: mQueueProcessed = true ; try { Task task ; while ( ( task = mTaskQueue . poll ( ) ) != null ) { switch ( task . code ) { case Task . CODE_FIRE_EVENT : { Object event = task . event ; final Class < ? extends Object > clazz = event . getClass ( ) ; fire ( clazz , event , StateHandler . STATE_ANY ) ; fire ( clazz , event , mCurrentState ) ; break ; } case Task . CODE_TRANSITION : { int state = task . state ; if ( mCurrentState != state ) { fire ( OnExit . class , null , StateHandler . STATE_ANY ) ; fire ( OnExit . class , null , mCurrentState ) ; mCurrentState = state ; if ( mTraceTag != null ) { log ( "new state" , null ) ; } fire ( OnEntry . class , null , StateHandler . STATE_ANY ) ; fire ( OnEntry . class , null , mCurrentState ) ; } break ; } default : throw new IllegalStateException ( "wrong code: " + task . code ) ; } task . recycle ( ) ; } } finally { mQueueProcessed = false ; }


signature:
public class StructsBatchCompiler { /** * Installs the complete JvmTypeProvider including index access into the
 * { @ link ResourceSet } . The lookup classpath is enhanced with the given tmp
 * directory . */
@ Deprecated protected void installJvmTypeProvider ( XtextResourceSet resourceSet , File tmpClassDirectory ) { } }

implementation: internalInstallJvmTypeProvider ( resourceSet , tmpClassDirectory , false ) ;


signature:
public class StructsBatchCompiler { /** * Installs the JvmTypeProvider optionally including index access into the
 * { @ link ResourceSet } . The lookup classpath is enhanced with the given tmp
 * directory . */
protected void installJvmTypeProvider ( XtextResourceSet resourceSet , File tmpClassDirectory , boolean skipIndexLookup ) { } }

implementation:
if ( skipIndexLookup ) { internalInstallJvmTypeProvider ( resourceSet , tmpClassDirectory , skipIndexLookup ) ; } else { // delegate to the deprecated signature in case it was overridden by
// clients
installJvmTypeProvider ( resourceSet , tmpClassDirectory ) ; }


signature:
public class StructsBatchCompiler { /** * Performs the actual installation of the JvmTypeProvider . */
private void internalInstallJvmTypeProvider ( XtextResourceSet resourceSet , File tmpClassDirectory , boolean skipIndexLookup ) { } }

implementation:
Iterable < String > classPathEntries = concat ( getClassPathEntries ( ) , getSourcePathDirectories ( ) , asList ( tmpClassDirectory . toString ( ) ) ) ; classPathEntries = filter ( classPathEntries , new Predicate < String > ( ) { public boolean apply ( String input ) { return ! Strings . isEmpty ( input . trim ( ) ) ; } } ) ; Function < String , URL > toUrl = new Function < String , URL > ( ) { public URL apply ( String from ) { try { return new File ( from ) . toURI ( ) . toURL ( ) ; } catch ( MalformedURLException e ) { throw new RuntimeException ( e ) ; } } } ; Iterable < URL > classPathUrls = Iterables . transform ( classPathEntries , toUrl ) ; log . debug ( "classpath used for Struct compilation : " + classPathUrls ) ; ClassLoader parentClassLoader ; if ( useCurrentClassLoaderAsParent ) { parentClassLoader = currentClassLoader ; } else { if ( isEmpty ( bootClassPath ) ) { parentClassLoader = ClassLoader . getSystemClassLoader ( ) . getParent ( ) ; } else { Iterable < URL > bootClassPathUrls = Iterables . transform ( getBootClassPathEntries ( ) , toUrl ) ; parentClassLoader = new BootClassLoader ( toArray ( bootClassPathUrls , URL . class ) ) ; } } ClassLoader urlClassLoader = new URLClassLoader ( toArray ( classPathUrls , URL . class ) , parentClassLoader ) ; new ClasspathTypeProvider ( urlClassLoader , resourceSet , skipIndexLookup ? null : indexedJvmTypeAccess ) ; resourceSet . setClasspathURIContext ( urlClassLoader ) ; // for annotation processing we need to have the compiler ' s classpath as
// a parent .
URLClassLoader urlClassLoaderForAnnotationProcessing = new URLClassLoader ( toArray ( classPathUrls , URL . class ) , currentClassLoader ) ; resourceSet . eAdapters ( ) . add ( new ProcessorClassloaderAdapter ( urlClassLoaderForAnnotationProcessing ) ) ;


signature:
public class StructsBatchCompiler { /** * version 2.2 . x */
protected static boolean cleanFolder ( File parentFolder , FileFilter filter , boolean continueOnError , boolean deleteParentFolder ) { } }

implementation: if ( ! parentFolder . exists ( ) ) { return true ; } if ( filter == null ) filter = ACCEPT_ALL_FILTER ; log . debug ( "Cleaning folder " + parentFolder . toString ( ) ) ; final File [ ] contents = parentFolder . listFiles ( filter ) ; for ( int j = 0 ; j < contents . length ; j ++ ) { final File file = contents [ j ] ; if ( file . isDirectory ( ) ) { if ( ! cleanFolder ( file , filter , continueOnError , true ) && ! continueOnError ) return false ; } else { if ( ! file . delete ( ) ) { log . warn ( "Couldn't delete " + file . getAbsolutePath ( ) ) ; if ( ! continueOnError ) return false ; } } } if ( deleteParentFolder ) { if ( parentFolder . list ( ) . length == 0 && ! parentFolder . delete ( ) ) { log . warn ( "Couldn't delete " + parentFolder . getAbsolutePath ( ) ) ; return false ; } } return true ;


signature:
public class Dispatcher { /** * Dispatch the given action . Dispatching is always done on the JavaFX application
 * thread , even if this method is called from another thread .
 * @ param action the action that will be dispatched to the stores . */
public void dispatchOnFxThread ( Action action ) { } }

implementation: if ( Platform . isFxApplicationThread ( ) ) { actionStream . push ( action ) ; } else { Platform . runLater ( ( ) -> actionStream . push ( action ) ) ; }


signature:
public class Dispatcher { /** * A filtered event - stream of actions of the given type .
 * @ param actionType the class type of the action .
 * @ param < T > the generic type of the action .
 * @ return an event - stream of all actions of the given type . */
@ SuppressWarnings ( "unchecked" ) < T extends Action > EventStream < T > getActionStream ( Class < T > actionType ) { } }

implementation: return Dispatcher . getInstance ( ) . getActionStream ( ) . filter ( action -> action . getClass ( ) . equals ( actionType ) ) . map ( action -> ( T ) action ) ;


signature:
public class ViewLoader { /** * Taken from mvvmFX */
private static String createFxmlPath ( Class < ? > viewType ) { } }

implementation: final StringBuilder pathBuilder = new StringBuilder ( ) ; pathBuilder . append ( "/" ) ; if ( viewType . getPackage ( ) != null ) { pathBuilder . append ( viewType . getPackage ( ) . getName ( ) . replaceAll ( "\\." , "/" ) ) ; pathBuilder . append ( "/" ) ; } pathBuilder . append ( viewType . getSimpleName ( ) ) ; pathBuilder . append ( ".fxml" ) ; return pathBuilder . toString ( ) ;


signature:
public class ViewCellFactory { /** * Update all views by invoking the update function ( { @ link # getUpdateFunction ( ) } ) . */
public void updateViews ( ) { } }

implementation: cache . entrySet ( ) . forEach ( entry -> updateFunction . accept ( entry . getKey ( ) , entry . getValue ( ) . getController ( ) ) ) ;


signature:
public class ViewCellFactory { /** * Update all views that match the given predicate by invoking the update function ( { @ link # getUpdateFunction ( ) } ) . */
public void updateViews ( Predicate < T > predicate ) { } }

implementation: cache . entrySet ( ) . stream ( ) . filter ( entry -> predicate . test ( entry . getKey ( ) ) ) . forEach ( entry -> updateFunction . accept ( entry . getKey ( ) , entry . getValue ( ) . getController ( ) ) ) ;


signature:
public class Store { /** * This method can be used to subscribe to actions of a given type . The subscription is managed by the { @ link Dispatcher } .
 * @ param actionType the class type of the action .
 * @ param actionConsumer a consumer function that is invoked when an action is dispatched .
 * @ param < T > the generic type of the action . */
protected < T extends Action > void subscribe ( Class < T > actionType , Consumer < T > actionConsumer ) { } }

implementation: Dispatcher . getInstance ( ) . getActionStream ( actionType ) . subscribe ( actionConsumer ) ;


signature:
public class TimberAndroidLoggerFactory { /** * Return an appropriate { @ link TimberAndroidLoggerAdapter } instance by name . */
public Logger getLogger ( String name ) { } }

implementation: String tag = name == null ? ANONYMOUS_TAG : name ; Logger logger = loggerMap . get ( tag ) ; if ( logger == null ) { Logger newInstance = new TimberAndroidLoggerAdapter ( tag ) ; Logger oldInstance = loggerMap . putIfAbsent ( tag , newInstance ) ; logger = oldInstance == null ? newInstance : oldInstance ; } return logger ;


signature:
public class TimberAndroidLoggerAdapter { /** * Log a message at level VERBOSE according to the specified format and
 * argument .
 * This form avoids superfluous object creation when the logger is disabled
 * for level VERBOSE .
 * @ param format the format string
 * @ param arg the argument */
public void trace ( String format , Object arg ) { } }

implementation: formatAndLog ( Log . VERBOSE , format , arg ) ;


signature:
public class TimberAndroidLoggerAdapter { /** * Log a message at level VERBOSE according to the specified format and
 * arguments .
 * This form avoids superfluous object creation when the logger is disabled
 * for the VERBOSE level .
 * @ param format the format string
 * @ param arg1 the first argument
 * @ param arg2 the second argument */
public void trace ( String format , Object arg1 , Object arg2 ) { } }

implementation: formatAndLog ( Log . VERBOSE , format , arg1 , arg2 ) ;