Browse Source

Clean up some audit warnings

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@271399 13f79535-47bb-0310-9956-ffa450edef68
master
Peter Donald 24 years ago
parent
commit
8cbceeceb4
1 changed files with 29 additions and 23 deletions
  1. +29
    -23
      proposal/myrmidon/src/java/org/apache/myrmidon/components/configurer/ClassicConfigurer.java

+ 29
- 23
proposal/myrmidon/src/java/org/apache/myrmidon/components/configurer/ClassicConfigurer.java View File

@@ -40,16 +40,7 @@ public class ClassicConfigurer
ResourceManager.getPackageResources( DefaultConfigurer.class ); ResourceManager.getPackageResources( DefaultConfigurer.class );


///Compile time constant to turn on extreme debugging ///Compile time constant to turn on extreme debugging
private final static boolean DEBUG = false;

/*
* TODO: Should reserved names be "configurable" ?
*/
///Element names that are reserved
private final static String[] RESERVED_ELEMENTS = new String[]
{
"content"
};
private static final boolean DEBUG = false;


///Converter to use for converting between values ///Converter to use for converting between values
private MasterConverter m_converter; private MasterConverter m_converter;
@@ -81,7 +72,7 @@ public class ClassicConfigurer
if( DEBUG ) if( DEBUG )
{ {
final String message = REZ.getString( "configuring-object.notice", object ); final String message = REZ.getString( "configuring-object.notice", object );
getLogger().debug( "Configuring " + object );
getLogger().debug( message );
} }


if( object instanceof Configurable ) if( object instanceof Configurable )
@@ -89,7 +80,7 @@ public class ClassicConfigurer
if( DEBUG ) if( DEBUG )
{ {
final String message = REZ.getString( "configurable.notice" ); final String message = REZ.getString( "configurable.notice" );
getLogger().debug( "Configuring object via Configurable interface" );
getLogger().debug( message );
} }


( (Configurable)object ).configure( configuration ); ( (Configurable)object ).configure( configuration );
@@ -221,7 +212,7 @@ public class ClassicConfigurer
private void setValue( final Object object, private void setValue( final Object object,
final String value, final String value,
final Context context, final Context context,
final Method methods[] )
final Method[] methods )
throws ConfigurationException throws ConfigurationException
{ {
try try
@@ -241,7 +232,7 @@ public class ClassicConfigurer


private void setValue( final Object object, private void setValue( final Object object,
Object value, Object value,
final Method methods[],
final Method[] methods,
final Context context ) final Context context )
throws ConfigurationException throws ConfigurationException
{ {
@@ -250,7 +241,7 @@ public class ClassicConfigurer


for( int i = 0; i < methods.length; i++ ) for( int i = 0; i < methods.length; i++ )
{ {
if( setValue( object, value, methods[ i ], sourceClass, source, context ) )
if( setValue( object, value, methods[ i ], context ) )
{ {
return; return;
} }
@@ -262,10 +253,8 @@ public class ClassicConfigurer
} }


private boolean setValue( final Object object, private boolean setValue( final Object object,
Object value,
final Object originalValue,
final Method method, final Method method,
final Class sourceClass,
final String source,
final Context context ) final Context context )
throws ConfigurationException throws ConfigurationException
{ {
@@ -275,6 +264,7 @@ public class ClassicConfigurer
parameterType = getComplexTypeFor( parameterType ); parameterType = getComplexTypeFor( parameterType );
} }


Object value = originalValue;
try try
{ {
value = m_converter.convert( parameterType, value, context ); value = m_converter.convert( parameterType, value, context );
@@ -323,21 +313,37 @@ public class ClassicConfigurer
private Class getComplexTypeFor( final Class clazz ) private Class getComplexTypeFor( final Class clazz )
{ {
if( String.class == clazz ) if( String.class == clazz )
{
return String.class; return String.class;
}
else if( Integer.TYPE.equals( clazz ) ) else if( Integer.TYPE.equals( clazz ) )
{
return Integer.class; return Integer.class;
}
else if( Long.TYPE.equals( clazz ) ) else if( Long.TYPE.equals( clazz ) )
{
return Long.class; return Long.class;
}
else if( Short.TYPE.equals( clazz ) ) else if( Short.TYPE.equals( clazz ) )
{
return Short.class; return Short.class;
}
else if( Byte.TYPE.equals( clazz ) ) else if( Byte.TYPE.equals( clazz ) )
{
return Byte.class; return Byte.class;
}
else if( Boolean.TYPE.equals( clazz ) ) else if( Boolean.TYPE.equals( clazz ) )
{
return Boolean.class; return Boolean.class;
}
else if( Float.TYPE.equals( clazz ) ) else if( Float.TYPE.equals( clazz ) )
{
return Float.class; return Float.class;
}
else if( Double.TYPE.equals( clazz ) ) else if( Double.TYPE.equals( clazz ) )
{
return Double.class; return Double.class;
}
else else
{ {
final String message = REZ.getString( "no-complex-type.error", clazz.getName() ); final String message = REZ.getString( "no-complex-type.error", clazz.getName() );
@@ -347,7 +353,7 @@ public class ClassicConfigurer


private Method[] getMethodsFor( final Class clazz, final String methodName ) private Method[] getMethodsFor( final Class clazz, final String methodName )
{ {
final Method methods[] = clazz.getMethods();
final Method[] methods = clazz.getMethods();
final ArrayList matches = new ArrayList(); final ArrayList matches = new ArrayList();


for( int i = 0; i < methods.length; i++ ) for( int i = 0; i < methods.length; i++ )
@@ -358,7 +364,7 @@ public class ClassicConfigurer
{ {
if( method.getReturnType().equals( Void.TYPE ) ) if( method.getReturnType().equals( Void.TYPE ) )
{ {
final Class parameters[] = method.getParameterTypes();
final Class[] parameters = method.getParameterTypes();
if( 1 == parameters.length ) if( 1 == parameters.length )
{ {
matches.add( method ); matches.add( method );
@@ -372,7 +378,7 @@ public class ClassicConfigurer


private Method[] getCreateMethodsFor( final Class clazz, final String methodName ) private Method[] getCreateMethodsFor( final Class clazz, final String methodName )
{ {
final Method methods[] = clazz.getMethods();
final Method[] methods = clazz.getMethods();
final ArrayList matches = new ArrayList(); final ArrayList matches = new ArrayList();


for( int i = 0; i < methods.length; i++ ) for( int i = 0; i < methods.length; i++ )
@@ -385,7 +391,7 @@ public class ClassicConfigurer
if( !returnType.equals( Void.TYPE ) && if( !returnType.equals( Void.TYPE ) &&
!returnType.isPrimitive() ) !returnType.isPrimitive() )
{ {
final Class parameters[] = method.getParameterTypes();
final Class[] parameters = method.getParameterTypes();
if( 0 == parameters.length ) if( 0 == parameters.length )
{ {
matches.add( method ); matches.add( method );
@@ -437,7 +443,7 @@ public class ClassicConfigurer
// OMFG the rest of this is soooooooooooooooooooooooooooooooo // OMFG the rest of this is soooooooooooooooooooooooooooooooo
// slow. Need to cache results per class etc. // slow. Need to cache results per class etc.
final Class clazz = object.getClass(); final Class clazz = object.getClass();
Method methods[] = getMethodsFor( clazz, "add" + javaName );
Method[] methods = getMethodsFor( clazz, "add" + javaName );


if( 0 != methods.length ) if( 0 != methods.length )
{ {


Loading…
Cancel
Save