mcconnell 2003/11/24 13:17:29
Modified: merlin/util/defaults/src/java/org/apache/avalon/defaults
Defaults.java
Log:
Fix problem concering coposite symbolic references. You can not doing things like
define a property in the form: bin.dir = ${merlin.home}/bin
Revision Changes Path
1.3 +28 -20
avalon/merlin/util/defaults/src/java/org/apache/avalon/defaults/Defaults.java
Index: Defaults.java
===================================================================
RCS file:
/home/cvs/avalon/merlin/util/defaults/src/java/org/apache/avalon/defaults/Defaults.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Defaults.java 3 Nov 2003 23:57:30 -0000 1.2
+++ Defaults.java 24 Nov 2003 21:17:29 -0000 1.3
@@ -331,27 +331,31 @@
String l_key = ( String ) l_list.nextElement() ;
String l_macro = a_expanded.getProperty( l_key ) ;
- /*
- * Skip all regular properties that are not macros: used de Morgans
- * to convert ! l_key.startsWith( "${" ) && l_key.endsWith( "}" )
- * to conditional below since it is faster.
- */
- if ( ! l_macro.startsWith( "${" ) || ! l_macro.endsWith( "}" ) )
+ int n = l_macro.indexOf( "${" );
+ if( n < 0 )
{
- continue ;
+ continue;
+ }
+
+ int m = l_macro.indexOf( "}", n+2 );
+ if( m < 0 )
+ {
+ continue;
}
+
+ final String symbol = l_macro.substring( n+2, m );
- /*
- * Check if the macro key exists within the expanded Properties. If
- * so we continue onto the next macro skipping the optional props.
- */
- String l_macroKey = l_macro.substring( 2, l_macro.length() - 1 ) ;
- if ( a_expanded.containsKey( l_macroKey ) )
+ if ( a_expanded.containsKey( symbol ) )
{
- a_expanded.put( l_key, a_expanded.getProperty( l_macroKey ) ) ;
+ final String value = a_expanded.getProperty( symbol );
+ final String head = l_macro.substring( 0, n );
+ final String tail = l_macro.substring( m+1 );
+ final String resolved = head + value + tail;
+
+ a_expanded.put( l_key, resolved ) ;
continue ;
}
-
+
/*
* Check if the macro key exists within the array of optional
* Properties. Set expanded value to first Properties with the
@@ -359,10 +363,14 @@
*/
for ( int ii = 0; ii < a_optionals.length; ii++ )
{
- if ( a_optionals[ii].containsKey( l_macroKey ) )
+ if ( a_optionals[ii].containsKey( symbol ) )
{
- String l_value = a_optionals[ii].getProperty( l_macroKey ) ;
- a_expanded.put( l_key, l_value ) ;
+ String value = a_optionals[ii].getProperty( symbol ) ;
+ final String head = l_macro.substring( 0, n );
+ final String tail = l_macro.substring( m+1 );
+ final String resolved = head + value + tail;
+
+ a_expanded.put( l_key, resolved ) ;
break ;
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]