signature:
public class Resolver { /** * Return the applicable PUBLIC or SYSTEM identifier , resorting
 * to external resolvers if necessary .
 * < p > This method searches the Catalog and returns the system
 * identifier specified for the given system or
 * public identifiers . If
 * no appropriate PUBLIC or SYSTEM entry is found in the Catalog ,
 * null is returned . < / p >
 * < p > Note that a system or public identifier in the current catalog
 * ( or subordinate catalogs ) will be used in preference to an
 * external resolver . Further , if a systemId is present , the external
 * resolver ( s ) will be queried for that before the publicId . < / p >
 * @ param publicId The public identifier to locate in the catalog .
 * Public identifiers are normalized before comparison .
 * @ param systemId The nominal system identifier for the entity
 * in question ( as provided in the source document ) .
 * @ throws MalformedURLException The formal system identifier of a
 * subordinate catalog cannot be turned into a valid URL .
 * @ throws IOException Error reading subordinate catalog file .
 * @ return The system identifier to use .
 * Note that the nominal system identifier is not returned if a
 * match is not found in the catalog , instead null is returned
 * to indicate that no match was found . */
public String resolvePublic ( String publicId , String systemId ) throws MalformedURLException , IOException { } }

implementation: String resolved = super . resolvePublic ( publicId , systemId ) ; if ( resolved != null ) { return resolved ; } Enumeration enumt = catalogEntries . elements ( ) ; while ( enumt . hasMoreElements ( ) ) { CatalogEntry e = ( CatalogEntry ) enumt . nextElement ( ) ; if ( e . getEntryType ( ) == RESOLVER ) { if ( systemId != null ) { resolved = resolveExternalSystem ( systemId , e . getEntryArg ( 0 ) ) ; if ( resolved != null ) { return resolved ; } } resolved = resolveExternalPublic ( publicId , e . getEntryArg ( 0 ) ) ; if ( resolved != null ) { return resolved ; } } } return resolveSubordinateCatalogs ( Catalog . PUBLIC , null , publicId , systemId ) ;


signature:
public class Resolver { /** * Query an external RFC2483 resolver for a system identifier .
 * @ param systemId The system ID to locate .
 * @ param resolver The name of the resolver to use .
 * @ return The system identifier to use for the systemId .
 * @ throws MalformedURLException
 * @ throws IOException */
protected String resolveExternalSystem ( String systemId , String resolver ) throws MalformedURLException , IOException { } }

implementation: Resolver r = queryResolver ( resolver , "i2l" , systemId , null ) ; if ( r != null ) { return r . resolveSystem ( systemId ) ; } else { return null ; }


signature:
public class Resolver { /** * Query an external RFC2483 resolver for a public identifier .
 * @ param publicId The system ID to locate .
 * @ param resolver The name of the resolver to use .
 * @ throws MalformedURLException
 * @ throws IOException
 * @ return The system identifier to use for the systemId . */
protected String resolveExternalPublic ( String publicId , String resolver ) throws MalformedURLException , IOException { } }

implementation: Resolver r = queryResolver ( resolver , "fpi2l" , publicId , null ) ; if ( r != null ) { return r . resolvePublic ( publicId , null ) ; } else { return null ; }


signature:
public class Resolver { /** * Query an external RFC2483 resolver .
 * @ param resolver The URL of the RFC2483 resolver .
 * @ param command The command to send the resolver .
 * @ param arg1 The first argument to the resolver .
 * @ param arg2 The second argument to the resolver , usually null .
 * @ return The Resolver constructed . */
protected Resolver queryResolver ( String resolver , String command , String arg1 , String arg2 ) { } }

implementation:
String RFC2483 = resolver + "?command=" + command + "&format=tr9401&uri=" + arg1 + "&uri2=" + arg2 ; try { URL url = new URL ( RFC2483 ) ; URLConnection urlCon = url . openConnection ( ) ; urlCon . setUseCaches ( false ) ; Resolver r = ( Resolver ) newCatalog ( ) ; String cType = urlCon . getContentType ( ) ; // I don ' t care about the character set or subtype
if ( cType . indexOf ( ";" ) > 0 ) { cType = cType . substring ( 0 , cType . indexOf ( ";" ) ) ; } r . parseCatalog ( cType , urlCon . getInputStream ( ) ) ; return r ; } catch ( CatalogException cex ) { if ( cex . getExceptionType ( ) == CatalogException . UNPARSEABLE ) { catalogManager . debug . message ( 1 , "Unparseable catalog: " + RFC2483 ) ; } else if ( cex . getExceptionType ( ) == CatalogException . UNKNOWN_FORMAT ) { catalogManager . debug . message ( 1 , "Unknown catalog format: " + RFC2483 ) ; } return null ; } catch ( MalformedURLException mue ) { catalogManager . debug . message ( 1 , "Malformed resolver URL: " + RFC2483 ) ; return null ; } catch ( IOException ie ) { catalogManager . debug . message ( 1 , "I/O Exception opening resolver: " + RFC2483 ) ; return null ; }


signature:
public class Resolver { /** * Append two vectors , returning the result .
 * @ param vec The first vector
 * @ param appvec The vector to be appended
 * @ return The vector vec , with appvec ' s elements appended to it */
private Vector appendVector ( Vector vec , Vector appvec ) { } }

implementation: if ( appvec != null ) { for ( int count = 0 ; count < appvec . size ( ) ; count ++ ) { vec . addElement ( appvec . elementAt ( count ) ) ; } } return vec ;


signature:
public class Resolver { /** * Find the URNs for a given system identifier in all catalogs .
 * @ param systemId The system ID to locate .
 * @ throws MalformedURLException
 * @ throws IOException
 * @ return A vector of URNs that map to the systemId . */
public Vector resolveAllSystemReverse ( String systemId ) throws MalformedURLException , IOException { } }

implementation:
Vector resolved = new Vector ( ) ; // If there ' s a SYSTEM entry in this catalog , use it
if ( systemId != null ) { Vector localResolved = resolveLocalSystemReverse ( systemId ) ; resolved = appendVector ( resolved , localResolved ) ; } // Otherwise , look in the subordinate catalogs
Vector subResolved = resolveAllSubordinateCatalogs ( SYSTEMREVERSE , null , null , systemId ) ; return appendVector ( resolved , subResolved ) ;


signature:
public class Resolver { /** * Find the URN for a given system identifier .
 * @ param systemId The system ID to locate .
 * @ throws MalformedURLException
 * @ throws IOException
 * @ return A ( single ) URN that maps to the systemId . */
public String resolveSystemReverse ( String systemId ) throws MalformedURLException , IOException { } }

implementation: Vector resolved = resolveAllSystemReverse ( systemId ) ; if ( resolved != null && resolved . size ( ) > 0 ) { return ( String ) resolved . elementAt ( 0 ) ; } else { return null ; }


signature:
public class Resolver { /** * Return the applicable SYSTEM system identifiers .
 * < p > If one or more SYSTEM entries exists in the Catalog
 * for the system ID specified , return the mapped values . < / p >
 * < p > The caller is responsible for doing any necessary
 * normalization of the system identifier before calling
 * this method . For example , a relative system identifier in
 * a document might be converted to an absolute system identifier
 * before attempting to resolve it . < / p >
 * < p > Note that this function will force all subordinate catalogs
 * to be loaded . < / p >
 * < p > On Windows - based operating systems , the comparison between
 * the system identifier provided and the SYSTEM entries in the
 * Catalog is case - insensitive . < / p >
 * @ param systemId The system ID to locate in the catalog .
 * @ return The system identifier to use for the notation .
 * @ throws MalformedURLException The formal system identifier of a
 * subordinate catalog cannot be turned into a valid URL .
 * @ throws IOException Error reading subordinate catalog file . */
public Vector resolveAllSystem ( String systemId ) throws MalformedURLException , IOException { } }

implementation:
Vector resolutions = new Vector ( ) ; // If there are SYSTEM entries in this catalog , start with them
if ( systemId != null ) { Vector localResolutions = resolveAllLocalSystem ( systemId ) ; resolutions = appendVector ( resolutions , localResolutions ) ; } // Then look in the subordinate catalogs
Vector subResolutions = resolveAllSubordinateCatalogs ( SYSTEM , null , null , systemId ) ; resolutions = appendVector ( resolutions , subResolutions ) ; if ( resolutions . size ( ) > 0 ) { return resolutions ; } else { return null ; }


signature:
public class Resolver { /** * Return all applicable SYSTEM system identifiers in this
 * catalog .
 * < p > If one or more SYSTEM entries exists in the catalog file
 * for the system ID specified , return the mapped values . < / p >
 * @ param systemId The system ID to locate in the catalog
 * @ return A vector of the mapped system identifiers or null */
private Vector resolveAllLocalSystem ( String systemId ) { } }

implementation: Vector map = new Vector ( ) ; String osname = System . getProperty ( "os.name" ) ; boolean windows = ( osname . indexOf ( "Windows" ) >= 0 ) ; Enumeration enumt = catalogEntries . elements ( ) ; while ( enumt . hasMoreElements ( ) ) { CatalogEntry e = ( CatalogEntry ) enumt . nextElement ( ) ; if ( e . getEntryType ( ) == SYSTEM && ( e . getEntryArg ( 0 ) . equals ( systemId ) || ( windows && e . getEntryArg ( 0 ) . equalsIgnoreCase ( systemId ) ) ) ) { map . addElement ( e . getEntryArg ( 1 ) ) ; } } if ( map . size ( ) == 0 ) { return null ; } else { return map ; }


signature:
public class Resolver { /** * Search the subordinate catalogs , in order , looking for all
 * match .
 * < p > This method searches the Catalog and returns all of the system
 * identifiers specified for the given entity type with the given
 * name , public , and system identifiers . In some contexts , these
 * may be null . < / p >
 * @ param entityType The CatalogEntry type for which this query is
 * being conducted . This is necessary in order to do the approprate
 * query on a subordinate catalog .
 * @ param entityName The name of the entity being searched for , if
 * appropriate .
 * @ param publicId The public identifier of the entity in question
 * ( as provided in the source document ) .
 * @ param systemId The nominal system identifier for the entity
 * in question ( as provided in the source document ) .
 * @ throws MalformedURLException The formal system identifier of a
 * delegated catalog cannot be turned into a valid URL .
 * @ throws IOException Error reading delegated catalog file .
 * @ return The system identifier to use .
 * Note that the nominal system identifier is not returned if a
 * match is not found in the catalog , instead null is returned
 * to indicate that no match was found . */
private synchronized Vector resolveAllSubordinateCatalogs ( int entityType , String entityName , String publicId , String systemId ) throws MalformedURLException , IOException { } }

implementation:
Vector resolutions = new Vector ( ) ; for ( int catPos = 0 ; catPos < catalogs . size ( ) ; catPos ++ ) { Resolver c = null ; try { c = ( Resolver ) catalogs . elementAt ( catPos ) ; } catch ( ClassCastException e ) { String catfile = ( String ) catalogs . elementAt ( catPos ) ; c = ( Resolver ) newCatalog ( ) ; try { c . parseCatalog ( catfile ) ; } catch ( MalformedURLException mue ) { catalogManager . debug . message ( 1 , "Malformed Catalog URL" , catfile ) ; } catch ( FileNotFoundException fnfe ) { catalogManager . debug . message ( 1 , "Failed to load catalog, file not found" , catfile ) ; } catch ( IOException ioe ) { catalogManager . debug . message ( 1 , "Failed to load catalog, I/O error" , catfile ) ; } catalogs . setElementAt ( c , catPos ) ; } String resolved = null ; // Ok , now what are we supposed to call here ?
if ( entityType == DOCTYPE ) { resolved = c . resolveDoctype ( entityName , publicId , systemId ) ; if ( resolved != null ) { // Only find one DOCTYPE resolution
resolutions . addElement ( resolved ) ; return resolutions ; } } else if ( entityType == DOCUMENT ) { resolved = c . resolveDocument ( ) ; if ( resolved != null ) { // Only find one DOCUMENT resolution
resolutions . addElement ( resolved ) ; return resolutions ; } } else if ( entityType == ENTITY ) { resolved = c . resolveEntity ( entityName , publicId , systemId ) ; if ( resolved != null ) { // Only find one ENTITY resolution
resolutions . addElement ( resolved ) ; return resolutions ; } } else if ( entityType == NOTATION ) { resolved = c . resolveNotation ( entityName , publicId , systemId ) ; if ( resolved != null ) { // Only find one NOTATION resolution
resolutions . addElement ( resolved ) ; return resolutions ; } } else if ( entityType == PUBLIC ) { resolved = c . resolvePublic ( publicId , systemId ) ; if ( resolved != null ) { // Only find one PUBLIC resolution
resolutions . addElement ( resolved ) ; return resolutions ; } } else if ( entityType == SYSTEM ) { Vector localResolutions = c . resolveAllSystem ( systemId ) ; resolutions = appendVector ( resolutions , localResolutions ) ; break ; } else if ( entityType == SYSTEMREVERSE ) { Vector localResolutions = c . resolveAllSystemReverse ( systemId ) ; resolutions = appendVector ( resolutions , localResolutions ) ; } } if ( resolutions != null ) { return resolutions ; } else { return null ; }


