Input: Return all applicable SYSTEM system identifiers in this catalog . [CODESPLIT] private Vector resolveAllLocalSystem ( String systemId ) { Vector map = new Vector ( ) ; String osname = System . getProperty ( "os.name" ) ; boolean windows = ( osname . indexOf ( "Windows" ) >= 0 ) ; Enumeration enumt = catalogEntries . elements ( ) ; while ( enumt . hasMoreElements ( ) ) { CatalogEntry e = ( CatalogEntry ) enumt . nextElement ( ) ; if ( e . getEntryType ( ) == SYSTEM && ( e . getEntryArg ( 0 ) . equals ( systemId ) || ( windows && e . getEntryArg ( 0 ) . equalsIgnoreCase ( systemId ) ) ) ) { map . addElement ( e . getEntryArg ( 1 ) ) ; } } if ( map . size ( ) == 0 ) { return null ; } else { return map ; } }


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


Input: Set the SAXCatalogParser class for the given namespace / root element type . [CODESPLIT] public void setCatalogParser ( String namespaceURI , String rootElement , String parserClass ) { if ( namespaceURI == null ) { namespaceMap . put ( rootElement , parserClass ) ; } else { namespaceMap . put ( "{" + namespaceURI + "}" + rootElement , parserClass ) ; } }


Input: Get the SAXCatalogParser class for the given namespace / root element type . [CODESPLIT] public String getCatalogParser ( String namespaceURI , String rootElement ) { if ( namespaceURI == null ) { return ( String ) namespaceMap . get ( rootElement ) ; } else { return ( String ) namespaceMap . get ( "{" + namespaceURI + "}" + rootElement ) ; } }


Input: Parse an XML Catalog file . [CODESPLIT] public void readCatalog ( Catalog catalog , String fileUrl ) throws MalformedURLException , IOException , CatalogException { URL url = null ; try { url = new URL ( fileUrl ) ; } catch ( MalformedURLException e ) { url = new URL ( "file:///" + fileUrl ) ; } debug = catalog . getCatalogManager ( ) . debug ; try { URLConnection urlCon = url . openConnection ( ) ; readCatalog ( catalog , urlCon . getInputStream ( ) ) ; } catch ( FileNotFoundException e ) { catalog . getCatalogManager ( ) . debug . message ( 1 , "Failed to load catalog, file not found" , url . toString ( ) ) ; } }


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


Input: The SAX <code > startElement< / code > method . [CODESPLIT] public void startElement ( String name , AttributeList atts ) throws SAXException { if ( abandonHope ) { return ; } if ( saxParser == null ) { String prefix = "" ; if ( name . indexOf ( ' ' ) > 0 ) { prefix = name . substring ( 0 , name . indexOf ( ' ' ) ) ; } String localName = name ; if ( localName . indexOf ( ' ' ) > 0 ) { localName = localName . substring ( localName . indexOf ( ' ' ) + 1 ) ; } String namespaceURI = null ; if ( prefix . equals ( "" ) ) { namespaceURI = atts . getValue ( "xmlns" ) ; } else { namespaceURI = atts . getValue ( "xmlns:" + prefix ) ; } String saxParserClass = getCatalogParser ( namespaceURI , localName ) ; if ( saxParserClass == null ) { abandonHope = true ; if ( namespaceURI == null ) { debug . message ( 2 , "No Catalog parser for " + name ) ; } else { debug . message ( 2 , "No Catalog parser for " + "{" + namespaceURI + "}" + name ) ; } return ; } try { saxParser = ( SAXCatalogParser ) Class . forName ( saxParserClass ) . newInstance ( ) ; saxParser . setCatalog ( catalog ) ; saxParser . startDocument ( ) ; saxParser . startElement ( name , atts ) ; } catch ( ClassNotFoundException cnfe ) { saxParser = null ; abandonHope = true ; debug . message ( 2 , cnfe . toString ( ) ) ; } catch ( InstantiationException ie ) { saxParser = null ; abandonHope = true ; debug . message ( 2 , ie . toString ( ) ) ; } catch ( IllegalAccessException iae ) { saxParser = null ; abandonHope = true ; debug . message ( 2 , iae . toString ( ) ) ; } catch ( ClassCastException cce ) { saxParser = null ; abandonHope = true ; debug . message ( 2 , cce . toString ( ) ) ; } } else { saxParser . startElement ( name , atts ) ; } }


Input: The SAX2 <code > startElement< / code > method . [CODESPLIT] public void startElement ( String namespaceURI , String localName , String qName , Attributes atts ) throws SAXException { if ( abandonHope ) { return ; } if ( saxParser == null ) { String saxParserClass = getCatalogParser ( namespaceURI , localName ) ; if ( saxParserClass == null ) { abandonHope = true ; if ( namespaceURI == null ) { debug . message ( 2 , "No Catalog parser for " + localName ) ; } else { debug . message ( 2 , "No Catalog parser for " + "{" + namespaceURI + "}" + localName ) ; } return ; } try { saxParser = ( SAXCatalogParser ) Class . forName ( saxParserClass ) . newInstance ( ) ; saxParser . setCatalog ( catalog ) ; saxParser . startDocument ( ) ; saxParser . startElement ( namespaceURI , localName , qName , atts ) ; } catch ( ClassNotFoundException cnfe ) { saxParser = null ; abandonHope = true ; debug . message ( 2 , cnfe . toString ( ) ) ; } catch ( InstantiationException ie ) { saxParser = null ; abandonHope = true ; debug . message ( 2 , ie . toString ( ) ) ; } catch ( IllegalAccessException iae ) { saxParser = null ; abandonHope = true ; debug . message ( 2 , iae . toString ( ) ) ; } catch ( ClassCastException cce ) { saxParser = null ; abandonHope = true ; debug . message ( 2 , cce . toString ( ) ) ; } } else { saxParser . startElement ( namespaceURI , localName , qName , atts ) ; } }


Input: The SAX2 <code > endElement< / code > method . Does nothing . [CODESPLIT] public void endElement ( String namespaceURI , String localName , String qName ) throws SAXException { if ( saxParser != null ) { saxParser . endElement ( namespaceURI , localName , qName ) ; } }


Input: The SAX <code > processingInstruction< / code > method . Does nothing . [CODESPLIT] public void processingInstruction ( String target , String data ) throws SAXException { if ( saxParser != null ) { saxParser . processingInstruction ( target , data ) ; } }


Input: The SAX <code > startPrefixMapping< / code > method . Does nothing . [CODESPLIT] public void startPrefixMapping ( String prefix , String uri ) throws SAXException { if ( saxParser != null ) { saxParser . startPrefixMapping ( prefix , uri ) ; } }


Input: Entity Resolver [CODESPLIT] public InputSource resolveEntity ( String publicId , String systemId ) throws SAXException { if ( er != null ) { try { return er . resolveEntity ( publicId , systemId ) ; } catch ( IOException e ) { System . out . println ( "resolveEntity threw IOException!" ) ; return null ; } } else { return null ; } }


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


