signature:
public class Catalog { /** * Cleanup and process a Catalog entry .
 * < p > This method processes each Catalog entry , changing mapped
 * relative system identifiers into absolute ones ( based on the current
 * base URI ) , and maintaining other information about the current
 * catalog . < / p >
 * @ param entry The CatalogEntry to process . */
public void addEntry ( CatalogEntry entry ) { } }

implementation:
int type = entry . getEntryType ( ) ; if ( type == BASE ) { String value = entry . getEntryArg ( 0 ) ; URL newbase = null ; catalogManager . debug . message ( 5 , "BASE CUR" , base . toString ( ) ) ; catalogManager . debug . message ( 4 , "BASE STR" , value ) ; try { value = fixSlashes ( value ) ; newbase = new URL ( base , value ) ; } catch ( MalformedURLException e ) { try { newbase = new URL ( "file:" + value ) ; } catch ( MalformedURLException e2 ) { catalogManager . debug . message ( 1 , "Malformed URL on base" , value ) ; newbase = null ; } } if ( newbase != null ) { base = newbase ; } catalogManager . debug . message ( 5 , "BASE NEW" , base . toString ( ) ) ; } else if ( type == CATALOG ) { String fsi = makeAbsolute ( entry . getEntryArg ( 0 ) ) ; catalogManager . debug . message ( 4 , "CATALOG" , fsi ) ; localCatalogFiles . addElement ( fsi ) ; } else if ( type == PUBLIC ) { String publicid = PublicId . normalize ( entry . getEntryArg ( 0 ) ) ; String systemid = makeAbsolute ( normalizeURI ( entry . getEntryArg ( 1 ) ) ) ; entry . setEntryArg ( 0 , publicid ) ; entry . setEntryArg ( 1 , systemid ) ; catalogManager . debug . message ( 4 , "PUBLIC" , publicid , systemid ) ; catalogEntries . addElement ( entry ) ; } else if ( type == SYSTEM ) { String systemid = normalizeURI ( entry . getEntryArg ( 0 ) ) ; String fsi = makeAbsolute ( normalizeURI ( entry . getEntryArg ( 1 ) ) ) ; entry . setEntryArg ( 1 , fsi ) ; catalogManager . debug . message ( 4 , "SYSTEM" , systemid , fsi ) ; catalogEntries . addElement ( entry ) ; } else if ( type == URI ) { String uri = normalizeURI ( entry . getEntryArg ( 0 ) ) ; String altURI = makeAbsolute ( normalizeURI ( entry . getEntryArg ( 1 ) ) ) ; entry . setEntryArg ( 1 , altURI ) ; catalogManager . debug . message ( 4 , "URI" , uri , altURI ) ; catalogEntries . addElement ( entry ) ; } else if ( type == DOCUMENT ) { String fsi = makeAbsolute ( normalizeURI ( entry . getEntryArg ( 0 ) ) ) ; entry . setEntryArg ( 0 , fsi ) ; catalogManager . debug . message ( 4 , "DOCUMENT" , fsi ) ; catalogEntries . addElement ( entry ) ; } else if ( type == OVERRIDE ) { catalogManager . debug . message ( 4 , "OVERRIDE" , entry . getEntryArg ( 0 ) ) ; catalogEntries . addElement ( entry ) ; } else if ( type == SGMLDECL ) { // meaningless in XML
String fsi = makeAbsolute ( normalizeURI ( entry . getEntryArg ( 0 ) ) ) ; entry . setEntryArg ( 0 , fsi ) ; catalogManager . debug . message ( 4 , "SGMLDECL" , fsi ) ; catalogEntries . addElement ( entry ) ; } else if ( type == DELEGATE_PUBLIC ) { String ppi = PublicId . normalize ( entry . getEntryArg ( 0 ) ) ; String fsi = makeAbsolute ( normalizeURI ( entry . getEntryArg ( 1 ) ) ) ; entry . setEntryArg ( 0 , ppi ) ; entry . setEntryArg ( 1 , fsi ) ; catalogManager . debug . message ( 4 , "DELEGATE_PUBLIC" , ppi , fsi ) ; addDelegate ( entry ) ; } else if ( type == DELEGATE_SYSTEM ) { String psi = normalizeURI ( entry . getEntryArg ( 0 ) ) ; String fsi = makeAbsolute ( normalizeURI ( entry . getEntryArg ( 1 ) ) ) ; entry . setEntryArg ( 0 , psi ) ; entry . setEntryArg ( 1 , fsi ) ; catalogManager . debug . message ( 4 , "DELEGATE_SYSTEM" , psi , fsi ) ; addDelegate ( entry ) ; } else if ( type == DELEGATE_URI ) { String pui = normalizeURI ( entry . getEntryArg ( 0 ) ) ; String fsi = makeAbsolute ( normalizeURI ( entry . getEntryArg ( 1 ) ) ) ; entry . setEntryArg ( 0 , pui ) ; entry . setEntryArg ( 1 , fsi ) ; catalogManager . debug . message ( 4 , "DELEGATE_URI" , pui , fsi ) ; addDelegate ( entry ) ; } else if ( type == REWRITE_SYSTEM ) { String psi = normalizeURI ( entry . getEntryArg ( 0 ) ) ; String rpx = makeAbsolute ( normalizeURI ( entry . getEntryArg ( 1 ) ) ) ; entry . setEntryArg ( 0 , psi ) ; entry . setEntryArg ( 1 , rpx ) ; catalogManager . debug . message ( 4 , "REWRITE_SYSTEM" , psi , rpx ) ; catalogEntries . addElement ( entry ) ; } else if ( type == REWRITE_URI ) { String pui = normalizeURI ( entry . getEntryArg ( 0 ) ) ; String upx = makeAbsolute ( normalizeURI ( entry . getEntryArg ( 1 ) ) ) ; entry . setEntryArg ( 0 , pui ) ; entry . setEntryArg ( 1 , upx ) ; catalogManager . debug . message ( 4 , "REWRITE_URI" , pui , upx ) ; catalogEntries . addElement ( entry ) ; } else if ( type == DOCTYPE ) { String fsi = makeAbsolute ( normalizeURI ( entry . getEntryArg ( 1 ) ) ) ; entry . setEntryArg ( 1 , fsi ) ; catalogManager . debug . message ( 4 , "DOCTYPE" , entry . getEntryArg ( 0 ) , fsi ) ; catalogEntries . addElement ( entry ) ; } else if ( type == DTDDECL ) { // meaningless in XML
String fpi = PublicId . normalize ( entry . getEntryArg ( 0 ) ) ; entry . setEntryArg ( 0 , fpi ) ; String fsi = makeAbsolute ( normalizeURI ( entry . getEntryArg ( 1 ) ) ) ; entry . setEntryArg ( 1 , fsi ) ; catalogManager . debug . message ( 4 , "DTDDECL" , fpi , fsi ) ; catalogEntries . addElement ( entry ) ; } else if ( type == ENTITY ) { String fsi = makeAbsolute ( normalizeURI ( entry . getEntryArg ( 1 ) ) ) ; entry . setEntryArg ( 1 , fsi ) ; catalogManager . debug . message ( 4 , "ENTITY" , entry . getEntryArg ( 0 ) , fsi ) ; catalogEntries . addElement ( entry ) ; } else if ( type == LINKTYPE ) { // meaningless in XML
String fsi = makeAbsolute ( normalizeURI ( entry . getEntryArg ( 1 ) ) ) ; entry . setEntryArg ( 1 , fsi ) ; catalogManager . debug . message ( 4 , "LINKTYPE" , entry . getEntryArg ( 0 ) , fsi ) ; catalogEntries . addElement ( entry ) ; } else if ( type == NOTATION ) { String fsi = makeAbsolute ( normalizeURI ( entry . getEntryArg ( 1 ) ) ) ; entry . setEntryArg ( 1 , fsi ) ; catalogManager . debug . message ( 4 , "NOTATION" , entry . getEntryArg ( 0 ) , fsi ) ; catalogEntries . addElement ( entry ) ; } else { catalogEntries . addElement ( entry ) ; }


signature:
public class Catalog { /** * Handle unknown CatalogEntry types .
 * < p > This method exists to allow subclasses to deal with unknown
 * entry types . < / p >
 * @ param strings */
public void unknownEntry ( Vector strings ) { } }

implementation: if ( strings != null && strings . size ( ) > 0 ) { String keyword = ( String ) strings . elementAt ( 0 ) ; catalogManager . debug . message ( 2 , "Unrecognized token parsing catalog" , keyword ) ; }


signature:
public class Catalog { /** * Parse all subordinate catalogs .
 * < p > This method recursively parses all of the subordinate catalogs .
 * If this method does not throw an exception , you can be confident that
 * no subsequent call to any resolve * ( ) method will either , with two
 * possible exceptions : < / p >
 * < ol >
 * < li > < p > Delegated catalogs are re - parsed each time they are needed
 * ( because a variable list of them may be needed in each case ,
 * depending on the length of the matching partial public identifier ) . < / p >
 * < p > But they are parsed by this method , so as long as they don ' t
 * change or disappear while the program is running , they shouldn ' t
 * generate errors later if they don ' t generate errors now . < / p >
 * < li > < p > If you add new catalogs with < code > parseCatalog < / code > , they
 * won ' t be loaded until they are needed or until you call
 * < code > parseAllCatalogs < / code > again . < / p >
 * < / ol >
 * < p > On the other hand , if you don ' t call this method , you may
 * successfully parse documents without having to load all possible
 * catalogs . < / p >
 * @ throws MalformedURLException The filename ( URL ) for a
 * subordinate or delegated catalog is not a valid URL .
 * @ throws IOException Error reading some subordinate or delegated
 * catalog file . */
public void parseAllCatalogs ( ) throws MalformedURLException , IOException { } }

implementation:
// Parse all the subordinate catalogs
for ( int catPos = 0 ; catPos < catalogs . size ( ) ; catPos ++ ) { Catalog c = null ; try { c = ( Catalog ) catalogs . elementAt ( catPos ) ; } catch ( ClassCastException e ) { String catfile = ( String ) catalogs . elementAt ( catPos ) ; c = newCatalog ( ) ; c . parseCatalog ( catfile ) ; catalogs . setElementAt ( c , catPos ) ; c . parseAllCatalogs ( ) ; } } // Parse all the DELEGATE catalogs
Enumeration enumt = catalogEntries . elements ( ) ; while ( enumt . hasMoreElements ( ) ) { CatalogEntry e = ( CatalogEntry ) enumt . nextElement ( ) ; if ( e . getEntryType ( ) == DELEGATE_PUBLIC || e . getEntryType ( ) == DELEGATE_SYSTEM || e . getEntryType ( ) == DELEGATE_URI ) { Catalog dcat = newCatalog ( ) ; dcat . parseCatalog ( e . getEntryArg ( 1 ) ) ; } }