signature:
public class SAXCatalogReader { /** * Set the SAXCatalogParser class for the given namespace / root
 * element type .
 * @ param namespaceURI
 * @ param rootElement
 * @ param parserClass */
public void setCatalogParser ( String namespaceURI , String rootElement , String parserClass ) { } }

implementation: if ( namespaceURI == null ) { namespaceMap . put ( rootElement , parserClass ) ; } else { namespaceMap . put ( "{" + namespaceURI + "}" + rootElement , parserClass ) ; }


signature:
public class SAXCatalogReader { /** * Get the SAXCatalogParser class for the given namespace / root
 * element type .
 * @ param namespaceURI
 * @ param rootElement
 * @ return the catalog parser */
public String getCatalogParser ( String namespaceURI , String rootElement ) { } }

implementation: if ( namespaceURI == null ) { return ( String ) namespaceMap . get ( rootElement ) ; } else { return ( String ) namespaceMap . get ( "{" + namespaceURI + "}" + rootElement ) ; }


signature:
public class SAXCatalogReader { /** * Parse an XML Catalog file .
 * @ param catalog The catalog to which this catalog file belongs
 * @ param fileUrl The URL or filename of the catalog file to process
 * @ throws MalformedURLException Improper fileUrl
 * @ throws IOException Error reading catalog file */
public void readCatalog ( Catalog catalog , String fileUrl ) throws MalformedURLException , IOException , CatalogException { } }

implementation: URL url = null ; try { url = new URL ( fileUrl ) ; } catch ( MalformedURLException e ) { url = new URL ( "file:///" + fileUrl ) ; } debug = catalog . getCatalogManager ( ) . debug ; try { URLConnection urlCon = url . openConnection ( ) ; readCatalog ( catalog , urlCon . getInputStream ( ) ) ; } catch ( FileNotFoundException e ) { catalog . getCatalogManager ( ) . debug . message ( 1 , "Failed to load catalog, file not found" , url . toString ( ) ) ; }


signature:
public class SAXCatalogReader { /** * Parse an XML Catalog stream .
 * @ param catalog The catalog to which this catalog file belongs
 * @ param is The input stream from which the catalog will be read
 * @ throws MalformedURLException Improper fileUrl
 * @ throws IOException Error reading catalog file
 * @ throws CatalogException A Catalog exception */
public void readCatalog ( Catalog catalog , InputStream is ) throws IOException , CatalogException { } }

implementation:
// Create an instance of the parser
if ( parserFactory == null && parserClass == null ) { debug . message ( 1 , "Cannot read SAX catalog without a parser" ) ; throw new CatalogException ( CatalogException . UNPARSEABLE ) ; } debug = catalog . getCatalogManager ( ) . debug ; EntityResolver bResolver = catalog . getCatalogManager ( ) . getBootstrapResolver ( ) ; this . catalog = catalog ; try { if ( parserFactory != null ) { SAXParser parser = parserFactory . newSAXParser ( ) ; SAXParserHandler spHandler = new SAXParserHandler ( ) ; spHandler . setContentHandler ( this ) ; if ( bResolver != null ) { spHandler . setEntityResolver ( bResolver ) ; } parser . parse ( new InputSource ( is ) , spHandler ) ; } else { Parser parser = ( Parser ) Class . forName ( parserClass ) . newInstance ( ) ; parser . setDocumentHandler ( this ) ; if ( bResolver != null ) { parser . setEntityResolver ( bResolver ) ; } parser . parse ( new InputSource ( is ) ) ; } } catch ( ClassNotFoundException cnfe ) { throw new CatalogException ( CatalogException . UNPARSEABLE ) ; } catch ( IllegalAccessException iae ) { throw new CatalogException ( CatalogException . UNPARSEABLE ) ; } catch ( InstantiationException ie ) { throw new CatalogException ( CatalogException . UNPARSEABLE ) ; } catch ( ParserConfigurationException pce ) { throw new CatalogException ( CatalogException . UNKNOWN_FORMAT ) ; } catch ( SAXException se ) { Exception e = se . getException ( ) ; // FIXME : there must be a better way
UnknownHostException uhe = new UnknownHostException ( ) ; FileNotFoundException fnfe = new FileNotFoundException ( ) ; if ( e != null ) { if ( e . getClass ( ) == uhe . getClass ( ) ) { throw new CatalogException ( CatalogException . PARSE_FAILED , e . toString ( ) ) ; } else if ( e . getClass ( ) == fnfe . getClass ( ) ) { throw new CatalogException ( CatalogException . PARSE_FAILED , e . toString ( ) ) ; } } throw new CatalogException ( se ) ; }


signature:
public class SAXCatalogReader { /** * The SAX < code > startElement < / code > method .
 * < p > The catalog parser is selected based on the namespace of the
 * first element encountered in the catalog . < / p > */
public void startElement ( String name , AttributeList atts ) throws SAXException { } }

implementation: if ( abandonHope ) { return ; } if ( saxParser == null ) { String prefix = "" ; if ( name . indexOf ( ':' ) > 0 ) { prefix = name . substring ( 0 , name . indexOf ( ':' ) ) ; } String localName = name ; if ( localName . indexOf ( ':' ) > 0 ) { localName = localName . substring ( localName . indexOf ( ':' ) + 1 ) ; } String namespaceURI = null ; if ( prefix . equals ( "" ) ) { namespaceURI = atts . getValue ( "xmlns" ) ; } else { namespaceURI = atts . getValue ( "xmlns:" + prefix ) ; } String saxParserClass = getCatalogParser ( namespaceURI , localName ) ; if ( saxParserClass == null ) { abandonHope = true ; if ( namespaceURI == null ) { debug . message ( 2 , "No Catalog parser for " + name ) ; } else { debug . message ( 2 , "No Catalog parser for " + "{" + namespaceURI + "}" + name ) ; } return ; } try { saxParser = ( SAXCatalogParser ) Class . forName ( saxParserClass ) . newInstance ( ) ; saxParser . setCatalog ( catalog ) ; saxParser . startDocument ( ) ; saxParser . startElement ( name , atts ) ; } catch ( ClassNotFoundException cnfe ) { saxParser = null ; abandonHope = true ; debug . message ( 2 , cnfe . toString ( ) ) ; } catch ( InstantiationException ie ) { saxParser = null ; abandonHope = true ; debug . message ( 2 , ie . toString ( ) ) ; } catch ( IllegalAccessException iae ) { saxParser = null ; abandonHope = true ; debug . message ( 2 , iae . toString ( ) ) ; } catch ( ClassCastException cce ) { saxParser = null ; abandonHope = true ; debug . message ( 2 , cce . toString ( ) ) ; } } else { saxParser . startElement ( name , atts ) ; }


signature:
public class SAXCatalogReader { /** * The SAX2 < code > startElement < / code > method .
 * < p > The catalog parser is selected based on the namespace of the
 * first element encountered in the catalog . < / p > */
public void startElement ( String namespaceURI , String localName , String qName , Attributes atts ) throws SAXException { } }

implementation: if ( abandonHope ) { return ; } if ( saxParser == null ) { String saxParserClass = getCatalogParser ( namespaceURI , localName ) ; if ( saxParserClass == null ) { abandonHope = true ; if ( namespaceURI == null ) { debug . message ( 2 , "No Catalog parser for " + localName ) ; } else { debug . message ( 2 , "No Catalog parser for " + "{" + namespaceURI + "}" + localName ) ; } return ; } try { saxParser = ( SAXCatalogParser ) Class . forName ( saxParserClass ) . newInstance ( ) ; saxParser . setCatalog ( catalog ) ; saxParser . startDocument ( ) ; saxParser . startElement ( namespaceURI , localName , qName , atts ) ; } catch ( ClassNotFoundException cnfe ) { saxParser = null ; abandonHope = true ; debug . message ( 2 , cnfe . toString ( ) ) ; } catch ( InstantiationException ie ) { saxParser = null ; abandonHope = true ; debug . message ( 2 , ie . toString ( ) ) ; } catch ( IllegalAccessException iae ) { saxParser = null ; abandonHope = true ; debug . message ( 2 , iae . toString ( ) ) ; } catch ( ClassCastException cce ) { saxParser = null ; abandonHope = true ; debug . message ( 2 , cce . toString ( ) ) ; } } else { saxParser . startElement ( namespaceURI , localName , qName , atts ) ; }


signature:
public class SAXCatalogReader { /** * The SAX2 < code > endElement < / code > method . Does nothing . */
public void endElement ( String namespaceURI , String localName , String qName ) throws SAXException { } }

implementation: if ( saxParser != null ) { saxParser . endElement ( namespaceURI , localName , qName ) ; }


signature:
public class SAXCatalogReader { /** * The SAX < code > processingInstruction < / code > method . Does nothing . */
public void processingInstruction ( String target , String data ) throws SAXException { } }

implementation: if ( saxParser != null ) { saxParser . processingInstruction ( target , data ) ; }


signature:
public class SAXCatalogReader { /** * The SAX < code > startPrefixMapping < / code > method . Does nothing . */
public void startPrefixMapping ( String prefix , String uri ) throws SAXException { } }

implementation: if ( saxParser != null ) { saxParser . startPrefixMapping ( prefix , uri ) ; }


signature:
public class SAXParserHandler { /** * Entity Resolver */
public InputSource resolveEntity ( String publicId , String systemId ) throws SAXException { } }

implementation: if ( er != null ) { try { return er . resolveEntity ( publicId , systemId ) ; } catch ( IOException e ) { System . out . println ( "resolveEntity threw IOException!" ) ; return null ; } } else { return null ; }


signature:
public class Semaphore { /** * Sync implementation - - - - - */
public void acquire ( ) throws InterruptedException { } }

implementation:
synchronized ( this ) { logAcquire ( ) ; // One user more called acquire , increase users
++ m_users ; boolean waitSuccessful = false ; while ( m_allowed <= 0 ) { waitSuccessful = waitImpl ( this ) ; if ( ! waitSuccessful ) { // Dealock was detected , restore status , ' cause it ' s like a release ( )
// that will probably be never called
-- m_users ; ++ m_allowed ; } } -- m_allowed ; }


signature:
public class Semaphore { /** * Protected - - - - - */
protected boolean waitImpl ( Object lock ) throws InterruptedException { } }

implementation:
// Wait ( forever ) until notified . To discover deadlocks ,
// turn on debugging of this class
long start = System . currentTimeMillis ( ) ; lock . wait ( DEADLOCK_TIMEOUT ) ; long end = System . currentTimeMillis ( ) ; if ( ( end - start ) > ( DEADLOCK_TIMEOUT - 1000 ) ) { logDeadlock ( ) ; return false ; } return true ;


signature:
public class FileURLConnection { /** * Checks if the underlying file for this connection exists .
 * @ throws FileNotFoundException */
public void connect ( ) throws IOException { } }

implementation: if ( connected ) return ; if ( ! file . exists ( ) ) { throw new FileNotFoundException ( file . getPath ( ) ) ; } connected = true ;


