FileDocCategorySizeDatePackage
ParserImplBase.javaAPI DocJava SE 5 API3158Fri Aug 26 14:54:38 BST 2005com.sun.corba.se.spi.orb

ParserImplBase

public abstract class ParserImplBase extends Object

Fields Summary
private com.sun.corba.se.impl.logging.ORBUtilSystemException
wrapper
Constructors Summary
public ParserImplBase()

	// Do nothing in this case: no parsing takes place
	wrapper = ORBUtilSystemException.get( 
	    CORBALogDomains.ORB_LIFECYCLE ) ;
    
Methods Summary
protected voidcomplete()
Override this method if there is some needed initialization that takes place after argument parsing. It is always called at the end of setFields.

    
private java.lang.reflect.FieldgetAnyField(java.lang.String name)

	Field result = null ;

	try {
	    Class cls = this.getClass() ;
	    result = cls.getDeclaredField( name ) ;
	    while (result == null) {
		cls = cls.getSuperclass() ;
		if (cls == null)
		    break ;

		result = cls.getDeclaredField( name ) ;
	    }
	} catch (Exception exc) {
	    throw wrapper.fieldNotFound( exc, name ) ;
	}

	if (result == null)
	    throw wrapper.fieldNotFound( name ) ;

	return result ;
    
public voidinit(DataCollector coll)

	PropertyParser parser = makeParser() ;
	coll.setParser( parser ) ;
	Properties props = coll.getProperties() ;
	Map map = parser.parse( props ) ;
	setFields( map ) ;
    
protected abstract PropertyParsermakeParser()

protected voidsetFields(java.util.Map map)

	Set entries = map.entrySet() ;
	Iterator iter = entries.iterator() ;
	while (iter.hasNext()) {
	    java.util.Map.Entry entry = (java.util.Map.Entry)(iter.next()) ;
	    final String name = (String)(entry.getKey()) ;
	    final Object value = entry.getValue() ;

	    try {
		AccessController.doPrivileged( 
		    new PrivilegedExceptionAction() {
			public Object run() throws IllegalAccessException, 
			    IllegalArgumentException
			{
			    Field field = getAnyField( name ) ;
			    field.setAccessible( true ) ;
			    field.set( ParserImplBase.this, value ) ;
			    return null ;
			}
		    } 
		) ;
	    } catch (PrivilegedActionException exc) {
		// Since exc wraps the actual exception, use exc.getCause()
		// instead of exc.
		throw wrapper.errorSettingField( exc.getCause(), name,
		    ObjectUtility.compactObjectToString(value) ) ;
	    }
	}

	// Make sure that any extra initialization takes place after all the
	// fields are set from the map.
	complete() ;