Browse Source

Various fixes

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@273436 13f79535-47bb-0310-9956-ffa450edef68
master
Costin Manolache 22 years ago
parent
commit
0124baebe2
4 changed files with 48 additions and 11 deletions
  1. +22
    -2
      proposal/embed/src/java/org/apache/tools/ant/taskdefs/optional/JXPath.java
  2. +11
    -5
      proposal/embed/src/java/org/apache/tools/ant/taskdefs/optional/JXPathSet.java
  3. +5
    -1
      proposal/embed/src/java/org/apache/tools/ant/taskdefs/optional/JexlProperties.java
  4. +10
    -3
      proposal/embed/src/java/org/apache/tools/ant/taskdefs/optional/VelocityProperties.java

+ 22
- 2
proposal/embed/src/java/org/apache/tools/ant/taskdefs/optional/JXPath.java View File

@@ -77,8 +77,16 @@ public class JXPath extends Task implements PropertyInterceptor {
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) )
return null;
name=name.substring( PREFIX.length() );
@@ -105,13 +113,25 @@ public class JXPath extends Task implements PropertyInterceptor {
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() {
JXPathIntrospector.registerDynamicClass(Hashtable.class, JXPathHashtableHandler.class);

PropertyHelper phelper=PropertyHelper.getPropertyHelper( project );
phelper.addPropertyInterceptor( this );

project.addReference( "jxpathTask", this );
jxpathCtx=JXPathContext.newContext( project );


+ 11
- 5
proposal/embed/src/java/org/apache/tools/ant/taskdefs/optional/JXPathSet.java View File

@@ -71,12 +71,10 @@ import org.apache.commons.jxpath.*;
*/
public class JXPathSet extends Task {

JXPathContext jxpathCtx;
String path;
String value;
String valueString;
String refId;
public JXPathSet() {
}

@@ -99,12 +97,20 @@ public class JXPathSet extends Task {
/** Set the value to be used.
*/
public void setValue( String s ) {
this.value=s;
this.valueString=s;
}

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 );
}
}

+ 5
- 1
proposal/embed/src/java/org/apache/tools/ant/taskdefs/optional/JexlProperties.java View File

@@ -74,7 +74,11 @@ public class JexlProperties extends Task implements PropertyInterceptor {
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) )
return null;
try {


+ 10
- 3
proposal/embed/src/java/org/apache/tools/ant/taskdefs/optional/VelocityProperties.java View File

@@ -76,8 +76,12 @@ public class VelocityProperties extends Task implements PropertyInterceptor {
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) )
return null;
try {
@@ -93,13 +97,16 @@ public class VelocityProperties extends Task implements PropertyInterceptor {
return null;
}
}

public VelocityEngine getVelocityEngine() {
return engine;
}
public void execute() {
try {
PropertyHelper phelper=PropertyHelper.getPropertyHelper( project );
phelper.addPropertyInterceptor( this );
engine=new VelocityEngine();
engine.init();


Loading…
Cancel
Save