signature:
public class FileURLConnection { /** * We should probably disallow this ? */
public OutputStream getOutputStream ( ) throws IOException { } }

implementation:
connect ( ) ; SecurityManager sm = System . getSecurityManager ( ) ; if ( sm != null ) { // Check for write access
FilePermission p = new FilePermission ( file . getPath ( ) , "write" ) ; sm . checkPermission ( p ) ; } return new FileOutputStream ( file ) ;


signature:
public class FileURLConnection { /** * Provides support for the following headers :
 * < tt > last - modified < / tt >
 * < tt > content - length < / tt >
 * < tt > content - type < / tt >
 * < tt > date < / tt > */
public String getHeaderField ( final String name ) { } }

implementation:
String headerField = null ; if ( name . equalsIgnoreCase ( "last-modified" ) ) { long lastModified = getLastModified ( ) ; if ( lastModified != 0 ) { // return the last modified date formatted according to RFC 1123
Date modifiedDate = new Date ( lastModified ) ; SimpleDateFormat sdf = new SimpleDateFormat ( "EEE, dd MMM yyyy HH:mm:ss 'GMT'" , Locale . US ) ; sdf . setTimeZone ( TimeZone . getTimeZone ( "GMT" ) ) ; headerField = sdf . format ( modifiedDate ) ; } } else if ( name . equalsIgnoreCase ( "content-length" ) ) { headerField = String . valueOf ( file . length ( ) ) ; } else if ( name . equalsIgnoreCase ( "content-type" ) ) { if ( file . isDirectory ( ) ) { headerField = "text/plain" ; } else { headerField = getFileNameMap ( ) . getContentTypeFor ( file . getName ( ) ) ; if ( headerField == null ) { try { InputStream is = getInputStream ( ) ; BufferedInputStream bis = new BufferedInputStream ( is ) ; headerField = URLConnection . guessContentTypeFromStream ( bis ) ; bis . close ( ) ; } catch ( IOException e ) { // ignore
} } } } else if ( name . equalsIgnoreCase ( "date" ) ) { headerField = String . valueOf ( getLastModified ( ) ) ; } else { // This always returns null currently
headerField = super . getHeaderField ( name ) ; } return headerField ;


signature:
public class Node { /** * compareAndSet next field */
boolean casNext ( Node < K , V > cmp , Node < K , V > val ) { } }

implementation: return nextUpdater . compareAndSet ( this , cmp , val ) ;


signature:
public class Node { /** * Helps out a deletion by appending marker or unlinking from
 * predecessor . This is called during traversals when value
 * field seen to be null .
 * @ param b predecessor
 * @ param f successor */
void helpDelete ( Node < K , V > b , Node < K , V > f ) { } }

implementation:
/* * Rechecking links and then doing only one of the
 * help - out stages per call tends to minimize CAS
 * interference among helping threads . */
if ( f == next && this == b . next ) { if ( f == null || f . value != f ) // not already marked
appendMarker ( f ) ; else b . casNext ( this , f . next ) ; }


signature:
public class Node { /** * Return value if this node contains a valid key - value pair ,
 * else null .
 * @ return this node ' s value if it isn ' t a marker or header or
 * is deleted , else null . */
V getValidValue ( ) { } }

implementation: Object v = value ; if ( v == this || v == BASE_HEADER ) return null ; return ( V ) v ;


signature:
public class Node { /** * Create and return a new SnapshotEntry holding current
 * mapping if this node holds a valid value , else null
 * @ return new entry or null */
SnapshotEntry < K , V > createSnapshot ( ) { } }

implementation: V v = getValidValue ( ) ; if ( v == null ) return null ; return new SnapshotEntry ( key , v ) ;


signature:
public class Index { /** * compareAndSet right field */
final boolean casRight ( Index < K , V > cmp , Index < K , V > val ) { } }

implementation: return rightUpdater . compareAndSet ( this , cmp , val ) ;


signature:
public class Index { /** * Tries to CAS right field to skip over apparent successor
 * succ . Fails ( forcing a retraversal by caller ) if this node
 * is known to be deleted .
 * @ param succ the expected current successor
 * @ return true if successful */
final boolean unlink ( Index < K , V > succ ) { } }

implementation: return ! indexesDeletedNode ( ) && casRight ( succ , succ . right ) ;


signature:
public class JBossObject { /** * Create logger .
 * @ return the logger */
private Logger createLog ( ) { } }

implementation: Class < ? > clazz = getClass ( ) ; Logger logger = loggers . get ( clazz ) ; if ( logger == null ) { logger = Logger . getLogger ( clazz ) ; loggers . put ( clazz , logger ) ; } return logger ;


signature:
public class JBossObject { /** * List the set of JBossObjects
 * @ param buffer the buffer
 * @ param objects the collection of objects */
public static void list ( JBossStringBuilder buffer , Collection objects ) { } }

implementation: if ( objects == null ) return ; buffer . append ( '[' ) ; if ( objects . isEmpty ( ) == false ) { for ( Iterator i = objects . iterator ( ) ; i . hasNext ( ) ; ) { Object object = i . next ( ) ; if ( object instanceof JBossObject ) ( ( JBossObject ) object ) . toShortString ( buffer ) ; else buffer . append ( object . toString ( ) ) ; if ( i . hasNext ( ) ) buffer . append ( ", " ) ; } } buffer . append ( ']' ) ;


signature:
public class JBossObject { /** * Get the class short name
 * @ return the short name of the class */
public String getClassShortName ( ) { } }

implementation: String longName = getClass ( ) . getName ( ) ; int dot = longName . lastIndexOf ( '.' ) ; if ( dot != - 1 ) return longName . substring ( dot + 1 ) ; return longName ;


signature:
public class JBossObject { /** * Implementation of String
 * @ return the string */
protected String toStringImplementation ( ) { } }

implementation: JBossStringBuilder buffer = new JBossStringBuilder ( ) ; buffer . append ( getClassShortName ( ) ) . append ( '@' ) ; buffer . append ( Integer . toHexString ( System . identityHashCode ( this ) ) ) ; buffer . append ( '{' ) ; toString ( buffer ) ; buffer . append ( '}' ) ; return buffer . toString ( ) ;


signature:
public class PropertyManager { /** * Get the default < tt > PropertyMap < / tt > .
 * @ return Default < tt > PropertyMap < / tt > . */
public static PropertyMap getDefaultPropertyMap ( ) { } }

implementation: SecurityManager sm = System . getSecurityManager ( ) ; if ( sm != null ) sm . checkPropertiesAccess ( ) ; return props ;


signature:
public class PropertyManager { /** * Add a property listener .
 * @ param listener Property listener to add . */
public static void addPropertyListener ( final PropertyListener listener ) { } }

implementation: SecurityManager sm = System . getSecurityManager ( ) ; if ( sm != null ) sm . checkPropertiesAccess ( ) ; props . addPropertyListener ( listener ) ;


signature:
public class PropertyManager { /** * Add an array of property listeners .
 * @ param listeners Array of property listeners to add . */
public static void addPropertyListeners ( final PropertyListener [ ] listeners ) { } }

implementation: SecurityManager sm = System . getSecurityManager ( ) ; if ( sm != null ) sm . checkPropertiesAccess ( ) ; props . addPropertyListeners ( listeners ) ;


signature:
public class PropertyManager { /** * Load properties from a map .
 * @ param prefix Prefix to append to all map keys ( or < tt > null < / tt > ) .
 * @ param map Map containing properties to load .
 * @ throws PropertyException */
public static void load ( final String prefix , final Map map ) throws PropertyException { } }

implementation: SecurityManager sm = System . getSecurityManager ( ) ; if ( sm != null ) sm . checkPropertiesAccess ( ) ; props . load ( prefix , map ) ;


signature:
public class PropertyManager { /** * Load properties from a map .
 * @ param map Map containing properties to load .
 * @ throws PropertyException
 * @ throws IOException */
public static void load ( final Map map ) throws PropertyException , IOException { } }

implementation: SecurityManager sm = System . getSecurityManager ( ) ; if ( sm != null ) sm . checkPropertiesAccess ( ) ; props . load ( map ) ;


signature:
public class PropertyManager { /** * Load properties from a < tt > PropertyReader < / tt > .
 * @ param reader < tt > PropertyReader < / tt > to read properties from .
 * @ throws PropertyException
 * @ throws IOException */
public static void load ( final PropertyReader reader ) throws PropertyException , IOException { } }

implementation: SecurityManager sm = System . getSecurityManager ( ) ; if ( sm != null ) sm . checkPropertiesAccess ( ) ; props . load ( reader ) ;


signature:
public class PropertyManager { /** * Load properties from a < tt > PropertyReader < / tt > specifed by the
 * given class name .
 * @ param classname Class name of a < tt > PropertyReader < / tt > to
 * read from .
 * @ throws PropertyException
 * @ throws IOException */
public static void load ( final String classname ) throws PropertyException , IOException { } }

implementation: SecurityManager sm = System . getSecurityManager ( ) ; if ( sm != null ) sm . checkPropertiesAccess ( ) ; props . load ( classname ) ;


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

implementation: SecurityManager sm = System . getSecurityManager ( ) ; if ( sm != null ) sm . checkPropertyAccess ( name ) ; return ( String ) props . setProperty ( name , value ) ;


signature:
public class PropertyManager { /** * Remove a property .
 * @ param name Property name .
 * @ return Removed property value or < tt > null < / tt > . */
public static String removeProperty ( final String name ) { } }

implementation: SecurityManager sm = System . getSecurityManager ( ) ; if ( sm != null ) sm . checkPropertyAccess ( name ) ; return props . removeProperty ( name ) ;


signature:
public class PropertyManager { /** * Get an array style property .
 * @ param base Base property name .
 * @ param defaultValues Default property values .
 * @ return Array of property values or default . */
public static String [ ] getArrayProperty ( final String base , final String [ ] defaultValues ) { } }

implementation: SecurityManager sm = System . getSecurityManager ( ) ; if ( sm != null ) sm . checkPropertiesAccess ( ) ; return props . getArrayProperty ( base , defaultValues ) ;


signature:
public class PropertyManager { /** * Return an iterator over all contained property names .
 * @ return Property name iterator . */
public static Iterator names ( ) { } }

implementation: SecurityManager sm = System . getSecurityManager ( ) ; if ( sm != null ) sm . checkPropertiesAccess ( ) ; return props . names ( ) ;


signature:
public class PropertyManager { /** * Get a property group for the given property base .
 * @ param basename Base property name .
 * @ return Property group . */
public static PropertyGroup getPropertyGroup ( final String basename ) { } }

implementation: SecurityManager sm = System . getSecurityManager ( ) ; if ( sm != null ) sm . checkPropertiesAccess ( ) ; return props . getPropertyGroup ( basename ) ;


signature:
public class Objects { /** * Get a compatible constructor for the given value type
 * @ param type Class to look for constructor in
 * @ param valueType Argument type for constructor
 * @ return Constructor or null */
public static Constructor getCompatibleConstructor ( final Class type , final Class valueType ) { } }

implementation:
// first try and find a constructor with the exact argument type
try { return type . getConstructor ( new Class [ ] { valueType } ) ; } catch ( Exception ignore ) { // if the above failed , then try and find a constructor with
// an compatible argument type
// get an array of compatible types
Class [ ] types = type . getClasses ( ) ; for ( int i = 0 ; i < types . length ; i ++ ) { try { return type . getConstructor ( new Class [ ] { types [ i ] } ) ; } catch ( Exception ignore2 ) { } } } // if we get this far , then we can ' t find a compatible constructor
return null ;


signature:
public class Objects { /** * Copy an serializable object deeply .
 * @ param obj Object to copy .
 * @ return Copied object .
 * @ throws IOException
 * @ throws ClassNotFoundException */
public static Object copy ( final Serializable obj ) throws IOException , ClassNotFoundException { } }

implementation:
ObjectOutputStream out = null ; ObjectInputStream in = null ; Object copy = null ; try { // write the object
ByteArrayOutputStream baos = new ByteArrayOutputStream ( ) ; out = new ObjectOutputStream ( baos ) ; out . writeObject ( obj ) ; out . flush ( ) ; // read in the copy
byte data [ ] = baos . toByteArray ( ) ; ByteArrayInputStream bais = new ByteArrayInputStream ( data ) ; in = new ObjectInputStream ( bais ) ; copy = in . readObject ( ) ; } finally { Streams . close ( out ) ; Streams . close ( in ) ; } return copy ;


