Re: simple jelly explanation
This is true, but only if outputDir is a java.lang.String (or an empty Map, Collection, or Array). Properties in maven are org.apache.commons.jelly.expression.ConstantExpression, so they are only empty() if they are undefined. A jexl workaround to this would be ${empty(myEmptyProperty.toString())}. A possible long-term solution would be to return true in jexl's ASTEmptyFunction.java if Object.toString() is an empty string, rather than using an instanceof test. Unfortunately, this does break with the spec. Alternatively, ConstantExpression could extend String, although that might be taking it a bit far :-) Matt James Strachan wrote: On 6 Nov 2003, at 00:43, matt wrote: You could also use ${empty(outputDir)}, or ${outputDir == null}, which are both identical in meaning to ${empty outputDir}. Not quite, empty(outputDir) is also true if outputDir == "" Jelly uses the Jexl Expression Language, which is a superset of JSTL (Java Standard Tag Library). To quote from JSTL in Action, "The empty operator determines whether a collection or string is empty or null. For instance, ${empty param.firstname} will be true only if a request parameter named firstname is not present. JSTL expressions can also compare items directly against the keyword null, as in ${param.firstname == null}, but this is an advanced use." Although Jelly is not always in a web context (ie, doesn't have the param implicit object), the same rules apply. In addition, to quote from the jexl home page (http://jakarta.apache.org/commons/jexl.html): Jexl has extended the JSTL in a few ways : - Support for invocation of any accessible method (see example above). - Added a general size() method, which works on String, returning length, Map, returning # of keys, and List and arrays, returning the number of elements. - Optional syntax for the 'empty' function : empty(obj) - Misc : '+' has been overloaded to be use as a String concatenation operator The "invocation of any accessible method" means that you can call ${object.getProperty()}, and it will be the same as ${object.property}, or ${object.setProperty(someOtherObject)}. You can also call methods that do not correspond to properties, such as ${someString.endsWith(otherString)}. Strongly recommend reading up on Jexl and JSTL. Good answer Matt :) James --- http://radio.weblogs.com/0112098/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: simple jelly explanation
On 6 Nov 2003, at 00:43, matt wrote: You could also use ${empty(outputDir)}, or ${outputDir == null}, which are both identical in meaning to ${empty outputDir}. Not quite, empty(outputDir) is also true if outputDir == "" Jelly uses the Jexl Expression Language, which is a superset of JSTL (Java Standard Tag Library). To quote from JSTL in Action, "The empty operator determines whether a collection or string is empty or null. For instance, ${empty param.firstname} will be true only if a request parameter named firstname is not present. JSTL expressions can also compare items directly against the keyword null, as in ${param.firstname == null}, but this is an advanced use." Although Jelly is not always in a web context (ie, doesn't have the param implicit object), the same rules apply. In addition, to quote from the jexl home page (http://jakarta.apache.org/commons/jexl.html): Jexl has extended the JSTL in a few ways : - Support for invocation of any accessible method (see example above). - Added a general size() method, which works on String, returning length, Map, returning # of keys, and List and arrays, returning the number of elements. - Optional syntax for the 'empty' function : empty(obj) - Misc : '+' has been overloaded to be use as a String concatenation operator The "invocation of any accessible method" means that you can call ${object.getProperty()}, and it will be the same as ${object.property}, or ${object.setProperty(someOtherObject)}. You can also call methods that do not correspond to properties, such as ${someString.endsWith(otherString)}. Strongly recommend reading up on Jexl and JSTL. Good answer Matt :) James --- http://radio.weblogs.com/0112098/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: simple jelly explanation
You could also use ${empty(outputDir)}, or ${outputDir == null}, which are both identical in meaning to ${empty outputDir}. Jelly uses the Jexl Expression Language, which is a superset of JSTL (Java Standard Tag Library). To quote from JSTL in Action, "The empty operator determines whether a collection or string is empty or null. For instance, ${empty param.firstname} will be true only if a request parameter named firstname is not present. JSTL expressions can also compare items directly against the keyword null, as in ${param.firstname == null}, but this is an advanced use." Although Jelly is not always in a web context (ie, doesn't have the param implicit object), the same rules apply. In addition, to quote from the jexl home page (http://jakarta.apache.org/commons/jexl.html): Jexl has extended the JSTL in a few ways : - Support for invocation of any accessible method (see example above). - Added a general size() method, which works on String, returning length, Map, returning # of keys, and List and arrays, returning the number of elements. - Optional syntax for the 'empty' function : empty(obj) - Misc : '+' has been overloaded to be use as a String concatenation operator The "invocation of any accessible method" means that you can call ${object.getProperty()}, and it will be the same as ${object.property}, or ${object.setProperty(someOtherObject)}. You can also call methods that do not correspond to properties, such as ${someString.endsWith(otherString)}. Strongly recommend reading up on Jexl and JSTL. Matt Vikas Phonsa wrote: Hi Guys, I have this line in one of the jelly script in a maven plugin. I don't know jelly but have checked out its major tags. Could you pls help me understand this: I undertand j:if test But in ${empty outputDir}" does empty refers to some inbuilt function of checking the outputDir or what ? Or is it supposed to be some function written somewhere in the jelly script that I'm using. Please guide Thanks Vikas - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: simple jelly explanation
Yes. This will evaluate true is the jelly value outputDir is "empty". I think that means null or "", but am not certain. You might also see it written as ${empty(outputDir)} - Brett > -Original Message- > From: Vikas Phonsa [mailto:[EMAIL PROTECTED] > Sent: Thursday, 6 November 2003 11:14 AM > To: 'Maven Users List' > Subject: simple jelly explanation > > > > Hi Guys, > > I have this line in one of the jelly script in a maven > plugin. I don't know jelly but have checked out its major > tags. Could you pls help me understand > this: > > > > I undertand j:if test > > But in ${empty outputDir}" does empty refers to some inbuilt > function of checking the outputDir or what ? > > Or is it supposed to be some function written somewhere in > the jelly script that I'm using. > > Please guide > > Thanks > > Vikas > > > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] >