donaldp 01/12/29 16:16:24
Modified: proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs
Echo.java
Log:
Update to use getLogger().<method>() rather than log()
Move EchoLevel inner class to top level class
Revision Changes Path
1.8 +36 -47
jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Echo.java
Index: Echo.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Echo.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- Echo.java 23 Dec 2001 06:33:35 -0000 1.7
+++ Echo.java 30 Dec 2001 00:16:24 -0000 1.8
@@ -11,32 +11,29 @@
import java.io.FileWriter;
import java.io.IOException;
import org.apache.myrmidon.api.TaskException;
-import org.apache.tools.ant.Project;
import org.apache.tools.ant.Task;
-import org.apache.tools.ant.types.EnumeratedAttribute;
/**
* Log
*
* @author [EMAIL PROTECTED]
*/
-public class Echo extends Task
+public class Echo
+ extends Task
{
- protected String message = "";// required
- protected File file = null;
- protected boolean append = false;
-
- // by default, messages are always displayed
- protected int logLevel = Project.MSG_WARN;
+ private String m_message = "";// required
+ private File m_file;
+ private boolean m_append;
+ private EchoLevel m_echoLevel;
/**
* Shall we append to an existing file?
*
* @param append The new Append value
*/
- public void setAppend( boolean append )
+ public void setAppend( final boolean append )
{
- this.append = append;
+ m_append = append;
}
/**
@@ -44,9 +41,9 @@
*
* @param file The new File value
*/
- public void setFile( File file )
+ public void setFile( final File file )
{
- this.file = file;
+ m_file = file;
}
/**
@@ -64,30 +61,9 @@
*
* @param echoLevel The new Level value
*/
- public void setLevel( EchoLevel echoLevel )
+ public void setLevel( final EchoLevel echoLevel )
{
- String option = echoLevel.getValue();
- if( option.equals( "error" ) )
- {
- logLevel = Project.MSG_ERR;
- }
- else if( option.equals( "warning" ) )
- {
- logLevel = Project.MSG_WARN;
- }
- else if( option.equals( "info" ) )
- {
- logLevel = Project.MSG_INFO;
- }
- else if( option.equals( "verbose" ) )
- {
- logLevel = Project.MSG_VERBOSE;
- }
- else
- {
- // must be "debug"
- logLevel = Project.MSG_DEBUG;
- }
+ m_echoLevel = echoLevel;
}
/**
@@ -95,9 +71,9 @@
*
* @param msg Sets the value for the message variable.
*/
- public void setMessage( String msg )
+ public void setMessage( final String message )
{
- this.message = msg;
+ m_message = message;
}
/**
@@ -105,10 +81,10 @@
*
* @param msg The feature to be added to the Text attribute
*/
- public void addText( String msg )
+ public void addText( final String message )
throws TaskException
{
- message += getProject().replaceProperties( msg );
+ m_message += getProject().replaceProperties( message );
}
/**
@@ -119,17 +95,17 @@
public void execute()
throws TaskException
{
- if( file == null )
+ if( m_file == null )
{
- log( message, logLevel );
+ doLog();
}
else
{
FileWriter out = null;
try
{
- out = new FileWriter( file.getAbsolutePath(), append );
- out.write( message, 0, message.length() );
+ out = new FileWriter( m_file.getAbsolutePath(), m_append );
+ out.write( m_message, 0, m_message.length() );
}
catch( IOException ioe )
{
@@ -151,11 +127,24 @@
}
}
- public static class EchoLevel extends EnumeratedAttribute
+ private void doLog()
{
- public String[] getValues()
+ final String option = m_echoLevel.getValue();
+ if( option.equals( "error" ) )
+ {
+ getLogger().error( m_message );
+ }
+ else if( option.equals( "warning" ) )
+ {
+ getLogger().warn( m_message );
+ }
+ else if( option.equals( "info" ) )
+ {
+ getLogger().info( m_message );
+ }
+ else
{
- return new String[]{"error", "warning", "info", "verbose",
"debug"};
+ getLogger().debug( m_message );
}
}
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>