signature:
public class Objects { /** * Dereference the given object if it is < i > non - null < / i > and is an
 * instance of < code > Reference < / code > . If the object is < i > null < / i >
 * then < i > null < / i > is returned . If the object is not an instance of
 * < code > Reference < / code > , then the object is returned .
 * @ param obj Object to dereference .
 * @ return Dereferenced object . */
@ SuppressWarnings ( "unchecked" ) public static Object deref ( final Object obj ) { } }

implementation: if ( obj != null && obj instanceof Reference ) { Reference ref = ( Reference ) obj ; return ref . get ( ) ; } return obj ;


signature:
public class Objects { /** * Dereference an object
 * @ param < T > the expected type
 * @ param obj the object or reference
 * @ param expected the expected type
 * @ return the object or null */
public static < T > T deref ( final Object obj , Class < T > expected ) { } }

implementation: Object result = deref ( obj ) ; if ( result == null ) return null ; return expected . cast ( result ) ;


signature:
public class Objects { /** * @ return an Object array for the given object .
 * @ param obj Object to convert to an array . Converts primitive
 * arrays to Object arrays consisting of their wrapper
 * classes . If the object is not an array ( object or primitve )
 * then a new array of the given type is created and the
 * object is set as the sole element . */
public static Object [ ] toArray ( final Object obj ) { } }

implementation:
// if the object is an array , the cast and return it .
if ( obj instanceof Object [ ] ) { return ( Object [ ] ) obj ; } // if the object is an array of primitives then wrap the array
Class type = obj . getClass ( ) ; Object array ; if ( type . isArray ( ) ) { int length = Array . getLength ( obj ) ; Class componentType = type . getComponentType ( ) ; array = Array . newInstance ( componentType , length ) ; for ( int i = 0 ; i < length ; i ++ ) { Array . set ( array , i , Array . get ( obj , i ) ) ; } } else { array = Array . newInstance ( type , 1 ) ; Array . set ( array , 0 , obj ) ; } return ( Object [ ] ) array ;


signature:
public class PropertyMap { /** * Initialized listener lists and the JNDI properties cache map */
private void init ( ) { } }

implementation: unboundListeners = Collections . synchronizedList ( new ArrayList ( ) ) ; boundListeners = Collections . synchronizedMap ( new HashMap ( ) ) ; jndiMap = new HashMap ( ) ; PrivilegedAction action = new PrivilegedAction ( ) { public Object run ( ) { Object value = System . getProperty ( Context . PROVIDER_URL ) ; if ( value == null ) value = NULL_VALUE ; jndiMap . put ( Context . PROVIDER_URL , value ) ; value = System . getProperty ( Context . INITIAL_CONTEXT_FACTORY ) ; if ( value == null ) value = NULL_VALUE ; jndiMap . put ( Context . INITIAL_CONTEXT_FACTORY , value ) ; value = System . getProperty ( Context . OBJECT_FACTORIES ) ; if ( value == null ) value = NULL_VALUE ; jndiMap . put ( Context . OBJECT_FACTORIES , value ) ; value = System . getProperty ( Context . URL_PKG_PREFIXES ) ; if ( value == null ) value = NULL_VALUE ; jndiMap . put ( Context . URL_PKG_PREFIXES , value ) ; value = System . getProperty ( Context . STATE_FACTORIES ) ; if ( value == null ) value = NULL_VALUE ; jndiMap . put ( Context . STATE_FACTORIES , value ) ; value = System . getProperty ( Context . DNS_URL ) ; if ( value == null ) value = NULL_VALUE ; jndiMap . put ( Context . DNS_URL , value ) ; value = System . getProperty ( LdapContext . CONTROL_FACTORIES ) ; if ( value == null ) value = NULL_VALUE ; jndiMap . put ( LdapContext . CONTROL_FACTORIES , value ) ; return null ; } } ; AccessController . doPrivileged ( action ) ;


signature:
public class PropertyMap { /** * Called by setProperty to update the jndiMap cache values .
 * @ param name the property name
 * @ param value the property value */
private void updateJndiCache ( String name , String value ) { } }

implementation: if ( name == null ) return ; boolean isJndiProperty = name . equals ( Context . PROVIDER_URL ) || name . equals ( Context . INITIAL_CONTEXT_FACTORY ) || name . equals ( Context . OBJECT_FACTORIES ) || name . equals ( Context . URL_PKG_PREFIXES ) || name . equals ( Context . STATE_FACTORIES ) || name . equals ( Context . DNS_URL ) || name . equals ( LdapContext . CONTROL_FACTORIES ) ; if ( isJndiProperty == true ) jndiMap . put ( name , value ) ;


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

implementation:
if ( name == null ) throw new NullArgumentException ( "name" ) ; // value can be null
// check if this is a new addition or not prior to updating the hash
boolean add = ! containsKey ( name ) ; Object prev = super . put ( name , value ) ; PropertyEvent event = new PropertyEvent ( this , name . toString ( ) , value . toString ( ) ) ; // fire propertyAdded or propertyChanged
if ( add ) { firePropertyAdded ( event ) ; } else { firePropertyChanged ( event ) ; } return prev ;


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

implementation:
if ( name == null ) throw new NullArgumentException ( "name" ) ; // check if there is a property with this name
boolean contains = containsKey ( name ) ; Object value = null ; if ( contains ) { value = super . remove ( name ) ; if ( defaults != null ) { Object obj = defaults . remove ( name ) ; if ( value == null ) { value = obj ; } } // Remove any JNDI property value
jndiMap . remove ( name ) ; PropertyEvent event = new PropertyEvent ( this , name . toString ( ) , value . toString ( ) ) ; firePropertyRemoved ( event ) ; } return value ;


signature:
public class PropertyMap { /** * Returns a set of keys for all entries in this group and optionally
 * all of the keys in the defaults map .
 * @ param includeDefaults
 * @ return the key set */
public Set keySet ( final boolean includeDefaults ) { } }

implementation: if ( includeDefaults ) { Set set = new HashSet ( ) ; set . addAll ( defaults . keySet ( ) ) ; set . addAll ( super . keySet ( ) ) ; return Collections . synchronizedSet ( set ) ; } return super . keySet ( ) ;


signature:
public class PropertyMap { /** * Returns a set of entrys for all entries in this group and optionally
 * all of the entrys in the defaults map .
 * @ param includeDefaults
 * @ return the entry set */
public Set entrySet ( final boolean includeDefaults ) { } }

implementation: if ( includeDefaults ) { Set set = new HashSet ( ) ; set . addAll ( defaults . entrySet ( ) ) ; set . addAll ( super . entrySet ( ) ) ; return Collections . synchronizedSet ( set ) ; } return super . entrySet ( ) ;


signature:
public class PropertyMap { /** * Add a property listener .
 * @ param listener Property listener to add . */
public void addPropertyListener ( PropertyListener listener ) { } }

implementation:
if ( listener == null ) throw new NullArgumentException ( "listener" ) ; if ( listener instanceof BoundPropertyListener ) { addPropertyListener ( ( BoundPropertyListener ) listener ) ; } else { // only add the listener if it is not in the list already
if ( ! unboundListeners . contains ( listener ) ) unboundListeners . add ( listener ) ; }


signature:
public class PropertyMap { /** * Add an array of property listeners .
 * @ param listeners Array of property listeners to add . */
public void addPropertyListeners ( PropertyListener [ ] listeners ) { } }

implementation: if ( listeners == null ) throw new NullArgumentException ( "listeners" ) ; for ( int i = 0 ; i < listeners . length ; i ++ ) { addPropertyListener ( listeners [ i ] ) ; }


signature:
public class PropertyMap { /** * Remove a property listener .
 * @ param listener Property listener to remove .
 * @ return True if listener was removed . */
public boolean removePropertyListener ( PropertyListener listener ) { } }

implementation: if ( listener == null ) throw new NullArgumentException ( "listener" ) ; boolean removed = false ; if ( listener instanceof BoundPropertyListener ) { removed = removePropertyListener ( ( BoundPropertyListener ) listener ) ; } else { removed = unboundListeners . remove ( listener ) ; } return removed ;


signature:
public class PropertyMap { /** * Fire a property added event to the given list of listeners .
 * @ param list Listener list .
 * @ param event Property event . */
private void firePropertyAdded ( List list , PropertyEvent event ) { } }

implementation: if ( list == null ) return ; int size = list . size ( ) ; for ( int i = 0 ; i < size ; i ++ ) { PropertyListener listener = ( PropertyListener ) list . get ( i ) ; listener . propertyAdded ( event ) ; }


signature:
public class PropertyMap { /** * Fire a property removed event to the given list of listeners .
 * @ param list Listener list .
 * @ param event Property event . */
private void firePropertyRemoved ( List list , PropertyEvent event ) { } }

implementation: if ( list == null ) return ; int size = list . size ( ) ; for ( int i = 0 ; i < size ; i ++ ) { PropertyListener listener = ( PropertyListener ) list . get ( i ) ; listener . propertyRemoved ( event ) ; }


signature:
public class PropertyMap { /** * Fire a property changed event to the given list of listeners .
 * @ param list Listener list .
 * @ param event Property event . */
private void firePropertyChanged ( List list , PropertyEvent event ) { } }

implementation: if ( list == null ) return ; int size = list . size ( ) ; for ( int i = 0 ; i < size ; i ++ ) { PropertyListener listener = ( PropertyListener ) list . get ( i ) ; listener . propertyChanged ( event ) ; }


signature:
public class PropertyMap { /** * Fire a property changed event to all listeners .
 * @ param event Property event . */
protected void firePropertyChanged ( PropertyEvent event ) { } }

implementation:
// fire all bound listeners ( if any ) first
if ( boundListeners != null ) { List list = ( List ) boundListeners . get ( event . getPropertyName ( ) ) ; if ( list != null ) { firePropertyChanged ( list , event ) ; } } // next fire all unbound listeners
firePropertyChanged ( unboundListeners , event ) ;


signature:
public class PropertyMap { /** * Make a optionaly prefixed property name .
 * @ param base Base property name .
 * @ param prefix Optional prefix ( can be null ) .
 * @ return Property name . */
protected String makePrefixedPropertyName ( String base , String prefix ) { } }

implementation: String name = base ; if ( prefix != null ) { StringBuffer buff = new StringBuffer ( base ) ; if ( prefix != null ) { buff . insert ( 0 , PROPERTY_NAME_SEPARATOR ) ; buff . insert ( 0 , prefix ) ; } return buff . toString ( ) ; } return name ;


signature:
public class PropertyMap { /** * Load properties from a map .
 * @ param prefix Prefix to append to all map keys ( or null ) .
 * @ param map Map containing properties to load .
 * @ throws PropertyException */
public void load ( String prefix , Map map ) throws PropertyException { } }

implementation:
// prefix can be null
if ( map == null ) throw new NullArgumentException ( "map" ) ; // set properties for each key in map
Iterator iter = map . keySet ( ) . iterator ( ) ; while ( iter . hasNext ( ) ) { // make a string key with optional prefix
String key = String . valueOf ( iter . next ( ) ) ; String name = makePrefixedPropertyName ( key , prefix ) ; String value = String . valueOf ( map . get ( name ) ) ; // set the property
setProperty ( name , value ) ; }


signature:
public class PropertyMap { /** * Load properties from a PropertyReader .
 * @ param reader PropertyReader to read properties from .
 * @ throws PropertyException
 * @ throws IOException */
public void load ( PropertyReader reader ) throws PropertyException , IOException { } }

implementation: if ( reader == null ) throw new NullArgumentException ( "reader" ) ; load ( reader . readProperties ( ) ) ;


signature:
public class PropertyMap { /** * Load properties from a PropertyReader specifed by the given class name .
 * @ param className Class name of a PropertyReader to read from .
 * @ throws PropertyException
 * @ throws IOException */
public void load ( String className ) throws PropertyException , IOException { } }

