nsIXULTemplateResult.idl 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. #include "nsISupports.idl"
  6. interface nsIAtom;
  7. interface nsIDOMNode;
  8. interface nsIRDFResource;
  9. /**
  10. * A single result generated from a template query. Each result is identified
  11. * by an id, which must be unique within the set of results produced from a
  12. * query. The result may optionally be identified by an RDF resource.
  13. *
  14. * Generally, the result and its id will be able to uniquely identify a node
  15. * in the source data, such as an RDF or XML node. In other contexts, such as
  16. * a database query, a result would represent a particular record.
  17. *
  18. * A result is expected to only be created by a query processor.
  19. *
  20. * Each result also contains a set of variable bindings. The value for a
  21. * particular variable may be retrieved using the getBindingFor and
  22. * getBindingObjectFor methods.
  23. */
  24. [scriptable, uuid(ebea0230-36fa-41b7-8e31-760806057965)]
  25. interface nsIXULTemplateResult : nsISupports
  26. {
  27. /**
  28. * True if the result represents a container.
  29. */
  30. readonly attribute boolean isContainer;
  31. /**
  32. * True if the result represents an empty container.
  33. */
  34. readonly attribute boolean isEmpty;
  35. /**
  36. * True if the template builder may use this result as the reference point
  37. * for additional recursive processing of the template. The template builder
  38. * will reprocess the template using this result as the reference point and
  39. * generate output content that is expected to be inserted as children of the
  40. * output generated for this result. If false, child content is not
  41. * processed. This property identifies only the default handling and may be
  42. * overriden by syntax used in the template.
  43. */
  44. readonly attribute boolean mayProcessChildren;
  45. /**
  46. * ID of the result. The DOM element created for this result, if any, will
  47. * have its id attribute set to this value. The id must be unique for a
  48. * query.
  49. */
  50. readonly attribute AString id;
  51. /**
  52. * Resource for the result, which may be null. If set, the resource uri
  53. * must be the same as the ID property.
  54. */
  55. readonly attribute nsIRDFResource resource;
  56. /**
  57. * The type of the object. The predefined value 'separator' may be used
  58. * for separators. Other values may be used for application specific
  59. * purposes.
  60. */
  61. readonly attribute AString type;
  62. /**
  63. * Get the string representation of the value of a variable for this
  64. * result. This string will be used in the action body from a template as
  65. * the replacement text. For instance, if the text ?name appears in an
  66. * attribute within the action body, it will be replaced with the result
  67. * of this method. The question mark is considered part of the variable
  68. * name, thus aVar should be ?name and not simply name.
  69. *
  70. * @param aVar the variable to look up
  71. *
  72. * @return the value for the variable or a null string if it has no value
  73. */
  74. AString getBindingFor(in nsIAtom aVar);
  75. /**
  76. * Get an object value for a variable such as ?name for this result.
  77. *
  78. * This method may return null for a variable, even if getBindingFor returns
  79. * a non-null value for the same variable. This method is provided as a
  80. * convenience when sorting results.
  81. *
  82. * @param aVar the variable to look up
  83. *
  84. * @return the value for the variable or null if it has no value
  85. */
  86. nsISupports getBindingObjectFor(in nsIAtom aVar);
  87. /**
  88. * Indicate that a particular rule of a query has matched and that output
  89. * will be generated for it. Both the query as compiled by the query
  90. * processor's compileQuery method and the XUL <rule> element are supplied.
  91. * The query must always be one that was compiled by the query processor
  92. * that created this result. The <rule> element must always be a child of
  93. * the <query> element that was used to compile the query.
  94. *
  95. * @param aQuery the query that matched
  96. * @param aRuleNode the rule node that matched
  97. */
  98. void ruleMatched(in nsISupports aQuery, in nsIDOMNode aRuleNode);
  99. /**
  100. * Indicate that the output for a result has beeen removed and that the
  101. * result is no longer being used by the builder.
  102. */
  103. void hasBeenRemoved();
  104. };