001// Copyright 2004, 2005 The Apache Software Foundation 002// 003// Licensed under the Apache License, Version 2.0 (the "License"); 004// you may not use this file except in compliance with the License. 005// You may obtain a copy of the License at 006// 007// http://www.apache.org/licenses/LICENSE-2.0 008// 009// Unless required by applicable law or agreed to in writing, software 010// distributed under the License is distributed on an "AS IS" BASIS, 011// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 012// See the License for the specific language governing permissions and 013// limitations under the License. 014 015package org.apache.tapestry.util.xml; 016 017import org.xml.sax.Attributes; 018 019/** 020 * A rule that may be pushed onto the {@link org.apache.tapestry.util.xml.RuleDirectedParser}'s 021 * rule stack. A rule is associated with an XML element. It is pushed onto the stack when the 022 * open tag for the rule is encountered. It is is popped off the stack after the end-tag is 023 * encountered. It is notified about any text it directly wraps around. 024 * 025 * <p>Rules should be stateless, because a rule instance may appear multiple times in the 026 * rule stack (if elements can be recusively nested). 027 * 028 * @author Howard Lewis Ship 029 * @since 3.0 030 **/ 031 032public interface IRule 033{ 034 /** 035 * Invoked just after the rule is pushed onto the rule stack. Typically, a Rule will 036 * use the information to create a new object and push it onto the object stack. 037 * If the rule needs to know about the element (rather than the attributes), it 038 * may obtain the URI, localName and qName from the parser. 039 * 040 */ 041 public void startElement(RuleDirectedParser parser, Attributes attributes); 042 043 /** 044 * Invoked just after the rule is popped off the rule stack. 045 */ 046 public void endElement(RuleDirectedParser parser); 047 048 049 /** 050 * Invoked when real content is found. The parser is responsible for aggregating 051 * all content provided by the underlying SAX parser into a single string. 052 */ 053 054 public void content(RuleDirectedParser parser, String content); 055}