implementation:
if ( className == null ) throw new NullArgumentException ( "className" ) ; PropertyReader reader = null ; try { Class type = Class . forName ( className ) ; reader = ( PropertyReader ) type . newInstance ( ) ; } catch ( Exception e ) { throw new PropertyException ( e ) ; } // load the properties from the source
load ( reader ) ;


signature:
public class PropertyMap { /** * Set a property .
 * < p > Returns Object instead of String due to limitations with
 * < code > java . util . Properties < / code > .
 * @ param name Property name .
 * @ param value Property value .
 * @ return Previous property value or null . */
public synchronized Object setProperty ( String name , String value ) { } }

implementation: updateJndiCache ( name , value ) ; return put ( name , value ) ;


signature:
public class PropertyMap { /** * Get an array style property .
 * < p > Array properties are specified as :
 * < code > base _ property _ name . < b > INDEX < / b > .
 * < p > Indexes begin with zero and must be contiguous . A break in
 * continuity signals the end of the array .
 * @ param base Base property name .
 * @ param defaultValues Default property values .
 * @ return Array of property values or default . */
public String [ ] getArrayProperty ( String base , String [ ] defaultValues ) { } }

implementation:
if ( base == null ) throw new NullArgumentException ( "base" ) ; // create a new list to store indexed values into
List list = new LinkedList ( ) ; int i = 0 ; while ( true ) { // make the index property name
String name = makeIndexPropertyName ( base , i ) ; // see if there is a value for this property
String value = getProperty ( name ) ; if ( value != null ) { list . add ( value ) ; } else if ( i >= 0 ) { break ; // no more index properties
} i ++ ; } String values [ ] = defaultValues ; // if the list is not empty , then return it as an array
if ( list . size ( ) != 0 ) { values = ( String [ ] ) list . toArray ( new String [ list . size ( ) ] ) ; } return values ;


signature:
public class PropertyMap { /** * Get a property group for the given property base at the given index .
 * @ param basename Base property name .
 * @ param index Array property index .
 * @ return Property group . */
public PropertyGroup getPropertyGroup ( String basename , int index ) { } }

implementation: String name = makeIndexPropertyName ( basename , index ) ; return getPropertyGroup ( name ) ;


signature:
public class JBossEntityResolver { /** * Register the mapping from the public id / system id to the dtd / xsd file
 * name . This overwrites any existing mapping .
 * @ param id the DOCTYPE public id or system id such as
 * " - / / Sun Microsystems , Inc . / / DTD Enterprise JavaBeans 1.1 / / EN "
 * @ param dtdOrSchema the simple dtd / xsd file name , " ejb - jar . dtd " */
public synchronized void registerLocalEntity ( String id , String dtdOrSchema ) { } }

implementation: if ( localEntities == null ) localEntities = new ConcurrentHashMap ( ) ; localEntities . put ( id , dtdOrSchema ) ;


signature:
public class JBossEntityResolver { /** * Returns DTD / Schema inputSource . The resolution logic is :
 * 1 . Check the publicId against the current registered values in the class
 * mapping of entity name to dtd / schema file name . If found , the resulting
 * file name is passed to the loadClasspathResource to locate the file as a
 * classpath resource .
 * 2 . Check the systemId against the current registered values in the class
 * mapping of entity name to dtd / schema file name . If found , the resulting
 * file name is passed to the loadClasspathResource to locate the file as a
 * classpath resource .
 * 3 . Strip the systemId name down to the simple file name by removing an URL
 * style path elements ( myschemas / x . dtd becomes x . dtd ) , and call
 * loadClasspathResource to locate the simple file name as a classpath resource .
 * 4 . Attempt to resolve the systemId as a URL from which the schema can be
 * read . If the URL input stream can be opened this returned as the resolved
 * input .
 * @ 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 */
public InputSource resolveEntity ( String publicId , String systemId ) throws SAXException , IOException { } }

implementation:
entityResolved . set ( Boolean . FALSE ) ; // nothing to resolve
if ( publicId == null && systemId == null ) return null ; boolean trace = log . isTraceEnabled ( ) ; boolean resolvePublicIdFirst = true ; if ( publicId != null && systemId != null ) { String registeredSystemId = null ; if ( localEntities != null ) registeredSystemId = ( String ) localEntities . get ( publicId ) ; if ( registeredSystemId == null ) registeredSystemId = ( String ) entities . get ( publicId ) ; if ( registeredSystemId != null && ! registeredSystemId . equals ( systemId ) ) { resolvePublicIdFirst = false ; if ( trace ) log . trace ( "systemId argument '" + systemId + "' for publicId '" + publicId + "' is different from the registered systemId '" + registeredSystemId + "', resolution will be based on the argument" ) ; } } InputSource inputSource = null ; if ( resolvePublicIdFirst ) { // Look for a registered publicID
inputSource = resolvePublicID ( publicId , trace ) ; } if ( inputSource == null ) { // Try to resolve the systemID from the registry
inputSource = resolveSystemID ( systemId , trace ) ; } if ( inputSource == null ) { // Try to resolve the systemID as a classpath reference under dtd or schema
inputSource = resolveClasspathName ( systemId , trace ) ; } if ( inputSource == null ) { // Try to resolve the systemID as a absolute URL
inputSource = resolveSystemIDasURL ( systemId , trace ) ; } entityResolved . set ( new Boolean ( inputSource != null ) ) ; if ( inputSource == null ) log . debug ( "Cannot resolve [publicID=" + publicId + ",systemID=" + systemId + "]" ) ; return inputSource ;


signature:
public class JBossEntityResolver { /** * Returns the boolean value to inform id DTD was found in the XML file or not
 * @ return boolean - true if DTD was found in XML */
public boolean isEntityResolved ( ) { } }

implementation: Boolean value = entityResolved . get ( ) ; return value != null ? value . booleanValue ( ) : false ;


signature:
public class JBossEntityResolver { /** * Load the schema from the class entity to schema file mapping .
 * @ see # registerEntity ( String , String )
 * @ param publicId - the public entity name of the schema
 * @ param trace - trace level logging flag
 * @ return the InputSource for the schema file found on the classpath , null
 * if the publicId is not registered or found . */
protected InputSource resolvePublicID ( String publicId , boolean trace ) { } }

implementation:
if ( publicId == null ) return null ; if ( trace ) log . trace ( "resolvePublicID, publicId=" + publicId ) ; InputSource inputSource = null ; String filename = null ; if ( localEntities != null ) filename = ( String ) localEntities . get ( publicId ) ; if ( filename == null ) filename = ( String ) entities . get ( publicId ) ; if ( filename != null ) { if ( trace ) log . trace ( "Found entity from publicId=" + publicId + " fileName=" + filename ) ; InputStream ins = loadClasspathResource ( filename , trace ) ; if ( ins != null ) { inputSource = new InputSource ( ins ) ; inputSource . setPublicId ( publicId ) ; } else { log . trace ( "Cannot load publicId from classpath resource: " + filename ) ; // Try the file name as a URI
inputSource = resolveSystemIDasURL ( filename , trace ) ; if ( inputSource == null ) log . warn ( "Cannot load publicId from resource: " + filename ) ; } } return inputSource ;


signature:
public class JBossEntityResolver { /** * Attempt to use the systemId as a URL from which the schema can be read . This
 * checks to see whether the systemId is a key to an entry in the class
 * entity map .
 * @ param systemId - the systemId
 * @ param trace - trace level logging flag
 * @ return the URL InputSource if the URL input stream can be opened , null
 * if the systemId is not a URL or could not be opened . */
protected InputSource resolveSystemID ( String systemId , boolean trace ) { } }

implementation:
if ( systemId == null ) return null ; if ( trace ) log . trace ( "resolveSystemID, systemId=" + systemId ) ; InputSource inputSource = null ; // Try to resolve the systemId as an entity key
String filename = null ; if ( localEntities != null ) filename = ( String ) localEntities . get ( systemId ) ; if ( filename == null ) filename = ( String ) entities . get ( systemId ) ; if ( filename != null ) { if ( trace ) log . trace ( "Found entity systemId=" + systemId + " fileName=" + filename ) ; InputStream ins = loadClasspathResource ( filename , trace ) ; if ( ins != null ) { inputSource = new InputSource ( ins ) ; inputSource . setSystemId ( systemId ) ; } else { log . warn ( "Cannot load systemId from resource: " + filename ) ; } } return inputSource ;


signature:
public class JBossEntityResolver { /** * Attempt to use the systemId as a URL from which the schema can be read . This
 * uses the systemID as a URL .
 * @ param systemId - the systemId
 * @ param trace - trace level logging flag
 * @ return the URL InputSource if the URL input stream can be opened , null
 * if the systemId is not a URL or could not be opened . */
protected InputSource resolveSystemIDasURL ( String systemId , boolean trace ) { } }

implementation:
if ( systemId == null ) return null ; if ( trace ) log . trace ( "resolveSystemIDasURL, systemId=" + systemId ) ; InputSource inputSource = null ; // Try to use the systemId as a URL to the schema
try { if ( trace ) log . trace ( "Trying to resolve systemId as a URL" ) ; // Replace any system property refs if isReplaceSystemProperties is true
if ( isReplaceSystemProperties ( ) ) systemId = StringPropertyReplacer . replaceProperties ( systemId ) ; URL url = new URL ( systemId ) ; if ( warnOnNonFileURLs && url . getProtocol ( ) . equalsIgnoreCase ( "file" ) == false && url . getProtocol ( ) . equalsIgnoreCase ( "vfszip" ) == false ) { log . warn ( "Trying to resolve systemId as a non-file URL: " + systemId ) ; } InputStream ins = url . openStream ( ) ; if ( ins != null ) { inputSource = new InputSource ( ins ) ; inputSource . setSystemId ( systemId ) ; } else { log . warn ( "Cannot load systemId as URL: " + systemId ) ; } if ( trace ) log . trace ( "Resolved systemId as a URL" ) ; } catch ( MalformedURLException ignored ) { if ( trace ) log . trace ( "SystemId is not a url: " + systemId , ignored ) ; } catch ( IOException e ) { if ( trace ) log . trace ( "Failed to obtain URL.InputStream from systemId: " + systemId , e ) ; } return inputSource ;


signature:
public class JBossEntityResolver { /** * Resolve the systemId as a classpath resource . If not found , the
 * systemId is simply used as a classpath resource name .
 * @ param systemId - the system ID of DTD or Schema
 * @ param trace - trace level logging flag
 * @ return the InputSource for the schema file found on the classpath , null
 * if the systemId is not registered or found . */
protected InputSource resolveClasspathName ( String systemId , boolean trace ) { } }

implementation:
if ( systemId == null ) return null ; if ( trace ) log . trace ( "resolveClasspathName, systemId=" + systemId ) ; String filename = systemId ; // Parse the systemId as a uri to get the final path component
try { URI url = new URI ( systemId ) ; String path = url . getPath ( ) ; if ( path == null ) path = url . getSchemeSpecificPart ( ) ; int slash = path . lastIndexOf ( '/' ) ; if ( slash >= 0 ) filename = path . substring ( slash + 1 ) ; else filename = path ; if ( filename . length ( ) == 0 ) return null ; if ( trace ) log . trace ( "Mapped systemId to filename: " + filename ) ; } catch ( URISyntaxException e ) { if ( trace ) log . trace ( "systemId: is not a URI, using systemId as resource" , e ) ; } // Resolve the filename as a classpath resource
InputStream is = loadClasspathResource ( filename , trace ) ; InputSource inputSource = null ; if ( is != null ) { inputSource = new InputSource ( is ) ; inputSource . setSystemId ( systemId ) ; } return inputSource ;


signature:
public class JBossEntityResolver { /** * Look for the resource name on the thread context loader resource path . This
 * first simply tries the resource name as is , and if not found , the resource
 * is prepended with either " dtd / " or " schema / " depending on whether the
 * resource ends in " . dtd " or " . xsd " .
 * @ param resource - the classpath resource name of the schema
 * @ param trace - trace level logging flag
 * @ return the resource InputStream if found , null if not found . */
protected InputStream loadClasspathResource ( String resource , boolean trace ) { } }

