[Jelly/JEXL] String concatenation

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

[Jelly/JEXL] String concatenation

Grant Ingersoll
Hi,


I would like to dynamically construct a String and for the life of me
can't figure out how to concatenate two strings together.

Would like to do something like (in Maven, btw):
<j:set var="classPath" value=""/>
<j:forEach var="lib" items="${pom.artifacts}">
           <j:set var="dep" value="${lib.dependency}"/>    
           <j:if test="${dep.type =='jar'}">
             <ant:copy todir="${delivery.home.lib}"
file="${lib.path}"/>
             <j:set var="classPath" value="${classPath +  './lib/' +
dep.artifactId + '.jar'}"/>
           </j:if>
</j:forEach>

where the 2nd j:set command is doing the concatenation.

Any help would be greatly appreciated.

Thanks,
Grant

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: [Jelly/JEXL] String concatenation

Grant Ingersoll
One possible way I found, to answer my own question:
<j:set var="classPath" value="./conf "/>
       
         <j:forEach var="lib" items="${pom.artifacts}">
           <j:set var="dep" value="${lib.dependency}"/>    
           <j:if test="${dep.type =='jar'}">
             <ant:copy todir="${delivery.home.lib}"
file="${lib.path}"/>
             <j:file var="classPath" omitXmlDeclaration="true"
escapeText="false">
                 ${classPath} ./lib/${dep.artifactId}.jar
             </j:file>
           </j:if>
         </j:forEach>
         <!-- Jar it all up -->
         <ant:echo message="ClassPath: ${classPath}"/>

The j:file tag has an option to write the string to memory instead of a
file.  

-Grant

>>> [hidden email] 07/18/05 12:51 PM >>>
Hi,


I would like to dynamically construct a String and for the life of me
can't figure out how to concatenate two strings together.

Would like to do something like (in Maven, btw):
<j:set var="classPath" value=""/>
<j:forEach var="lib" items="${pom.artifacts}">
           <j:set var="dep" value="${lib.dependency}"/>    
           <j:if test="${dep.type =='jar'}">
             <ant:copy todir="${delivery.home.lib}"
file="${lib.path}"/>
             <j:set var="classPath" value="${classPath +  './lib/' +
dep.artifactId + '.jar'}"/>
           </j:if>
</j:forEach>

where the 2nd j:set command is doing the concatenation.

Any help would be greatly appreciated.

Thanks,
Grant

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: [Jelly/JEXL] String concatenation

J.Enrique Ruiz
In reply to this post by Grant Ingersoll
Try this:

<j:set var="classPath" value="${classPath}./lib/${dep.artifactId}.jar"/>



>Hi,
>
>
>I would like to dynamically construct a String and for the life of me
>can't figure out how to concatenate two strings together.
>
>Would like to do something like (in Maven, btw):
><j:set var="classPath" value=""/>
><j:forEach var="lib" items="${pom.artifacts}">
>           <j:set var="dep" value="${lib.dependency}"/>    
>           <j:if test="${dep.type =='jar'}">
>             <ant:copy todir="${delivery.home.lib}"
>file="${lib.path}"/>
>             <j:set var="classPath" value="${classPath +  './lib/' +
>dep.artifactId + '.jar'}"/>
>           </j:if>
></j:forEach>
>
>where the 2nd j:set command is doing the concatenation.
>
>Any help would be greatly appreciated.
>
>Thanks,
>Grant
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [hidden email]
>For additional commands, e-mail: [hidden email]
>
>
>  
>

--
J.Enrique Ruiz-Valenciano
CIO, DiSiD S.L.L. (http://www.disid.com)
Phone: +34.655407965
Email: [hidden email]


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: [Jelly/JEXL] String concatenation

Paul Libbrecht
In reply to this post by Grant Ingersoll
Have you tried:

<j:set var="classPath"
   value="${classPath}./lib/${dep.artifactId}.jar"/>

which is more compact. Or
<j:set var="classPath"
   
value="${classPath.toString().concat('./lib/
').concat(dep.artifactId).concat('.jar')"/>

Remember... java under the hood!

paul

PS: .toString() only needed just to make sure classPath is actually a  
string.


Le 18 juil. 05, à 18:51, Grant Ingersoll a écrit :
> <j:set var="classPath" value="${classPath +  './lib/' +
> dep.artifactId + '.jar'}"/>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: [Jelly/JEXL] String concatenation

Grant Ingersoll
In reply to this post by Grant Ingersoll
Thanks, although I must confess, I thought I was doing "java under the hood" when I used the + operator to concatenate what I thought were strings!  Especially since the JEXL front page has an announcement about how the + operator has been overloaded for String concatenation (perhaps my version of Maven has an older version of JEXL).

Is there some documentation that describes the syntax?  http://jakarta.apache.org/commons/jexl/reference/syntax.html doesn't seem to have what we are discussing and I noticed the JEXL examples link is dead, so I can't go there.

Thanks,
Grant

>>> [hidden email] 07/18/05 3:58 PM >>>
Remember... java under the hood!

paul

PS: .toString() only needed just to make sure classPath is actually a  
string.


Le 18 juil. 05, à 18:51, Grant Ingersoll a écrit :
> <j:set var="classPath" value="${classPath +  './lib/' +
> dep.artifactId + '.jar'}"/>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]



---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: [Jelly/JEXL] String concatenation

Dion Gillard-2
Hmmm....must fix that examples link.

On 7/20/05, Grant Ingersoll <[hidden email]> wrote:

> Thanks, although I must confess, I thought I was doing "java under the hood" when I used the + operator to concatenate what I thought were strings!  Especially since the JEXL front page has an announcement about how the + operator has been overloaded for String concatenation (perhaps my version of Maven has an older version of JEXL).
>
> Is there some documentation that describes the syntax?  http://jakarta.apache.org/commons/jexl/reference/syntax.html doesn't seem to have what we are discussing and I noticed the JEXL examples link is dead, so I can't go there.
>
> Thanks,
> Grant
>
> >>> [hidden email] 07/18/05 3:58 PM >>>
> Remember... java under the hood!
>
> paul
>
> PS: .toString() only needed just to make sure classPath is actually a
> string.
>
>
> Le 18 juil. 05, à 18:51, Grant Ingersoll a écrit :
> > <j:set var="classPath" value="${classPath +  './lib/' +
> > dep.artifactId + '.jar'}"/>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>


--
http://www.multitask.com.au/people/dion/
"You are going to let the fear of poverty govern your life and your
reward will be that you will eat, but you will not live." - George
Bernard Shaw

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]