signature:
public class Catalog { /** * Return the applicable DOCTYPE system identifier .
 * @ param entityName The name of the entity ( element ) for which
 * a doctype is required .
 * @ param publicId The nominal public identifier for the doctype
 * ( as provided in the source document ) .
 * @ param systemId The nominal system identifier for the doctype
 * ( as provided in the source document ) .
 * @ return The system identifier to use for the doctype .
 * @ 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 String resolveDoctype ( String entityName , String publicId , String systemId ) throws MalformedURLException , IOException { } }

implementation:
String resolved = null ; catalogManager . debug . message ( 3 , "resolveDoctype(" + entityName + "," + publicId + "," + systemId + ")" ) ; systemId = normalizeURI ( systemId ) ; if ( publicId != null && publicId . startsWith ( "urn:publicid:" ) ) { publicId = PublicId . decodeURN ( publicId ) ; } if ( systemId != null && systemId . startsWith ( "urn:publicid:" ) ) { systemId = PublicId . decodeURN ( systemId ) ; if ( publicId != null && ! publicId . equals ( systemId ) ) { catalogManager . debug . message ( 1 , "urn:publicid: system identifier differs from public identifier; using public identifier" ) ; systemId = null ; } else { publicId = systemId ; systemId = null ; } } if ( systemId != null ) { // If there ' s a SYSTEM entry in this catalog , use it
resolved = resolveLocalSystem ( systemId ) ; if ( resolved != null ) { return resolved ; } } if ( publicId != null ) { // If there ' s a PUBLIC entry in this catalog , use it
resolved = resolveLocalPublic ( DOCTYPE , entityName , publicId , systemId ) ; if ( resolved != null ) { return resolved ; } } // If there ' s a DOCTYPE entry in this catalog , use it
boolean over = default_override ; Enumeration enumt = catalogEntries . elements ( ) ; while ( enumt . hasMoreElements ( ) ) { CatalogEntry e = ( CatalogEntry ) enumt . nextElement ( ) ; if ( e . getEntryType ( ) == OVERRIDE ) { over = e . getEntryArg ( 0 ) . equalsIgnoreCase ( "YES" ) ; continue ; } if ( e . getEntryType ( ) == DOCTYPE && e . getEntryArg ( 0 ) . equals ( entityName ) ) { if ( over || systemId == null ) { return e . getEntryArg ( 1 ) ; } } } // Otherwise , look in the subordinate catalogs
return resolveSubordinateCatalogs ( DOCTYPE , entityName , publicId , systemId ) ;


signature:
public class Catalog { /** * Return the applicable DOCUMENT entry .
 * @ return The system identifier to use for the doctype .
 * @ 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 String resolveDocument ( ) throws MalformedURLException , IOException { } }

implementation:
// If there ' s a DOCUMENT entry , return it
catalogManager . debug . message ( 3 , "resolveDocument" ) ; Enumeration enumt = catalogEntries . elements ( ) ; while ( enumt . hasMoreElements ( ) ) { CatalogEntry e = ( CatalogEntry ) enumt . nextElement ( ) ; if ( e . getEntryType ( ) == DOCUMENT ) { return e . getEntryArg ( 1 ) ; // FIXME check this
} } return resolveSubordinateCatalogs ( DOCUMENT , null , null , null ) ;


signature:
public class Catalog { /** * Return the applicable PUBLIC or SYSTEM identifier .
 * < 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 >
 * @ 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:
catalogManager . debug . message ( 3 , "resolvePublic(" + publicId + "," + systemId + ")" ) ; systemId = normalizeURI ( systemId ) ; if ( publicId != null && publicId . startsWith ( "urn:publicid:" ) ) { publicId = PublicId . decodeURN ( publicId ) ; } if ( systemId != null && systemId . startsWith ( "urn:publicid:" ) ) { systemId = PublicId . decodeURN ( systemId ) ; if ( publicId != null && ! publicId . equals ( systemId ) ) { catalogManager . debug . message ( 1 , "urn:publicid: system identifier differs from public identifier; using public identifier" ) ; systemId = null ; } else { publicId = systemId ; systemId = null ; } } // If there ' s a SYSTEM entry in this catalog , use it
if ( systemId != null ) { String resolved = resolveLocalSystem ( systemId ) ; if ( resolved != null ) { return resolved ; } } // If there ' s a PUBLIC entry in this catalog , use it
String resolved = resolveLocalPublic ( PUBLIC , null , publicId , systemId ) ; if ( resolved != null ) { return resolved ; } // Otherwise , look in the subordinate catalogs
return resolveSubordinateCatalogs ( PUBLIC , null , publicId , systemId ) ;


signature:
public class Catalog { /** * Return the applicable PUBLIC or SYSTEM identifier .
 * < 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 ,
 * delegated Catalogs are interrogated . < / p >
 * < p > There are four possible cases : < / p >
 * < ul >
 * < li > If the system identifier provided matches a SYSTEM entry
 * in the current catalog , the SYSTEM entry is returned .
 * < li > If the system identifier is not null , the PUBLIC entries
 * that were encountered when OVERRIDE YES was in effect are
 * interrogated and the first matching entry is returned . < / li >
 * < li > If the system identifier is null , then all of the PUBLIC
 * entries are interrogated and the first matching entry
 * is returned . This may not be the same as the preceding case , if
 * some PUBLIC entries are encountered when OVERRIDE NO is in effect . In
 * XML , the only place where a public identifier may occur without
 * a system identifier is in a notation declaration . < / li >
 * < li > Finally , if the public identifier matches one of the partial
 * public identifiers specified in a DELEGATE * entry in
 * the Catalog , the delegated catalog is interrogated . The first
 * time that the delegated catalog is required , it will be
 * retrieved and parsed . It is subsequently cached .
 * < / li >
 * < / ul >
 * @ param entityType The CatalogEntry type for which this query is
 * being conducted . This is necessary in order to do the approprate
 * query on a delegated catalog .
 * @ param entityName The name of the entity being searched for , if
 * appropriate .
 * @ param publicId The public identifier of the entity in question .
 * @ 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 . */
protected synchronized String resolveLocalPublic ( int entityType , String entityName , String publicId , String systemId ) throws MalformedURLException , IOException { } }

implementation:
// Always normalize the public identifier before attempting a match
publicId = PublicId . normalize ( publicId ) ; // If there ' s a SYSTEM entry in this catalog , use it
if ( systemId != null ) { String resolved = resolveLocalSystem ( systemId ) ; if ( resolved != null ) { return resolved ; } } // If there ' s a PUBLIC entry in this catalog , use it
boolean over = default_override ; Enumeration enumt = catalogEntries . elements ( ) ; while ( enumt . hasMoreElements ( ) ) { CatalogEntry e = ( CatalogEntry ) enumt . nextElement ( ) ; if ( e . getEntryType ( ) == OVERRIDE ) { over = e . getEntryArg ( 0 ) . equalsIgnoreCase ( "YES" ) ; continue ; } if ( e . getEntryType ( ) == PUBLIC && e . getEntryArg ( 0 ) . equals ( publicId ) ) { if ( over || systemId == null ) { return e . getEntryArg ( 1 ) ; } } } // If there ' s a DELEGATE _ PUBLIC entry in this catalog , use it
over = default_override ; enumt = catalogEntries . elements ( ) ; Vector delCats = new Vector ( ) ; while ( enumt . hasMoreElements ( ) ) { CatalogEntry e = ( CatalogEntry ) enumt . nextElement ( ) ; if ( e . getEntryType ( ) == OVERRIDE ) { over = e . getEntryArg ( 0 ) . equalsIgnoreCase ( "YES" ) ; continue ; } if ( e . getEntryType ( ) == DELEGATE_PUBLIC && ( over || systemId == null ) ) { String p = e . getEntryArg ( 0 ) ; if ( p . length ( ) <= publicId . length ( ) && p . equals ( publicId . substring ( 0 , p . length ( ) ) ) ) { // delegate this match to the other catalog
delCats . addElement ( e . getEntryArg ( 1 ) ) ; } } } if ( delCats . size ( ) > 0 ) { Enumeration enumCats = delCats . elements ( ) ; if ( catalogManager . debug . getDebug ( ) > 1 ) { catalogManager . debug . message ( 2 , "Switching to delegated catalog(s):" ) ; while ( enumCats . hasMoreElements ( ) ) { String delegatedCatalog = ( String ) enumCats . nextElement ( ) ; catalogManager . debug . message ( 2 , "\t" + delegatedCatalog ) ; } } Catalog dcat = newCatalog ( ) ; enumCats = delCats . elements ( ) ; while ( enumCats . hasMoreElements ( ) ) { String delegatedCatalog = ( String ) enumCats . nextElement ( ) ; dcat . parseCatalog ( delegatedCatalog ) ; } return dcat . resolvePublic ( publicId , null ) ; } // Nada !
return null ;


signature:
public class Catalog { /** * Return the applicable SYSTEM system identifier .
 * < p > If a SYSTEM entry exists in the Catalog
 * for the system ID specified , return the mapped value . < / 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 resolved system identifier .
 * @ 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 String resolveSystem ( String systemId ) throws MalformedURLException , IOException { } }

implementation:
catalogManager . debug . message ( 3 , "resolveSystem(" + systemId + ")" ) ; systemId = normalizeURI ( systemId ) ; if ( systemId != null && systemId . startsWith ( "urn:publicid:" ) ) { systemId = PublicId . decodeURN ( systemId ) ; return resolvePublic ( systemId , null ) ; } // If there ' s a SYSTEM entry in this catalog , use it
if ( systemId != null ) { String resolved = resolveLocalSystem ( systemId ) ; if ( resolved != null ) { return resolved ; } } // Otherwise , look in the subordinate catalogs
return resolveSubordinateCatalogs ( SYSTEM , null , null , systemId ) ;


signature:
public class Catalog { /** * Return the applicable SYSTEM system identifier in this
 * catalog .
 * < p > If a SYSTEM entry exists in the catalog file
 * for the system ID specified , return the mapped value . < / p >
 * @ param systemId The system ID to locate in the catalog
 * @ return The mapped system identifier or null
 * @ throws MalformedURLException
 * @ throws IOException */
protected String resolveLocalSystem ( String systemId ) throws MalformedURLException , IOException { } }

implementation:
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 ) ) ) ) { return e . getEntryArg ( 1 ) ; } } // If there ' s a REWRITE _ SYSTEM entry in this catalog , use it
enumt = catalogEntries . elements ( ) ; String startString = null ; String prefix = null ; while ( enumt . hasMoreElements ( ) ) { CatalogEntry e = ( CatalogEntry ) enumt . nextElement ( ) ; if ( e . getEntryType ( ) == REWRITE_SYSTEM ) { String p = e . getEntryArg ( 0 ) ; if ( p . length ( ) <= systemId . length ( ) && p . equals ( systemId . substring ( 0 , p . length ( ) ) ) ) { // Is this the longest prefix ?
if ( startString == null || p . length ( ) > startString . length ( ) ) { startString = p ; prefix = e . getEntryArg ( 1 ) ; } } } if ( prefix != null ) { // return the systemId with the new prefix
return prefix + systemId . substring ( startString . length ( ) ) ; } } // If there ' s a DELEGATE _ SYSTEM entry in this catalog , use it
enumt = catalogEntries . elements ( ) ; Vector delCats = new Vector ( ) ; while ( enumt . hasMoreElements ( ) ) { CatalogEntry e = ( CatalogEntry ) enumt . nextElement ( ) ; if ( e . getEntryType ( ) == DELEGATE_SYSTEM ) { String p = e . getEntryArg ( 0 ) ; if ( p . length ( ) <= systemId . length ( ) && p . equals ( systemId . substring ( 0 , p . length ( ) ) ) ) { // delegate this match to the other catalog
delCats . addElement ( e . getEntryArg ( 1 ) ) ; } } } if ( delCats . size ( ) > 0 ) { Enumeration enumCats = delCats . elements ( ) ; if ( catalogManager . debug . getDebug ( ) > 1 ) { catalogManager . debug . message ( 2 , "Switching to delegated catalog(s):" ) ; while ( enumCats . hasMoreElements ( ) ) { String delegatedCatalog = ( String ) enumCats . nextElement ( ) ; catalogManager . debug . message ( 2 , "\t" + delegatedCatalog ) ; } } Catalog dcat = newCatalog ( ) ; enumCats = delCats . elements ( ) ; while ( enumCats . hasMoreElements ( ) ) { String delegatedCatalog = ( String ) enumCats . nextElement ( ) ; dcat . parseCatalog ( delegatedCatalog ) ; } return dcat . resolveSystem ( systemId ) ; } return null ;


