Players (query directive)
(→Notes) |
|||
Line 9: | Line 9: | ||
== Notes == | == Notes == | ||
− | This directive contains a method ''whereInputIs(String role)''. This method can be used to set an additional requirement for the returned rows. The input topic must play the specified role for a row to be included in the results. For example ''new Players(XTMPSI.SUPERCLASS_SUBCLASS,XTMPSI.SUBCLASS).whereInputIs(XTMPSI.SUPERCLASS)'' will return all subclasses of input. Since the input class itself is likely to be a subclass of some other class, it might be returned as well without the ''whereInputIs'' method call. | + | This directive contains a method ''whereInputIs(String role)''. This method can be used to set an additional requirement for the returned rows. The input topic must play the specified role for a row to be included in the results. For example ''new Players(XTMPSI.SUPERCLASS_SUBCLASS,XTMPSI.SUBCLASS).whereInputIs(XTMPSI.SUPERCLASS)'' will return all subclasses of input. Since the input class itself is likely to be a subclass of some other class, it might be returned as well without the ''whereInputIs'' method call. |
+ | |||
+ | The players directive contains another helpful method, ''usingColumns''. This can be used to set the role names of the columns returned by the directive, like using the [[As (query directive) |As]] directive, or the equivalent method present in all directive. However, ''usingColumns'' lets you set all the returned players in one go instead of having to chain multiple [[Of (query directive) |Of]] and [[As (query directive) |As]] directives. ''usingColumns'' takes any number of parameters, first parameter being the role of the first returned player and so on. | ||
== Examples == | == Examples == |
Latest revision as of 10:02, 23 September 2014
Contents |
[edit] Description
Gets players of specified roles from associations of specified type. Input topic is the active column value of input row.
[edit] Constructor
Players(TopicOperand associationType,TopicOperand r1,...)
[edit] Notes
This directive contains a method whereInputIs(String role). This method can be used to set an additional requirement for the returned rows. The input topic must play the specified role for a row to be included in the results. For example new Players(XTMPSI.SUPERCLASS_SUBCLASS,XTMPSI.SUBCLASS).whereInputIs(XTMPSI.SUPERCLASS) will return all subclasses of input. Since the input class itself is likely to be a subclass of some other class, it might be returned as well without the whereInputIs method call.
The players directive contains another helpful method, usingColumns. This can be used to set the role names of the columns returned by the directive, like using the As directive, or the equivalent method present in all directive. However, usingColumns lets you set all the returned players in one go instead of having to chain multiple Of and As directives. usingColumns takes any number of parameters, first parameter being the role of the first returned player and so on.
[edit] Examples
Following example gets the super classes of the input topic. The call to whereInputIs makes sure that the input topic plays the role sub class in any association whose players might be included. Without it an association where the input topic is a super class of some other topic might be considered and the input topic included in the results.
importPackage(org.wandora.query2); importPackage(org.wandora.topicmap); new Players(XTMPSI.SUPERCLASS_SUBCLASS,XTMPSI.SUPERCLASS) .whereInputIs(XTMPSI.SUBCLASS),