Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: gnu/java/beans/decoder/ElementHandler.java


1   /* gnu.java.beans.decoder.ElementHandler
2      Copyright (C) 2004 Free Software Foundation, Inc.
3   
4   This file is part of GNU Classpath.
5   
6   GNU Classpath is free software; you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation; either version 2, or (at your option)
9   any later version.
10   
11  GNU Classpath is distributed in the hope that it will be useful, but
12  WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  General Public License for more details.
15  
16  You should have received a copy of the GNU General Public License
17  along with GNU Classpath; see the file COPYING.  If not, write to the
18  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19  02110-1301 USA.
20  
21  Linking this library statically or dynamically with other modules is
22  making a combined work based on this library.  Thus, the terms and
23  conditions of the GNU General Public License cover the whole
24  combination.
25  
26  As a special exception, the copyright holders of this library give you
27  permission to link this library with independent modules to produce an
28  executable, regardless of the license terms of these independent
29  modules, and to copy and distribute the resulting executable under
30  terms of your choice, provided that you also meet, for each linked
31  independent module, the terms and conditions of the license of that
32  module.  An independent module is a module which is not derived from
33  or based on this library.  If you modify this library, you may extend
34  this exception to your version of the library, but you are not
35  obligated to do so.  If you do not wish to do so, delete this
36  exception statement from your version. */
37  
38  package gnu.java.beans.decoder;
39  
40  import java.beans.ExceptionListener;
41  
42  import org.xml.sax.Attributes;
43  
44  /** ElementHandler manages a Context instance and interacts with
45   * its parent and child handlers.
46   *
47   * @author Robert Schuster
48   */
49  interface ElementHandler
50  {
51    /** Evaluates the attributes and creates a Context instance.
52     * If the creation of the Context instance fails the ElementHandler
53     * is marked as failed which may affect the parent handler other.
54     *
55     * @param attributes Attributes of the XML tag.
56     */
57    void start(Attributes attributes, ExceptionListener exceptionListener);
58  
59    /** Post-processes the Context.
60     */
61    void end(ExceptionListener exceptionListener);
62  
63    /** Adds characters from the body of the XML tag to the buffer.
64     *
65     * @param ch
66     * @param start
67     * @param length
68     * @throws SAXException
69     */
70    void characters(char[] ch, int start, int length);
71  
72    /** Returns whether a subelement of the given name is allowed. The rules
73     * for evaluating this are derived from the javabeans.dtd which can be found
74     * here: <a href="http://java.sun.com/products/jfc/tsc/articles/persistence3">Java Persistence Article</a>.
75     * 
76     * @param subElementName 
77     * @return
78     */
79    boolean isSubelementAllowed(String subElementName);
80  
81    /** Provides the same functionality as Class.forName() but allows the decoder
82     * to use a different class loader.
83     * 
84     * @param className
85     * @return
86     * @throws ClassNotFoundException
87     */ 
88    Class instantiateClass(String className) throws ClassNotFoundException;
89  
90    /** Notifies the handler's Context that its child Context will not return
91     * a value back. Some Context variants need this information to know when
92     * a method or a constructor call can be made.
93     *
94     * This method is called by a child handler.
95     */
96    void notifyStatement(ExceptionListener exceptionListener);
97  
98    /** Returns whether this handler has failed.
99     *
100    * This is used to skip child elements.
101    *
102    * @return Whether this handler has failed.
103    */
104   boolean hasFailed();
105 
106   /** Returns the Context instance this handler is working on.
107    * 
108    * @return The handler's Context instance.
109    */
110   Context getContext();
111 
112   /** Notifies the handler that its Context failed and starts a recursive
113    * invocation of the parent handler if it is affected by that failure.
114    * 
115    * Although the method is a public API member it is only used internally.
116    */
117   void notifyContextFailed();
118 
119   /** Stores the object under the given id. The object is not stored if the
120    * id is null.
121    * 
122    * @param objectId
123    * @param o
124    */
125   void putObject(String objectId, Object o);
126 
127   Object getObject(String objectId) throws AssemblyException;
128 
129   ElementHandler getParent();
130 }