signature:
public class Catalog { /** * Return the applicable URI .
 * < p > If a URI entry exists in the Catalog
 * for the URI specified , return the mapped value . < / p >
 * < p > URI comparison is case sensitive . < / p >
 * @ param uri The URI to locate in the catalog .
 * @ return The resolved URI .
 * @ throws MalformedURLException The system identifier of a
 * subordinate catalog cannot be turned into a valid URL .
 * @ throws IOException Error reading subordinate catalog file . */
public String resolveURI ( String uri ) throws MalformedURLException , IOException { } }

implementation:
catalogManager . debug . message ( 3 , "resolveURI(" + uri + ")" ) ; uri = normalizeURI ( uri ) ; if ( uri != null && uri . startsWith ( "urn:publicid:" ) ) { uri = PublicId . decodeURN ( uri ) ; return resolvePublic ( uri , null ) ; } // If there ' s a URI entry in this catalog , use it
if ( uri != null ) { String resolved = resolveLocalURI ( uri ) ; if ( resolved != null ) { return resolved ; } } // Otherwise , look in the subordinate catalogs
return resolveSubordinateCatalogs ( URI , null , null , uri ) ;


signature:
public class Catalog { /** * Return the applicable URI in this catalog .
 * < p > If a URI entry exists in the catalog file
 * for the URI specified , return the mapped value . < / p >
 * @ param uri The URI to locate in the catalog
 * @ return The mapped URI or null
 * @ throws MalformedURLException
 * @ throws IOException */
protected String resolveLocalURI ( String uri ) throws MalformedURLException , IOException { } }

implementation:
Enumeration enumt = catalogEntries . elements ( ) ; while ( enumt . hasMoreElements ( ) ) { CatalogEntry e = ( CatalogEntry ) enumt . nextElement ( ) ; if ( e . getEntryType ( ) == URI && ( e . getEntryArg ( 0 ) . equals ( uri ) ) ) { return e . getEntryArg ( 1 ) ; } } // If there ' s a REWRITE _ URI entry in this catalog , use it
enumt = catalogEntries . elements ( ) ; String startString = null ; String prefix = null ; while ( enumt . hasMoreElements ( ) ) { CatalogEntry e = ( CatalogEntry ) enumt . nextElement ( ) ; if ( e . getEntryType ( ) == REWRITE_URI ) { String p = e . getEntryArg ( 0 ) ; if ( p . length ( ) <= uri . length ( ) && p . equals ( uri . substring ( 0 , p . length ( ) ) ) ) { // Is this the longest prefix ?
if ( startString == null || p . length ( ) > startString . length ( ) ) { startString = p ; prefix = e . getEntryArg ( 1 ) ; } } } if ( prefix != null ) { // return the systemId with the new prefix
return prefix + uri . substring ( startString . length ( ) ) ; } } // If there ' s a DELEGATE _ URI entry in this catalog , use it
enumt = catalogEntries . elements ( ) ; Vector delCats = new Vector ( ) ; while ( enumt . hasMoreElements ( ) ) { CatalogEntry e = ( CatalogEntry ) enumt . nextElement ( ) ; if ( e . getEntryType ( ) == DELEGATE_URI ) { String p = e . getEntryArg ( 0 ) ; if ( p . length ( ) <= uri . length ( ) && p . equals ( uri . substring ( 0 , p . length ( ) ) ) ) { // delegate this match to the other catalog
delCats . addElement ( e . getEntryArg ( 1 ) ) ; } } } if ( delCats . size ( ) > 0 ) { Enumeration enumCats = delCats . elements ( ) ; if ( catalogManager . debug . getDebug ( ) > 1 ) { catalogManager . debug . message ( 2 , "Switching to delegated catalog(s):" ) ; while ( enumCats . hasMoreElements ( ) ) { String delegatedCatalog = ( String ) enumCats . nextElement ( ) ; catalogManager . debug . message ( 2 , "\t" + delegatedCatalog ) ; } } Catalog dcat = newCatalog ( ) ; enumCats = delCats . elements ( ) ; while ( enumCats . hasMoreElements ( ) ) { String delegatedCatalog = ( String ) enumCats . nextElement ( ) ; dcat . parseCatalog ( delegatedCatalog ) ; } return dcat . resolveURI ( uri ) ; } return null ;


signature:
public class Catalog { /** * Search the subordinate catalogs , in order , looking for a match .
 * < p > This method searches the Catalog and returns the system
 * identifier 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 ) . This parameter is
 * overloaded for the URI entry type .
 * @ 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 . */
protected synchronized String resolveSubordinateCatalogs ( int entityType , String entityName , String publicId , String systemId ) throws MalformedURLException , IOException { } }

implementation:
for ( int catPos = 0 ; catPos < catalogs . size ( ) ; catPos ++ ) { Catalog c = null ; try { c = ( Catalog ) catalogs . elementAt ( catPos ) ; } catch ( ClassCastException e ) { String catfile = ( String ) catalogs . elementAt ( catPos ) ; c = 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 ) ; } else if ( entityType == DOCUMENT ) { resolved = c . resolveDocument ( ) ; } else if ( entityType == ENTITY ) { resolved = c . resolveEntity ( entityName , publicId , systemId ) ; } else if ( entityType == NOTATION ) { resolved = c . resolveNotation ( entityName , publicId , systemId ) ; } else if ( entityType == PUBLIC ) { resolved = c . resolvePublic ( publicId , systemId ) ; } else if ( entityType == SYSTEM ) { resolved = c . resolveSystem ( systemId ) ; } else if ( entityType == URI ) { resolved = c . resolveURI ( systemId ) ; } if ( resolved != null ) { return resolved ; } } return null ;


signature:
public class Catalog { /** * Construct an absolute URI from a relative one , using the current
 * base URI .
 * @ param sysid The ( possibly relative ) system identifier
 * @ return The system identifier made absolute with respect to the
 * current { @ link # base } . */
protected String makeAbsolute ( String sysid ) { } }

implementation: URL local = null ; sysid = fixSlashes ( sysid ) ; try { local = new URL ( base , sysid ) ; } catch ( MalformedURLException e ) { catalogManager . debug . message ( 1 , "Malformed URL on system identifier" , sysid ) ; } if ( local != null ) { return local . toString ( ) ; } else { return sysid ; }


signature:
public class Catalog { /** * Perform character normalization on a URI reference .
 * @ param uriref The URI reference
 * @ return The normalized URI reference . */
protected String normalizeURI ( String uriref ) { } }

implementation:
String newRef = "" ; byte [ ] bytes ; if ( uriref == null ) { return null ; } try { bytes = uriref . getBytes ( "UTF-8" ) ; } catch ( UnsupportedEncodingException uee ) { // this can ' t happen
catalogManager . debug . message ( 1 , "UTF-8 is an unsupported encoding!?" ) ; return uriref ; } for ( int count = 0 ; count < bytes . length ; count ++ ) { int ch = bytes [ count ] & 0xFF ; if ( ( ch <= 0x20 ) // ctrl
|| ( ch > 0x7F ) // high ascii
|| ( ch == 0x22 ) || ( ch == 0x3C ) || ( ch == 0x3E ) || ( ch == 0x5C ) || ( ch == 0x5E ) || ( ch == 0x60 ) || ( ch == 0x7B ) || ( ch == 0x7C ) || ( ch == 0x7D ) || ( ch == 0x7F ) ) { newRef += encodedByte ( ch ) ; } else { newRef += ( char ) bytes [ count ] ; } } return newRef ;


signature:
public class Catalog { /** * Perform % - encoding on a single byte .
 * @ param b The 8 - bit integer that represents th byte . ( Bytes are signed
 * but encoding needs to look at the bytes unsigned . )
 * @ return The % - encoded string for the byte in question . */
protected String encodedByte ( int b ) { } }

implementation: String hex = Integer . toHexString ( b ) . toUpperCase ( ) ; if ( hex . length ( ) < 2 ) { return "%0" + hex ; } else { return "%" + hex ; }


signature:
public class Catalog { /** * Add to the current list of delegated catalogs .
 * < p > This method always constructs the { @ link # localDelegate }
 * vector so that it is ordered by length of partial
 * public identifier . < / p >
 * @ param entry The DELEGATE catalog entry */
protected void addDelegate ( CatalogEntry entry ) { } }

implementation:
int pos = 0 ; String partial = entry . getEntryArg ( 0 ) ; Enumeration local = localDelegate . elements ( ) ; while ( local . hasMoreElements ( ) ) { CatalogEntry dpe = ( CatalogEntry ) local . nextElement ( ) ; String dp = dpe . getEntryArg ( 0 ) ; if ( dp . equals ( partial ) ) { // we already have this prefix
return ; } if ( dp . length ( ) > partial . length ( ) ) { pos ++ ; } if ( dp . length ( ) < partial . length ( ) ) { break ; } } // now insert partial into the vector at [ pos ]
if ( localDelegate . size ( ) == 0 ) { localDelegate . addElement ( entry ) ; } else { localDelegate . insertElementAt ( entry , pos ) ; }


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

implementation: Socket s = new Socket ( host , port ) ; s . setSoTimeout ( 1000 ) ; TimeoutSocket ts = new TimeoutSocket ( s ) ; return ts ;


signature:
public class IntArrayEditor { /** * Build a int [ ] from comma or eol seperated elements */
public void setAsText ( final String text ) { } }

implementation: StringTokenizer stok = new StringTokenizer ( text , ",\r\n" ) ; int [ ] theValue = new int [ stok . countTokens ( ) ] ; int i = 0 ; while ( stok . hasMoreTokens ( ) ) { theValue [ i ++ ] = Integer . decode ( stok . nextToken ( ) ) . intValue ( ) ; } setValue ( theValue ) ;


signature:
public class SoftValueRef { /** * Safely create a new SoftValueRef
 * @ param < K > the key type
 * @ param < V > the value type
 * @ param key the key
 * @ param val the value
 * @ param q the reference queue
 * @ return the reference or null if the value is null */
static < K , V > SoftValueRef < K , V > create ( K key , V val , ReferenceQueue < V > q ) { } }

implementation: if ( val == null ) return null ; else return new SoftValueRef < K , V > ( key , val , q ) ;


signature:
public class PropertiesEditor { /** * Returns a Properties object initialized with current getAsText value
 * interpretted as a . properties file contents . This replaces any
 * references of the form $ { x } with the corresponding system property .
 * @ return a Properties object
 * @ throws NestedRuntimeException An IOException occured . */
public Object getValue ( ) { } }

implementation:
try { // Load the current key = value properties into a Properties object
String propsText = getAsText ( ) ; Properties rawProps = new Properties ( System . getProperties ( ) ) ; ByteArrayInputStream bais = new ByteArrayInputStream ( propsText . getBytes ( ) ) ; rawProps . load ( bais ) ; // Now go through the rawProps and replace any $ { x } refs
Properties props = new Properties ( ) ; Iterator keys = rawProps . keySet ( ) . iterator ( ) ; while ( keys . hasNext ( ) ) { String key = ( String ) keys . next ( ) ; String value = rawProps . getProperty ( key ) ; String value2 = StringPropertyReplacer . replaceProperties ( value , rawProps ) ; props . setProperty ( key , value2 ) ; } rawProps . clear ( ) ; return props ; } catch ( IOException e ) { throw new NestedRuntimeException ( e ) ; }


