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

Quick Search    Search Deep

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


1   /* gnu.java.beans.decoder.DummyHandler
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  /** An ElementHandler implementation that is used as an artificial root
45   * element. This avoids having to check for a null element.
46   *
47   * @author Robert Schuster
48   */
49  class DummyHandler implements ElementHandler
50  {
51      /* (non-Javadoc)
52       * @see gnu.java.beans.decoder.ElementHandler#start(org.xml.sax.Attributes, java.beans.ExceptionListener)
53       */
54      public void start(
55          Attributes attributes,
56          ExceptionListener exceptionListener)
57      {
58          fail();
59      }
60  
61      /* (non-Javadoc)
62       * @see gnu.java.beans.decoder.ElementHandler#end(java.beans.ExceptionListener)
63       */
64      public void end(ExceptionListener exceptionListener)
65      {
66          fail();
67      }
68  
69      /* (non-Javadoc)
70       * @see gnu.java.beans.decoder.ElementHandler#characters(char[], int, int)
71       */
72      public void characters(char[] ch, int start, int length)
73      {
74          fail();
75      }
76  
77      /* (non-Javadoc)
78       * @see gnu.java.beans.decoder.ElementHandler#isSubelementAllowed(java.lang.String)
79       */
80      public boolean isSubelementAllowed(String subElementName)
81      {
82          return true;
83      }
84  
85      /* (non-Javadoc)
86       * @see gnu.java.beans.decoder.ElementHandler#instantiateClass(java.lang.String)
87       */
88      public Class instantiateClass(String className)
89          throws ClassNotFoundException
90      {
91          fail();
92    return null;
93      }
94  
95      /* (non-Javadoc)
96       * @see gnu.java.beans.decoder.ElementHandler#reportStatement(java.beans.ExceptionListener)
97       */
98      public void notifyStatement(ExceptionListener exceptionListener)
99      {
100         // ignore
101     }
102 
103     /* (non-Javadoc)
104      * @see gnu.java.beans.decoder.ElementHandler#hasFailed()
105      */
106     public boolean hasFailed()
107     {
108         return false;
109     }
110 
111     /* (non-Javadoc)
112      * @see gnu.java.beans.decoder.ElementHandler#getContext()
113      */
114     public Context getContext()
115     {
116         return new DummyContext();
117     }
118 
119     /* (non-Javadoc)
120      * @see gnu.java.beans.decoder.ElementHandler#contextFailed()
121      */
122     public void notifyContextFailed()
123     {
124         fail();
125     }
126 
127     /* (non-Javadoc)
128      * @see gnu.java.beans.decoder.ElementHandler#putObject(java.lang.String, java.lang.Object)
129      */
130     public void putObject(String objectId, Object o)
131     {
132         fail();
133     }
134 
135     /* (non-Javadoc)
136      * @see gnu.java.beans.decoder.ElementHandler#getObject(java.lang.String)
137      */
138     public Object getObject(String objectId)
139     {
140         fail();
141   return null;
142     }
143 
144     public ElementHandler getParent()
145     {
146         fail();
147   return null;
148     }
149 
150     private void fail()
151     {
152         throw new InternalError("Invoking the DummyHandler is not expected"
153               + " - Please file a bug report at "
154         + " http://www.gnu.org/software/classpath/.");
155     }
156 }