Browse Source

Update implementation of TaskContext to support the new resolveValue method in TaskContext

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@270515 13f79535-47bb-0310-9956-ffa450edef68
master
Peter Donald 23 years ago
parent
commit
425e6f46c6
2 changed files with 36 additions and 0 deletions
  1. +34
    -0
      proposal/myrmidon/src/java/org/apache/myrmidon/components/workspace/DefaultTaskContext.java
  2. +2
    -0
      proposal/myrmidon/src/java/org/apache/myrmidon/components/workspace/Resources.properties

+ 34
- 0
proposal/myrmidon/src/java/org/apache/myrmidon/components/workspace/DefaultTaskContext.java View File

@@ -12,6 +12,8 @@ import java.util.Map;
import org.apache.avalon.excalibur.i18n.ResourceManager;
import org.apache.avalon.excalibur.i18n.Resources;
import org.apache.avalon.excalibur.io.FileUtil;
import org.apache.avalon.excalibur.property.PropertyException;
import org.apache.avalon.excalibur.property.PropertyUtil;
import org.apache.avalon.framework.context.ContextException;
import org.apache.avalon.framework.context.DefaultContext;
import org.apache.myrmidon.api.TaskContext;
@@ -104,6 +106,38 @@ public class DefaultTaskContext
return FileUtil.resolveFile( getBaseDirectory(), filename );
}

/**
* Resolve a value according to the context.
* This involves evaluating the string and thus removing
* ${} sequences according to the rules specified at
* ............
*
* @param value the value to resolve
* @return the resolved value
*/
public Object resolveValue( final String value )
throws TaskException
{
try
{
final Object object =
PropertyUtil.resolveProperty( value, this, false );

if( null == object )
{
final String message = REZ.getString( "null-resolved-value.error", value );
throw new TaskException( message );
}

return object;
}
catch( final PropertyException pe )
{
final String message = REZ.getString( "bad-resolve.error", value );
throw new TaskException( message, pe );
}
}

/**
* Retrieve property for name.
*


+ 2
- 0
proposal/myrmidon/src/java/org/apache/myrmidon/components/workspace/Resources.properties View File

@@ -17,3 +17,5 @@ no-dir.error=No Base Directory in Context.
no-parent.error=Can't set a property with parent scope when context has no parent.
bad-scope.error=Unknown property scope! ({0}).
bad-property.error=Property {0} must have a value of type {1}.
null-resolved-value.error=Value "{0}" resolved to null.
bad-resolve.error=Unable to resolve value "{0}".

Loading…
Cancel
Save