signature:
public class ThrowableHandler { /** * Fire onThrowable to all registered listeners .
 * @ param type The type off the throwable .
 * @ param t Throwable */
protected static void fireOnThrowable ( int type , Throwable t ) { } }

implementation: Object [ ] list = listeners . toArray ( ) ; for ( int i = 0 ; i < list . length ; i ++ ) { ( ( ThrowableListener ) list [ i ] ) . onThrowable ( type , t ) ; }


signature:
public class ThrowableHandler { /** * Add a throwable that is to be handled .
 * @ param type The type off the throwable .
 * @ param t Throwable to be handled . */
public static void add ( int type , Throwable t ) { } }

implementation:
// don ' t add null throwables
if ( t == null ) return ; try { fireOnThrowable ( type , t ) ; } catch ( Throwable bad ) { // don ' t let these propagate , that could introduce unwanted side - effects
System . err . println ( "Unable to handle throwable: " + t + " because of:" ) ; bad . printStackTrace ( ) ; }


signature:
public class LazyList { /** * Create the list implementation
 * @ return the list */
private List < T > createImplementation ( ) { } }

implementation: if ( delegate instanceof ArrayList == false ) return new ArrayList < T > ( delegate ) ; return delegate ;


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

implementation: boolean added = false ; if ( ! list . contains ( obj ) ) { added = list . add ( obj ) ; } return added ;


signature:
public class QueuedClientSocketFactory { /** * Create a server socket on the specified port ( port 0 indicates
 * an anonymous port ) .
 * @ param port the port number
 * @ return the server socket on the specified port
 * @ exception IOException if an I / O error occurs during server socket
 * creation
 * @ since 1.2 */
public Socket createSocket ( String host , int port ) throws IOException { } }

implementation: try { permits . acquire ( ) ; return new Socket ( host , port ) ; } catch ( InterruptedException ex ) { throw new IOException ( "Failed to acquire FIFOSemaphore for ClientSocketFactory" ) ; } finally { permits . release ( ) ; }


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

implementation: InetAddress addr = null ; if ( bindAddress != null ) addr = bindAddress ; else addr = InetAddress . getByName ( host ) ; Socket s = new Socket ( addr , port ) ; return s ;


signature:
public class TimerTask { /** * A TimerTask is less than another if it will be scheduled before .
 * @ throws ClassCastException if other is not a TimerTask , according to the Comparable contract */
public int compareTo ( Object other ) { } }

implementation: if ( other == this ) return 0 ; TimerTask t = ( TimerTask ) other ; long diff = getNextExecutionTime ( ) - t . getNextExecutionTime ( ) ; return ( int ) diff ;


signature:
public class InetAddressEditor { /** * Returns a InetAddress for the input object converted to a string .
 * @ return an InetAddress
 * @ throws NestedRuntimeException An UnknownHostException occured . */
public Object getValue ( ) { } }

implementation:
try { String text = getAsText ( ) ; if ( text == null ) { return null ; } if ( text . startsWith ( "/" ) ) { // seems like localhost sometimes will look like :
// /127.0.0.1 and the getByNames barfs on the slash - JGH
text = text . substring ( 1 ) ; } return InetAddress . getByName ( StringPropertyReplacer . replaceProperties ( text ) ) ; } catch ( UnknownHostException e ) { throw new NestedRuntimeException ( e ) ; }


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

implementation: boolean success = false ; for ( int i = 0 ; i < suffixes . length && ! success ; i ++ ) { if ( ignoreCase ) success = file . getName ( ) . toLowerCase ( ) . endsWith ( suffixes [ i ] ) ; else success = file . getName ( ) . endsWith ( suffixes [ i ] ) ; } return success ;


signature:
public class CachedList { /** * Dereference the object at the given index . */
private Object getObject ( final int index ) { } }

implementation: Object obj = list . get ( index ) ; return Objects . deref ( obj ) ;


signature:
public class CachedList { /** * Replaces the element at the specified position in this list with the
 * specified element .
 * @ param index Index of element to replace .
 * @ param obj Element to be stored at the specified postion .
 * @ return The previous element at the given index . */
public Object set ( final int index , final Object obj ) { } }

implementation: maintain ( ) ; SoftObject soft = SoftObject . create ( obj , queue ) ; soft = ( SoftObject ) list . set ( index , soft ) ; return Objects . deref ( soft ) ;


signature:
public class CachedList { /** * Inserts the specified element at the specified position in this list
 * ( optional operation ) . Shifts the element currently at that position
 * ( if any ) and any subsequent elements to the right ( adds one to their
 * indices ) .
 * @ param index Index at which the specified element is to be inserted .
 * @ param obj Element to be inserted . */
public void add ( final int index , final Object obj ) { } }

implementation: maintain ( ) ; SoftObject soft = SoftObject . create ( obj , queue ) ; list . add ( index , soft ) ;


signature:
public class CachedList { /** * Removes the element at the specified position in this list ( optional
 * operation ) . Shifts any subsequent elements to the left ( subtracts one
 * from their indices ) . Returns the element that was removed from the list .
 * @ param index The index of the element to remove .
 * @ return The element previously at the specified position . */
public Object remove ( final int index ) { } }

implementation: maintain ( ) ; Object obj = list . remove ( index ) ; return Objects . deref ( obj ) ;


signature:
public class CachedList { /** * Maintains the collection by removing garbage collected objects . */
private void maintain ( ) { } }

implementation:
SoftObject obj ; int count = 0 ; while ( ( obj = ( SoftObject ) queue . poll ( ) ) != null ) { count ++ ; list . remove ( obj ) ; } if ( count != 0 ) { // some temporary debugging fluff
System . err . println ( "vm reclaimed " + count + " objects" ) ; }


signature:
public class CatalogEntry { /** * Adds a new catalog entry type .
 * @ param name The name of the catalog entry type . This must be
 * unique among all types and is case - sensitive . ( Adding a duplicate
 * name effectively replaces the old type with the new type . )
 * @ param numArgs The number of arguments that this entry type
 * is required to have . There is no provision for variable numbers
 * of arguments .
 * @ return The type for the new entry . */
public static int addEntryType ( String name , int numArgs ) { } }

implementation: entryTypes . put ( name , new Integer ( nextEntry ) ) ; entryArgs . add ( nextEntry , new Integer ( numArgs ) ) ; nextEntry ++ ; return nextEntry - 1 ;


signature:
public class CatalogEntry { /** * Lookup an entry type
 * @ param name The name of the catalog entry type .
 * @ return The type of the catalog entry with the specified name .
 * @ throws CatalogException for any error */
public static int getEntryType ( String name ) throws CatalogException { } }

implementation: if ( ! entryTypes . containsKey ( name ) ) { throw new CatalogException ( CatalogException . INVALID_ENTRY_TYPE ) ; } Integer iType = ( Integer ) entryTypes . get ( name ) ; if ( iType == null ) { throw new CatalogException ( CatalogException . INVALID_ENTRY_TYPE ) ; } return iType . intValue ( ) ;


signature:
public class CatalogEntry { /** * Find out how many arguments an entry is required to have .
 * @ param type A valid catalog entry type .
 * @ return The number of arguments that entry type is required to have .
 * @ throws CatalogException for any error */
public static int getEntryArgCount ( int type ) throws CatalogException { } }

implementation: try { Integer iArgs = ( Integer ) entryArgs . get ( type ) ; return iArgs . intValue ( ) ; } catch ( ArrayIndexOutOfBoundsException e ) { throw new CatalogException ( CatalogException . INVALID_ENTRY_TYPE ) ; }


signature:
public class CatalogEntry { /** * Get an entry argument .
 * @ param argNum The argument number ( arguments are numbered from 0 ) .
 * @ return The specified argument or null if an invalid argNum is
 * provided . */
public String getEntryArg ( int argNum ) { } }

implementation: try { String arg = ( String ) args . get ( argNum ) ; return arg ; } catch ( ArrayIndexOutOfBoundsException e ) { return null ; }


signature:
public class Heap { /** * Inserts the given element in this heap .
 * @ param obj
 * @ see # extract */
public void insert ( Object obj ) { } }

implementation:
int length = m_nodes . length ; // Expand if necessary
if ( m_count == length ) { Object [ ] newNodes = new Object [ length + length ] ; System . arraycopy ( m_nodes , 0 , newNodes , 0 , length ) ; m_nodes = newNodes ; } // Be cur _ slot the first unused slot index ; be par _ slot its parent index .
// Start from cur _ slot and walk up the tree comparing the object to
// insert with the object at par _ slot ; if it ' s smaller move down the object at par _ slot ,
// otherwise cur _ slot is the index where insert the object . If not done ,
// shift up the tree so that now cur _ slot is the old par _ slot and
// par _ slot is the parent index of the new cur _ slot ( so the grand - parent
// index of the old cur _ slot ) and compare again .
int k = m_count ; while ( k > 0 ) { int par = parent ( k ) ; if ( compare ( obj , m_nodes [ par ] ) < 0 ) { m_nodes [ k ] = m_nodes [ par ] ; k = par ; } else break ; } m_nodes [ k ] = obj ; ++ m_count ;


signature:
public class Heap { /** * Removes and returns the least element of this heap .
 * @ return the extracted object
 * @ see # insert
 * @ see # peek */
public Object extract ( ) { } }

implementation:
if ( m_count < 1 ) { return null ; } else { int length = m_nodes . length >> 1 ; // Shrink if necessary
if ( length > 5 && m_count < ( length >> 1 ) ) { Object [ ] newNodes = new Object [ length ] ; System . arraycopy ( m_nodes , 0 , newNodes , 0 , length ) ; m_nodes = newNodes ; } int k = 0 ; Object ret = m_nodes [ k ] ; -- m_count ; Object last = m_nodes [ m_count ] ; for ( ; ; ) { int l = left ( k ) ; if ( l >= m_count ) { break ; } else { int r = right ( k ) ; int child = ( r >= m_count || compare ( m_nodes [ l ] , m_nodes [ r ] ) < 0 ) ? l : r ; if ( compare ( last , m_nodes [ child ] ) > 0 ) { m_nodes [ k ] = m_nodes [ child ] ; k = child ; } else { break ; } } } m_nodes [ k ] = last ; m_nodes [ m_count ] = null ; return ret ; }


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

implementation: if ( PropertyEditors . isNull ( text , false , false ) ) { setValue ( null ) ; return ; } Object newValue = text . getBytes ( ) ; setValue ( newValue ) ;


signature:
public class ContextClassLoaderSwitcher { /** * Set the context classloader for the given thread
 * @ param thread the thread
 * @ param cl the new context classloader */
public void setContextClassLoader ( final Thread thread , final ClassLoader cl ) { } }

implementation: AccessController . doPrivileged ( new PrivilegedAction ( ) { public Object run ( ) { thread . setContextClassLoader ( cl ) ; return null ; } } ) ;


signature:
public class TimeoutPriorityQueueImpl { /** * A new node has been added at index < code > index < / code > .
 * Normalize the tree by moving the new node up the tree .
 * @ return true if the tree was modified . */
private boolean normalizeUp ( int index ) { } }

implementation:
// INV : assertExpr ( index > 0 ) ;
// INV : assertExpr ( index < = size ) ;
// INV : assertExpr ( queue [ index ] ! = null ) ;
if ( index == 1 ) return false ; // at root
boolean ret = false ; long t = queue [ index ] . time ; int p = index >> 1 ; while ( queue [ p ] . time > t ) { // INV : assertExpr ( queue [ index ] . time = = t ) ;
swap ( p , index ) ; ret = true ; if ( p == 1 ) break ; // at root
index = p ; p >>= 1 ; } return ret ;