Input: Protected ----------------------------------------------------- [CODESPLIT] protected boolean waitImpl ( Object lock ) throws InterruptedException { // Wait (forever) until notified. To discover deadlocks, // turn on debugging of this class long start = System . currentTimeMillis ( ) ; lock . wait ( DEADLOCK_TIMEOUT ) ; long end = System . currentTimeMillis ( ) ; if ( ( end - start ) > ( DEADLOCK_TIMEOUT - 1000 ) ) { logDeadlock ( ) ; return false ; } return true ; }


Input: Checks if the underlying file for this connection exists . [CODESPLIT] public void connect ( ) throws IOException { if ( connected ) return ; if ( ! file . exists ( ) ) { throw new FileNotFoundException ( file . getPath ( ) ) ; } connected = true ; }


Input: We should probably disallow this? [CODESPLIT] public OutputStream getOutputStream ( ) throws IOException { connect ( ) ; SecurityManager sm = System . getSecurityManager ( ) ; if ( sm != null ) { // Check for write access FilePermission p = new FilePermission ( file . getPath ( ) , "write" ) ; sm . checkPermission ( p ) ; } return new FileOutputStream ( file ) ; }


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


Input: compareAndSet next field [CODESPLIT] boolean casNext ( Node < K , V > cmp , Node < K , V > val ) { return nextUpdater . compareAndSet ( this , cmp , val ) ; }


Input:
Helps out a deletion by appending marker or unlinking from predecessor . This is called during traversals when value field seen to be null . [CODESPLIT] void helpDelete ( Node < K , V > b , Node < K , V > f ) { /*
             * Rechecking links and then doing only one of the
             * help-out stages per call tends to minimize CAS
             * interference among helping threads.
             */ if ( f == next && this == b . next ) { if ( f == null || f . value != f ) // not already marked appendMarker ( f ) ; else b . casNext ( this , f . next ) ; } }


Input: Return value if this node contains a valid key - value pair else null . [CODESPLIT] V getValidValue ( ) { Object v = value ; if ( v == this || v == BASE_HEADER ) return null ; return ( V ) v ; }


Input: Create and return a new SnapshotEntry holding current mapping if this node holds a valid value else null [CODESPLIT] SnapshotEntry < K , V > createSnapshot ( ) { V v = getValidValue ( ) ; if ( v == null ) return null ; return new SnapshotEntry ( key , v ) ; }


Input: compareAndSet right field [CODESPLIT] final boolean casRight ( Index < K , V > cmp , Index < K , V > val ) { return rightUpdater . compareAndSet ( this , cmp , val ) ; }


Input: Tries to CAS right field to skip over apparent successor succ . Fails ( forcing a retraversal by caller ) if this node is known to be deleted . [CODESPLIT] final boolean unlink ( Index < K , V > succ ) { return ! indexesDeletedNode ( ) && casRight ( succ , succ . right ) ; }


Input: Create logger . [CODESPLIT] private Logger createLog ( ) { Class < ? > clazz = getClass ( ) ; Logger logger = loggers . get ( clazz ) ; if ( logger == null ) { logger = Logger . getLogger ( clazz ) ; loggers . put ( clazz , logger ) ; } return logger ; }


Input: List the set of JBossObjects [CODESPLIT] public static void list ( JBossStringBuilder buffer , Collection objects ) { if ( objects == null ) return ; buffer . append ( ' ' ) ; if ( objects . isEmpty ( ) == false ) { for ( Iterator i = objects . iterator ( ) ; i . hasNext ( ) ; ) { Object object = i . next ( ) ; if ( object instanceof JBossObject ) ( ( JBossObject ) object ) . toShortString ( buffer ) ; else buffer . append ( object . toString ( ) ) ; if ( i . hasNext ( ) ) buffer . append ( ", " ) ; } } buffer . append ( ' ' ) ; }


Input: Get the class short name [CODESPLIT] public String getClassShortName ( ) { String longName = getClass ( ) . getName ( ) ; int dot = longName . lastIndexOf ( ' ' ) ; if ( dot != - 1 ) return longName . substring ( dot + 1 ) ; return longName ; }


Input: Implementation of String [CODESPLIT] protected String toStringImplementation ( ) { JBossStringBuilder buffer = new JBossStringBuilder ( ) ; buffer . append ( getClassShortName ( ) ) . append ( ' ' ) ; buffer . append ( Integer . toHexString ( System . identityHashCode ( this ) ) ) ; buffer . append ( ' ' ) ; toString ( buffer ) ; buffer . append ( ' ' ) ; return buffer . toString ( ) ; }


Input: Get the default <tt > PropertyMap< / tt > . [CODESPLIT] public static PropertyMap getDefaultPropertyMap ( ) { SecurityManager sm = System . getSecurityManager ( ) ; if ( sm != null ) sm . checkPropertiesAccess ( ) ; return props ; }


Input: Add a property listener . [CODESPLIT] public static void addPropertyListener ( final PropertyListener listener ) { SecurityManager sm = System . getSecurityManager ( ) ; if ( sm != null ) sm . checkPropertiesAccess ( ) ; props . addPropertyListener ( listener ) ; }


Input: Add an array of property listeners . [CODESPLIT] public static void addPropertyListeners ( final PropertyListener [ ] listeners ) { SecurityManager sm = System . getSecurityManager ( ) ; if ( sm != null ) sm . checkPropertiesAccess ( ) ; props . addPropertyListeners ( listeners ) ; }


Input: Load properties from a map . [CODESPLIT] public static void load ( final String prefix , final Map map ) throws PropertyException { SecurityManager sm = System . getSecurityManager ( ) ; if ( sm != null ) sm . checkPropertiesAccess ( ) ; props . load ( prefix , map ) ; }


Input: Load properties from a map . [CODESPLIT] public static void load ( final Map map ) throws PropertyException , IOException { SecurityManager sm = System . getSecurityManager ( ) ; if ( sm != null ) sm . checkPropertiesAccess ( ) ; props . load ( map ) ; }


Input: Load properties from a <tt > PropertyReader< / tt > . [CODESPLIT] public static void load ( final PropertyReader reader ) throws PropertyException , IOException { SecurityManager sm = System . getSecurityManager ( ) ; if ( sm != null ) sm . checkPropertiesAccess ( ) ; props . load ( reader ) ; }


Input: Load properties from a <tt > PropertyReader< / tt > specifed by the given class name . [CODESPLIT] public static void load ( final String classname ) throws PropertyException , IOException { SecurityManager sm = System . getSecurityManager ( ) ; if ( sm != null ) sm . checkPropertiesAccess ( ) ; props . load ( classname ) ; }


Input: Set a property . [CODESPLIT] public static String setProperty ( final String name , final String value ) { SecurityManager sm = System . getSecurityManager ( ) ; if ( sm != null ) sm . checkPropertyAccess ( name ) ; return ( String ) props . setProperty ( name , value ) ; }


Input: Remove a property . [CODESPLIT] public static String removeProperty ( final String name ) { SecurityManager sm = System . getSecurityManager ( ) ; if ( sm != null ) sm . checkPropertyAccess ( name ) ; return props . removeProperty ( name ) ; }


Input: Get an array style property . [CODESPLIT] public static String [ ] getArrayProperty ( final String base , final String [ ] defaultValues ) { SecurityManager sm = System . getSecurityManager ( ) ; if ( sm != null ) sm . checkPropertiesAccess ( ) ; return props . getArrayProperty ( base , defaultValues ) ; }


Input: Return an iterator over all contained property names . [CODESPLIT] public static Iterator names ( ) { SecurityManager sm = System . getSecurityManager ( ) ; if ( sm != null ) sm . checkPropertiesAccess ( ) ; return props . names ( ) ; }


Input: Get a property group for the given property base . [CODESPLIT] public static PropertyGroup getPropertyGroup ( final String basename ) { SecurityManager sm = System . getSecurityManager ( ) ; if ( sm != null ) sm . checkPropertiesAccess ( ) ; return props . getPropertyGroup ( basename ) ; }


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


Input: Copy an serializable object deeply . [CODESPLIT] public static Object copy ( final Serializable obj ) throws IOException , ClassNotFoundException { ObjectOutputStream out = null ; ObjectInputStream in = null ; Object copy = null ; try { // write the object ByteArrayOutputStream baos = new ByteArrayOutputStream ( ) ; out = new ObjectOutputStream ( baos ) ; out . writeObject ( obj ) ; out . flush ( ) ; // read in the copy byte data [ ] = baos . toByteArray ( ) ; ByteArrayInputStream bais = new ByteArrayInputStream ( data ) ; in = new ObjectInputStream ( bais ) ; copy = in . readObject ( ) ; } finally { Streams . close ( out ) ; Streams . close ( in ) ; } return copy ; }


Input: Dereference the given object if it is <i > non - null< / i > and is an instance of <code > Reference< / code > . If the object is <i > null< / i > then <i > null< / i > is returned . If the object is not an instance of <code > Reference< / code > then the object is returned . [CODESPLIT] @ SuppressWarnings ( "unchecked" ) public static Object deref ( final Object obj ) { if ( obj != null && obj instanceof Reference ) { Reference ref = ( Reference ) obj ; return ref . get ( ) ; } return obj ; }


Input: Dereference an object [CODESPLIT] public static < T > T deref ( final Object obj , Class < T > expected ) { Object result = deref ( obj ) ; if ( result == null ) return null ; return expected . cast ( result ) ; }


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


Input: Initialized listener lists and the JNDI properties cache map [CODESPLIT] private void init ( ) { unboundListeners = Collections . synchronizedList ( new ArrayList ( ) ) ; boundListeners = Collections . synchronizedMap ( new HashMap ( ) ) ; jndiMap = new HashMap ( ) ; PrivilegedAction action = new PrivilegedAction ( ) { public Object run ( ) { Object value = System . getProperty ( Context . PROVIDER_URL ) ; if ( value == null ) value = NULL_VALUE ; jndiMap . put ( Context . PROVIDER_URL , value ) ; value = System . getProperty ( Context . INITIAL_CONTEXT_FACTORY ) ; if ( value == null ) value = NULL_VALUE ; jndiMap . put ( Context . INITIAL_CONTEXT_FACTORY , value ) ; value = System . getProperty ( Context . OBJECT_FACTORIES ) ; if ( value == null ) value = NULL_VALUE ; jndiMap . put ( Context . OBJECT_FACTORIES , value ) ; value = System . getProperty ( Context . URL_PKG_PREFIXES ) ; if ( value == null ) value = NULL_VALUE ; jndiMap . put ( Context . URL_PKG_PREFIXES , value ) ; value = System . getProperty ( Context . STATE_FACTORIES ) ; if ( value == null ) value = NULL_VALUE ; jndiMap . put ( Context . STATE_FACTORIES , value ) ; value = System . getProperty ( Context . DNS_URL ) ; if ( value == null ) value = NULL_VALUE ; jndiMap . put ( Context . DNS_URL , value ) ; value = System . getProperty ( LdapContext . CONTROL_FACTORIES ) ; if ( value == null ) value = NULL_VALUE ; jndiMap . put ( LdapContext . CONTROL_FACTORIES , value ) ; return null ; } } ; AccessController . doPrivileged ( action ) ; }


Input: Called by setProperty to update the jndiMap cache values . [CODESPLIT] private void updateJndiCache ( String name , String value ) { if ( name == null ) return ; boolean isJndiProperty = name . equals ( Context . PROVIDER_URL ) || name . equals ( Context . INITIAL_CONTEXT_FACTORY ) || name . equals ( Context . OBJECT_FACTORIES ) || name . equals ( Context . URL_PKG_PREFIXES ) || name . equals ( Context . STATE_FACTORIES ) || name . equals ( Context . DNS_URL ) || name . equals ( LdapContext . CONTROL_FACTORIES ) ; if ( isJndiProperty == true ) jndiMap . put ( name , value ) ; }


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


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


Input: Returns a set of keys for all entries in this group and optionally all of the keys in the defaults map . [CODESPLIT] public Set keySet ( final boolean includeDefaults ) { if ( includeDefaults ) { Set set = new HashSet ( ) ; set . addAll ( defaults . keySet ( ) ) ; set . addAll ( super . keySet ( ) ) ; return Collections . synchronizedSet ( set ) ; } return super . keySet ( ) ; }


Input: Returns a set of entrys for all entries in this group and optionally all of the entrys in the defaults map . [CODESPLIT] public Set entrySet ( final boolean includeDefaults ) { if ( includeDefaults ) { Set set = new HashSet ( ) ; set . addAll ( defaults . entrySet ( ) ) ; set . addAll ( super . entrySet ( ) ) ; return Collections . synchronizedSet ( set ) ; } return super . entrySet ( ) ; }


Input: Add a property listener . [CODESPLIT] public void addPropertyListener ( PropertyListener listener ) { if ( listener == null ) throw new NullArgumentException ( "listener" ) ; if ( listener instanceof BoundPropertyListener ) { addPropertyListener ( ( BoundPropertyListener ) listener ) ; } else { // only add the listener if it is not in the list already if ( ! unboundListeners . contains ( listener ) ) unboundListeners . add ( listener ) ; } }


Input: Add an array of property listeners . [CODESPLIT] public void addPropertyListeners ( PropertyListener [ ] listeners ) { if ( listeners == null ) throw new NullArgumentException ( "listeners" ) ; for ( int i = 0 ; i < listeners . length ; i ++ ) { addPropertyListener ( listeners [ i ] ) ; } }


Input: Remove a property listener . [CODESPLIT] public boolean removePropertyListener ( PropertyListener listener ) { if ( listener == null ) throw new NullArgumentException ( "listener" ) ; boolean removed = false ; if ( listener instanceof BoundPropertyListener ) { removed = removePropertyListener ( ( BoundPropertyListener ) listener ) ; } else { removed = unboundListeners . remove ( listener ) ; } return removed ; }


Input: Fire a property added event to the given list of listeners . [CODESPLIT] private void firePropertyAdded ( List list , PropertyEvent event ) { if ( list == null ) return ; int size = list . size ( ) ; for ( int i = 0 ; i < size ; i ++ ) { PropertyListener listener = ( PropertyListener ) list . get ( i ) ; listener . propertyAdded ( event ) ; } }


Input: Fire a property removed event to the given list of listeners . [CODESPLIT] private void firePropertyRemoved ( List list , PropertyEvent event ) { if ( list == null ) return ; int size = list . size ( ) ; for ( int i = 0 ; i < size ; i ++ ) { PropertyListener listener = ( PropertyListener ) list . get ( i ) ; listener . propertyRemoved ( event ) ; } }


Input: Fire a property changed event to the given list of listeners . [CODESPLIT] private void firePropertyChanged ( List list , PropertyEvent event ) { if ( list == null ) return ; int size = list . size ( ) ; for ( int i = 0 ; i < size ; i ++ ) { PropertyListener listener = ( PropertyListener ) list . get ( i ) ; listener . propertyChanged ( event ) ; } }


Input: Fire a property changed event to all listeners . [CODESPLIT] protected void firePropertyChanged ( PropertyEvent event ) { // fire all bound listeners (if any) first if ( boundListeners != null ) { List list = ( List ) boundListeners . get ( event . getPropertyName ( ) ) ; if ( list != null ) { firePropertyChanged ( list , event ) ; } } // next fire all unbound listeners firePropertyChanged ( unboundListeners , event ) ; }


Input: Make a optionaly prefixed property name . [CODESPLIT] protected String makePrefixedPropertyName ( String base , String prefix ) { String name = base ; if ( prefix != null ) { StringBuffer buff = new StringBuffer ( base ) ; if ( prefix != null ) { buff . insert ( 0 , PROPERTY_NAME_SEPARATOR ) ; buff . insert ( 0 , prefix ) ; } return buff . toString ( ) ; } return name ; }


Input: Load properties from a map . [CODESPLIT] public void load ( String prefix , Map map ) throws PropertyException { // prefix can be null if ( map == null ) throw new NullArgumentException ( "map" ) ; // set properties for each key in map Iterator iter = map . keySet ( ) . iterator ( ) ; while ( iter . hasNext ( ) ) { // make a string key with optional prefix String key = String . valueOf ( iter . next ( ) ) ; String name = makePrefixedPropertyName ( key , prefix ) ; String value = String . valueOf ( map . get ( name ) ) ; // set the property setProperty ( name , value ) ; } }


Input: Load properties from a PropertyReader . [CODESPLIT] public void load ( PropertyReader reader ) throws PropertyException , IOException { if ( reader == null ) throw new NullArgumentException ( "reader" ) ; load ( reader . readProperties ( ) ) ; }


Input: Load properties from a PropertyReader specifed by the given class name . [CODESPLIT] public void load ( String className ) throws PropertyException , IOException { if ( className == null ) throw new NullArgumentException ( "className" ) ; PropertyReader reader = null ; try { Class type = Class . forName ( className ) ; reader = ( PropertyReader ) type . newInstance ( ) ; } catch ( Exception e ) { throw new PropertyException ( e ) ; } // load the properties from the source load ( reader ) ; }


Input: Set a property . [CODESPLIT] public synchronized Object setProperty ( String name , String value ) { updateJndiCache ( name , value ) ; return put ( name , value ) ; }


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


Input: Get a property group for the given property base at the given index . [CODESPLIT] public PropertyGroup getPropertyGroup ( String basename , int index ) { String name = makeIndexPropertyName ( basename , index ) ; return getPropertyGroup ( name ) ; }


Input: Register the mapping from the public id / system id to the dtd / xsd file name . This overwrites any existing mapping . [CODESPLIT] public synchronized void registerLocalEntity ( String id , String dtdOrSchema ) { if ( localEntities == null ) localEntities = new ConcurrentHashMap ( ) ; localEntities . put ( id , dtdOrSchema ) ; }


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


Input: Returns the boolean value to inform id DTD was found in the XML file or not [CODESPLIT] public boolean isEntityResolved ( ) { Boolean value = entityResolved . get ( ) ; return value != null ? value . booleanValue ( ) : false ; }


Input: Load the schema from the class entity to schema file mapping . @see #registerEntity ( String String ) [CODESPLIT] protected InputSource resolvePublicID ( String publicId , boolean trace ) { if ( publicId == null ) return null ; if ( trace ) log . trace ( "resolvePublicID, publicId=" + publicId ) ; InputSource inputSource = null ; String filename = null ; if ( localEntities != null ) filename = ( String ) localEntities . get ( publicId ) ; if ( filename == null ) filename = ( String ) entities . get ( publicId ) ; if ( filename != null ) { if ( trace ) log . trace ( "Found entity from publicId=" + publicId + " fileName=" + filename ) ; InputStream ins = loadClasspathResource ( filename , trace ) ; if ( ins != null ) { inputSource = new InputSource ( ins ) ; inputSource . setPublicId ( publicId ) ; } else { log . trace ( "Cannot load publicId from classpath resource: " + filename ) ; // Try the file name as a URI inputSource = resolveSystemIDasURL ( filename , trace ) ; if ( inputSource == null ) log . warn ( "Cannot load publicId from resource: " + filename ) ; } } return inputSource ; }


Input: Attempt to use the systemId as a URL from which the schema can be read . This checks to see whether the systemId is a key to an entry in the class entity map . [CODESPLIT] protected InputSource resolveSystemID ( String systemId , boolean trace ) { if ( systemId == null ) return null ; if ( trace ) log . trace ( "resolveSystemID, systemId=" + systemId ) ; InputSource inputSource = null ; // Try to resolve the systemId as an entity key String filename = null ; if ( localEntities != null ) filename = ( String ) localEntities . get ( systemId ) ; if ( filename == null ) filename = ( String ) entities . get ( systemId ) ; if ( filename != null ) { if ( trace ) log . trace ( "Found entity systemId=" + systemId + " fileName=" + filename ) ; InputStream ins = loadClasspathResource ( filename , trace ) ; if ( ins != null ) { inputSource = new InputSource ( ins ) ; inputSource . setSystemId ( systemId ) ; } else { log . warn ( "Cannot load systemId from resource: " + filename ) ; } } return inputSource ; }


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


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


Input:
Look for the resource name on the thread context loader resource path . This first simply tries the resource name as is and if not found the resource is prepended with either dtd / or schema / depending on whether the resource ends in . dtd or . xsd . [CODESPLIT] protected InputStream loadClasspathResource ( String resource , boolean trace ) { ClassLoader loader = Thread . currentThread ( ) . getContextClassLoader ( ) ; URL url = loader . getResource ( resource ) ; if ( url == null ) { /* Prefix the simple filename with the schema type patch as this is the
               naming convention for the jboss bundled schemas.
            */ if ( resource . endsWith ( ".dtd" ) ) resource = "dtd/" + resource ; else if ( resource . endsWith ( ".xsd" ) ) resource = "schema/" + resource ; url = loader . getResource ( resource ) ; } InputStream inputStream = null ; if ( url != null ) { if ( trace ) log . trace ( resource + " maps to URL: " + url ) ; try { inputStream = url . openStream ( ) ; } catch ( IOException e ) { log . debug ( "Failed to open url stream" , e ) ; } } return inputStream ; }


Input: Sets as an Element created by a String . [CODESPLIT] public void setAsText ( String text ) { Document d = getAsDocument ( text ) ; setValue ( d . getDocumentElement ( ) ) ; }


Input: Normalize a public identifier . [CODESPLIT] public static String normalize ( String publicId ) { String normal = publicId . replace ( ' ' , ' ' ) ; normal = normal . replace ( ' ' , ' ' ) ; normal = normal . replace ( ' ' , ' ' ) ; normal = normal . trim ( ) ; int pos ; while ( ( pos = normal . indexOf ( "  " ) ) >= 0 ) { normal = normal . substring ( 0 , pos ) + normal . substring ( pos + 1 ) ; } return normal ; }


Input: Encode a public identifier as a publicid URN . [CODESPLIT] public static String encodeURN ( String publicId ) { String urn = PublicId . normalize ( publicId ) ; urn = PublicId . stringReplace ( urn , "%" , "%25" ) ; urn = PublicId . stringReplace ( urn , ";" , "%3B" ) ; urn = PublicId . stringReplace ( urn , "'" , "%27" ) ; urn = PublicId . stringReplace ( urn , "?" , "%3F" ) ; urn = PublicId . stringReplace ( urn , "#" , "%23" ) ; urn = PublicId . stringReplace ( urn , "+" , "%2B" ) ; urn = PublicId . stringReplace ( urn , " " , "+" ) ; urn = PublicId . stringReplace ( urn , "::" , ";" ) ; urn = PublicId . stringReplace ( urn , ":" , "%3A" ) ; urn = PublicId . stringReplace ( urn , "//" , ":" ) ; urn = PublicId . stringReplace ( urn , "/" , "%2F" ) ; return "urn:publicid:" + urn ; }


Input: Decode a publicid URN into a public identifier . [CODESPLIT] public static String decodeURN ( String urn ) { String publicId = "" ; if ( urn . startsWith ( "urn:publicid:" ) ) { publicId = urn . substring ( 13 ) ; } else { return urn ; } publicId = PublicId . stringReplace ( publicId , "%2F" , "/" ) ; publicId = PublicId . stringReplace ( publicId , ":" , "//" ) ; publicId = PublicId . stringReplace ( publicId , "%3A" , ":" ) ; publicId = PublicId . stringReplace ( publicId , ";" , "::" ) ; publicId = PublicId . stringReplace ( publicId , "+" , " " ) ; publicId = PublicId . stringReplace ( publicId , "%2B" , "+" ) ; publicId = PublicId . stringReplace ( publicId , "%23" , "#" ) ; publicId = PublicId . stringReplace ( publicId , "%3F" , "?" ) ; publicId = PublicId . stringReplace ( publicId , "%27" , "'" ) ; publicId = PublicId . stringReplace ( publicId , "%3B" , ";" ) ; publicId = PublicId . stringReplace ( publicId , "%25" , "%" ) ; return publicId ; }


Input: Replace one string with another . [CODESPLIT] private static String stringReplace ( String str , String oldStr , String newStr ) { String result = "" ; int pos = str . indexOf ( oldStr ) ; //    System.out.println(str + ": " + oldStr + " => " + newStr); while ( pos >= 0 ) { //      System.out.println(str + " (" + pos + ")"); result += str . substring ( 0 , pos ) ; result += newStr ; str = str . substring ( pos + 1 ) ; pos = str . indexOf ( oldStr ) ; } return result + str ; }


Input: Start the watch . [CODESPLIT] public void start ( final boolean reset ) { if ( ! running ) { if ( reset ) reset ( ) ; start = System . currentTimeMillis ( ) ; running = true ; } }


Input: Stop the watch . [CODESPLIT] public long stop ( ) { long lap = 0 ; if ( running ) { count ++ ; stop = System . currentTimeMillis ( ) ; lap = stop - start ; total += lap ; running = false ; } return lap ; }


Input: Return a synchronized stop watch . [CODESPLIT] public static StopWatch makeSynchronized ( final StopWatch watch ) { return new Wrapper ( watch ) { /** The serialVersionUID */ private static final long serialVersionUID = - 6284244000894114817L ; public synchronized void start ( final boolean reset ) { this . watch . start ( reset ) ; } public synchronized void start ( ) { this . watch . start ( ) ; } public synchronized long stop ( ) { return this . watch . stop ( ) ; } public synchronized void reset ( ) { this . watch . reset ( ) ; } public synchronized long getLapTime ( ) { return this . watch . getLapTime ( ) ; } public synchronized long getAverageLapTime ( ) { return this . watch . getAverageLapTime ( ) ; } public synchronized int getLapCount ( ) { return this . watch . getLapCount ( ) ; } public synchronized long getTime ( ) { return this . watch . getTime ( ) ; } public synchronized boolean isRunning ( ) { return this . watch . isRunning ( ) ; } public synchronized String toString ( ) { return this . watch . toString ( ) ; } } ; }


Input: Compares this object with the specified object for order . [CODESPLIT] public int compareTo ( final Object obj ) throws ClassCastException { HashCode hashCode = ( HashCode ) obj ; return compareTo ( hashCode . value ) ; }


Input: Generate a hash code for a byte array . [CODESPLIT] public static int generate ( final byte [ ] bytes ) { int hashcode = 0 ; for ( int i = 0 ; i < bytes . length ; i ++ ) { hashcode <<= 1 ; hashcode ^= bytes [ i ] ; } return hashcode ; }


Input: Generate a hash code for an object array . [CODESPLIT] public static int generate ( final Object array [ ] , final boolean deep ) { int hashcode = 0 ; for ( int i = 0 ; i < array . length ; i ++ ) { if ( deep && ( array [ i ] instanceof Object [ ] ) ) { hashcode ^= generate ( ( Object [ ] ) array [ i ] , true ) ; } else { hashcode ^= array [ i ] . hashCode ( ) ; } } return hashcode ; }


Input: Initializes the cache creating all required objects and initializing their values . [CODESPLIT] public void create ( ) { m_map = createMap ( ) ; m_list = createList ( ) ; m_list . m_maxCapacity = m_maxCapacity ; m_list . m_minCapacity = m_minCapacity ; m_list . m_capacity = m_maxCapacity ; }


Input: Coerce and set specified value to field . [CODESPLIT] protected void setFieldValue ( String value ) { try { // filter property value value = filterValue ( value ) ; // coerce value to field type Class < ? > type = fieldInstance . getField ( ) . getType ( ) ; PropertyEditor editor = PropertyEditors . findEditor ( type ) ; editor . setAsText ( value ) ; Object coerced = editor . getValue ( ) ; // bind value to field fieldInstance . set ( coerced ) ; } catch ( IllegalAccessException e ) { throw new PropertyException ( e ) ; } }


Input: Notifies that this listener was bound to a property . [CODESPLIT] public void propertyBound ( final PropertyMap map ) { // only set the field if the map contains the property already if ( map . containsProperty ( propertyName ) ) { setFieldValue ( map . getProperty ( propertyName ) ) ; } }


Input: Start parsing a text catalog file . The file is actually read and parsed as needed by <code > nextEntry< / code > . < / p > [CODESPLIT] public void readCatalog ( Catalog catalog , String fileUrl ) throws MalformedURLException , IOException { URL catURL = null ; try { catURL = new URL ( fileUrl ) ; } catch ( MalformedURLException e ) { catURL = new URL ( "file:///" + fileUrl ) ; } URLConnection urlCon = catURL . openConnection ( ) ; try { readCatalog ( catalog , urlCon . getInputStream ( ) ) ; } catch ( FileNotFoundException e ) { catalog . getCatalogManager ( ) . debug . message ( 1 , "Failed to load catalog, file not found" , catURL . toString ( ) ) ; } }


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


Input: Returns an Iterator containing the <i > union< / i > of all of the elements in the given iterator array . [CODESPLIT] public static Iterator union ( final Iterator iters [ ] ) { Map map = new HashMap ( ) ; for ( int i = 0 ; i < iters . length ; i ++ ) { if ( iters [ i ] != null ) { while ( iters [ i ] . hasNext ( ) ) { Object obj = iters [ i ] . next ( ) ; if ( ! map . containsKey ( obj ) ) { map . put ( obj , Null . VALUE ) ; } } } } return map . keySet ( ) . iterator ( ) ; }


Input: Setup the parsing formats . Offered as a separate static method to allow testing of locale changes since SimpleDateFormat will use the default locale upon construction . Should not be normally used! [CODESPLIT] public static void initialize ( ) { PrivilegedAction action = new PrivilegedAction ( ) { public Object run ( ) { String defaultFormat = System . getProperty ( "org.jboss.util.propertyeditor.DateEditor.format" , "MMM d, yyyy" ) ; String defaultLocale = System . getProperty ( "org.jboss.util.propertyeditor.DateEditor.locale" ) ; DateFormat defaultDateFormat ; if ( defaultLocale == null || defaultLocale . length ( ) == 0 ) { defaultDateFormat = new SimpleDateFormat ( defaultFormat ) ; } else { defaultDateFormat = new SimpleDateFormat ( defaultFormat , Strings . parseLocaleString ( defaultLocale ) ) ; } formats = new DateFormat [ ] { defaultDateFormat , // Tue Jan 04 00:00:00 PST 2005 new SimpleDateFormat ( "EEE MMM d HH:mm:ss z yyyy" ) , // Wed, 4 Jul 2001 12:08:56 -0700 new SimpleDateFormat ( "EEE, d MMM yyyy HH:mm:ss Z" ) } ; return null ; } } ; AccessController . doPrivileged ( action ) ; }


Input: Parse the text into a java . util . Date by trying one by one the registered DateFormat ( s ) . [CODESPLIT] public void setAsText ( String text ) { ParseException pe = null ; for ( int i = 0 ; i < formats . length ; i ++ ) { try { // try to parse the date DateFormat df = formats [ i ] ; Date date = df . parse ( text ) ; // store the date in both forms this . text = text ; super . setValue ( date ) ; // done return ; } catch ( ParseException e ) { // remember the last seen exception pe = e ; } } // couldn't parse throw new NestedRuntimeException ( pe ) ; }


Input: Add a vertex to the graph [CODESPLIT] public boolean addVertex ( Vertex < T > v ) { if ( verticies . containsValue ( v ) == false ) { verticies . put ( v . getName ( ) , v ) ; return true ; } return false ; }


Input: Set a root vertex . If root does no exist in the graph it is added . [CODESPLIT] public void setRootVertex ( Vertex < T > root ) { this . rootVertex = root ; if ( verticies . containsValue ( root ) == false ) addVertex ( root ) ; }


Input: Insert a directed weighted Edge<T > into the graph . [CODESPLIT] public boolean addEdge ( Vertex < T > from , Vertex < T > to , int cost ) throws IllegalArgumentException { if ( verticies . containsValue ( from ) == false ) throw new IllegalArgumentException ( "from is not in graph" ) ; if ( verticies . containsValue ( to ) == false ) throw new IllegalArgumentException ( "to is not in graph" ) ; Edge < T > e = new Edge < T > ( from , to , cost ) ; if ( from . findEdge ( to ) != null ) return false ; else { from . addEdge ( e ) ; to . addEdge ( e ) ; edges . add ( e ) ; return true ; } }


Input: Insert a bidirectional Edge<T > in the graph [CODESPLIT] public boolean insertBiEdge ( Vertex < T > from , Vertex < T > to , int cost ) throws IllegalArgumentException { return addEdge ( from , to , cost ) && addEdge ( to , from , cost ) ; }


Input: Remove a vertex from the graph [CODESPLIT] public boolean removeVertex ( Vertex < T > v ) { if ( ! verticies . containsValue ( v ) ) return false ; verticies . remove ( v . getName ( ) ) ; if ( v == rootVertex ) rootVertex = null ; // Remove the edges associated with v for ( int n = 0 ; n < v . getOutgoingEdgeCount ( ) ; n ++ ) { Edge < T > e = v . getOutgoingEdge ( n ) ; v . remove ( e ) ; Vertex < T > to = e . getTo ( ) ; to . remove ( e ) ; edges . remove ( e ) ; } for ( int n = 0 ; n < v . getIncomingEdgeCount ( ) ; n ++ ) { Edge < T > e = v . getIncomingEdge ( n ) ; v . remove ( e ) ; Vertex < T > predecessor = e . getFrom ( ) ; predecessor . remove ( e ) ; } return true ; }


Input: Remove an Edge<T > from the graph [CODESPLIT] public boolean removeEdge ( Vertex < T > from , Vertex < T > to ) { Edge < T > e = from . findEdge ( to ) ; if ( e == null ) return false ; else { from . remove ( e ) ; to . remove ( e ) ; edges . remove ( e ) ; return true ; } }


Input: Perform a depth first serach using recursion . [CODESPLIT] public void depthFirstSearch ( Vertex < T > v , final Visitor < T > visitor ) { VisitorEX < T , RuntimeException > wrapper = new VisitorEX < T , RuntimeException > ( ) { public void visit ( Graph < T > g , Vertex < T > v ) throws RuntimeException { if ( visitor != null ) visitor . visit ( g , v ) ; } } ; this . depthFirstSearch ( v , wrapper ) ; }


Input: Perform a depth first serach using recursion . The search may be cut short if the visitor throws an exception . @param <E > exception type [CODESPLIT] public < E extends Exception > void depthFirstSearch ( Vertex < T > v , VisitorEX < T , E > visitor ) throws E { if ( visitor != null ) visitor . visit ( this , v ) ; v . visit ( ) ; for ( int i = 0 ; i < v . getOutgoingEdgeCount ( ) ; i ++ ) { Edge < T > e = v . getOutgoingEdge ( i ) ; if ( ! e . getTo ( ) . visited ( ) ) { depthFirstSearch ( e . getTo ( ) , visitor ) ; } } }


Input: Perform a breadth first search of this graph starting at v . The vist may be cut short if visitor throws an exception during a vist callback . @param <E > exception type [CODESPLIT] public < E extends Exception > void breadthFirstSearch ( Vertex < T > v , VisitorEX < T , E > visitor ) throws E { LinkedList < Vertex < T >> q = new LinkedList < Vertex < T > > ( ) ; q . add ( v ) ; if ( visitor != null ) visitor . visit ( this , v ) ; v . visit ( ) ; while ( q . isEmpty ( ) == false ) { v = q . removeFirst ( ) ; for ( int i = 0 ; i < v . getOutgoingEdgeCount ( ) ; i ++ ) { Edge < T > e = v . getOutgoingEdge ( i ) ; Vertex < T > to = e . getTo ( ) ; if ( ! to . visited ( ) ) { q . add ( to ) ; if ( visitor != null ) visitor . visit ( this , to ) ; to . visit ( ) ; } } } }


Input: Find the spanning tree using a DFS starting from v . [CODESPLIT] public void dfsSpanningTree ( Vertex < T > v , DFSVisitor < T > visitor ) { v . visit ( ) ; if ( visitor != null ) visitor . visit ( this , v ) ; for ( int i = 0 ; i < v . getOutgoingEdgeCount ( ) ; i ++ ) { Edge < T > e = v . getOutgoingEdge ( i ) ; if ( ! e . getTo ( ) . visited ( ) ) { if ( visitor != null ) visitor . visit ( this , v , e ) ; e . mark ( ) ; dfsSpanningTree ( e . getTo ( ) , visitor ) ; } } }


Input: Search the verticies for one with data . [CODESPLIT] public Vertex < T > findVertexByData ( T data , Comparator < T > compare ) { Vertex < T > match = null ; for ( Vertex < T > v : verticies . values ( ) ) { if ( compare . compare ( data , v . getData ( ) ) == 0 ) { match = v ; break ; } } return match ; }


Input: Search the graph for cycles . In order to detect cycles we use a modified depth first search called a colored DFS . All nodes are initially marked white . When a node is encountered it is marked grey and when its descendants are completely visited it is marked black . If a grey node is ever encountered then there is a cycle . [CODESPLIT] public Edge < T > [ ] findCycles ( ) { ArrayList < Edge < T >> cycleEdges = new ArrayList < Edge < T > > ( ) ; // Mark all verticies as white for ( int n = 0 ; n < verticies . size ( ) ; n ++ ) { Vertex < T > v = getVertex ( n ) ; v . setMarkState ( VISIT_COLOR_WHITE ) ; } for ( int n = 0 ; n < verticies . size ( ) ; n ++ ) { Vertex < T > v = getVertex ( n ) ; visit ( v , cycleEdges ) ; } Edge < T > [ ] cycles = new Edge [ cycleEdges . size ( ) ] ; cycleEdges . toArray ( cycles ) ; return cycles ; }


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


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


Input: Normalizes the given string . [CODESPLIT] public static String normalize ( String s , boolean canonical ) { StringBuffer str = new StringBuffer ( ) ; int len = ( s != null ) ? s . length ( ) : 0 ; for ( int i = 0 ; i < len ; i ++ ) { char ch = s . charAt ( i ) ; switch ( ch ) { case ' ' : { str . append ( "<" ) ; break ; } case ' ' : { str . append ( ">" ) ; break ; } case ' ' : { str . append ( "&" ) ; break ; } case ' ' : { str . append ( """ ) ; break ; } case ' ' : { str . append ( "'" ) ; break ; } case ' ' : case ' ' : { if ( canonical ) { str . append ( "&#" ) ; str . append ( Integer . toString ( ch ) ) ; str . append ( ' ' ) ; break ; } // else, default append char } default : { str . append ( ch ) ; } } } return ( str . toString ( ) ) ; }


Input: Parse the given XML string and return the root Element [CODESPLIT] public static Element parse ( String xmlString ) throws IOException { try { return parse ( new ByteArrayInputStream ( xmlString . getBytes ( "UTF-8" ) ) ) ; } catch ( IOException e ) { log . error ( "Cannot parse: " + xmlString ) ; throw e ; } }


Input: Parse the given XML stream and return the root Element [CODESPLIT] public static Element parse ( InputStream xmlStream ) throws IOException { try { Document doc = getDocumentBuilder ( ) . parse ( xmlStream ) ; Element root = doc . getDocumentElement ( ) ; return root ; } catch ( SAXException e ) { throw new IOException ( e . toString ( ) ) ; } }


Input: Parse the given input source and return the root Element [CODESPLIT] public static Element parse ( InputSource source ) throws IOException { try { Document doc = getDocumentBuilder ( ) . parse ( source ) ; Element root = doc . getDocumentElement ( ) ; return root ; } catch ( SAXException e ) { throw new IOException ( e . toString ( ) ) ; } }


Input: Create an Element for a given name [CODESPLIT] public static Element createElement ( String localPart ) { Document doc = getOwnerDocument ( ) ; log . trace ( "createElement {}" + localPart ) ; return doc . createElement ( localPart ) ; }


Input: Transform the giveen qualified name into a QName [CODESPLIT] public static QName resolveQName ( Element el , String qualifiedName ) { QName qname ; String prefix = "" ; String namespaceURI = "" ; String localPart = qualifiedName ; int colIndex = qualifiedName . indexOf ( ":" ) ; if ( colIndex > 0 ) { prefix = qualifiedName . substring ( 0 , colIndex ) ; localPart = qualifiedName . substring ( colIndex + 1 ) ; if ( "xmlns" . equals ( prefix ) ) { namespaceURI = "URI:XML_PREDEFINED_NAMESPACE" ; } else { Element nsElement = el ; while ( namespaceURI . equals ( "" ) && nsElement != null ) { namespaceURI = nsElement . getAttribute ( "xmlns:" + prefix ) ; if ( namespaceURI . equals ( "" ) ) nsElement = getParentElement ( nsElement ) ; } } if ( namespaceURI . equals ( "" ) ) throw new IllegalArgumentException ( "Cannot find namespace uri for: " + qualifiedName ) ; } qname = new QName ( namespaceURI , localPart , prefix ) ; return qname ; }


Input: Get the value from the given attribute @param el @param attrName [CODESPLIT] public static String getAttributeValue ( Element el , String attrName ) { return getAttributeValue ( el , new QName ( attrName ) ) ; }


Input: Get the value from the given attribute @param el @param attrName [CODESPLIT] public static String getAttributeValue ( Element el , QName attrName ) { String attr = null ; if ( "" . equals ( attrName . getNamespaceURI ( ) ) ) attr = el . getAttribute ( attrName . getLocalPart ( ) ) ; else attr = el . getAttributeNS ( attrName . getNamespaceURI ( ) , attrName . getLocalPart ( ) ) ; if ( "" . equals ( attr ) ) attr = null ; return attr ; }


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


Input: True if the node has child elements [CODESPLIT] public static boolean hasChildElements ( Node node ) { NodeList nlist = node . getChildNodes ( ) ; for ( int i = 0 ; i < nlist . getLength ( ) ; i ++ ) { Node child = nlist . item ( i ) ; if ( child . getNodeType ( ) == Node . ELEMENT_NODE ) return true ; } return false ; }


Input: Gets child elements [CODESPLIT] public static Iterator getChildElements ( Node node ) { ArrayList list = new ArrayList ( ) ; NodeList nlist = node . getChildNodes ( ) ; for ( int i = 0 ; i < nlist . getLength ( ) ; i ++ ) { Node child = nlist . item ( i ) ; if ( child . getNodeType ( ) == Node . ELEMENT_NODE ) list . add ( child ) ; } return list . iterator ( ) ; }


Input: Get the concatenated text content or null . [CODESPLIT] public static String getTextContent ( Node node , boolean replaceProps ) { boolean hasTextContent = false ; StringBuffer buffer = new StringBuffer ( ) ; NodeList nlist = node . getChildNodes ( ) ; for ( int i = 0 ; i < nlist . getLength ( ) ; i ++ ) { Node child = nlist . item ( i ) ; if ( child . getNodeType ( ) == Node . TEXT_NODE ) { buffer . append ( child . getNodeValue ( ) ) ; hasTextContent = true ; } } String text = ( hasTextContent ? buffer . toString ( ) : null ) ; if ( text != null && replaceProps ) text = StringPropertyReplacer . replaceProperties ( text ) ; return text ; }


Input: Gets the child elements for a given local name without namespace [CODESPLIT] public static Iterator getChildElements ( Node node , String nodeName ) { return getChildElementsIntern ( node , new QName ( nodeName ) ) ; }


Input: Gets parent element or null if there is none [CODESPLIT] public static Element getParentElement ( Node node ) { Node parent = node . getParentNode ( ) ; return ( parent instanceof Element ? ( Element ) parent : null ) ; }


Input: Add a transaction waiting for a lock [CODESPLIT] public void addWaiting ( Object holder , Resource resource ) { synchronized ( waiting ) { waiting . put ( holder , resource ) ; } }


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


Input: Read the catalog behind the specified URL . [CODESPLIT] public void readCatalog ( Catalog catalog , String fileUrl ) throws MalformedURLException , IOException , CatalogException { URL url = new URL ( fileUrl ) ; URLConnection urlCon = url . openConnection ( ) ; readCatalog ( catalog , urlCon . getInputStream ( ) ) ; }


Input: Return the current host internet address . [CODESPLIT] private static byte [ ] getHostAddress ( ) { return ( byte [ ] ) AccessController . doPrivileged ( new PrivilegedAction ( ) { public Object run ( ) { try { return InetAddress . getLocalHost ( ) . getAddress ( ) ; } catch ( Exception e ) { return UNKNOWN_HOST ; } } } ) ; }


Input: Tries to resolve the entity using the thread specific catolog resolvers [CODESPLIT] public InputSource resolveEntity ( String publicId , String systemId ) throws MalformedURLException , IOException { String resolvedURI = catologResolver . resolveSystem ( systemId ) ; if ( resolvedURI == null ) { resolvedURI = catologResolver . resolvePublic ( publicId , systemId ) ; } if ( resolvedURI != null ) { final InputSource is = new InputSource ( ) ; is . setPublicId ( publicId ) ; is . setSystemId ( systemId ) ; is . setByteStream ( this . loadResource ( resolvedURI ) ) ; this . isLastEntityResolved = true ; return is ; } else { //resource could�t be resloved this . isLastEntityResolved = false ; return null ; } }


Input: Seach the path for oasis catalog files . The classpath of <code > Thread . currentThread () . getContextClassLoader () < / code > is used for the lookup . @return the url where the <code > jax - ws - catalog . xml< / code > is located @throws IOException if the catalog files cannot be loaded [CODESPLIT] public static URL lookupCatalogFiles ( ) throws IOException { URL url = null ; //JAXWS-2.-0 spec, Line 27:the current context class loader MUST be used to //retrieve all the resources with the specified name ClassLoader loader = Thread . currentThread ( ) . getContextClassLoader ( ) ; for ( int i = 0 ; i < catalogFilesNames . length ; i ++ ) { url = loader . getResource ( catalogFilesNames [ i ] ) ; //use the first hit if ( url != null ) { break ; } } return url ; }


Input: JBoss lifecycle [CODESPLIT] public void create ( ) { Throwable error = setSystemPropertyClassValue ( property , className ) ; if ( error != null ) log . trace ( "Error loading class " + className + " property " + property + " not set." , error ) ; }


Input: Sets the system property to a class when the class is available . [CODESPLIT] public static Throwable setSystemPropertyClassValue ( String property , String className ) { // Validation if ( property == null || property . trim ( ) . length ( ) == 0 ) throw new IllegalArgumentException ( "Null or empty property" ) ; if ( className == null || className . trim ( ) . length ( ) == 0 ) throw new IllegalArgumentException ( "Null or empty class name" ) ; // Is the class available? try { Thread . currentThread ( ) . getContextClassLoader ( ) . loadClass ( className ) ; } catch ( Throwable problem ) { return problem ; } // The class is there, set the property. System . setProperty ( property , className ) ; return null ; }


Input: Format a string buffer containing the Class Interfaces CodeSource and ClassLoader information for the given object clazz . [CODESPLIT] public static void displayClassInfo ( Class clazz , StringBuffer results ) { // Print out some codebase info for the clazz ClassLoader cl = clazz . getClassLoader ( ) ; results . append ( "\n" ) ; results . append ( clazz . getName ( ) ) ; results . append ( "(" ) ; results . append ( Integer . toHexString ( clazz . hashCode ( ) ) ) ; results . append ( ").ClassLoader=" ) ; results . append ( cl ) ; ClassLoader parent = cl ; while ( parent != null ) { results . append ( "\n.." ) ; results . append ( parent ) ; URL [ ] urls = getClassLoaderURLs ( parent ) ; int length = urls != null ? urls . length : 0 ; for ( int u = 0 ; u < length ; u ++ ) { results . append ( "\n...." ) ; results . append ( urls [ u ] ) ; } if ( parent != null ) parent = parent . getParent ( ) ; } CodeSource clazzCS = clazz . getProtectionDomain ( ) . getCodeSource ( ) ; if ( clazzCS != null ) { results . append ( "\n++++CodeSource: " ) ; results . append ( clazzCS ) ; } else results . append ( "\n++++Null CodeSource" ) ; results . append ( "\nImplemented Interfaces:" ) ; Class [ ] ifaces = clazz . getInterfaces ( ) ; for ( int i = 0 ; i < ifaces . length ; i ++ ) { Class iface = ifaces [ i ] ; results . append ( "\n++" ) ; results . append ( iface ) ; results . append ( "(" ) ; results . append ( Integer . toHexString ( iface . hashCode ( ) ) ) ; results . append ( ")" ) ; ClassLoader loader = ifaces [ i ] . getClassLoader ( ) ; results . append ( "\n++++ClassLoader: " ) ; results . append ( loader ) ; ProtectionDomain pd = ifaces [ i ] . getProtectionDomain ( ) ; CodeSource cs = pd . getCodeSource ( ) ; if ( cs != null ) { results . append ( "\n++++CodeSource: " ) ; results . append ( cs ) ; } else results . append ( "\n++++Null CodeSource" ) ; } }


Input: Use reflection to access a URL [] getURLs or URL [] getClasspath method so that non - URLClassLoader class loaders or class loaders that override getURLs to return null or empty can provide the true classpath info . [CODESPLIT] public static URL [ ] getClassLoaderURLs ( ClassLoader cl ) { URL [ ] urls = { } ; try { Class returnType = urls . getClass ( ) ; Class [ ] parameterTypes = { } ; Class clClass = cl . getClass ( ) ; Method getURLs = clClass . getMethod ( "getURLs" , parameterTypes ) ; if ( returnType . isAssignableFrom ( getURLs . getReturnType ( ) ) ) { Object [ ] args = { } ; urls = ( URL [ ] ) getURLs . invoke ( cl , args ) ; } if ( urls == null || urls . length == 0 ) { Method getCp = clClass . getMethod ( "getClasspath" , parameterTypes ) ; if ( returnType . isAssignableFrom ( getCp . getReturnType ( ) ) ) { Object [ ] args = { } ; urls = ( URL [ ] ) getCp . invoke ( cl , args ) ; } } } catch ( Exception ignore ) { } return urls ; }


Input: Describe the class of an object [CODESPLIT] public static String getDescription ( Object object ) { StringBuffer buffer = new StringBuffer ( ) ; describe ( buffer , object ) ; return buffer . toString ( ) ; }


Input: Describe the class of an object [CODESPLIT] public static void describe ( StringBuffer buffer , Object object ) { if ( object == null ) buffer . append ( "**null**" ) ; else describe ( buffer , object . getClass ( ) ) ; }


Input: Describe the class [CODESPLIT] public static void describe ( StringBuffer buffer , Class clazz ) { if ( clazz == null ) buffer . append ( "**null**" ) ; else { buffer . append ( "{class=" ) . append ( clazz . getName ( ) ) ; Class [ ] intfs = clazz . getInterfaces ( ) ; if ( intfs . length > 0 ) { buffer . append ( " intfs=" ) ; for ( int i = 0 ; i < intfs . length ; ++ i ) { buffer . append ( intfs [ i ] . getName ( ) ) ; if ( i < intfs . length - 1 ) buffer . append ( ", " ) ; } } buffer . append ( "}" ) ; } }


Input: Get the short name of the specified class by striping off the package name . [CODESPLIT] public static String stripPackageName ( final String classname ) { int idx = classname . lastIndexOf ( PACKAGE_SEPARATOR ) ; if ( idx != - 1 ) return classname . substring ( idx + 1 , classname . length ( ) ) ; return classname ; }


Input: Get the package name of the specified class . [CODESPLIT] public static String getPackageName ( final String classname ) { if ( classname . length ( ) == 0 ) throw new EmptyStringException ( ) ; int index = classname . lastIndexOf ( PACKAGE_SEPARATOR ) ; if ( index != - 1 ) return classname . substring ( 0 , index ) ; return "" ; }


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


Input: Get the wrapper class for the given primitive type . [CODESPLIT] public static Class getPrimitiveWrapper ( final Class type ) { if ( ! type . isPrimitive ( ) ) { throw new IllegalArgumentException ( "type is not a primitive class" ) ; } for ( int i = 0 ; i < PRIMITIVE_WRAPPER_MAP . length ; i += 2 ) { if ( type . equals ( PRIMITIVE_WRAPPER_MAP [ i ] ) ) return PRIMITIVE_WRAPPER_MAP [ i + 1 ] ; } // should never get here, if we do then PRIMITIVE_WRAPPER_MAP // needs to be updated to include the missing mapping throw new UnreachableStatementException ( ) ; }


Input: Populates a list with all the interfaces implemented by the argument class c and all its superclasses . [CODESPLIT] public static void getAllInterfaces ( List allIfaces , Class c ) { while ( c != null ) { Class [ ] ifaces = c . getInterfaces ( ) ; for ( int n = 0 ; n < ifaces . length ; n ++ ) { allIfaces . add ( ifaces [ n ] ) ; } c = c . getSuperclass ( ) ; } }


Input: Returns an array containing all the unique interfaces implemented by the argument class c and all its superclasses . Interfaces that appear multiple times through inheritence are only accounted for once . [CODESPLIT] public static Class [ ] getAllUniqueInterfaces ( Class c ) { Set uniqueIfaces = new HashSet ( ) ; while ( c != null ) { Class [ ] ifaces = c . getInterfaces ( ) ; for ( int n = 0 ; n < ifaces . length ; n ++ ) { uniqueIfaces . add ( ifaces [ n ] ) ; } c = c . getSuperclass ( ) ; } return ( Class [ ] ) uniqueIfaces . toArray ( new Class [ uniqueIfaces . size ( ) ] ) ; }


Input: Check if the given class is a primitive wrapper class . [CODESPLIT] public static boolean isPrimitiveWrapper ( final Class type ) { for ( int i = 0 ; i < PRIMITIVE_WRAPPER_MAP . length ; i += 2 ) { if ( type . equals ( PRIMITIVE_WRAPPER_MAP [ i + 1 ] ) ) { return true ; } } return false ; }


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


Input: This method acts equivalently to invoking <code > Thread . currentThread () . getContextClassLoader () . loadClass ( className ) ; < / code > but it also supports primitive types and array classes of object types or primitive types . [CODESPLIT] public static Class loadClass ( String className ) throws ClassNotFoundException { return loadClass ( className , Thread . currentThread ( ) . getContextClassLoader ( ) ) ; }


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


Input: Convert a list of Strings from an Interator into an array of Classes ( the Strings are taken as classnames ) . [CODESPLIT] public final static Class < ? > [ ] convertToJavaClasses ( Iterator < String > it , ClassLoader cl ) throws ClassNotFoundException { ArrayList < Class < ? > > classes = new ArrayList < Class < ? > > ( ) ; while ( it . hasNext ( ) ) { classes . add ( convertToJavaClass ( it . next ( ) , cl ) ) ; } return classes . toArray ( new Class [ classes . size ( ) ] ) ; }


Input: Returns attribute s getter method . If the method not found then NoSuchMethodException will be thrown . [CODESPLIT] public final static Method getAttributeGetter ( Class cls , String attr ) throws NoSuchMethodException { StringBuffer buf = new StringBuffer ( attr . length ( ) + 3 ) ; buf . append ( "get" ) ; if ( Character . isLowerCase ( attr . charAt ( 0 ) ) ) { buf . append ( Character . toUpperCase ( attr . charAt ( 0 ) ) ) . append ( attr . substring ( 1 ) ) ; } else { buf . append ( attr ) ; } try { return cls . getMethod ( buf . toString ( ) , ( Class [ ] ) null ) ; } catch ( NoSuchMethodException e ) { buf . replace ( 0 , 3 , "is" ) ; return cls . getMethod ( buf . toString ( ) , ( Class [ ] ) null ) ; } }


Input: Returns attribute s setter method . If the method not found then NoSuchMethodException will be thrown . [CODESPLIT] public final static Method getAttributeSetter ( Class cls , String attr , Class type ) throws NoSuchMethodException { StringBuffer buf = new StringBuffer ( attr . length ( ) + 3 ) ; buf . append ( "set" ) ; if ( Character . isLowerCase ( attr . charAt ( 0 ) ) ) { buf . append ( Character . toUpperCase ( attr . charAt ( 0 ) ) ) . append ( attr . substring ( 1 ) ) ; } else { buf . append ( attr ) ; } return cls . getMethod ( buf . toString ( ) , new Class [ ] { type } ) ; }


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


Input: Get a system property [CODESPLIT] private static String getProperty ( final String name , final String defaultValue ) { return ( String ) AccessController . doPrivileged ( new PrivilegedAction ( ) { public Object run ( ) { return System . getProperty ( name , defaultValue ) ; } } ) ; }


Input: Map the argument text into and Byte using Byte . decode . [CODESPLIT] public void setAsText ( final String text ) { if ( PropertyEditors . isNull ( text ) ) { setValue ( null ) ; return ; } Object newValue = Byte . decode ( text ) ; setValue ( newValue ) ; }


Input: Get an array of filenames to load . [CODESPLIT] public static String [ ] getFilenames ( final String propertyName ) throws PropertyException { String filenames [ ] ; // check for singleton property first Object filename = PropertyManager . getProperty ( propertyName ) ; if ( filename != null ) { filenames = new String [ ] { String . valueOf ( filename ) } ; } else { // if no singleton property exists then look for array props filenames = PropertyManager . getArrayProperty ( propertyName ) ; } return filenames ; }


Input: Check if a file is acceptible . [CODESPLIT] public boolean accept ( final File dir , final String name ) { if ( ignoreCase ) { return name . toLowerCase ( ) . startsWith ( prefix ) ; } else { return name . startsWith ( prefix ) ; } }


Input: Maintain the elements in the set . Removes objects from the set that have been reclaimed due to GC . [CODESPLIT] protected final void maintain ( ) { WeakObject weak ; while ( ( weak = ( WeakObject ) queue . poll ( ) ) != null ) { set . remove ( weak ) ; } }


Input: Return an iteration over the elements in the set . [CODESPLIT] public Iterator iterator ( ) { return new Iterator ( ) { /** The set's iterator */ Iterator iter = set . iterator ( ) ; /** JBCOMMON-24, handle null values and multiple invocations of hasNext() */ Object UNKNOWN = new Object ( ) ; /** The next available object. */ Object next = UNKNOWN ; public boolean hasNext ( ) { if ( next != UNKNOWN ) { return true ; } while ( iter . hasNext ( ) ) { WeakObject weak = ( WeakObject ) iter . next ( ) ; Object obj = null ; if ( weak != null && ( obj = weak . get ( ) ) == null ) { // object has been reclaimed by the GC continue ; } next = obj ; return true ; } return false ; } public Object next ( ) { if ( ( next == UNKNOWN ) && ! hasNext ( ) ) { throw new NoSuchElementException ( ) ; } Object obj = next ; next = UNKNOWN ; return obj ; } public void remove ( ) { iter . remove ( ) ; } } ; }


Input: Add an element to the set . [CODESPLIT] public boolean add ( final Object obj ) { maintain ( ) ; return set . add ( WeakObject . create ( obj , queue ) ) ; }


Input: Create a URL lister for the supplied protocol [CODESPLIT] public URLLister createURLLister ( String protocol ) throws MalformedURLException { try { String className = ( String ) classes . get ( protocol ) ; if ( className == null ) { throw new MalformedURLException ( "No lister class defined for protocol " + protocol ) ; } Class < ? > clazz = Thread . currentThread ( ) . getContextClassLoader ( ) . loadClass ( className ) ; return ( URLLister ) clazz . newInstance ( ) ; } catch ( ClassNotFoundException e ) { throw new MalformedURLException ( e . getMessage ( ) ) ; } catch ( InstantiationException e ) { throw new MalformedURLException ( e . getMessage ( ) ) ; } catch ( IllegalAccessException e ) { throw new MalformedURLException ( e . getMessage ( ) ) ; } }


Input: Check if a file is acceptible . [CODESPLIT] public boolean accept ( final File file ) { if ( ignoreCase ) { return file . getName ( ) . toLowerCase ( ) . startsWith ( prefix ) ; } else { return file . getName ( ) . startsWith ( prefix ) ; } }


Input: Print debug message ( if the debug level is high enough ) . [CODESPLIT] public void message ( int level , String message ) { if ( debug >= level ) { System . out . println ( message ) ; } }


Input: Print debug message ( if the debug level is high enough ) . [CODESPLIT] public void message ( int level , String message , String spec1 , String spec2 ) { if ( debug >= level ) { System . out . println ( message + ": " + spec1 ) ; System . out . println ( "\t" + spec2 ) ; } }


Input: Set a property . [CODESPLIT] public Object put ( final Object name , final Object value ) { if ( name == null ) throw new NullArgumentException ( "name" ) ; return super . put ( makePropertyName ( name ) , value ) ; }


Input: Get a property [CODESPLIT] public Object get ( final Object name ) { if ( name == null ) throw new NullArgumentException ( "name" ) ; return super . get ( makePropertyName ( name ) ) ; }


Input: Remove a property . [CODESPLIT] public Object remove ( final Object name ) { if ( name == null ) throw new NullArgumentException ( "name" ) ; return super . remove ( makePropertyName ( name ) ) ; }


Input: Returns an entry set for all properties in this group . [CODESPLIT] @ SuppressWarnings ( "unchecked" ) public Set entrySet ( ) { final Set superSet = super . entrySet ( true ) ; return new java . util . AbstractSet ( ) { private boolean isInGroup ( Map . Entry entry ) { String key = ( String ) entry . getKey ( ) ; return key . startsWith ( basename ) ; } public int size ( ) { Iterator iter = superSet . iterator ( ) ; int count = 0 ; while ( iter . hasNext ( ) ) { Map . Entry entry = ( Map . Entry ) iter . next ( ) ; if ( isInGroup ( entry ) ) { count ++ ; } } return count ; } public Iterator iterator ( ) { return new Iterator ( ) { private Iterator iter = superSet . iterator ( ) ; private Object next ; public boolean hasNext ( ) { if ( next != null ) return true ; while ( next == null ) { if ( iter . hasNext ( ) ) { Map . Entry entry = ( Map . Entry ) iter . next ( ) ; if ( isInGroup ( entry ) ) { next = entry ; return true ; } } else { break ; } } return false ; } public Object next ( ) { if ( next == null ) throw new java . util . NoSuchElementException ( ) ; Object obj = next ; next = null ; return obj ; } public void remove ( ) { iter . remove ( ) ; } } ; } } ; }


Input: Add a bound property listener . [CODESPLIT] protected void addPropertyListener ( final BoundPropertyListener listener ) { // get the bound property name String name = makePropertyName ( listener . getPropertyName ( ) ) ; // get the bound listener list for the property List list = ( List ) boundListeners . get ( name ) ; // if list is null, then add a new list if ( list == null ) { list = new ArrayList ( ) ; boundListeners . put ( name , list ) ; } // if listener is not in the list already, then add it if ( ! list . contains ( listener ) ) { list . add ( listener ) ; // notify listener that is is bound listener . propertyBound ( this ) ; } }


Input: Remove a bound property listener . [CODESPLIT] protected boolean removePropertyListener ( final BoundPropertyListener listener ) { // get the bound property name String name = makePropertyName ( listener . getPropertyName ( ) ) ; // get the bound listener list for the property List list = ( List ) boundListeners . get ( name ) ; boolean removed = false ; if ( list != null ) { removed = list . remove ( listener ) ; // notify listener that is was unbound if ( removed ) listener . propertyUnbound ( this ) ; } return removed ; }


Input: Creates a { @link FieldBoundPropertyListener } for the field and property name and adds it the underlying property group . [CODESPLIT] protected void bindField ( final String name , final String propertyName ) { if ( name == null || name . equals ( "" ) ) throw new IllegalArgumentException ( "name" ) ; if ( propertyName == null || propertyName . equals ( "" ) ) throw new IllegalArgumentException ( "propertyName" ) ; addPropertyListener ( new FieldBoundPropertyListener ( this , name , propertyName ) ) ; }


Input: Creates a { @link MethodBoundPropertyListener } for the method and property name and adds it the underlying property group . [CODESPLIT] protected void bindMethod ( final String name , final String propertyName ) { if ( name == null || name . equals ( "" ) ) throw new IllegalArgumentException ( "name" ) ; if ( propertyName == null || propertyName . equals ( "" ) ) throw new IllegalArgumentException ( "propertyName" ) ; addPropertyListener //                opposite of field bound =( ( new MethodBoundPropertyListener ( this , propertyName , name ) ) ; }


Input: Start parsing an OASIS TR9401 Open Catalog file . The file is actually read and parsed as needed by <code > nextEntry< / code > . [CODESPLIT] public void readCatalog ( Catalog catalog , InputStream is ) throws MalformedURLException , IOException { catfile = is ; if ( catfile == null ) { return ; } Vector unknownEntry = null ; while ( true ) { String token = nextToken ( ) ; if ( token == null ) { if ( unknownEntry != null ) { catalog . unknownEntry ( unknownEntry ) ; unknownEntry = null ; } catfile . close ( ) ; catfile = null ; return ; } String entryToken = null ; if ( caseSensitive ) { entryToken = token ; } else { entryToken = token . toUpperCase ( ) ; } if ( entryToken . equals ( "DELEGATE" ) ) { entryToken = "DELEGATE_PUBLIC" ; } try { int type = CatalogEntry . getEntryType ( entryToken ) ; int numArgs = CatalogEntry . getEntryArgCount ( type ) ; Vector args = new Vector ( ) ; if ( unknownEntry != null ) { catalog . unknownEntry ( unknownEntry ) ; unknownEntry = null ; } for ( int count = 0 ; count < numArgs ; count ++ ) { args . addElement ( nextToken ( ) ) ; } catalog . addEntry ( new CatalogEntry ( entryToken , args ) ) ; } catch ( CatalogException cex ) { if ( cex . getExceptionType ( ) == CatalogException . INVALID_ENTRY_TYPE ) { if ( unknownEntry == null ) { unknownEntry = new Vector ( ) ; } unknownEntry . addElement ( token ) ; } else if ( cex . getExceptionType ( ) == CatalogException . INVALID_ENTRY ) { catalog . getCatalogManager ( ) . debug . message ( 1 , "Invalid catalog entry" , token ) ; unknownEntry = null ; } } } }


Input: Get the information for a class [CODESPLIT] public T get ( Class < ? > clazz ) { if ( clazz == null ) throw new IllegalArgumentException ( "Null class" ) ; Map < String , WeakReference < T > > classLoaderCache = getClassLoaderCache ( clazz . getClassLoader ( ) ) ; WeakReference < T > weak = classLoaderCache . get ( clazz . getName ( ) ) ; if ( weak != null ) { T result = weak . get ( ) ; if ( result != null ) return result ; } T result = instantiate ( clazz ) ; weak = new WeakReference < T > ( result ) ; classLoaderCache . put ( clazz . getName ( ) , weak ) ; generate ( clazz , result ) ; return result ; }


Input: Get the cache for the classloader [CODESPLIT] protected Map < String , WeakReference < T > > getClassLoaderCache ( ClassLoader cl ) { synchronized ( cache ) { Map < String , WeakReference < T > > result = cache . get ( cl ) ; if ( result == null ) { result = CollectionsFactory . createConcurrentReaderMap ( ) ; cache . put ( cl , result ) ; } return result ; } }


Input: Whether a string is interpreted as the null value [CODESPLIT] public static final boolean isNull ( final String value , final boolean trim , final boolean empty ) { // For backwards compatibility if ( disableIsNull ) return false ; // No value? if ( value == null ) return true ; // Trim the text when requested String trimmed = trim ? value . trim ( ) : value ; // Is the empty string null? if ( empty && trimmed . length ( ) == 0 ) return true ; // Just check it. return NULL . equalsIgnoreCase ( trimmed ) ; }


Input: Locate a value editor for a given target type . [CODESPLIT] public static PropertyEditor findEditor ( final String typeName ) throws ClassNotFoundException { // see if it is a primitive type first Class < ? > type = Classes . getPrimitiveTypeForName ( typeName ) ; if ( type == null ) { // nope try look up ClassLoader loader = Thread . currentThread ( ) . getContextClassLoader ( ) ; type = loader . loadClass ( typeName ) ; } return PropertyEditorManager . findEditor ( type ) ; }