1. /* $Id: Rules.java,v 1.11 2004/05/10 06:30:06 skitching Exp $
  2. *
  3. * Copyright 2001-2004 The Apache Software Foundation.
  4. *
  5. * Licensed under the Apache License, Version 2.0 (the "License");
  6. * you may not use this file except in compliance with the License.
  7. * You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. package org.apache.commons.digester;
  18. import java.util.List;
  19. /**
  20. * Public interface defining a collection of Rule instances (and corresponding
  21. * matching patterns) plus an implementation of a matching policy that selects
  22. * the rules that match a particular pattern of nested elements discovered
  23. * during parsing.
  24. */
  25. public interface Rules {
  26. // ------------------------------------------------------------- Properties
  27. /**
  28. * Return the Digester instance with which this Rules instance is
  29. * associated.
  30. */
  31. public Digester getDigester();
  32. /**
  33. * Set the Digester instance with which this Rules instance is associated.
  34. *
  35. * @param digester The newly associated Digester instance
  36. */
  37. public void setDigester(Digester digester);
  38. /**
  39. * Return the namespace URI that will be applied to all subsequently
  40. * added <code>Rule</code> objects.
  41. */
  42. public String getNamespaceURI();
  43. /**
  44. * Set the namespace URI that will be applied to all subsequently
  45. * added <code>Rule</code> objects.
  46. *
  47. * @param namespaceURI Namespace URI that must match on all
  48. * subsequently added rules, or <code>null</code> for matching
  49. * regardless of the current namespace URI
  50. */
  51. public void setNamespaceURI(String namespaceURI);
  52. // --------------------------------------------------------- Public Methods
  53. /**
  54. * Register a new Rule instance matching the specified pattern.
  55. *
  56. * @param pattern Nesting pattern to be matched for this Rule
  57. * @param rule Rule instance to be registered
  58. */
  59. public void add(String pattern, Rule rule);
  60. /**
  61. * Clear all existing Rule instance registrations.
  62. */
  63. public void clear();
  64. /**
  65. * Return a List of all registered Rule instances that match the specified
  66. * nesting pattern, or a zero-length List if there are no matches. If more
  67. * than one Rule instance matches, they <strong>must</strong> be returned
  68. * in the order originally registered through the <code>add()</code>
  69. * method.
  70. *
  71. * @param pattern Nesting pattern to be matched
  72. *
  73. * @deprecated Call match(namespaceURI,pattern) instead.
  74. */
  75. public List match(String pattern);
  76. /**
  77. * Return a List of all registered Rule instances that match the specified
  78. * nesting pattern, or a zero-length List if there are no matches. If more
  79. * than one Rule instance matches, they <strong>must</strong> be returned
  80. * in the order originally registered through the <code>add()</code>
  81. * method.
  82. *
  83. * @param namespaceURI Namespace URI for which to select matching rules,
  84. * or <code>null</code> to match regardless of namespace URI
  85. * @param pattern Nesting pattern to be matched
  86. */
  87. public List match(String namespaceURI, String pattern);
  88. /**
  89. * Return a List of all registered Rule instances, or a zero-length List
  90. * if there are no registered Rule instances. If more than one Rule
  91. * instance has been registered, they <strong>must</strong> be returned
  92. * in the order originally registered through the <code>add()</code>
  93. * method.
  94. */
  95. public List rules();
  96. }