signature:
public class TimeoutPriorityQueueImpl { /** * Swap two nodes in the tree .
 * @ param a the first index
 * @ param b the second index */
private void swap ( int a , int b ) { } }

implementation:
// INV : assertExpr ( a > 0 ) ;
// INV : assertExpr ( a < = size ) ;
// INV : assertExpr ( b > 0 ) ;
// INV : assertExpr ( b < = size ) ;
// INV : assertExpr ( queue [ a ] ! = null ) ;
// INV : assertExpr ( queue [ b ] ! = null ) ;
// INV : assertExpr ( queue [ a ] . index = = a ) ;
// INV : assertExpr ( queue [ b ] . index = = b ) ;
TimeoutExtImpl temp = queue [ a ] ; queue [ a ] = queue [ b ] ; queue [ a ] . index = a ; queue [ b ] = temp ; queue [ b ] . index = b ;


signature:
public class TimeoutPriorityQueueImpl { /** * Remove a node from the tree and normalize .
 * @ param index the index in the queue
 * @ return the removed node . */
private TimeoutExtImpl removeNode ( int index ) { } }

implementation:
// INV : assertExpr ( index > 0 ) ;
// INV : assertExpr ( index < = size ) ;
TimeoutExtImpl res = queue [ index ] ; // INV : assertExpr ( res ! = null ) ;
// INV : assertExpr ( res . index = = index ) ;
if ( index == size ) { -- size ; queue [ index ] = null ; return res ; } swap ( index , size ) ; // Exchange removed node with last leaf node
-- size ; // INV : assertExpr ( res . index = = size + 1 ) ;
queue [ res . index ] = null ; if ( normalizeUp ( index ) ) return res ; // Node moved up , so it shouldn ' t move down
long t = queue [ index ] . time ; int c = index << 1 ; while ( c <= size ) { // INV : assertExpr ( q [ index ] . time = = t ) ;
TimeoutExtImpl l = queue [ c ] ; // INV : assertExpr ( l ! = null ) ;
// INV : assertExpr ( l . index = = c ) ;
if ( c + 1 <= size ) { // two children , swap with smallest
TimeoutExtImpl r = queue [ c + 1 ] ; // INV : assertExpr ( r ! = null ) ;
// INV : assertExpr ( r . index = = c + 1 ) ;
if ( l . time <= r . time ) { if ( t <= l . time ) break ; // done
swap ( index , c ) ; index = c ; } else { if ( t <= r . time ) break ; // done
swap ( index , c + 1 ) ; index = c + 1 ; } } else { // one child
if ( t <= l . time ) break ; // done
swap ( index , c ) ; index = c ; } c = index << 1 ; } return res ;


signature:
public class TimeoutPriorityQueueImpl { /** * Recursive cleanup of a TimeoutImpl
 * @ return null */
private TimeoutExtImpl cleanupTimeoutExtImpl ( TimeoutExtImpl timeout ) { } }

implementation: if ( timeout != null ) timeout . target = null ; return null ;


signature:
public class DelegatingClassLoader { /** * Load a class , by asking the parent
 * @ param className the class name to load
 * @ param resolve whether to link the class
 * @ return the loaded class
 * @ throws ClassNotFoundException when the class could not be found */
protected Class < ? > loadClass ( String className , boolean resolve ) throws ClassNotFoundException { } }

implementation:
// Revert to standard rules
if ( standard ) return super . loadClass ( className , resolve ) ; // Ask the parent
Class < ? > clazz = null ; try { clazz = parent . loadClass ( className ) ; } catch ( ClassNotFoundException e ) { // Not found in parent ,
// maybe it is a proxy registered against this classloader ?
clazz = findLoadedClass ( className ) ; if ( clazz == null ) throw e ; } // Link the class
if ( resolve ) resolveClass ( clazz ) ; return clazz ;


signature:
public class URLStreamHandlerFactory { /** * Preload the JBoss specific protocol handlers , so that URL knows about
 * them even if the handler factory is changed . */
@ SuppressWarnings ( "unused" ) public static void preload ( ) { } }

implementation: for ( int i = 0 ; i < PROTOCOLS . length ; i ++ ) { try { URL url = new URL ( PROTOCOLS [ i ] , "" , - 1 , "" ) ; log . trace ( "Loaded protocol: " + PROTOCOLS [ i ] ) ; } catch ( Exception e ) { log . warn ( "Failed to load protocol: " + PROTOCOLS [ i ] , e ) ; } }


signature:
public class URLStreamHandlerFactory { /** * Search the handlerPkgs for URLStreamHandler classes matching the
 * pkg + protocol + " . Handler " naming convention .
 * @ param protocol The protocol to create a stream handler for
 * @ return The protocol handler or null if not found */
public URLStreamHandler createURLStreamHandler ( final String protocol ) { } }

implementation:
// Check the handler map
URLStreamHandler handler = ( URLStreamHandler ) handlerMap . get ( protocol ) ; if ( handler != null ) return handler ; // Validate that createURLStreamHandler is not recursing
String prevProtocol = ( String ) createURLStreamHandlerProtocol . get ( ) ; if ( prevProtocol != null && prevProtocol . equals ( protocol ) ) return null ; createURLStreamHandlerProtocol . set ( protocol ) ; // See if the handler pkgs definition has changed
checkHandlerPkgs ( ) ; // Search the handlerPkgs for a matching protocol handler
ClassLoader ctxLoader = Thread . currentThread ( ) . getContextClassLoader ( ) ; for ( int p = 0 ; p < handlerPkgs . length ; p ++ ) { try { // Form the standard protocol handler class name
String classname = handlerPkgs [ p ] + "." + protocol + ".Handler" ; Class < ? > type = null ; try { type = ctxLoader . loadClass ( classname ) ; } catch ( ClassNotFoundException e ) { // Try our class loader
type = Class . forName ( classname ) ; } if ( type != null ) { handler = ( URLStreamHandler ) type . newInstance ( ) ; handlerMap . put ( protocol , handler ) ; log . trace ( "Found protocol:" + protocol + " handler:" + handler ) ; } } catch ( Throwable ignore ) { } } createURLStreamHandlerProtocol . set ( null ) ; return handler ;


signature:
public class URLStreamHandlerFactory { /** * See if the java . protocol . handler . pkgs system property has changed
 * and if it has , parse it to update the handlerPkgs array . */
private synchronized void checkHandlerPkgs ( ) { } }

implementation:
String handlerPkgsProp = System . getProperty ( "java.protocol.handler.pkgs" ) ; if ( handlerPkgsProp != null && handlerPkgsProp . equals ( lastHandlerPkgs ) == false ) { // Update the handlerPkgs [ ] from the handlerPkgsProp
StringTokenizer tokeninzer = new StringTokenizer ( handlerPkgsProp , "|" ) ; ArrayList < String > tmp = new ArrayList < String > ( ) ; while ( tokeninzer . hasMoreTokens ( ) ) { String pkg = tokeninzer . nextToken ( ) . intern ( ) ; if ( tmp . contains ( pkg ) == false ) tmp . add ( pkg ) ; } // Include the JBoss default protocol handler pkg
if ( tmp . contains ( PACKAGE_PREFIX ) == false ) tmp . add ( PACKAGE_PREFIX ) ; handlerPkgs = new String [ tmp . size ( ) ] ; tmp . toArray ( handlerPkgs ) ; lastHandlerPkgs = handlerPkgsProp ; }


signature:
public class ClassEditor { /** * Returns a Class for the input object converted to a string .
 * @ return a Class object
 * @ throws NestedRuntimeException Failed to create Class instance . */
public Object getValue ( ) { } }

implementation: try { ClassLoader loader = Thread . currentThread ( ) . getContextClassLoader ( ) ; String classname = getAsText ( ) ; Class < ? > type = loader . loadClass ( classname ) ; return type ; } catch ( Exception e ) { throw new NestedRuntimeException ( e ) ; }


signature:
public class LazySet { /** * Create the set implementation
 * @ return the set */
private Set < T > createImplementation ( ) { } }

implementation: if ( delegate instanceof HashSet == false ) return new HashSet < T > ( delegate ) ; return delegate ;


signature:
public class Streams { /** * Attempt to close an array of < tt > InputStream < / tt > s .
 * @ param streams Array of < tt > InputStream < / tt > s to attempt to close .
 * @ return < tt > True < / tt > if all streams were closed , or < tt > false < / tt >
 * if an exception was thrown . */
public static boolean close ( final InputStream [ ] streams ) { } }

implementation: boolean success = true ; for ( int i = 0 ; i < streams . length ; i ++ ) { boolean rv = close ( streams [ i ] ) ; if ( ! rv ) success = false ; } return success ;


signature:
public class OASISXMLCatalogReader { /** * Are we in an extension namespace ?
 * @ return true if the current stack of open namespaces includes
 * an extension namespace . */
protected boolean inExtensionNamespace ( ) { } }

implementation: boolean inExtension = false ; Enumeration elements = namespaceStack . elements ( ) ; while ( ! inExtension && elements . hasMoreElements ( ) ) { String ns = ( String ) elements . nextElement ( ) ; if ( ns == null ) { inExtension = true ; } else { inExtension = ( ! ns . equals ( tr9401NamespaceName ) && ! ns . equals ( namespaceName ) ) ; } } return inExtension ;


signature:
public class OASISXMLCatalogReader { /** * The SAX < code > startDocument < / code > method does nothing . */
public void startDocument ( ) throws SAXException { } }

implementation: baseURIStack . push ( catalog . getCurrentBase ( ) ) ; overrideStack . push ( catalog . getDefaultOverride ( ) ) ; return ;


