From (query directive)
(→Notes) |
|||
Line 14: | Line 14: | ||
You may also give the ''from'' method, not the directive constructor, one or more strings. In this case a [[Literals (query directive) |Literals]] directive will be implicitly created from the strings. ''A.from("b","c","d")'' resolves to ''new From(A,new Literals("b","c","d"))''. | You may also give the ''from'' method, not the directive constructor, one or more strings. In this case a [[Literals (query directive) |Literals]] directive will be implicitly created from the strings. ''A.from("b","c","d")'' resolves to ''new From(A,new Literals("b","c","d"))''. | ||
+ | |||
+ | All directives also have a ''to'' method which is inverse of ''from''. It is advisable that you use this sparingly as mixing both ''from'' and ''to'' in the same query can make it very hard to follow where the input comes from and where results go. The next two queries are equivalent. | ||
+ | |||
+ | importPackage(org.wandora.query2); | ||
+ | new BaseName().from(new Instances()) | ||
+ | |||
+ | importPackage(org.wandora.query2); | ||
+ | new Instances().to(new BaseName()) | ||
== Examples == | == Examples == |
Revision as of 11:36, 20 August 2009
Contents |
Description
Takes the results from one directive and feeds them one row at a time to another combining all results.
Constructor
From(Directive to,Directive from)
Notes
This directive is best used using the from method present in every directive. Calling A.from(B) will resolve to new From(A,B).
The from method, but not the directive constructor, can be given several directives. In this case they will be joined using the Join directive. A.from(B,C) will resolve to new From(A,new Join(B,C)).
You may also give the from method, not the directive constructor, one or more strings. In this case a Literals directive will be implicitly created from the strings. A.from("b","c","d") resolves to new From(A,new Literals("b","c","d")).
All directives also have a to method which is inverse of from. It is advisable that you use this sparingly as mixing both from and to in the same query can make it very hard to follow where the input comes from and where results go. The next two queries are equivalent.
importPackage(org.wandora.query2); new BaseName().from(new Instances())
importPackage(org.wandora.query2); new Instances().to(new BaseName())
Examples
importPackage(org.wandora.query2); new Instances().from(new Instances())
Above example selects the instances of the instances of the input topic.
importPackage(org.wandora.query2); new Instances().from("http://www.wandora.org/core/schema-type")
Above example gets instances of the specified topic. The from method implicitly creates a Literals directive. Instances directive can take as input both topics or subject identifier string so this works without explicitly converting the string to a topic.