implementation:
ClassLoader loader = Thread . currentThread ( ) . getContextClassLoader ( ) ; URL url = loader . getResource ( resource ) ; if ( url == null ) { /* Prefix the simple filename with the schema type patch as this is the
 naming convention for the jboss bundled schemas . */
if ( resource . endsWith ( ".dtd" ) ) resource = "dtd/" + resource ; else if ( resource . endsWith ( ".xsd" ) ) resource = "schema/" + resource ; url = loader . getResource ( resource ) ; } InputStream inputStream = null ; if ( url != null ) { if ( trace ) log . trace ( resource + " maps to URL: " + url ) ; try { inputStream = url . openStream ( ) ; } catch ( IOException e ) { log . debug ( "Failed to open url stream" , e ) ; } } return inputStream ;


signature:
public class ElementEditor { /** * Sets as an Element created by a String . */
public void setAsText ( String text ) { } }

implementation: Document d = getAsDocument ( text ) ; setValue ( d . getDocumentElement ( ) ) ;


signature:
public class PublicId { /** * Normalize a public identifier .
 * < p > Public identifiers must be normalized according to the following
 * rules before comparisons between them can be made : < / p >
 * < ul >
 * < li > Whitespace characters are normalized to spaces ( e . g . , line feeds ,
 * tabs , etc . become spaces ) . < / li >
 * < li > Leading and trailing whitespace is removed . < / li >
 * < li > Multiple internal whitespaces are normalized to a single
 * space . < / li >
 * < / ul >
 * < p > This method is declared static so that other classes
 * can use it directly . < / p >
 * @ param publicId The unnormalized public identifier .
 * @ return The normalized identifier . */
public static String normalize ( String publicId ) { } }

implementation: String normal = publicId . replace ( '\t' , ' ' ) ; normal = normal . replace ( '\r' , ' ' ) ; normal = normal . replace ( '\n' , ' ' ) ; normal = normal . trim ( ) ; int pos ; while ( ( pos = normal . indexOf ( "  " ) ) >= 0 ) { normal = normal . substring ( 0 , pos ) + normal . substring ( pos + 1 ) ; } return normal ;


signature:
public class PublicId { /** * Encode a public identifier as a " publicid " URN .
 * < p > This method is declared static so that other classes
 * can use it directly . < / p >
 * @ param publicId The unnormalized public identifier .
 * @ return The normalized identifier . */
public static String encodeURN ( String publicId ) { } }

implementation: String urn = PublicId . normalize ( publicId ) ; urn = PublicId . stringReplace ( urn , "%" , "%25" ) ; urn = PublicId . stringReplace ( urn , ";" , "%3B" ) ; urn = PublicId . stringReplace ( urn , "'" , "%27" ) ; urn = PublicId . stringReplace ( urn , "?" , "%3F" ) ; urn = PublicId . stringReplace ( urn , "#" , "%23" ) ; urn = PublicId . stringReplace ( urn , "+" , "%2B" ) ; urn = PublicId . stringReplace ( urn , " " , "+" ) ; urn = PublicId . stringReplace ( urn , "::" , ";" ) ; urn = PublicId . stringReplace ( urn , ":" , "%3A" ) ; urn = PublicId . stringReplace ( urn , "//" , ":" ) ; urn = PublicId . stringReplace ( urn , "/" , "%2F" ) ; return "urn:publicid:" + urn ;


signature:
public class PublicId { /** * Decode a " publicid " URN into a public identifier .
 * < p > This method is declared static so that other classes
 * can use it directly . < / p >
 * @ param urn The unnormalized public identifier .
 * @ return The normalized identifier . */
public static String decodeURN ( String urn ) { } }

implementation: String publicId = "" ; if ( urn . startsWith ( "urn:publicid:" ) ) { publicId = urn . substring ( 13 ) ; } else { return urn ; } publicId = PublicId . stringReplace ( publicId , "%2F" , "/" ) ; publicId = PublicId . stringReplace ( publicId , ":" , "//" ) ; publicId = PublicId . stringReplace ( publicId , "%3A" , ":" ) ; publicId = PublicId . stringReplace ( publicId , ";" , "::" ) ; publicId = PublicId . stringReplace ( publicId , "+" , " " ) ; publicId = PublicId . stringReplace ( publicId , "%2B" , "+" ) ; publicId = PublicId . stringReplace ( publicId , "%23" , "#" ) ; publicId = PublicId . stringReplace ( publicId , "%3F" , "?" ) ; publicId = PublicId . stringReplace ( publicId , "%27" , "'" ) ; publicId = PublicId . stringReplace ( publicId , "%3B" , ";" ) ; publicId = PublicId . stringReplace ( publicId , "%25" , "%" ) ; return publicId ;


signature:
public class PublicId { /** * Replace one string with another . */
private static String stringReplace ( String str , String oldStr , String newStr ) { } }

implementation:
String result = "" ; int pos = str . indexOf ( oldStr ) ; // System . out . println ( str + " : " + oldStr + " = > " + newStr ) ;
while ( pos >= 0 ) { // System . out . println ( str + " ( " + pos + " ) " ) ;
result += str . substring ( 0 , pos ) ; result += newStr ; str = str . substring ( pos + 1 ) ; pos = str . indexOf ( oldStr ) ; } return result + str ;


signature:
public class StopWatch { /** * Start the watch .
 * @ param reset True to reset the watch prior to starting . */
public void start ( final boolean reset ) { } }

implementation: if ( ! running ) { if ( reset ) reset ( ) ; start = System . currentTimeMillis ( ) ; running = true ; }


signature:
public class StopWatch { /** * Stop the watch .
 * @ return Elapsed time or 0 if the watch was never started . */
public long stop ( ) { } }

implementation: long lap = 0 ; if ( running ) { count ++ ; stop = System . currentTimeMillis ( ) ; lap = stop - start ; total += lap ; running = false ; } return lap ;


signature:
public class HashCode { /** * Compares this object with the specified object for order .
 * @ param obj Value to compare with .
 * @ return A negative integer , zero , or a positive integer as
 * this object is less than , equal to , or greater than
 * the specified object .
 * @ throws ClassCastException Object is not a < tt > HashCode < / tt > . */
public int compareTo ( final Object obj ) throws ClassCastException { } }

implementation: HashCode hashCode = ( HashCode ) obj ; return compareTo ( hashCode . value ) ;


signature:
public class HashCode { /** * Generate a hash code for a byte array .
 * @ param bytes An array of bytes to generate a hash code from .
 * @ return Hash code . */
public static int generate ( final byte [ ] bytes ) { } }

implementation: int hashcode = 0 ; for ( int i = 0 ; i < bytes . length ; i ++ ) { hashcode <<= 1 ; hashcode ^= bytes [ i ] ; } return hashcode ;


signature:
public class HashCode { /** * Generate a hash code for an object array .
 * < p > Does not handle nested primitive array elements .
 * @ param array Array to generate hashcode for .
 * @ param deep True to traverse elements which are arrays to
 * determine the elements hash code .
 * @ return Hash code . */
public static int generate ( final Object array [ ] , final boolean deep ) { } }

implementation: int hashcode = 0 ; for ( int i = 0 ; i < array . length ; i ++ ) { if ( deep && ( array [ i ] instanceof Object [ ] ) ) { hashcode ^= generate ( ( Object [ ] ) array [ i ] , true ) ; } else { hashcode ^= array [ i ] . hashCode ( ) ; } } return hashcode ;


signature:
public class LRUCachePolicy { /** * Initializes the cache , creating all required objects and initializing their
 * values .
 * @ see # start
 * @ see # destroy */
public void create ( ) { } }

implementation: m_map = createMap ( ) ; m_list = createList ( ) ; m_list . m_maxCapacity = m_maxCapacity ; m_list . m_minCapacity = m_minCapacity ; m_list . m_capacity = m_maxCapacity ;


signature:
public class FieldBoundPropertyListener { /** * Coerce and set specified value to field .
 * @ param value Field value .
 * @ throws PropertyException Failed to set field value . */
protected void setFieldValue ( String value ) { } }

implementation:
try { // filter property value
value = filterValue ( value ) ; // coerce value to field type
Class < ? > type = fieldInstance . getField ( ) . getType ( ) ; PropertyEditor editor = PropertyEditors . findEditor ( type ) ; editor . setAsText ( value ) ; Object coerced = editor . getValue ( ) ; // bind value to field
fieldInstance . set ( coerced ) ; } catch ( IllegalAccessException e ) { throw new PropertyException ( e ) ; }


signature:
public class FieldBoundPropertyListener { /** * 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 ) ) { setFieldValue ( map . getProperty ( propertyName ) ) ; }


signature:
public class TextCatalogReader { /** * Start parsing a text catalog file . The file is
 * actually read and parsed
 * as needed by < code > nextEntry < / code > . < / p >
 * @ param fileUrl The URL or filename of the catalog file to process
 * @ throws MalformedURLException Improper fileUrl
 * @ throws IOException Error reading catalog file */
public void readCatalog ( Catalog catalog , String fileUrl ) throws MalformedURLException , IOException { } }

implementation: URL catURL = null ; try { catURL = new URL ( fileUrl ) ; } catch ( MalformedURLException e ) { catURL = new URL ( "file:///" + fileUrl ) ; } URLConnection urlCon = catURL . openConnection ( ) ; try { readCatalog ( catalog , urlCon . getInputStream ( ) ) ; } catch ( FileNotFoundException e ) { catalog . getCatalogManager ( ) . debug . message ( 1 , "Failed to load catalog, file not found" , catURL . toString ( ) ) ; }


signature:
public class TextCatalogReader { /** * Return the next token in the catalog file .
 * @ return The Catalog file token from the input stream .
 * @ throws IOException If an error occurs reading from the stream . */
protected String nextToken ( ) throws IOException { } }

implementation:
String token = "" ; int ch , nextch ; if ( ! tokenStack . empty ( ) ) { return ( String ) tokenStack . pop ( ) ; } // Skip over leading whitespace and comments
while ( true ) { // skip leading whitespace
ch = catfile . read ( ) ; while ( ch <= ' ' ) { // all ctrls are whitespace
ch = catfile . read ( ) ; if ( ch < 0 ) { return null ; } } // now ' ch ' is the current char from the file
nextch = catfile . read ( ) ; if ( nextch < 0 ) { return null ; } if ( ch == '-' && nextch == '-' ) { // we ' ve found a comment , skip it . . .
ch = ' ' ; nextch = nextChar ( ) ; while ( ch != '-' || nextch != '-' ) { ch = nextch ; nextch = nextChar ( ) ; } // Ok , we ' ve found the end of the comment ,
// loop back to the top and start again . . .
} else { stack [ ++ top ] = nextch ; stack [ ++ top ] = ch ; break ; } } ch = nextChar ( ) ; if ( ch == '"' || ch == '\'' ) { int quote = ch ; while ( ( ch = nextChar ( ) ) != quote ) { char [ ] chararr = new char [ 1 ] ; chararr [ 0 ] = ( char ) ch ; String s = new String ( chararr ) ; token = token . concat ( s ) ; } return token ; } else { // return the next whitespace or comment delimited
// string
while ( ch > ' ' ) { nextch = nextChar ( ) ; if ( ch == '-' && nextch == '-' ) { stack [ ++ top ] = ch ; stack [ ++ top ] = nextch ; return token ; } else { char [ ] chararr = new char [ 1 ] ; chararr [ 0 ] = ( char ) ch ; String s = new String ( chararr ) ; token = token . concat ( s ) ; ch = nextch ; } } return token ; }


signature:
public class Iterators { /** * Returns an Iterator containing the < i > union < / i > of all of the elements
 * in the given iterator array .
 * @ param iters Array of iterators .
 * @ return Iterator containing the < i > union < / i > . */
public static Iterator union ( final Iterator iters [ ] ) { } }

implementation: Map map = new HashMap ( ) ; for ( int i = 0 ; i < iters . length ; i ++ ) { if ( iters [ i ] != null ) { while ( iters [ i ] . hasNext ( ) ) { Object obj = iters [ i ] . next ( ) ; if ( ! map . containsKey ( obj ) ) { map . put ( obj , Null . VALUE ) ; } } } } return map . keySet ( ) . iterator ( ) ;