signature:
public class OASISXMLCatalogReader { /** * 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:
int entryType = - 1 ; Vector entryArgs = new Vector ( ) ; namespaceStack . push ( namespaceURI ) ; boolean inExtension = inExtensionNamespace ( ) ; if ( namespaceURI != null && namespaceName . equals ( namespaceURI ) && ! inExtension ) { // This is an 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 ( "catalog" ) || localName . equals ( "group" ) ) && atts . getValue ( "prefer" ) != null ) { String override = atts . getValue ( "prefer" ) ; if ( override . equals ( "public" ) ) { override = "yes" ; } else if ( override . equals ( "system" ) ) { override = "no" ; } else { debug . message ( 1 , "Invalid prefer: must be 'system' or 'public'" , localName ) ; override = catalog . getDefaultOverride ( ) ; } entryType = Catalog . OVERRIDE ; entryArgs . add ( override ) ; overrideStack . push ( override ) ; debug . message ( 4 , "override" , override ) ; 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 (override)" , localName ) ; } } entryType = - 1 ; entryArgs = new Vector ( ) ; } else { overrideStack . push ( overrideStack . peek ( ) ) ; } if ( localName . equals ( "delegatePublic" ) ) { if ( checkAttributes ( atts , "publicIdStartString" , "catalog" ) ) { entryType = Catalog . DELEGATE_PUBLIC ; entryArgs . add ( atts . getValue ( "publicIdStartString" ) ) ; entryArgs . add ( atts . getValue ( "catalog" ) ) ; debug . message ( 4 , "delegatePublic" , PublicId . normalize ( atts . getValue ( "publicIdStartString" ) ) , atts . getValue ( "catalog" ) ) ; } } else if ( localName . equals ( "delegateSystem" ) ) { if ( checkAttributes ( atts , "systemIdStartString" , "catalog" ) ) { entryType = Catalog . DELEGATE_SYSTEM ; entryArgs . add ( atts . getValue ( "systemIdStartString" ) ) ; entryArgs . add ( atts . getValue ( "catalog" ) ) ; debug . message ( 4 , "delegateSystem" , atts . getValue ( "systemIdStartString" ) , atts . getValue ( "catalog" ) ) ; } } else if ( localName . equals ( "delegateURI" ) ) { if ( checkAttributes ( atts , "uriStartString" , "catalog" ) ) { entryType = Catalog . DELEGATE_URI ; entryArgs . add ( atts . getValue ( "uriStartString" ) ) ; entryArgs . add ( atts . getValue ( "catalog" ) ) ; debug . message ( 4 , "delegateURI" , atts . getValue ( "uriStartString" ) , atts . getValue ( "catalog" ) ) ; } } else if ( localName . equals ( "rewriteSystem" ) ) { if ( checkAttributes ( atts , "systemIdStartString" , "rewritePrefix" ) ) { entryType = Catalog . REWRITE_SYSTEM ; entryArgs . add ( atts . getValue ( "systemIdStartString" ) ) ; entryArgs . add ( atts . getValue ( "rewritePrefix" ) ) ; debug . message ( 4 , "rewriteSystem" , atts . getValue ( "systemIdStartString" ) , atts . getValue ( "rewritePrefix" ) ) ; } } else if ( localName . equals ( "rewriteURI" ) ) { if ( checkAttributes ( atts , "uriStartString" , "rewritePrefix" ) ) { entryType = Catalog . REWRITE_URI ; entryArgs . add ( atts . getValue ( "uriStartString" ) ) ; entryArgs . add ( atts . getValue ( "rewritePrefix" ) ) ; debug . message ( 4 , "rewriteURI" , atts . getValue ( "uriStartString" ) , atts . getValue ( "rewritePrefix" ) ) ; } } else if ( localName . equals ( "nextCatalog" ) ) { if ( checkAttributes ( atts , "catalog" ) ) { entryType = Catalog . CATALOG ; entryArgs . add ( atts . getValue ( "catalog" ) ) ; debug . message ( 4 , "nextCatalog" , atts . getValue ( "catalog" ) ) ; } } else if ( localName . equals ( "public" ) ) { if ( checkAttributes ( atts , "publicId" , "uri" ) ) { entryType = Catalog . PUBLIC ; entryArgs . add ( atts . getValue ( "publicId" ) ) ; entryArgs . add ( atts . getValue ( "uri" ) ) ; debug . message ( 4 , "public" , PublicId . normalize ( atts . getValue ( "publicId" ) ) , atts . getValue ( "uri" ) ) ; } } else if ( localName . equals ( "system" ) ) { if ( checkAttributes ( atts , "systemId" , "uri" ) ) { entryType = Catalog . SYSTEM ; entryArgs . add ( atts . getValue ( "systemId" ) ) ; entryArgs . add ( atts . getValue ( "uri" ) ) ; debug . message ( 4 , "system" , atts . getValue ( "systemId" ) , atts . getValue ( "uri" ) ) ; } } else if ( localName . equals ( "uri" ) ) { if ( checkAttributes ( atts , "name" , "uri" ) ) { entryType = Catalog . URI ; entryArgs . add ( atts . getValue ( "name" ) ) ; entryArgs . add ( atts . getValue ( "uri" ) ) ; debug . message ( 4 , "uri" , atts . getValue ( "name" ) , atts . getValue ( "uri" ) ) ; } } else if ( localName . equals ( "catalog" ) ) { // nop , start of catalog
} else if ( localName . equals ( "group" ) ) { // nop , a group
} 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 ) ; } } } } if ( namespaceURI != null && tr9401NamespaceName . equals ( namespaceURI ) && ! inExtension ) { // This is a TR9401 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 ( "doctype" ) ) { entryType = catalog . DOCTYPE ; entryArgs . add ( atts . getValue ( "name" ) ) ; entryArgs . add ( atts . getValue ( "uri" ) ) ; } else if ( localName . equals ( "document" ) ) { entryType = catalog . DOCUMENT ; entryArgs . add ( atts . getValue ( "uri" ) ) ; } else if ( localName . equals ( "dtddecl" ) ) { entryType = catalog . DTDDECL ; entryArgs . add ( atts . getValue ( "publicId" ) ) ; entryArgs . add ( atts . getValue ( "uri" ) ) ; } else if ( localName . equals ( "entity" ) ) { entryType = Catalog . ENTITY ; entryArgs . add ( atts . getValue ( "name" ) ) ; entryArgs . add ( atts . getValue ( "uri" ) ) ; } else if ( localName . equals ( "linktype" ) ) { entryType = Catalog . LINKTYPE ; entryArgs . add ( atts . getValue ( "name" ) ) ; entryArgs . add ( atts . getValue ( "uri" ) ) ; } else if ( localName . equals ( "notation" ) ) { entryType = Catalog . NOTATION ; entryArgs . add ( atts . getValue ( "name" ) ) ; entryArgs . add ( atts . getValue ( "uri" ) ) ; } else if ( localName . equals ( "sgmldecl" ) ) { entryType = Catalog . SGMLDECL ; entryArgs . add ( 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 OASISXMLCatalogReader { /** * The SAX < code > endElement < / code > method does nothing . */
public void endElement ( String namespaceURI , String localName , String qName ) throws SAXException { } }

