git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@273436 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -77,8 +77,16 @@ public class JXPath extends Task implements PropertyInterceptor { | |||||
| public JXPath() { | public JXPath() { | ||||
| } | } | ||||
| public JXPathContext getJXPathContext() { | |||||
| return jxpathCtx; | |||||
| } | |||||
| public Object getProperty( Project p, String ns, String name ) { | |||||
| public boolean setProperty( Object c, String ns, String name, Object v ) { | |||||
| return false; | |||||
| } | |||||
| public Object getProperty( Object p, String ns, String name ) { | |||||
| if( ! name.startsWith(PREFIX) ) | if( ! name.startsWith(PREFIX) ) | ||||
| return null; | return null; | ||||
| name=name.substring( PREFIX.length() ); | name=name.substring( PREFIX.length() ); | ||||
| @@ -105,13 +113,25 @@ public class JXPath extends Task implements PropertyInterceptor { | |||||
| return result; | return result; | ||||
| } | } | ||||
| // testing | |||||
| String foo; | |||||
| public void setFoo( String s ) { | |||||
| System.out.println("Set foo " + s ); | |||||
| foo=s; | |||||
| } | |||||
| public String getFoo() { | |||||
| return foo; | |||||
| } | |||||
| public void execute() { | public void execute() { | ||||
| JXPathIntrospector.registerDynamicClass(Hashtable.class, JXPathHashtableHandler.class); | JXPathIntrospector.registerDynamicClass(Hashtable.class, JXPathHashtableHandler.class); | ||||
| PropertyHelper phelper=PropertyHelper.getPropertyHelper( project ); | PropertyHelper phelper=PropertyHelper.getPropertyHelper( project ); | ||||
| phelper.addPropertyInterceptor( this ); | phelper.addPropertyInterceptor( this ); | ||||
| project.addReference( "jxpathTask", this ); | |||||
| jxpathCtx=JXPathContext.newContext( project ); | jxpathCtx=JXPathContext.newContext( project ); | ||||
| @@ -71,12 +71,10 @@ import org.apache.commons.jxpath.*; | |||||
| */ | */ | ||||
| public class JXPathSet extends Task { | public class JXPathSet extends Task { | ||||
| JXPathContext jxpathCtx; | |||||
| String path; | String path; | ||||
| String value; | |||||
| String valueString; | |||||
| String refId; | String refId; | ||||
| public JXPathSet() { | public JXPathSet() { | ||||
| } | } | ||||
| @@ -99,12 +97,20 @@ public class JXPathSet extends Task { | |||||
| /** Set the value to be used. | /** Set the value to be used. | ||||
| */ | */ | ||||
| public void setValue( String s ) { | public void setValue( String s ) { | ||||
| this.value=s; | |||||
| this.valueString=s; | |||||
| } | } | ||||
| public void execute() { | public void execute() { | ||||
| jxpathCtx=JXPathContext.newContext( project ); | |||||
| JXPathContext jxpathCtx; | |||||
| JXPath jxpathTask=(JXPath)project.getReference( "jxpathTask" ); | |||||
| jxpathCtx=jxpathTask.getJXPathContext(); | |||||
| Object value=null; | |||||
| if( refId!=null ) | |||||
| value=project.getReference( refId ); | |||||
| if( value==null ) | |||||
| value=valueString; | |||||
| jxpathCtx.setValue( path, value ); | |||||
| } | } | ||||
| } | } | ||||
| @@ -74,7 +74,11 @@ public class JexlProperties extends Task implements PropertyInterceptor { | |||||
| public JexlProperties() { | public JexlProperties() { | ||||
| } | } | ||||
| public Object getProperty( Project p, String ns, String name ) { | |||||
| public boolean setProperty( Object ctx, String ns, String name, Object value ) { | |||||
| return false; | |||||
| } | |||||
| public Object getProperty( Object p, String ns, String name ) { | |||||
| if( ! name.startsWith(PREFIX) ) | if( ! name.startsWith(PREFIX) ) | ||||
| return null; | return null; | ||||
| try { | try { | ||||
| @@ -76,8 +76,12 @@ public class VelocityProperties extends Task implements PropertyInterceptor { | |||||
| public VelocityProperties() { | public VelocityProperties() { | ||||
| } | } | ||||
| public boolean setProperty( Object c, String ns, String name, Object v ) { | |||||
| return false; | |||||
| } | |||||
| public Object getProperty( Project p, String ns, String name ) { | |||||
| public Object getProperty( Object p, String ns, String name ) { | |||||
| if( ! name.startsWith(PREFIX) ) | if( ! name.startsWith(PREFIX) ) | ||||
| return null; | return null; | ||||
| try { | try { | ||||
| @@ -93,13 +97,16 @@ public class VelocityProperties extends Task implements PropertyInterceptor { | |||||
| return null; | return null; | ||||
| } | } | ||||
| } | } | ||||
| public VelocityEngine getVelocityEngine() { | |||||
| return engine; | |||||
| } | |||||
| public void execute() { | public void execute() { | ||||
| try { | try { | ||||
| PropertyHelper phelper=PropertyHelper.getPropertyHelper( project ); | PropertyHelper phelper=PropertyHelper.getPropertyHelper( project ); | ||||
| phelper.addPropertyInterceptor( this ); | phelper.addPropertyInterceptor( this ); | ||||
| engine=new VelocityEngine(); | engine=new VelocityEngine(); | ||||
| engine.init(); | engine.init(); | ||||