signature:
public class DateEditor { /** * Setup the parsing formats . Offered as a separate static method to allow
 * testing of locale changes , since SimpleDateFormat will use the default
 * locale upon construction . Should not be normally used ! */
public static void initialize ( ) { } }

implementation:
PrivilegedAction action = new PrivilegedAction ( ) { public Object run ( ) { String defaultFormat = System . getProperty ( "org.jboss.util.propertyeditor.DateEditor.format" , "MMM d, yyyy" ) ; String defaultLocale = System . getProperty ( "org.jboss.util.propertyeditor.DateEditor.locale" ) ; DateFormat defaultDateFormat ; if ( defaultLocale == null || defaultLocale . length ( ) == 0 ) { defaultDateFormat = new SimpleDateFormat ( defaultFormat ) ; } else { defaultDateFormat = new SimpleDateFormat ( defaultFormat , Strings . parseLocaleString ( defaultLocale ) ) ; } formats = new DateFormat [ ] { defaultDateFormat , // Tue Jan 04 00:00:00 PST 2005
new SimpleDateFormat ( "EEE MMM d HH:mm:ss z yyyy" ) , // Wed , 4 Jul 2001 12:08:56 - 0700
new SimpleDateFormat ( "EEE, d MMM yyyy HH:mm:ss Z" ) } ; return null ; } } ; AccessController . doPrivileged ( action ) ;


signature:
public class DateEditor { /** * Parse the text into a java . util . Date by trying
 * one by one the registered DateFormat ( s ) .
 * @ param text the string date */
public void setAsText ( String text ) { } }

implementation:
ParseException pe = null ; for ( int i = 0 ; i < formats . length ; i ++ ) { try { // try to parse the date
DateFormat df = formats [ i ] ; Date date = df . parse ( text ) ; // store the date in both forms
this . text = text ; super . setValue ( date ) ; // done
return ; } catch ( ParseException e ) { // remember the last seen exception
pe = e ; } } // couldn ' t parse
throw new NestedRuntimeException ( pe ) ;


signature:
public class Graph { /** * Add a vertex to the graph
 * @ param v the Vertex to add
 * @ return true if the vertex was added , false if it was already in the graph . */
public boolean addVertex ( Vertex < T > v ) { } }

implementation: if ( verticies . containsValue ( v ) == false ) { verticies . put ( v . getName ( ) , v ) ; return true ; } return false ;


signature:
public class Graph { /** * Set a root vertex . If root does no exist in the graph it is added .
 * @ param root - the vertex to set as the root and optionally add if it
 * does not exist in the graph . */
public void setRootVertex ( Vertex < T > root ) { } }

implementation: this . rootVertex = root ; if ( verticies . containsValue ( root ) == false ) addVertex ( root ) ;


signature:
public class Graph { /** * Insert a directed , weighted Edge < T > into the graph .
 * @ param from - the Edge < T > starting vertex
 * @ param to - the Edge < T > ending vertex
 * @ param cost - the Edge < T > weight / cost
 * @ return true if the Edge < T > was added , false if from already has this Edge < T >
 * @ throws IllegalArgumentException if from / to are not verticies in
 * the graph */
public boolean addEdge ( Vertex < T > from , Vertex < T > to , int cost ) throws IllegalArgumentException { } }

implementation: if ( verticies . containsValue ( from ) == false ) throw new IllegalArgumentException ( "from is not in graph" ) ; if ( verticies . containsValue ( to ) == false ) throw new IllegalArgumentException ( "to is not in graph" ) ; Edge < T > e = new Edge < T > ( from , to , cost ) ; if ( from . findEdge ( to ) != null ) return false ; else { from . addEdge ( e ) ; to . addEdge ( e ) ; edges . add ( e ) ; return true ; }


signature:
public class Graph { /** * Insert a bidirectional Edge < T > in the graph
 * @ param from - the Edge < T > starting vertex
 * @ param to - the Edge < T > ending vertex
 * @ param cost - the Edge < T > weight / cost
 * @ return true if edges between both nodes were added , false otherwise
 * @ throws IllegalArgumentException if from / to are not verticies in
 * the graph */
public boolean insertBiEdge ( Vertex < T > from , Vertex < T > to , int cost ) throws IllegalArgumentException { } }

implementation: return addEdge ( from , to , cost ) && addEdge ( to , from , cost ) ;


signature:
public class Graph { /** * Remove a vertex from the graph
 * @ param v the Vertex to remove
 * @ return true if the Vertex was removed */
public boolean removeVertex ( Vertex < T > v ) { } }

implementation:
if ( ! verticies . containsValue ( v ) ) return false ; verticies . remove ( v . getName ( ) ) ; if ( v == rootVertex ) rootVertex = null ; // Remove the edges associated with v
for ( int n = 0 ; n < v . getOutgoingEdgeCount ( ) ; n ++ ) { Edge < T > e = v . getOutgoingEdge ( n ) ; v . remove ( e ) ; Vertex < T > to = e . getTo ( ) ; to . remove ( e ) ; edges . remove ( e ) ; } for ( int n = 0 ; n < v . getIncomingEdgeCount ( ) ; n ++ ) { Edge < T > e = v . getIncomingEdge ( n ) ; v . remove ( e ) ; Vertex < T > predecessor = e . getFrom ( ) ; predecessor . remove ( e ) ; } return true ;


signature:
public class Graph { /** * Remove an Edge < T > from the graph
 * @ param from - the Edge < T > starting vertex
 * @ param to - the Edge < T > ending vertex
 * @ return true if the Edge < T > exists , false otherwise */
public boolean removeEdge ( Vertex < T > from , Vertex < T > to ) { } }

implementation: Edge < T > e = from . findEdge ( to ) ; if ( e == null ) return false ; else { from . remove ( e ) ; to . remove ( e ) ; edges . remove ( e ) ; return true ; }


signature:
public class Graph { /** * Perform a depth first serach using recursion .
 * @ param v - the Vertex to start the search from
 * @ param visitor - the vistor to inform prior to
 * @ see Visitor # visit ( Graph , Vertex ) */
public void depthFirstSearch ( Vertex < T > v , final Visitor < T > visitor ) { } }

implementation: VisitorEX < T , RuntimeException > wrapper = new VisitorEX < T , RuntimeException > ( ) { public void visit ( Graph < T > g , Vertex < T > v ) throws RuntimeException { if ( visitor != null ) visitor . visit ( g , v ) ; } } ; this . depthFirstSearch ( v , wrapper ) ;


signature:
public class Graph { /** * Perform a depth first serach using recursion . The search may
 * be cut short if the visitor throws an exception .
 * @ param < E > exception type
 * @ param v - the Vertex to start the search from
 * @ param visitor - the vistor to inform prior to
 * @ see Visitor # visit ( Graph , Vertex )
 * @ throws E if visitor . visit throws an exception */
public < E extends Exception > void depthFirstSearch ( Vertex < T > v , VisitorEX < T , E > visitor ) throws E { } }

implementation: if ( visitor != null ) visitor . visit ( this , v ) ; v . visit ( ) ; for ( int i = 0 ; i < v . getOutgoingEdgeCount ( ) ; i ++ ) { Edge < T > e = v . getOutgoingEdge ( i ) ; if ( ! e . getTo ( ) . visited ( ) ) { depthFirstSearch ( e . getTo ( ) , visitor ) ; } }


signature:
public class Graph { /** * Perform a breadth first search of this graph , starting at v . The
 * vist may be cut short if visitor throws an exception during
 * a vist callback .
 * @ param < E > exception type
 * @ param v - the search starting point
 * @ param visitor - the vistor whose vist method is called prior
 * to visting a vertex .
 * @ throws E if vistor . visit throws an exception */
public < E extends Exception > void breadthFirstSearch ( Vertex < T > v , VisitorEX < T , E > visitor ) throws E { } }

implementation: LinkedList < Vertex < T > > q = new LinkedList < Vertex < T > > ( ) ; q . add ( v ) ; if ( visitor != null ) visitor . visit ( this , v ) ; v . visit ( ) ; while ( q . isEmpty ( ) == false ) { v = q . removeFirst ( ) ; for ( int i = 0 ; i < v . getOutgoingEdgeCount ( ) ; i ++ ) { Edge < T > e = v . getOutgoingEdge ( i ) ; Vertex < T > to = e . getTo ( ) ; if ( ! to . visited ( ) ) { q . add ( to ) ; if ( visitor != null ) visitor . visit ( this , to ) ; to . visit ( ) ; } } }


signature:
public class Graph { /** * Find the spanning tree using a DFS starting from v .
 * @ param v - the vertex to start the search from
 * @ param visitor - visitor invoked after each vertex
 * is visited and an edge is added to the tree . */
public void dfsSpanningTree ( Vertex < T > v , DFSVisitor < T > visitor ) { } }

implementation: v . visit ( ) ; if ( visitor != null ) visitor . visit ( this , v ) ; for ( int i = 0 ; i < v . getOutgoingEdgeCount ( ) ; i ++ ) { Edge < T > e = v . getOutgoingEdge ( i ) ; if ( ! e . getTo ( ) . visited ( ) ) { if ( visitor != null ) visitor . visit ( this , v , e ) ; e . mark ( ) ; dfsSpanningTree ( e . getTo ( ) , visitor ) ; } }


signature:
public class Graph { /** * Search the verticies for one with data .
 * @ param data - the vertex data to match
 * @ param compare - the comparator to perform the match
 * @ return the first vertex with a matching data , null if no
 * matches are found */
public Vertex < T > findVertexByData ( T data , Comparator < T > compare ) { } }

implementation: Vertex < T > match = null ; for ( Vertex < T > v : verticies . values ( ) ) { if ( compare . compare ( data , v . getData ( ) ) == 0 ) { match = v ; break ; } } return match ;


signature:
public class Graph { /** * Search the graph for cycles . In order to detect cycles , we use
 * a modified depth first search called a colored DFS . All nodes are
 * initially marked white . When a node is encountered , it is marked
 * grey , and when its descendants are completely visited , it is
 * marked black . If a grey node is ever encountered , then there is
 * a cycle .
 * @ return the edges that form cycles in the graph . The array will
 * be empty if there are no cycles . */
public Edge < T > [ ] findCycles ( ) { } }

implementation:
ArrayList < Edge < T > > cycleEdges = new ArrayList < Edge < T > > ( ) ; // Mark all verticies as white
for ( int n = 0 ; n < verticies . size ( ) ; n ++ ) { Vertex < T > v = getVertex ( n ) ; v . setMarkState ( VISIT_COLOR_WHITE ) ; } for ( int n = 0 ; n < verticies . size ( ) ; n ++ ) { Vertex < T > v = getVertex ( n ) ; visit ( v , cycleEdges ) ; } Edge < T > [ ] cycles = new Edge [ cycleEdges . size ( ) ] ; cycleEdges . toArray ( cycles ) ; return cycles ;


signature:
public class ExtendedXMLCatalogReader { /** * The SAX < code > startElement < / code > method recognizes elements
 * from the plain catalog format and instantiates CatalogEntry
 * objects for them .
 * @ param namespaceURI The namespace name of the element .
 * @ param localName The local name of the element .
 * @ param qName The QName of the element .
 * @ param atts The list of attributes on the element .
 * @ see CatalogEntry */
public void startElement ( String namespaceURI , String localName , String qName , Attributes atts ) throws SAXException { } }

