From (query directive)
(→Notes) |
|||
Line 15: | Line 15: | ||
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. | + | 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. ''A.from(B)'' is same as ''B.to(A)''. |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
== Examples == | == Examples == | ||
Line 34: | Line 28: | ||
Above example gets instances of the specified topic. The from method implicitly creates a [[Literals (query directive) |Literals]] directive. [[Instances (query directive) |Instances]] directive can take as input both topics or subject identifier string so this works without explicitly converting the string to a topic. | Above example gets instances of the specified topic. The from method implicitly creates a [[Literals (query directive) |Literals]] directive. [[Instances (query directive) |Instances]] directive can take as input both topics or subject identifier string so this works without explicitly converting the string to a topic. | ||
+ | |||
+ | Next two examples get the base names of the instances of the input. The second example uses ''to'' instead of ''from'' turning the query other way round. | ||
+ | |||
+ | importPackage(org.wandora.query2); | ||
+ | new BaseName().from(new Instances()) | ||
+ | |||
+ | importPackage(org.wandora.query2); | ||
+ | new Instances().to(new BaseName()) | ||
[[Category:Query directives]] | [[Category:Query directives]] |
Revision as of 11:38, 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. A.from(B) is same as B.to(A).
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.
Next two examples get the base names of the instances of the input. The second example uses to instead of from turning the query other way round.
importPackage(org.wandora.query2); new BaseName().from(new Instances())
importPackage(org.wandora.query2); new Instances().to(new BaseName())