avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nic...@apache.org
Subject svn commit: rev 45863 - in avalon/trunk/tools/magic/src/main/org/apache/avalon/tools: model tasks
Date Sat, 11 Sep 2004 04:20:07 GMT
Author: niclas
Date: Fri Sep 10 21:20:05 2004
New Revision: 45863

Modified:
   avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/ElementHelper.java
   avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/PrepareTask.java
Log:
Formatting and preparation for ${abc.def} styled expansion in index.xml.

Modified: avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/ElementHelper.java
==============================================================================
--- avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/ElementHelper.java	(original)
+++ avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/ElementHelper.java	Fri
Sep 10 21:20:05 2004
@@ -192,12 +192,18 @@
     */
     public static String getValue( final Element node )
     {
-        if( null == node ) return null;
+        if( null == node ) 
+            return null;
+        String value;
         if( node.getChildNodes().getLength() > 0 )
         {
-            return node.getFirstChild().getNodeValue();
+            value = node.getFirstChild().getNodeValue();
         }
-        return node.getNodeValue(); 
+        else
+        {
+            value = node.getNodeValue(); 
+        }
+        return normalize( value );
     }
 
    /**
@@ -220,10 +226,12 @@
     */
     public static String getAttribute( final Element node, final String key, final String
def )
     {
-        if( null == node ) return def;
+        if( null == node ) 
+            return def;
         final String value = node.getAttribute( key );
-        if( null == value ) return def;
-        return value;
+        if( null == value ) 
+            return def;
+        return normalize( value );
     }
 
    /**
@@ -246,14 +254,36 @@
     */
     public static boolean getBooleanAttribute( final Element node, final String key, final
boolean def )
     {
-        if( null == node ) return def;
-        final String value = node.getAttribute( key );
-        if( null == value ) return def;
-        if( value.equals( "" ) ) return def;
-        if( value.equals( "true" ) ) return true;
-        if( value.equals( "false" ) ) return false;
+        if( null == node ) 
+            return def;
+        String value = node.getAttribute( key );
+        value = normalize( value );
+        
+        if( null == value ) 
+            return def;
+        if( value.equals( "" ) ) 
+            return def;
+        if( value.equals( "true" ) ) 
+            return true;
+        if( value.equals( "false" ) ) 
+            return false;
         final String error = 
           "Boolean argument [" + value + "] not recognized.";
         throw new BuildException( error );
+    }
+    
+    static String normalize( String value )
+    {
+        return normalize( value, System.getProperties() );
+    }
+    
+    static String normalize( String value, Properties props )
+    {
+        if( value.indexOf( '$' ) < 0 )
+            return value;
+        int pos = value.indexOf( "$" );
+        if( pos < 0 )
+            return value;
+        return value;
     }
 }

Modified: avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/PrepareTask.java
==============================================================================
--- avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/PrepareTask.java	(original)
+++ avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/PrepareTask.java	Fri Sep
10 21:20:05 2004
@@ -143,14 +143,16 @@
     private String getSrcMain()
     {
         final String path = getProject().getProperty( Context.SRC_MAIN_KEY );
-        if( null != path ) return path;
+        if( null != path ) 
+            return path;
         return Context.SRC_MAIN;
     }
 
     private String getSrcConfig()
     {
         final String path = getProject().getProperty( Context.SRC_CONFIG_KEY );
-        if( null != path ) return path;
+        if( null != path ) 
+            return path;
         return Context.SRC_CONFIG;
     }
 
@@ -165,10 +167,14 @@
        final File projectSrc, final File targetMain, final String source, 
        final String path )
     {
-        if( null == projectSrc ) throw new NullPointerException( "projectSrc" );
-        if( null == targetMain ) throw new NullPointerException( "targetMain" );
-        if( null == source ) throw new NullPointerException( "source" );
-        if( null == path ) throw new NullPointerException( "path" );
+        if( null == projectSrc ) 
+            throw new NullPointerException( "projectSrc" );
+        if( null == targetMain ) 
+            throw new NullPointerException( "targetMain" );
+        if( null == source ) 
+            throw new NullPointerException( "source" );
+        if( null == path ) 
+            throw new NullPointerException( "path" );
 
         final File src = new File( projectSrc, source );
         if( src.exists() )

---------------------------------------------------------------------
To unsubscribe, e-mail: cvs-unsubscribe@avalon.apache.org
For additional commands, e-mail: cvs-help@avalon.apache.org


Mime
View raw message