dion 2002/06/11 19:36:06
Modified: src/java/org/apache/maven/jelly JellyAntProject.java
Log:
Mainly documentation updates I did while I was reading the code
Revision Changes Path
1.2 +66 -13
jakarta-turbine-maven/src/java/org/apache/maven/jelly/JellyAntProject.java
Index: JellyAntProject.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/jelly/JellyAntProject.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- JellyAntProject.java 10 Jun 2002 15:43:58 -0000 1.1
+++ JellyAntProject.java 12 Jun 2002 02:36:06 -0000 1.2
@@ -10,23 +10,46 @@
import java.util.Hashtable;
+/**
+ * An Ant {@link org.apache.tools.ant.Project project} that uses Jexl
+ * for it's variable context and resolution when 'normal' ant properties
+ * can't be found
+ *
+ * @task jexl expressions are not cached, and should be.
+ *
+ * @version $Id$
+ * @author <a href="mailto:[EMAIL PROTECTED]">Bob McWhirter</a>
+ * @author <a href="mailto:[EMAIL PROTECTED]">dIon Gillard</a>
+ */
public class JellyAntProject extends org.apache.tools.ant.Project
{
+ /** the jexl context used to store variables */
private HashMapContext jexlContext;
+ /** Create a new instance with a default {@link JexlContext jexl context} */
public JellyAntProject()
{
- this.jexlContext = new HashMapContext();
+ jexlContext = new HashMapContext();
}
+ /** Create a new instance with the provided {@link JexlContext jexl context}
+ * for property resolution
+ * @param jexlContext the context to use for resolution
+ */
public JellyAntProject(JexlContext jexlContext)
{
setJexlContext( jexlContext );
}
+ /**
+ * Retrieve a property by name, checking the Ant properties first, and
+ * then the jexl context
+ *
+ * @param name the name of the property to retrieve
+ * @return the value of the property, or null if not found
+ */
public String getProperty(String name)
{
- System.err.println( "################### getProperty(" + name + ")" );
String value = super.getProperty( name );
@@ -38,9 +61,15 @@
return value;
}
+ /**
+ * Retrieve a user property by name, checking the Ant properties first, and
+ * then the jexl context
+ *
+ * @param name the name of the user property to retrieve
+ * @return the value of the property, or null if not found
+ */
public String getUserProperty(String name)
{
- System.err.println( "################### getUserProperty(" + name + ")" );
String value = super.getUserProperty( name );
if ( value == null )
@@ -51,30 +80,41 @@
return value;
}
+ /**
+ * Retrieve a {@link Hashtable} of all properties. This implementation
+ * uses {@link JellyAntProps} so that dynamic properties based on bean
+ * properties can be accessed.
+ *
+ * @return a Hashtable of properties backed by the jexl context for
+ * dynamic properties
+ */
public Hashtable getProperties()
{
- System.err.println( "##### getProperties()" );
return new JellyAntProps( this );
}
+ /**
+ * Look up properties in the jexl context. These properties can be 'dynamic'
+ * and for example use properties of beans stored in the context.
+ *
+ * @param name the name of the property to retrieve
+ * @return the value of the named property, or null if not found
+ */
public String getMavenProperty(String name)
{
String value = null;
try
{
- System.err.println( name + " CCCC" );
+ // FIXME: Add caching of expressions here
Expression expr = ExpressionFactory.createExpression( name );
- System.err.println( name + " DDD: " + expr );
-
Object result = expr.evaluate( getJexlContext() );
if ( result != null )
{
value = result.toString();
}
-
- System.err.println( name + " EEE: " + value );
+
}
catch (Exception e)
{
@@ -85,22 +125,35 @@
return value;
}
+ /**
+ * accept a maven project object and make it accessible via the jexl context
+ *
+ * @param project a configured {@link Project project}
+ */
public void setMavenProject(Project project)
{
- this.jexlContext.put( "maven",
- project );
+ jexlContext.put( "maven", project );
}
+ /**
+ * Create a new jexl context for the project, and copy over any variables
+ * from the provided context
+ *
+ * @param jexlContext a context to copy variables from
+ */
public void setJexlContext(JexlContext jexlContext)
{
this.jexlContext = new HashMapContext();
-
this.jexlContext.putAll( jexlContext.getVars() );
}
+ /**
+ * provide access to the currently used context
+ * @return a {@link JexlContext}
+ */
public JexlContext getJexlContext()
{
- return this.jexlContext;
+ return jexlContext;
}
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>