protected String resolveLocalURI ( String uri ) throws MalformedURLException , IOException { 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 ; }
Return the applicable URI in this catalog .