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 2002/01/05 04:03:56 UTC
cvs commit: jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/workspace Resources.properties DefaultTaskContext.java
donaldp 02/01/04 19:03:56
Modified: proposal/myrmidon/src/java/org/apache/myrmidon/components/workspace
Resources.properties DefaultTaskContext.java
Log:
Update implementation of TaskContext to support the new resolveValue method in TaskContext
Revision Changes Path
1.4 +2 -0 jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/workspace/Resources.properties
Index: Resources.properties
===================================================================
RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/workspace/Resources.properties,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Resources.properties 19 Nov 2001 12:37:26 -0000 1.3
+++ Resources.properties 5 Jan 2002 03:03:55 -0000 1.4
@@ -17,3 +17,5 @@
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}".
\ No newline at end of file
1.7 +34 -0 jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/workspace/DefaultTaskContext.java
Index: DefaultTaskContext.java
===================================================================
RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/workspace/DefaultTaskContext.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- DefaultTaskContext.java 30 Dec 2001 06:13:33 -0000 1.6
+++ DefaultTaskContext.java 5 Jan 2002 03:03:55 -0000 1.7
@@ -12,6 +12,8 @@
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;
@@ -102,6 +104,38 @@
public File resolveFile( final String filename )
{
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 );
+ }
}
/**
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>