示例#1
0
  /**
   * Set the Digester instance with which this Rules instance is associated.
   *
   * @param digester The newly associated Digester instance
   */
  public void setDigester(Digester digester) {

    this.digester = digester;
    Iterator<Rule> items = rules.iterator();
    while (items.hasNext()) {
      Rule item = items.next();
      item.setDigester(digester);
    }
  }
示例#2
0
  /**
   * Register a new Rule instance matching the specified pattern.
   *
   * @param pattern Nesting pattern to be matched for this Rule
   * @param rule Rule instance to be registered
   */
  public void add(String pattern, Rule rule) {
    // to help users who accidently add '/' to the end of their patterns
    int patternLength = pattern.length();
    if (patternLength > 1 && pattern.endsWith("/")) {
      pattern = pattern.substring(0, patternLength - 1);
    }

    List<Rule> list = cache.get(pattern);
    if (list == null) {
      list = new ArrayList<Rule>();
      cache.put(pattern, list);
    }
    list.add(rule);
    rules.add(rule);
    if (this.digester != null) {
      rule.setDigester(this.digester);
    }
    if (this.namespaceURI != null) {
      rule.setNamespaceURI(this.namespaceURI);
    }
  }
示例#3
0
  /**
   * Constructor sets the associated Digester.
   *
   * @param digester The digester with which this rule is associated
   * @deprecated The digester instance is now set in the {@link Digester#addRule} method. Use {@link
   *     #Rule()} instead.
   */
  public Rule(Digester digester) {

    super();
    setDigester(digester);
  }