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
015 package org.apache.tapestry.util.xml;
016
017 import org.xml.sax.Attributes;
018
019 /**
020 * A rule that may be pushed onto the
021 * {@link org.apache.tapestry.util.xml.RuleDirectedParser}'s rule stack. A rule
022 * is associated with an XML element. It is pushed onto the stack when the open
023 * tag for the rule is encountered. It is is popped off the stack after the
024 * end-tag is encountered. It is notified about any text it directly wraps
025 * around.
026 * <p>
027 * Rules should be stateless, because a rule instance may appear multiple times
028 * in the rule stack (if elements can be recusively nested).
029 *
030 * @author Howard Lewis Ship
031 * @since 3.0
032 */
033
034 public interface IRule
035 {
036
037 /**
038 * Invoked just after the rule is pushed onto the rule stack. Typically, a
039 * Rule will use the information to create a new object and push it onto the
040 * object stack. If the rule needs to know about the element (rather than
041 * the attributes), it may obtain the URI, localName and qName from the
042 * parser.
043 */
044 void startElement(RuleDirectedParser parser, Attributes attributes);
045
046 /**
047 * Invoked just after the rule is popped off the rule stack.
048 */
049 void endElement(RuleDirectedParser parser);
050
051 /**
052 * Invoked when real content is found. The parser is responsible for
053 * aggregating all content provided by the underlying SAX parser into a
054 * single string.
055 */
056
057 void content(RuleDirectedParser parser, String content);
058 }