implementation: int entryType = - 1 ; Vector entryArgs = new Vector ( ) ; boolean inExtension = inExtensionNamespace ( ) ; if ( namespaceURI != null && ! inExtension && ( namespaceName . equals ( namespaceURI ) || tr9401NamespaceName . equals ( namespaceURI ) ) ) { 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 ) ; } } } } if ( namespaceURI != null && namespaceName . equals ( namespaceURI ) && ! inExtension ) { if ( localName . equals ( "catalog" ) || localName . equals ( "group" ) ) { String popOverride = ( String ) overrideStack . pop ( ) ; String override = ( String ) overrideStack . peek ( ) ; if ( ! override . equals ( popOverride ) ) { entryType = catalog . OVERRIDE ; entryArgs . add ( override ) ; overrideStack . push ( override ) ; debug . message ( 4 , "(reset) override" , override ) ; 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 (roverride)" , localName ) ; } } } } } namespaceStack . pop ( ) ; return ;


signature:
public class NotifyingBufferedOutputStream { /** * Checks whether a notification is required and
 * notifies as appropriate
 * @ param result the number of bytes written */
public void checkNotification ( int result ) { } }

implementation:
// Is a notification required ?
chunk += result ; if ( chunk >= chunkSize ) { if ( listener != null ) listener . onStreamNotification ( this , chunk ) ; // Start a new chunk
chunk = 0 ; }


signature:
public class NonSerializableFactory { /** * Lookup a value from the NonSerializableFactory map .
 * @ param key
 * @ return the object bound to key is one exists , null otherwise . */
public static Object lookup ( String key ) { } }

implementation: Object value = wrapperMap . get ( key ) ; return value ;


signature:
public class NonSerializableFactory { /** * Lookup a value from the NonSerializableFactory map .
 * @ param name
 * @ return the object bound to key is one exists , null otherwise . */
public static Object lookup ( Name name ) { } }

implementation: String key = name . toString ( ) ; Object value = wrapperMap . get ( key ) ; return value ;


signature:
public class NonSerializableFactory { /** * A convenience method that simplifies the process of rebinding a
 * non - serializable object into a JNDI context .
 * @ param ctx the JNDI context to rebind to .
 * @ param key the key to use in both the NonSerializableFactory map and JNDI . It
 * must be a valid name for use in ctx . bind ( ) .
 * @ param target the non - Serializable object to bind .
 * @ throws NamingException thrown on failure to rebind key into ctx . */
public static synchronized void rebind ( Context ctx , String key , Object target ) throws NamingException { } }

implementation:
NonSerializableFactory . rebind ( key , target ) ; // Bind a reference to target using NonSerializableFactory as the ObjectFactory
String className = target . getClass ( ) . getName ( ) ; String factory = NonSerializableFactory . class . getName ( ) ; StringRefAddr addr = new StringRefAddr ( "nns" , key ) ; Reference memoryRef = new Reference ( className , addr , factory , null ) ; ctx . rebind ( key , memoryRef ) ;


signature:
public class NonSerializableFactory { /** * A convenience method that simplifies the process of rebinding a
 * non - serializable object into a JNDI context .
 * @ param ctx the JNDI context to rebind to .
 * @ param key the key to use in both the NonSerializableFactory map and JNDI . It
 * must be a valid name for use in ctx . bind ( ) .
 * @ param target the non - Serializable object to bind .
 * @ param createSubcontexts a flag indicating if subcontexts of name should
 * be created if they do not already exist .
 * @ throws NamingException thrown on failure to rebind key into ctx . */
public static synchronized void rebind ( Context ctx , String key , Object target , boolean createSubcontexts ) throws NamingException { } }

implementation: Name name = ctx . getNameParser ( "" ) . parse ( key ) ; if ( createSubcontexts == true && name . size ( ) > 1 ) { int size = name . size ( ) - 1 ; Util . createSubcontext ( ctx , name . getPrefix ( size ) ) ; } rebind ( ctx , key , target ) ;


signature:
public class NonSerializableFactory { /** * A convenience method that simplifies the process of rebinding a
 * non - serializable object into a JNDI context . This version binds the
 * target object into the default IntitialContext using name path .
 * @ param name the name to use as JNDI path name . The key into the
 * NonSerializableFactory map is obtained from the toString ( ) value of name .
 * The name parameter cannot be a 0 length name .
 * @ param target the non - Serializable object to bind .
 * @ param createSubcontexts a flag indicating if subcontexts of name should
 * be created if they do not already exist .
 * @ throws NamingException thrown on failure to rebind key into ctx .
 * @ author Matt Carter */
public static synchronized void rebind ( Name name , Object target , boolean createSubcontexts ) throws NamingException { } }

implementation: String key = name . toString ( ) ; InitialContext ctx = new InitialContext ( ) ; if ( createSubcontexts == true && name . size ( ) > 1 ) { int size = name . size ( ) - 1 ; Util . createSubcontext ( ctx , name . getPrefix ( size ) ) ; } rebind ( ctx , key , target ) ;


signature:
public class NonSerializableFactory { /** * Transform the obj Reference bound into the JNDI namespace into the
 * actual non - Serializable object .
 * @ param obj the object bound in the JNDI namespace . This must be an implementation
 * of javax . naming . Reference with a javax . naming . RefAddr of type " nns " whose
 * content is the String key used to location the non - Serializable object in the
 * NonSerializableFactory map .
 * @ param name ignored .
 * @ param nameCtx ignored .
 * @ param env ignored .
 * @ return the non - Serializable object associated with the obj Reference if one
 * exists , null if one does not . */
public Object getObjectInstance ( Object obj , Name name , Context nameCtx , Hashtable env ) throws Exception { } }

implementation:
// Get the nns value from the Reference obj and use it as the map key
Reference ref = ( Reference ) obj ; RefAddr addr = ref . get ( "nns" ) ; String key = ( String ) addr . getContent ( ) ; Object target = wrapperMap . get ( key ) ; return target ;


signature:
public class Strings { /** * Substitute sub - strings in side of a string .
 * @ param buff String buffer to use for substitution ( buffer is not reset )
 * @ param string String to subst mappings in
 * @ param map Map of from - > to strings
 * @ param beginToken Beginning token
 * @ param endToken Ending token
 * @ return Substituted string */
public static String subst ( final StringBuffer buff , final String string , final Map map , final String beginToken , final String endToken ) { } }

implementation:
int begin = 0 , rangeEnd = 0 ; Range range ; while ( ( range = rangeOf ( beginToken , endToken , string , rangeEnd ) ) != null ) { // append the first part of the string
buff . append ( string . substring ( begin , range . begin ) ) ; // Get the string to replace from the map
String key = string . substring ( range . begin + beginToken . length ( ) , range . end ) ; Object value = map . get ( key ) ; // if mapping does not exist then use empty ;
if ( value == null ) value = EMPTY ; // append the replaced string
buff . append ( value ) ; // update positions
begin = range . end + endToken . length ( ) ; rangeEnd = begin ; } // append the rest of the string
buff . append ( string . substring ( begin , string . length ( ) ) ) ; return buff . toString ( ) ;


signature:
public class Strings { /** * Split up a string into multiple strings based on a delimiter .
 * @ param string String to split up .
 * @ param delim Delimiter .
 * @ param limit Limit the number of strings to split into
 * ( - 1 for no limit ) .
 * @ return Array of strings . */
public static String [ ] split ( final String string , final String delim , final int limit ) { } }

implementation:
// get the count of delim in string , if count is > limit
// then use limit for count . The number of delimiters is less by one
// than the number of elements , so add one to count .
int count = count ( string , delim ) + 1 ; if ( limit > 0 && count > limit ) { count = limit ; } String strings [ ] = new String [ count ] ; int begin = 0 ; for ( int i = 0 ; i < count ; i ++ ) { // get the next index of delim
int end = string . indexOf ( delim , begin ) ; // if the end index is - 1 or if this is the last element
// then use the string ' s length for the end index
if ( end == - 1 || i + 1 == count ) end = string . length ( ) ; // if end is 0 , then the first element is empty
if ( end == 0 ) strings [ i ] = EMPTY ; else strings [ i ] = string . substring ( begin , end ) ; // update the begining index
begin = end + 1 ; } return strings ;


signature:
public class Strings { /** * Convert and join an array of bytes into one string .
 * @ param array Array of objects to join as strings .
 * @ return Converted and joined objects . */
public static String join ( final byte array [ ] ) { } }

implementation: Byte bytes [ ] = new Byte [ array . length ] ; for ( int i = 0 ; i < bytes . length ; i ++ ) { bytes [ i ] = new Byte ( array [ i ] ) ; } return join ( bytes , null ) ;


signature:
public class Strings { /** * The default toString implementation of an object
 * @ param object the object
 * @ param buffer the string builder */
public static final void defaultToString ( JBossStringBuilder buffer , Object object ) { } }

implementation: if ( object == null ) buffer . append ( "null" ) ; else { buffer . append ( object . getClass ( ) . getName ( ) ) ; buffer . append ( '@' ) ; buffer . append ( Integer . toHexString ( System . identityHashCode ( object ) ) ) ; }


signature:
public class Strings { /** * Trim all occurences of the supplied leading character from the given String .
 * @ param str the string to check
 * @ param leadingCharacter the leading character to be trimmed
 * @ return the trimmed String */
public static String trimLeadingCharacter ( String str , final char leadingCharacter ) { } }

implementation: return trimLeadingCharacter ( str , new CharacterChecker ( ) { public boolean isCharacterLegal ( char character ) { return character == leadingCharacter ; } } ) ;


signature:
public class Strings { /** * Trim all occurences of the supplied leading character from the given String .
 * @ param str the string to check
 * @ param checker the character checker
 * @ return the trimmed String */
public static String trimLeadingCharacter ( String str , CharacterChecker checker ) { } }

implementation: if ( hasLength ( str ) == false ) { return str ; } if ( checker == null ) throw new IllegalArgumentException ( "Null character checker" ) ; StringBuffer buf = new StringBuffer ( str ) ; while ( buf . length ( ) > 0 && checker . isCharacterLegal ( buf . charAt ( 0 ) ) ) { buf . deleteCharAt ( 0 ) ; } return buf . toString ( ) ;


signature:
public class BlockingModeEditor { /** * Returns a BlockingMode for the input object converted to a string .
 * @ return a BlockingMode enum instance */
public Object getValue ( ) { } }

implementation: String text = getAsText ( ) ; BlockingMode mode = BlockingMode . toBlockingMode ( text ) ; return mode ;


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

implementation: if ( ignoreCase ) { return name . toLowerCase ( ) . endsWith ( suffix ) ; } else { return name . endsWith ( suffix ) ; }


signature:
public class TimedCachePolicy { /** * Initializes the cache for use . Prior to this the cache has no store . */
public void create ( ) { } }

implementation: if ( threadSafe ) entryMap = Collections . synchronizedMap ( new HashMap ( ) ) ; else entryMap = new HashMap ( ) ; now = System . currentTimeMillis ( ) ;


signature:
public class TimedCachePolicy { /** * Get the cache value for key if it has not expired . If the TimedEntry
 * is expired its destroy method is called and then removed from the cache .
 * @ return the TimedEntry value or the original value if it was not an
 * instance of TimedEntry if key is in the cache , null otherwise . */
public Object get ( Object key ) { } }

implementation:
TimedEntry entry = ( TimedEntry ) entryMap . get ( key ) ; if ( entry == null ) return null ; if ( entry . isCurrent ( now ) == false ) { // Try to refresh the entry
if ( entry . refresh ( ) == false ) { // Failed , remove the entry and return null
entry . destroy ( ) ; entryMap . remove ( key ) ; return null ; } } Object value = entry . getValue ( ) ; return value ;


signature:
public class TimedCachePolicy { /** * Get the cache value for key . This method does not check to see if
 * the entry has expired .
 * @ return the TimedEntry value or the original value if it was not an
 * instancee of TimedEntry if key is in the cache , null otherwise . */
public Object peek ( Object key ) { } }

implementation: TimedEntry entry = ( TimedEntry ) entryMap . get ( key ) ; Object value = null ; if ( entry != null ) value = entry . getValue ( ) ; return value ;


signature:
public class TimedCachePolicy { /** * Insert a value into the cache . In order to have the cache entry
 * reshresh itself value would have to implement TimedEntry and
 * implement the required refresh ( ) method logic .
 * @ param key - the key for the cache entry
 * @ param value - Either an instance of TimedEntry that will be inserted without
 * change , or an abitrary value that will be wrapped in a non - refreshing
 * TimedEntry . */
public void insert ( Object key , Object value ) { } }

implementation:
if ( entryMap . containsKey ( key ) ) throw new IllegalStateException ( "Attempt to insert duplicate entry" ) ; TimedEntry entry = null ; if ( ( value instanceof TimedEntry ) == false ) { // Wrap the value in a DefaultTimedEntry
entry = new DefaultTimedEntry ( defaultLifetime , value ) ; } else { entry = ( TimedEntry ) value ; } entry . init ( now ) ; entryMap . put ( key , entry ) ;


signature:
public class TimedCachePolicy { /** * Remove the entry associated with key and call destroy on the entry
 * if found . */
public void remove ( Object key ) { } }

implementation: TimedEntry entry = ( TimedEntry ) entryMap . remove ( key ) ; if ( entry != null ) entry . destroy ( ) ;


signature:
public class TimedCachePolicy { /** * Remove all entries from the cache . */
public void flush ( ) { } }

implementation:
Map tmpMap = null ; synchronized ( this ) { tmpMap = entryMap ; if ( threadSafe ) entryMap = Collections . synchronizedMap ( new HashMap ( ) ) ; else entryMap = new HashMap ( ) ; } // Notify the entries of their removal
Iterator iter = tmpMap . values ( ) . iterator ( ) ; while ( iter . hasNext ( ) ) { TimedEntry entry = ( TimedEntry ) iter . next ( ) ; entry . destroy ( ) ; } tmpMap . clear ( ) ;


signature:
public class TimedCachePolicy { /** * Get the list of keys for entries that are not expired .
 * @ return A List of the keys corresponding to valid entries */
public List getValidKeys ( ) { } }

implementation: ArrayList validKeys = new ArrayList ( ) ; synchronized ( entryMap ) { Iterator iter = entryMap . entrySet ( ) . iterator ( ) ; while ( iter . hasNext ( ) ) { Map . Entry entry = ( Map . Entry ) iter . next ( ) ; TimedEntry value = ( TimedEntry ) entry . getValue ( ) ; if ( value . isCurrent ( now ) == true ) validKeys . add ( entry . getKey ( ) ) ; } } return validKeys ;


signature:
public class TimedCachePolicy { /** * Set the cache timer resolution
 * @ param resolution - the resolution in seconds of the cache timer . A cache does
 * not query the system time on every get ( ) invocation . Rather the cache
 * updates its notion of the current time every ' resolution ' seconds . */
public synchronized void setResolution ( int resolution ) { } }

implementation: if ( resolution <= 0 ) resolution = 60 ; if ( resolution != this . resolution ) { this . resolution = resolution ; theTimer . cancel ( ) ; theTimer = new ResolutionTimer ( ) ; resolutionTimer . scheduleAtFixedRate ( theTimer , 0 , 1000 * resolution ) ; }


signature:
public class TimedCachePolicy { /** * Get the raw TimedEntry for key without performing any expiration check .
 * @ param key
 * @ return the TimedEntry value associated with key if one exists , null otherwise . */
public TimedEntry peekEntry ( Object key ) { } }

implementation: TimedEntry entry = ( TimedEntry ) entryMap . get ( key ) ; return entry ;


signature:
public class XmlHelper { /** * Returns an iterator over the children of the given element with
 * the given tag name .
 * @ param element The parent element
 * @ param tagName The name of the desired child
 * @ return An interator of children or null if element is null . */
public static Iterator getChildrenByTagName ( Element element , String tagName ) { } }

implementation:
if ( element == null ) return null ; // getElementsByTagName gives the corresponding elements in the whole
// descendance . We want only children
NodeList children = element . getChildNodes ( ) ; ArrayList goodChildren = new ArrayList ( ) ; for ( int i = 0 ; i < children . getLength ( ) ; i ++ ) { Node currentChild = children . item ( i ) ; if ( currentChild . getNodeType ( ) == Node . ELEMENT_NODE && ( ( Element ) currentChild ) . getTagName ( ) . equals ( tagName ) ) { goodChildren . add ( currentChild ) ; } } return goodChildren . iterator ( ) ;


signature:
public class XmlHelper { /** * Gets the child of the specified element having the specified unique
 * name . If there are more than one children elements with the same name
 * and exception is thrown .
 * @ param element The parent element
 * @ param tagName The name of the desired child
 * @ return The named child .
 * @ throws Exception Child was not found or was not unique . */
public static Element getUniqueChild ( Element element , String tagName ) throws Exception { } }

implementation: Iterator goodChildren = getChildrenByTagName ( element , tagName ) ; if ( goodChildren != null && goodChildren . hasNext ( ) ) { Element child = ( Element ) goodChildren . next ( ) ; if ( goodChildren . hasNext ( ) ) { throw new Exception ( "expected only one " + tagName + " tag" ) ; } return child ; } else { throw new Exception ( "expected one " + tagName + " tag" ) ; }


signature:
public class XmlHelper { /** * Gets the child of the specified element having the
 * specified name . If the child with this name doesn ' t exist
 * then null is returned instead .
 * @ param element the parent element
 * @ param tagName the name of the desired child
 * @ return either the named child or null
 * @ throws Exception */
public static Element getOptionalChild ( Element element , String tagName ) throws Exception { } }

implementation: return getOptionalChild ( element , tagName , null ) ;


signature:
public class XmlHelper { /** * Get the content of the given element .
 * @ param element The element to get the content for .
 * @ param defaultStr The default to return when there is no content .
 * @ return The content of the element or the default .
 * @ throws Exception */
public static String getElementContent ( Element element , String defaultStr ) throws Exception { } }

implementation:
if ( element == null ) return defaultStr ; NodeList children = element . getChildNodes ( ) ; String result = "" ; for ( int i = 0 ; i < children . getLength ( ) ; i ++ ) { if ( children . item ( i ) . getNodeType ( ) == Node . TEXT_NODE || children . item ( i ) . getNodeType ( ) == Node . CDATA_SECTION_NODE ) { result += children . item ( i ) . getNodeValue ( ) ; } else if ( children . item ( i ) . getNodeType ( ) == Node . COMMENT_NODE ) { // Ignore comment nodes
} } return result . trim ( ) ;


signature:
public class XmlHelper { /** * Macro to get the content of a unique child element .
 * @ param element The parent element .
 * @ param tagName The name of the desired child .
 * @ return The element content or null .
 * @ throws Exception */
public static String getUniqueChildContent ( Element element , String tagName ) throws Exception { } }

implementation: return getElementContent ( getUniqueChild ( element , tagName ) ) ;


signature:
public class XmlHelper { /** * Macro to get the content of an optional child element .
 * @ param element The parent element .
 * @ param tagName The name of the desired child .
 * @ return The element content or null .
 * @ throws Exception */
public static String getOptionalChildContent ( Element element , String tagName ) throws Exception { } }

implementation: return getElementContent ( getOptionalChild ( element , tagName ) ) ;


signature:
public class BasicThreadPool { /** * ThreadPool - - - - - */
public void stop ( boolean immediate ) { } }

implementation: log . debug ( "stop, immediate=" + immediate ) ; stopped . set ( true ) ; if ( immediate ) executor . shutdownNow ( ) ; else executor . shutdown ( ) ;


signature:
public class BasicThreadPool { /** * This resets the work queue capacity . This requires recreating the
 * work queue and ThreadPoolExecutor , so this needs to be called
 * before doing any work with the pool .
 * @ param size new work queue capacity */
public void setMaximumQueueSize ( int size ) { } }

implementation:
// Reset the executor work queue
ArrayList tmp = new ArrayList ( ) ; queue . drainTo ( tmp ) ; queue = new LinkedBlockingQueue ( size ) ; queue . addAll ( tmp ) ; ThreadFactory tf = executor . getThreadFactory ( ) ; RejectedExecutionHandler handler = executor . getRejectedExecutionHandler ( ) ; long keepAlive = executor . getKeepAliveTime ( TimeUnit . SECONDS ) ; int cs = executor . getCorePoolSize ( ) ; int mcs = executor . getMaximumPoolSize ( ) ; executor = new ThreadPoolExecutor ( cs , mcs , keepAlive , TimeUnit . SECONDS , queue ) ; executor . setThreadFactory ( tf ) ; executor . setRejectedExecutionHandler ( handler ) ;


signature:
public class BasicThreadPool { /** * For backward compatibility with the previous string based mode
 * @ param name - the string form of the mode enum */
public void setBlockingMode ( String name ) { } }

implementation: blockingMode = BlockingMode . toBlockingMode ( name ) ; if ( blockingMode == null ) blockingMode = BlockingMode . ABORT ;


signature:
public class BasicThreadPool { /** * For backward compatibility with the previous string based mode
 * This is needed for microcontainer as it gets confused with overloaded
 * setters .
 * @ param name - the string form of the mode enum */
public void setBlockingModeString ( String name ) { } }


signature:
public class BasicThreadPool { /** * Execute a task
 * @ param wrapper the task wrapper */
protected void execute ( TaskWrapper wrapper ) { } }

implementation: if ( trace ) log . trace ( "execute, wrapper=" + wrapper ) ; try { executor . execute ( wrapper ) ; } catch ( Throwable t ) { wrapper . rejectTask ( new ThreadPoolFullException ( "Error scheduling work: " + wrapper , t ) ) ; }


signature:
public class XCatalogReader { /** * 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:
int entryType = - 1 ; Vector entryArgs = new Vector ( ) ; if ( localName . equals ( "Base" ) ) { entryType = catalog . BASE ; entryArgs . add ( atts . getValue ( "HRef" ) ) ; catalog . getCatalogManager ( ) . debug . message ( 4 , "Base" , atts . getValue ( "HRef" ) ) ; } else if ( localName . equals ( "Delegate" ) ) { entryType = catalog . DELEGATE_PUBLIC ; entryArgs . add ( atts . getValue ( "PublicId" ) ) ; entryArgs . add ( atts . getValue ( "HRef" ) ) ; catalog . getCatalogManager ( ) . debug . message ( 4 , "Delegate" , PublicId . normalize ( atts . getValue ( "PublicId" ) ) , atts . getValue ( "HRef" ) ) ; } else if ( localName . equals ( "Extend" ) ) { entryType = catalog . CATALOG ; entryArgs . add ( atts . getValue ( "HRef" ) ) ; catalog . getCatalogManager ( ) . debug . message ( 4 , "Extend" , atts . getValue ( "HRef" ) ) ; } else if ( localName . equals ( "Map" ) ) { entryType = catalog . PUBLIC ; entryArgs . add ( atts . getValue ( "PublicId" ) ) ; entryArgs . add ( atts . getValue ( "HRef" ) ) ; catalog . getCatalogManager ( ) . debug . message ( 4 , "Map" , PublicId . normalize ( atts . getValue ( "PublicId" ) ) , atts . getValue ( "HRef" ) ) ; } else if ( localName . equals ( "Remap" ) ) { entryType = catalog . SYSTEM ; entryArgs . add ( atts . getValue ( "SystemId" ) ) ; entryArgs . add ( atts . getValue ( "HRef" ) ) ; catalog . getCatalogManager ( ) . debug . message ( 4 , "Remap" , atts . getValue ( "SystemId" ) , atts . getValue ( "HRef" ) ) ; } else if ( localName . equals ( "XMLCatalog" ) ) { // nop , start of catalog
} else { // This is equivalent to an invalid catalog entry type
catalog . getCatalogManager ( ) . 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 ) { catalog . getCatalogManager ( ) . debug . message ( 1 , "Invalid catalog entry type" , localName ) ; } else if ( cex . getExceptionType ( ) == CatalogException . INVALID_ENTRY ) { catalog . getCatalogManager ( ) . debug . message ( 1 , "Invalid catalog entry" , localName ) ; } } }


signature:
public class TimerQueue { /** * Schedule the given TimerTask to be executed after < code > delay < / code >
 * milliseconds .
 * @ param t
 * @ param delay */
public void schedule ( TimerTask t , long delay ) { } }

implementation: if ( t == null ) throw new IllegalArgumentException ( "Can't schedule a null TimerTask" ) ; if ( delay < 0 ) delay = 0 ; t . setNextExecutionTime ( System . currentTimeMillis ( ) + delay ) ; putJob ( t ) ;


signature:
public class TimerQueue { /** * WorkerQueue overrides - - - - - */
protected void putJobImpl ( Executable task ) { } }

implementation: m_heap . insert ( task ) ; ( ( TimerTask ) task ) . setState ( TimerTask . SCHEDULED ) ; notifyAll ( ) ;


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

implementation: Object newValue = Float . valueOf ( text ) ; setValue ( newValue ) ;


signature:
public class Resolver { /** * Cleanup and process a Catalog entry .
 * < p > This method processes each Catalog entry , changing mapped
 * relative system identifiers into absolute ones ( based on the current
 * base URI ) , and maintaining other information about the current
 * catalog . < / p >
 * @ param entry The CatalogEntry to process . */
public void addEntry ( CatalogEntry entry ) { } }

implementation: int type = entry . getEntryType ( ) ; if ( type == URISUFFIX ) { String suffix = normalizeURI ( entry . getEntryArg ( 0 ) ) ; String fsi = makeAbsolute ( normalizeURI ( entry . getEntryArg ( 1 ) ) ) ; entry . setEntryArg ( 1 , fsi ) ; catalogManager . debug . message ( 4 , "URISUFFIX" , suffix , fsi ) ; } else if ( type == SYSTEMSUFFIX ) { String suffix = normalizeURI ( entry . getEntryArg ( 0 ) ) ; String fsi = makeAbsolute ( normalizeURI ( entry . getEntryArg ( 1 ) ) ) ; entry . setEntryArg ( 1 , fsi ) ; catalogManager . debug . message ( 4 , "SYSTEMSUFFIX" , suffix , fsi ) ; } super . addEntry ( entry ) ;


signature:
public class Resolver { /** * Return the applicable URI .
 * < p > If a URI entry exists in the Catalog
 * for the URI specified , return the mapped value . < / p >
 * < p > In the Resolver ( as opposed to the Catalog ) class , if the
 * URI isn ' t found by the usual algorithm , URISUFFIX entries are
 * considered . < / p >
 * < p > URI comparison is case sensitive . < / p >
 * @ param uri The URI to locate in the catalog .
 * @ return The resolved URI .
 * @ throws MalformedURLException The system identifier of a
 * subordinate catalog cannot be turned into a valid URL .
 * @ throws IOException Error reading subordinate catalog file . */
public String resolveURI ( String uri ) throws MalformedURLException , IOException { } }

implementation:
String resolved = super . resolveURI ( uri ) ; if ( resolved != null ) { return resolved ; } Enumeration enumt = catalogEntries . elements ( ) ; while ( enumt . hasMoreElements ( ) ) { CatalogEntry e = ( CatalogEntry ) enumt . nextElement ( ) ; if ( e . getEntryType ( ) == RESOLVER ) { resolved = resolveExternalSystem ( uri , e . getEntryArg ( 0 ) ) ; if ( resolved != null ) { return resolved ; } } else if ( e . getEntryType ( ) == URISUFFIX ) { String suffix = e . getEntryArg ( 0 ) ; String result = e . getEntryArg ( 1 ) ; if ( suffix . length ( ) <= uri . length ( ) && uri . substring ( uri . length ( ) - suffix . length ( ) ) . equals ( suffix ) ) { return result ; } } } // Otherwise , look in the subordinate catalogs
return resolveSubordinateCatalogs ( Catalog . URI , null , null , uri ) ;


signature:
public class Resolver { /** * Return the applicable SYSTEM system identifier , resorting
 * to external RESOLVERs if necessary .
 * < p > If a SYSTEM entry exists in the Catalog
 * for the system ID specified , return the mapped value . < / p >
 * < p > In the Resolver ( as opposed to the Catalog ) class , if the
 * URI isn ' t found by the usual algorithm , SYSTEMSUFFIX entries are
 * considered . < / 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 systemId .
 * @ 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 String resolveSystem ( String systemId ) throws MalformedURLException , IOException { } }

implementation: String resolved = super . resolveSystem ( systemId ) ; if ( resolved != null ) { return resolved ; } Enumeration enumt = catalogEntries . elements ( ) ; while ( enumt . hasMoreElements ( ) ) { CatalogEntry e = ( CatalogEntry ) enumt . nextElement ( ) ; if ( e . getEntryType ( ) == RESOLVER ) { resolved = resolveExternalSystem ( systemId , e . getEntryArg ( 0 ) ) ; if ( resolved != null ) { return resolved ; } } else if ( e . getEntryType ( ) == SYSTEMSUFFIX ) { String suffix = e . getEntryArg ( 0 ) ; String result = e . getEntryArg ( 1 ) ; if ( suffix . length ( ) <= systemId . length ( ) && systemId . substring ( systemId . length ( ) - suffix . length ( ) ) . equals ( suffix ) ) { return result ; } } } return resolveSubordinateCatalogs ( Catalog . SYSTEM , null , null , systemId ) ;