svn commit: rev 22911 - avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks

[email protected]
Newsgroups gmane.comp.jakarta.avalon.cvs
Message-ID <[email protected]>
Author: mcconnell
Date: Wed Jul 14 11:37:31 2004
New Revision: 22911

Modified:
   avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/HomeTask.java
   avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/PropertyTask.java
Log:
Add some more features to the property task.

Modified: avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/HomeTask.java
==============================================================================
--- avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/HomeTask.java	(original)
+++ avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/HomeTask.java	Wed Jul 14 11:37:31 2004
@@ -85,7 +85,7 @@
             project.setProperty( "project.basedir", def.getBaseDir().toString() );
             project.setProperty( "project.path", info.getPath() );
             project.setProperty( "project.uri", info.getURI() );
-            project.setProperty( "project.spec", def.getInfo().getSpec() );
+            project.setProperty( "project.spec", info.getSpec() );
             project.setProperty( "project.type", info.getType() );
             project.setProperty( "project.filename", info.getFilename() );
             project.setProperty( "project.short-filename", info.getShortFilename() );

Modified: avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/PropertyTask.java
==============================================================================
--- avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/PropertyTask.java	(original)
+++ avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/PropertyTask.java	Wed Jul 14 11:37:31 2004
@@ -110,6 +110,10 @@
         {
             return resource.getInfo().getGroup();
         }
+        else if( m_feature.equals( "type" ) )
+        {
+            return resource.getInfo().getType();
+        }
         else if( m_feature.equals( "version" ) )
         {
             final String version = resource.getInfo().getVersion();
@@ -128,111 +132,19 @@
         {
             return resource.getInfo().getSpec();
         }
-        else if( resource instanceof Definition )
-        {
-            final Definition def = (Definition) resource;
-            if( m_feature.equals( "system-classpath-for-windows" ) )
-            {
-                return getPath( def, true );
-            }
-            else if( m_feature.equals( "system-classpath-for-unix" ) )
-            {
-                return getPath( def, false );
-            }
-        }
-        return null;
-    }
-
-    private String getPath( final Definition def, final boolean windows )
-    {
-        final StringBuffer buffer = new StringBuffer();
-        final ResourceRef[] refs =
-          def.getResourceRefs( getProject(), Policy.RUNTIME, ResourceRef.ANY, true );
-        for( int i=0; i<refs.length; i++ )
-        {
-            if( i>0 )
-            {
-                buffer.append( ";" );
-            }
-
-            final ResourceRef ref = refs[i];
-            final Resource resource = getHome().getResource( ref );
-            final String path = getNativePath( windows, resource );
-            buffer.append( path );
-        }
-
-        if( refs.length > 0 )
-        {
-            buffer.append( ";" );
-        }
-
-        buffer.append( getNativePath( windows, def ) ); 
-        return buffer.toString();
-    }
-
-    private String getNativePath( final boolean windows, final Resource resource )
-    {
-        final String symbol = getPlatformCacheSymbol( windows );
-        final StringBuffer buffer = new StringBuffer( symbol );
-        final String path = resource.getInfo().getPath();
-        if( windows )
+        else if( m_feature.equals( "filename" ) )
         {
-            buffer.append( "\\" );
-            buffer.append( path.replace( '/', '\\' ) );
+            return resource.getInfo().getFilename();
         }
-        else
+        else if( m_feature.equals( "short-filename" ) )
         {
-            buffer.append( "/" );
-            buffer.append( path );
-        }
-        return buffer.toString();
-    }
-
-    private String getPlatformCacheSymbol( final boolean windows )
-    {
-        if( windows )
-        {
-            return "%MAGIC_SCD%";
+            return resource.getInfo().getShortFilename();
         }
         else
         {
-            return "$MAGIC_SCD";
-        } 
-    }
-    
-    public static class Attribute
-    {
-        private String m_name;
-        private String m_value;
-       
-        public Attribute()
-        {
-        }
-
-        public Attribute( final String name, final String value )
-        {
-            m_name = name;
-            m_value = value;
-        }
-
-        public void setName( final String name )
-        {
-            m_name = name;
-        }
-
-        public void setValue( final String value )
-        {
-            m_value = value;
-        }
-
-        public String getName()
-        {
-            return m_name;
-        }
-
-        public String getValue()
-        {
-            return m_value;
+            final String error = 
+              "Invalid property name [" + m_feature + "].";
+            throw new BuildException( error );
         }
     }
 }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.