implementation:
// Check before calling the super because super will report our
// namespace as an extension namespace , but that doesn ' t count
// for this element .
boolean inExtension = inExtensionNamespace ( ) ; super . startElement ( namespaceURI , localName , qName , atts ) ; int entryType = - 1 ; Vector entryArgs = new Vector ( ) ; if ( namespaceURI != null && extendedNamespaceName . equals ( namespaceURI ) && ! inExtension ) { // This is an Extended XML Catalog entry
if ( atts . getValue ( "xml:base" ) != null ) { String baseURI = atts . getValue ( "xml:base" ) ; entryType = Catalog . BASE ; entryArgs . add ( baseURI ) ; baseURIStack . push ( baseURI ) ; debug . message ( 4 , "xml:base" , baseURI ) ; try { CatalogEntry ce = new CatalogEntry ( entryType , entryArgs ) ; catalog . addEntry ( ce ) ; } catch ( CatalogException cex ) { if ( cex . getExceptionType ( ) == CatalogException . INVALID_ENTRY_TYPE ) { debug . message ( 1 , "Invalid catalog entry type" , localName ) ; } else if ( cex . getExceptionType ( ) == CatalogException . INVALID_ENTRY ) { debug . message ( 1 , "Invalid catalog entry (base)" , localName ) ; } } entryType = - 1 ; entryArgs = new Vector ( ) ; } else { baseURIStack . push ( baseURIStack . peek ( ) ) ; } if ( localName . equals ( "uriSuffix" ) ) { if ( checkAttributes ( atts , "suffix" , "uri" ) ) { entryType = Resolver . URISUFFIX ; entryArgs . add ( atts . getValue ( "suffix" ) ) ; entryArgs . add ( atts . getValue ( "uri" ) ) ; debug . message ( 4 , "uriSuffix" , atts . getValue ( "suffix" ) , atts . getValue ( "uri" ) ) ; } } else if ( localName . equals ( "systemSuffix" ) ) { if ( checkAttributes ( atts , "suffix" , "uri" ) ) { entryType = Resolver . SYSTEMSUFFIX ; entryArgs . add ( atts . getValue ( "suffix" ) ) ; entryArgs . add ( atts . getValue ( "uri" ) ) ; debug . message ( 4 , "systemSuffix" , atts . getValue ( "suffix" ) , atts . getValue ( "uri" ) ) ; } } else { // This is equivalent to an invalid catalog entry type
debug . message ( 1 , "Invalid catalog entry type" , localName ) ; } if ( entryType >= 0 ) { try { CatalogEntry ce = new CatalogEntry ( entryType , entryArgs ) ; catalog . addEntry ( ce ) ; } catch ( CatalogException cex ) { if ( cex . getExceptionType ( ) == CatalogException . INVALID_ENTRY_TYPE ) { debug . message ( 1 , "Invalid catalog entry type" , localName ) ; } else if ( cex . getExceptionType ( ) == CatalogException . INVALID_ENTRY ) { debug . message ( 1 , "Invalid catalog entry" , localName ) ; } } } }


signature:
public class ExtendedXMLCatalogReader { /** * The SAX < code > endElement < / code > method does nothing . */
public void endElement ( String namespaceURI , String localName , String qName ) throws SAXException { } }

implementation:
super . endElement ( namespaceURI , localName , qName ) ; // Check after popping the stack so we don ' t erroneously think we
// are our own extension namespace . . .
boolean inExtension = inExtensionNamespace ( ) ; int entryType = - 1 ; Vector entryArgs = new Vector ( ) ; if ( namespaceURI != null && ( extendedNamespaceName . equals ( namespaceURI ) ) && ! inExtension ) { String popURI = ( String ) baseURIStack . pop ( ) ; String baseURI = ( String ) baseURIStack . peek ( ) ; if ( ! baseURI . equals ( popURI ) ) { entryType = catalog . BASE ; entryArgs . add ( baseURI ) ; debug . message ( 4 , "(reset) xml:base" , baseURI ) ; try { CatalogEntry ce = new CatalogEntry ( entryType , entryArgs ) ; catalog . addEntry ( ce ) ; } catch ( CatalogException cex ) { if ( cex . getExceptionType ( ) == CatalogException . INVALID_ENTRY_TYPE ) { debug . message ( 1 , "Invalid catalog entry type" , localName ) ; } else if ( cex . getExceptionType ( ) == CatalogException . INVALID_ENTRY ) { debug . message ( 1 , "Invalid catalog entry (rbase)" , localName ) ; } } } }


signature:
public class DOMWriter { /** * Normalizes the given string . */
public static String normalize ( String s , boolean canonical ) { } }

implementation:
StringBuffer str = new StringBuffer ( ) ; int len = ( s != null ) ? s . length ( ) : 0 ; for ( int i = 0 ; i < len ; i ++ ) { char ch = s . charAt ( i ) ; switch ( ch ) { case '<' : { str . append ( "<" ) ; break ; } case '>' : { str . append ( ">" ) ; break ; } case '&' : { str . append ( "&" ) ; break ; } case '"' : { str . append ( """ ) ; break ; } case '\'' : { str . append ( "'" ) ; break ; } case '\r' : case '\n' : { if ( canonical ) { str . append ( "&#" ) ; str . append ( Integer . toString ( ch ) ) ; str . append ( ';' ) ; break ; } // else , default append char
} default : { str . append ( ch ) ; } } } return ( str . toString ( ) ) ;


signature:
public class DOMUtils { /** * Parse the given XML string and return the root Element
 * @ param xmlString
 * @ return the element
 * @ throws IOException */
public static Element parse ( String xmlString ) throws IOException { } }

implementation: try { return parse ( new ByteArrayInputStream ( xmlString . getBytes ( "UTF-8" ) ) ) ; } catch ( IOException e ) { log . error ( "Cannot parse: " + xmlString ) ; throw e ; }


signature:
public class DOMUtils { /** * Parse the given XML stream and return the root Element
 * @ param xmlStream
 * @ return the element
 * @ throws IOException */
public static Element parse ( InputStream xmlStream ) throws IOException { } }

implementation: try { Document doc = getDocumentBuilder ( ) . parse ( xmlStream ) ; Element root = doc . getDocumentElement ( ) ; return root ; } catch ( SAXException e ) { throw new IOException ( e . toString ( ) ) ; }


signature:
public class DOMUtils { /** * Parse the given input source and return the root Element
 * @ param source
 * @ return the element
 * @ throws IOException */
public static Element parse ( InputSource source ) throws IOException { } }

implementation: try { Document doc = getDocumentBuilder ( ) . parse ( source ) ; Element root = doc . getDocumentElement ( ) ; return root ; } catch ( SAXException e ) { throw new IOException ( e . toString ( ) ) ; }


signature:
public class DOMUtils { /** * Create an Element for a given name
 * @ param localPart
 * @ return the element */
public static Element createElement ( String localPart ) { } }

implementation: Document doc = getOwnerDocument ( ) ; log . trace ( "createElement {}" + localPart ) ; return doc . createElement ( localPart ) ;


signature:
public class DOMUtils { /** * Transform the giveen qualified name into a QName
 * @ param el
 * @ param qualifiedName
 * @ return the resolved name */
public static QName resolveQName ( Element el , String qualifiedName ) { } }

implementation: QName qname ; String prefix = "" ; String namespaceURI = "" ; String localPart = qualifiedName ; int colIndex = qualifiedName . indexOf ( ":" ) ; if ( colIndex > 0 ) { prefix = qualifiedName . substring ( 0 , colIndex ) ; localPart = qualifiedName . substring ( colIndex + 1 ) ; if ( "xmlns" . equals ( prefix ) ) { namespaceURI = "URI:XML_PREDEFINED_NAMESPACE" ; } else { Element nsElement = el ; while ( namespaceURI . equals ( "" ) && nsElement != null ) { namespaceURI = nsElement . getAttribute ( "xmlns:" + prefix ) ; if ( namespaceURI . equals ( "" ) ) nsElement = getParentElement ( nsElement ) ; } } if ( namespaceURI . equals ( "" ) ) throw new IllegalArgumentException ( "Cannot find namespace uri for: " + qualifiedName ) ; } qname = new QName ( namespaceURI , localPart , prefix ) ; return qname ;


signature:
public class DOMUtils { /** * Get the value from the given attribute
 * @ param el
 * @ param attrName
 * @ return null if the attribute value is empty or the attribute is not present */
public static String getAttributeValue ( Element el , String attrName ) { } }

implementation: return getAttributeValue ( el , new QName ( attrName ) ) ;


signature:
public class DOMUtils { /** * Get the value from the given attribute
 * @ param el
 * @ param attrName
 * @ return null if the attribute value is empty or the attribute is not present */
public static String getAttributeValue ( Element el , QName attrName ) { } }

implementation: String attr = null ; if ( "" . equals ( attrName . getNamespaceURI ( ) ) ) attr = el . getAttribute ( attrName . getLocalPart ( ) ) ; else attr = el . getAttributeNS ( attrName . getNamespaceURI ( ) , attrName . getLocalPart ( ) ) ; if ( "" . equals ( attr ) ) attr = null ; return attr ;


signature:
public class DOMUtils { /** * Copy attributes between elements
 * @ param destElement
 * @ param srcElement */
public static void copyAttributes ( Element destElement , Element srcElement ) { } }

implementation:
NamedNodeMap attribs = srcElement . getAttributes ( ) ; for ( int i = 0 ; i < attribs . getLength ( ) ; i ++ ) { Attr attr = ( Attr ) attribs . item ( i ) ; String uri = attr . getNamespaceURI ( ) ; String qname = attr . getName ( ) ; String value = attr . getNodeValue ( ) ; // Prevent DOMException : NAMESPACE _ ERR : An attempt is made to create or
// change an object in a way which is incorrect with regard to namespaces .
if ( uri == null && qname . startsWith ( "xmlns" ) ) { log . trace ( "Ignore attribute: [uri=" + uri + ",qname=" + qname + ",value=" + value + "]" ) ; } else { destElement . setAttributeNS ( uri , qname , value ) ; } }


signature:
public class DOMUtils { /** * True if the node has child elements
 * @ param node
 * @ return true when has child elements */
public static boolean hasChildElements ( Node node ) { } }

implementation: NodeList nlist = node . getChildNodes ( ) ; for ( int i = 0 ; i < nlist . getLength ( ) ; i ++ ) { Node child = nlist . item ( i ) ; if ( child . getNodeType ( ) == Node . ELEMENT_NODE ) return true ; } return false ;


signature:
public class DOMUtils { /** * Gets child elements
 * @ param node
 * @ return the iterator */
public static Iterator getChildElements ( Node node ) { } }

implementation: ArrayList list = new ArrayList ( ) ; NodeList nlist = node . getChildNodes ( ) ; for ( int i = 0 ; i < nlist . getLength ( ) ; i ++ ) { Node child = nlist . item ( i ) ; if ( child . getNodeType ( ) == Node . ELEMENT_NODE ) list . add ( child ) ; } return list . iterator ( ) ;


signature:
public class DOMUtils { /** * Get the concatenated text content , or null .
 * @ param node node to search for TEXT _ NODE conent
 * @ param replaceProps flag indicating if $ { x } property refs should be replace
 * @ return the text content */
public static String getTextContent ( Node node , boolean replaceProps ) { } }

implementation: boolean hasTextContent = false ; StringBuffer buffer = new StringBuffer ( ) ; NodeList nlist = node . getChildNodes ( ) ; for ( int i = 0 ; i < nlist . getLength ( ) ; i ++ ) { Node child = nlist . item ( i ) ; if ( child . getNodeType ( ) == Node . TEXT_NODE ) { buffer . append ( child . getNodeValue ( ) ) ; hasTextContent = true ; } } String text = ( hasTextContent ? buffer . toString ( ) : null ) ; if ( text != null && replaceProps ) text = StringPropertyReplacer . replaceProperties ( text ) ; return text ;


signature:
public class DOMUtils { /** * Gets the child elements for a given local name without namespace
 * @ param node
 * @ param nodeName
 * @ return the iterator */
public static Iterator getChildElements ( Node node , String nodeName ) { } }

implementation: return getChildElementsIntern ( node , new QName ( nodeName ) ) ;


signature:
public class DOMUtils { /** * Gets parent element or null if there is none
 * @ param node
 * @ return the element */
public static Element getParentElement ( Node node ) { } }

implementation: Node parent = node . getParentNode ( ) ; return ( parent instanceof Element ? ( Element ) parent : null ) ;


signature:
public class DeadlockDetector { /** * Add a transaction waiting for a lock
 * @ param holder
 * @ param resource */
public void addWaiting ( Object holder , Resource resource ) { } }

implementation: synchronized ( waiting ) { waiting . put ( holder , resource ) ; }