Methods Summary |
---|
protected void | complete()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.Field | getAnyField(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 void | init(DataCollector coll)
PropertyParser parser = makeParser() ;
coll.setParser( parser ) ;
Properties props = coll.getProperties() ;
Map map = parser.parse( props ) ;
setFields( map ) ;
|
protected abstract PropertyParser | makeParser()
|
protected void | setFields(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() ;
|