ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dona...@apache.org
Subject cvs commit: jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/builder Resources.properties ATIProjectBuilder.java DefaultProjectBuilder.java
Date Tue, 28 Aug 2001 14:57:20 GMT
donaldp     01/08/28 07:57:20

  Modified:    proposal/myrmidon/src/java/org/apache/myrmidon/components/aspect
                        DefaultAspectManager.java
               proposal/myrmidon/src/java/org/apache/myrmidon/components/builder
                        ATIProjectBuilder.java DefaultProjectBuilder.java
  Added:       proposal/myrmidon/src/java/org/apache/myrmidon/components/aspect
                        Resources.properties
               proposal/myrmidon/src/java/org/apache/myrmidon/components/builder
                        Resources.properties
  Log:
  Begin integration of i18n'ed messages.
  
  Revision  Changes    Path
  1.4       +11 -3     jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/aspect/DefaultAspectManager.java
  
  Index: DefaultAspectManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/aspect/DefaultAspectManager.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DefaultAspectManager.java	2001/06/06 06:12:48	1.3
  +++ DefaultAspectManager.java	2001/08/28 14:57:20	1.4
  @@ -8,6 +8,8 @@
   package org.apache.myrmidon.components.aspect;
   
   import java.util.HashMap;
  +import org.apache.avalon.excalibur.i18n.ResourceManager;
  +import org.apache.avalon.excalibur.i18n.Resources;
   import org.apache.avalon.framework.activity.Initializable;
   import org.apache.avalon.framework.configuration.Configuration;
   import org.apache.avalon.framework.parameters.Parameters;
  @@ -25,6 +27,9 @@
   public class DefaultAspectManager
       implements AspectManager, Initializable
   {
  +    private static final Resources REZ =
  +        ResourceManager.getPackageResources( DefaultAspectManager.class );
  +
       private HashMap          m_aspectMap  = new HashMap();
       private AspectHandler[]  m_aspects    = new AspectHandler[ 0 ];
       private String[]         m_names      = new String[ 0 ];
  @@ -50,7 +55,8 @@
           final AspectHandler entry = (AspectHandler)m_aspectMap.remove( name );
           if( null == entry )
           {
  -            throw new TaskException( "No such aspect with name '" + name + "'" );
  +            final String message = REZ.getString( "no.aspect", name );
  +            throw new TaskException( message );
           }
   
           rebuildArrays();
  @@ -75,7 +81,8 @@
           final AspectHandler handler = (AspectHandler)m_aspectMap.get( name );
           if( null == handler )
           {
  -            throw new TaskException( "No such aspect with name '" + name + "'" );
  +            final String message = REZ.getString( "no.aspect", name );
  +            throw new TaskException( message );
           }
   
           handler.aspectSettings( parameters, elements );
  @@ -98,7 +105,8 @@
       public void aspectSettings( final Parameters parameters, final Configuration[] elements
)
           throws TaskException
       {
  -        throw new UnsupportedOperationException( "Can not provide Settings to AspectManager"
);
  +        final String message = REZ.getString( "no.settings" );
  +        throw new UnsupportedOperationException( message );
       }
   
       public void postCreate( final Task task )
  
  
  
  1.1                  jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/aspect/Resources.properties
  
  Index: Resources.properties
  ===================================================================
  no.aspect=No such aspect with name {0}.
  no.settings=Can not provide Settings to AspectManager.
  
  
  1.3       +40 -37    jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/builder/ATIProjectBuilder.java
  
  Index: ATIProjectBuilder.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/builder/ATIProjectBuilder.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ATIProjectBuilder.java	2001/07/27 07:24:54	1.2
  +++ ATIProjectBuilder.java	2001/08/28 14:57:20	1.3
  @@ -7,25 +7,27 @@
    */
   package org.apache.myrmidon.components.builder;
   
  -import java.net.URL;
   import java.io.InputStream;
  +import java.net.URL;
   import java.util.Properties;
   import javax.xml.parsers.SAXParser;
   import javax.xml.parsers.SAXParserFactory;
  -import org.apache.avalon.framework.configuration.SAXConfigurationHandler;
  -import org.apache.avalon.framework.parameters.Parameterizable;
  -import org.apache.avalon.framework.parameters.Parameters;
  -import org.xml.sax.SAXException;
  -import org.xml.sax.XMLReader;
  -import javax.xml.transform.TransformerFactory;
   import javax.xml.transform.Transformer;
   import javax.xml.transform.TransformerConfigurationException;
  +import javax.xml.transform.TransformerFactory;
   import javax.xml.transform.sax.SAXResult;
   import javax.xml.transform.sax.SAXSource;
   import javax.xml.transform.sax.SAXTransformerFactory;
   import javax.xml.transform.sax.TransformerHandler;
  -import javax.xml.transform.stream.StreamSource;
   import javax.xml.transform.stream.StreamResult;
  +import javax.xml.transform.stream.StreamSource;
  +import org.apache.avalon.excalibur.i18n.ResourceManager;
  +import org.apache.avalon.excalibur.i18n.Resources;
  +import org.apache.avalon.framework.configuration.SAXConfigurationHandler;
  +import org.apache.avalon.framework.parameters.Parameterizable;
  +import org.apache.avalon.framework.parameters.Parameters;
  +import org.xml.sax.SAXException;
  +import org.xml.sax.XMLReader;
   
   /**
    * Default implementation to construct project from a build file.
  @@ -36,15 +38,9 @@
       extends DefaultProjectBuilder
       implements Parameterizable
   {
  -    private final static String PARAM_EXCEPTION = 
  -        "Malformed PI: expected <?xsl-param name=\"foo\" value=\"bar\"?>";
  +    private static final Resources REZ =
  +        ResourceManager.getPackageResources( ATIProjectBuilder.class );
   
  -    private final static String PARAMS_EXCEPTION = 
  -        "Malformed PI: expected <?xsl-params location=\"myparams.properties\"?>";
  -
  -    private final static String STYLE_EXCEPTION = 
  -        "Malformed PI: expected <?xsl-params href=\"mystylesheet.xsl\"?>";
  -
       private Parameters     m_parameters;
       private URL            m_systemID;
   
  @@ -82,12 +78,12 @@
   
               if( target.equals( "xsl-param" ) ) handleParameter( data );
               else if( target.equals( "xsl-params" ) ) handleParameters( data, sourceID );
  -            else if( target.equals( "xsl-stylesheet" ) ) 
  +            else if( target.equals( "xsl-stylesheet" ) )
               {
                   if( null != transformer )
                   {
  -                    throw new SAXException( "Build file can not contain " + 
  -                                            "two xsl-stylesheet PIs" );
  +                    final String message = REZ.getString( "ati.two.stylesheet.pis" );
  +                    throw new SAXException( message );
                   }
   
                   final TransformerFactory factory = TransformerFactory.newInstance();
  @@ -113,9 +109,9 @@
   
               final SAXResult result = new SAXResult( handler );
               transformer.transform( new StreamSource( sourceID.toString() ), result );
  -            //transformer.transform( new StreamSource( sourceID.toString() ), 
  +            //transformer.transform( new StreamSource( sourceID.toString() ),
               //new StreamResult( System.out ) );
  -        }        
  +        }
       }
   
       private void handleParameter( final String data )
  @@ -124,22 +120,25 @@
           int index = data.indexOf( '\"' );
           if( -1 == index )
           {
  -            throw new SAXException( PARAM_EXCEPTION );
  +            final String message = REZ.getString( "ati.param.error" );
  +            throw new SAXException( message );
           }
   
           index = data.indexOf( '\"', index + 1 );
           if( -1 == index )
           {
  -            throw new SAXException( PARAM_EXCEPTION );
  +            final String message = REZ.getString( "ati.param.error" );
  +            throw new SAXException( message );
           }
   
           //split between two "attributes" occurs on index
           final String[] name = parseAttribute( data.substring( 0, index + 1 ) );
           final String[] value = parseAttribute( data.substring( index + 1 ).trim() );
  -        
  +
           if( !name[ 0 ].equals( "name" ) || !value[ 0 ].equals( "value" ) )
           {
  -            throw new SAXException( PARAM_EXCEPTION );
  +            final String message = REZ.getString( "ati.param.error" );
  +            throw new SAXException( message );
           }
   
           m_parameters.setParameter( name[ 1 ], value[ 1 ] );
  @@ -151,7 +150,8 @@
           final String[] params = parseAttribute( data );
           if( !params[ 0 ].equals( "location" ) )
           {
  -            throw new SAXException( PARAMS_EXCEPTION );
  +            final String message = REZ.getString( "ati.params.error" );
  +            throw new SAXException( message );
           }
   
           try
  @@ -165,7 +165,8 @@
           }
           catch( final Exception e )
           {
  -            throw new SAXException( "Error loading parameters: " + e );
  +            final String message = REZ.getString( "ati.loading-params.error", params[ 1
], e );
  +            throw new SAXException( message );
           }
       }
   
  @@ -175,14 +176,16 @@
           final String[] stylesheet = parseAttribute( data );
           if( !stylesheet[ 0 ].equals( "href" ) )
           {
  -            throw new SAXException( STYLE_EXCEPTION );
  +            final String message = REZ.getString( "ati.style.error" );
  +            throw new SAXException( message );
           }
   
           try { return new URL( baseSource, stylesheet[ 1 ] ).toString(); }
           catch( final Exception e )
           {
  -            throw new SAXException( "Error locating stylesheet '" + stylesheet[ 1 ] + 
  -                                    "' due to " + e );
  +            final String message =
  +                REZ.getString( "ati.loading-style.error", stylesheet[ 1 ], e );
  +            throw new SAXException( message );
           }
       }
   
  @@ -193,20 +196,20 @@
           int index = data.indexOf( '=' );
           if( -1 == index )
           {
  -            throw new SAXException( "Expecting an attribute but received '" + 
  -                                    data + "'" );
  +            final String message = REZ.getString( "ati.attribue-expected.error", data );
  +            throw new SAXException( message );
           }
   
           final int size = data.length();
  -        if( '\"' != data.charAt( index + 1 ) || 
  +        if( '\"' != data.charAt( index + 1 ) ||
               '\"' != data.charAt( size - 1 ) ||
               size - 1 == index )
           {
  -            throw new SAXException( "Expecting the value of attribute " + 
  -                                    data.substring( 0, index ) +
  -                                    " to be enclosed in quotes" );
  +            final String message =
  +                REZ.getString( "ati.attribue-unquoted.error", data.substring( 0, index
) );
  +            throw new SAXException( message );
           }
  -        
  +
           final String[] result = new String[ 2 ];
           result[ 0 ] = data.substring( 0, index );
           result[ 1 ] = data.substring( index + 2, size - 1 );
  
  
  
  1.13      +64 -28    jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/builder/DefaultProjectBuilder.java
  
  Index: DefaultProjectBuilder.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/builder/DefaultProjectBuilder.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- DefaultProjectBuilder.java	2001/06/29 02:40:00	1.12
  +++ DefaultProjectBuilder.java	2001/08/28 14:57:20	1.13
  @@ -29,6 +29,8 @@
   import org.apache.myrmidon.components.model.Target;
   import org.xml.sax.SAXException;
   import org.xml.sax.XMLReader;
  +import org.apache.avalon.excalibur.i18n.ResourceManager;
  +import org.apache.avalon.excalibur.i18n.Resources;
   
   /**
    * Default implementation to construct project from a build file.
  @@ -39,6 +41,9 @@
       extends AbstractLoggable
       implements ProjectBuilder
   {
  +    private static final Resources REZ =
  +        ResourceManager.getPackageResources( DefaultProjectBuilder.class );
  +
       private final static int    PROJECT_REFERENCES  = 0;
       private final static int    LIBRARY_IMPORTS     = 1;
       private final static int    IMPLICIT_TASKS      = 2;
  @@ -117,7 +122,8 @@
       {
           if( !configuration.getName().equals( "project" ) )
           {
  -            throw new Exception( "Project file must be enclosed in project element" );
  +            final String message = REZ.getString( "ant.no-project-element.error" );
  +            throw new Exception( message );
           }
   
           //get project-level attributes
  @@ -129,7 +135,11 @@
           final File baseDirectory =
               (new File( file.getParentFile(), baseDirectoryName )).getAbsoluteFile();
   
  -        getLogger().debug( "Project " + file + " base directory: " + baseDirectory );
  +        if( getLogger().isDebugEnabled() )
  +        {
  +            final String message = REZ.getString( "ant.project-banner.notice", file, baseDirectory
);
  +            getLogger().debug( message );
  +        }
   
           //create project and ...
           final DefaultProject project = new DefaultProject();
  @@ -205,9 +215,9 @@
               if( name.equals( "target" ) ) buildTarget( project, element );
               else
               {
  -                throw new Exception( "Unknown top-level element " + name +
  -                                     " at " + element.getLocation() +
  -                                     ". Expecting target" );
  +                final String message = 
  +                    REZ.getString( "ant.unknown-toplevel-element.error", name, element.getLocation()
);
  +                throw new Exception( message );
               }
           }
   
  @@ -228,20 +238,23 @@
   
           if( null == name )
           {
  -            throw new Exception( "Malformed projectref without a name attribute at " +
  -                                 element.getLocation() );
  +            final String message = 
  +                REZ.getString( "ant.projectref-no-name.error", element.getLocation() );
  +            throw new Exception( message );
           }
   
           if( !validName( name ) )
           {
  -            throw new Exception( "Projectref with an invalid name attribute at " +
  -                                 element.getLocation() );
  +            final String message = 
  +                REZ.getString( "ant.projectref-bad-name.error", element.getLocation() );
  +            throw new Exception( message );
           }
   
           if( null == location )
           {
  -            throw new Exception( "Malformed projectref without a location attribute at
" +
  -                                 element.getLocation() );
  +            final String message = 
  +                REZ.getString( "ant.projectref-no-location.error", element.getLocation()
);
  +            throw new Exception( message );
           }
   
           final File baseDirectory = project.getBaseDirectory();
  @@ -270,17 +283,18 @@
   
           if( null == library )
           {
  -            throw new Exception( "Malformed import without a library attribute at " +
  -                                 element.getLocation() );
  +            final String message = 
  +                REZ.getString( "ant.import-no-library.error", element.getLocation() );
  +            throw new Exception( message );
           }
   
           if( null == name || null == type )
           {
               if( null != name || null != type )
               {
  -                throw new Exception( "Malformed import at " + element.getLocation() +
  -                                     ". If name or type attribute is specified, both "
+
  -                                     "attributes must be specified." );
  +                final String message = 
  +                    REZ.getString( "ant.import-malformed.error", element.getLocation()
);
  +                throw new Exception( message );
               }
           }
   
  @@ -303,34 +317,49 @@
   
           if( null == name )
           {
  -            throw new Exception( "Discovered un-named target at " +
  -                                 target.getLocation() );
  +            final String message = 
  +                REZ.getString( "ant.target-noname.error", target.getLocation() );
  +            throw new Exception( message );
           }
   
           if( !validName( name ) )
           {
  -            throw new Exception( "Target with an invalid name at " +
  -                                 target.getLocation() );
  +            final String message = 
  +                REZ.getString( "ant.target-bad-name.error", target.getLocation() );
  +            throw new Exception( message );
           }
   
  -        getLogger().debug( "Parsing target: " + name );
  +        if( getLogger().isDebugEnabled() )
  +        {
  +            final String message = REZ.getString( "ant.target-parse.notice", name );
  +            getLogger().debug( message );
  +        }
   
           if( null != ifCondition && null != unlessCondition )
           {
  -            throw new Exception( "Discovered invalid target that has both a if and " +
  -                                    "unless condition at " + target.getLocation() );
  +            final String message = 
  +                REZ.getString( "ant.target-bad-logic.error", target.getLocation() );
  +            throw new Exception( message );
           }
   
           Condition condition = null;
   
           if( null != ifCondition )
           {
  -            getLogger().debug( "Target if condition: " + ifCondition );
  +            if( getLogger().isDebugEnabled() )
  +            {
  +                final String message = REZ.getString( "ant.target-if.notice", ifCondition
);
  +                getLogger().debug( message );
  +            }
               condition = new Condition( true, ifCondition );
           }
           else if( null != unlessCondition )
           {
  -            getLogger().debug( "Target unless condition: " + unlessCondition );
  +            if( getLogger().isDebugEnabled() )
  +            {
  +                final String message = REZ.getString( "ant.target-unless.notice", unlessCondition
);
  +                getLogger().debug( message );
  +            }
               condition = new Condition( false, unlessCondition );
           }
   
  @@ -348,11 +377,18 @@
   
                   if( 0 == dependency.length() )
                   {
  -                    throw new Exception( "Discovered empty dependency in target " +
  -                                         target.getName() + " at " + target.getLocation()
);
  +                    final String message = REZ.getString( "ant.target-bad-dependency.error",

  +                                                          target.getName(), 
  +                                                          target.getLocation() );
  +                    throw new Exception( message );
                   }
  +
  +                if( getLogger().isDebugEnabled() )
  +                {
  +                    final String message = REZ.getString( "ant.target-dependency.notice",
dependency );
  +                    getLogger().debug( message );
  +                }   
   
  -                getLogger().debug( "Target dependency: " + dependency );
                   dependsList.add( dependency );
               }
   
  
  
  
  1.1                  jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/builder/Resources.properties
  
  Index: Resources.properties
  ===================================================================
  ati.two.stylesheet.pis=Build file can not contain two xsl-stylesheet PIs.
  ati.params.error=Malformed PI: expected <?xsl-params location=\"myparams.properties\"?>
  ati.param.error=Malformed PI: expected <?xsl-param name=\"foo\" value=\"bar\"?>
  ati.style.error=Malformed PI: expected <?xsl-params href=\"mystylesheet.xsl\"?>
  ati.loading-params.error=Error loading parameters {0}. Reason: {1}.
  ati.loading-style.error=Error locating stylesheet {0}. Reason: {1}.
  ati.attribue-expected.error=Expecting an attribute but received {0}.
  ati.attribue-unquoted.error=Expecting the value of attribute {0} to be enclosed in quotes.
  
  ant.project-banner.notice=Project {0} base directory: {1}.
  ant.target-parse.notice=Parsing target: {0}.
  ant.target-if.notice=Target if condition: {0}
  ant.target- unless.notice=Target unless condition: {0}
  ant.target-dependency.notice=Target dependency: {0}
  ant.no-project-element.error=Project file must be enclosed in project element.
  ant.unknown-toplevel-element.error=Unknown top-level element {0} at {1}.
  ant.projectref-no-name.error=Malformed projectref without a name attribute at {0}.
  ant.projectref-bad-name.error=Projectref with an invalid name attribute at {0}.
  ant.projectref-no-location.error=Malformed projectref without a location attribute at {0}.
  ant.import-no-library.error=Malformed import without a library attribute at {0}.
  ant.import-malformed.error=Malformed import at {0}. If name or type attribute is specified,
both attributes must be specified.
  ant.target-noname.error=Discovered un-named target at {0}.
  ant.target-bad-name.error=Target with an invalid name at {0}.
  ant.target-bad-logic.error=Discovered invalid target that has both a if and unless condition
at {0}.
  ant.target-bad-dependency.error=Discovered empty dependency in target {0} at {1}.
  
  

Mime
View raw message