You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by do...@apache.org on 2001/07/08 09:15:13 UTC
cvs commit: jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/api DefaultTaskContext.java TaskContext.java
donaldp 01/07/08 00:15:13
Modified: proposal/myrmidon/src/java/org/apache/myrmidon/api
DefaultTaskContext.java TaskContext.java
Log:
Remove resolveValue() as it is not needed here but in AbstractContainerTask.
Cleaned up default implementation of TaskContext
Revision Changes Path
1.6 +22 -67 jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/api/DefaultTaskContext.java
Index: DefaultTaskContext.java
===================================================================
RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/api/DefaultTaskContext.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- DefaultTaskContext.java 2001/06/05 07:54:29 1.5
+++ DefaultTaskContext.java 2001/07/08 07:15:12 1.6
@@ -23,7 +23,13 @@
extends DefaultContext
implements TaskContext
{
- private File m_baseDirectory;
+ /**
+ * Constructor for Context with no parent contexts.
+ */
+ public DefaultTaskContext( final Map contextData )
+ {
+ this( contextData );
+ }
/**
* Constructor for Context with no parent contexts.
@@ -32,17 +38,13 @@
{
this( null );
}
+
/**
* Constructor.
*/
public DefaultTaskContext( final TaskContext parent )
{
super( parent );
-
- if( null != parent )
- {
- m_baseDirectory = (File)parent.getBaseDirectory();
- }
}
/**
@@ -52,10 +54,7 @@
*/
public JavaVersion getJavaVersion()
{
- try
- {
- return (JavaVersion)get( JAVA_VERSION );
- }
+ try { return (JavaVersion)get( JAVA_VERSION ); }
catch( final ContextException ce )
{
throw new IllegalStateException( "No JavaVersion in Context" );
@@ -70,10 +69,7 @@
*/
public String getName()
{
- try
- {
- return (String)get( NAME );
- }
+ try { return (String)get( NAME ); }
catch( final ContextException ce )
{
throw new IllegalStateException( "No Name in Context" );
@@ -87,7 +83,11 @@
*/
public File getBaseDirectory()
{
- return m_baseDirectory;
+ try { return (File)get( BASE_DIRECTORY ); }
+ catch( final ContextException ce )
+ {
+ throw new IllegalStateException( "No Base Directory in Context" );
+ }
}
/**
@@ -102,30 +102,10 @@
*/
public File resolveFile( final String filename )
{
- final File result = FileUtil.resolveFile( m_baseDirectory, filename );
- if( null != result ) return result;
- else return null;
+ return FileUtil.resolveFile( getBaseDirectory(), filename );
}
/**
- * Resolve property.
- * This evaluates all property substitutions based on current context.
- *
- * @param property the property to resolve
- * @return the resolved property
- */
- public Object resolveValue( final String property )
- throws TaskException
- {
- try { return PropertyUtil.resolveProperty( property, this, false ); }
- catch( final PropertyException pe )
- {
- throw new TaskException( "Error resolving " + property + " due to " + pe.getMessage(),
- pe );
- }
- }
-
- /**
* Retrieve property for name.
*
* @param name the name of property
@@ -157,7 +137,7 @@
*
* @param property the property
*/
- public void setProperty( final String name, final Object value, final ScopeEnum scope )
+ public void setProperty( final String name, final Object value, final ScopeEnum scope )
throws TaskException
{
checkPropertyValid( name, value );
@@ -168,11 +148,11 @@
if( null == getParent() )
{
throw new TaskException( "Can't set a property with parent scope when context " +
- " has no parent" );
+ " has no parent" );
}
else
{
- ((DefaultTaskContext)getParent()).put( name, value );
+ ((TaskContext)getParent()).setProperty( name, value );
}
}
else if( TOP_LEVEL == scope )
@@ -184,37 +164,12 @@
context = (DefaultTaskContext)context.getParent();
}
- context.putValue( name, value );
+ context.put( name, value );
}
else
- {
- throw new TaskException( "Can't set a property with an unknown " +
- "property context! (" + scope + ")" );
- }
- }
-
- /**
- * put a value in context.
- * This put method is overidden so new baseDirectory can be saved
- * in member variable.
- *
- * @param key the key
- * @param value the value
- */
- public void putValue( final Object key, final Object value )
- throws TaskException
- {
- if( key.equals( BASE_DIRECTORY ) )
{
- try { m_baseDirectory = (File)value; }
- catch( final ClassCastException cce )
- {
- throw new TaskException( "Can not set baseDirectory to a non-file value.",
- cce );
- }
+ throw new IllegalStateException( "Unknown property scope! (" + scope + ")" );
}
-
- put( key, value );
}
/**
@@ -241,7 +196,7 @@
}
else if( JAVA_VERSION.equals( name ) && !( value instanceof JavaVersion ) )
{
- throw new TaskException( "property " + JAVA_VERSION +
+ throw new TaskException( "Property " + JAVA_VERSION +
" must have a value of type " +
JavaVersion.class.getName() );
}
1.5 +0 -10 jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/api/TaskContext.java
Index: TaskContext.java
===================================================================
RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/api/TaskContext.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- TaskContext.java 2001/06/16 03:29:50 1.4
+++ TaskContext.java 2001/07/08 07:15:12 1.5
@@ -69,16 +69,6 @@
throws TaskException;
/**
- * Resolve property.
- * This evaluates all property substitutions based on current context.
- *
- * @param property the property to resolve
- * @return the resolved property
- */
- Object resolveValue( String property )
- throws TaskException;
-
- /**
* Retrieve property for name.
*
* @param name the name of property