[EMF Query 2]Parameter in XText query [message #651824] |
Tue, 01 February 2011 17:46 |
|
Hi,
I would like to have a parameter in the query that I wrote using Xtext.
For instance in my .query file:
smyQueryName:
from XXX as xxx
in resources{${myVariable}}
select xxx
I would like to replace ${myVariable} by the URI of the resource
Regards,
Aurélien Pupier - Red Hat
Senior Software Engineer in Fuse Tooling team
|
|
|
Re: [EMF Query 2]Parameter in XText query [message #651921 is a reply to message #651824] |
Wed, 02 February 2011 05:04 |
saurav sarkar Messages: 428 Registered: July 2009 |
Senior Member |
|
|
HI Aurelien,
Answers below
Aurelien Pupier wrote on Tue, 01 February 2011 12:46 | Hi,
I would like to have a parameter in the query that I wrote using Xtext.
For instance in my .query file:
smyQueryName:
from XXX as xxx
in resources{${myVariable}}
select xxx
I would like to replace ${myVariable} by the URI of the resource
Regards,
|
You can pass parameter to the XText strings.
Please have a look at the org.eclipse.emf.query2.syntax.test.TestTransformation class where you can see a test method named testSelectPar2AsParameter whose query takes paramteres.
We have an API which actually transforms the XText AST to Query2 AST by accepting parameters.
/**
* For queries accepting arguments. Each ? in where clause of the query is
* replaced with object in Object[] replacableValues ? in query is replaced
* in order of element in Object[] replacableValues. User can pass values
* has following: transform(query, new Object[] { new Integer(200), new
* String(""), new Double(20.0), new Long(20000000000), new Boolean(true) }
* );
*
* @param query
* @param replacableValues
* @return {@link Query}
*/
public static Query transform(MQLquery query, Object[] replacableValues)
cheers,
Saurav
My Blog http://codifyit.blogspot.com/
Follow me: http://twitter.com/sauravs
|
|
|
|
Powered by
FUDForum. Page generated in 0.03941 seconds