KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > sapia > util > xml > parser > DelegateHandlerContext


1 package org.sapia.util.xml.parser;
2
3
4 // Imports of Meggison's SAX classes
5
// ---------------------------------
6
import org.xml.sax.Attributes JavaDoc;
7 import org.xml.sax.SAXException JavaDoc;
8
9
10 /**
11  * The <CODE>DelegateHandlerContext</CODE> class is an implementation of the
12  * <CODE>HandlerStateIF</CODE> interface that act as a proxy and delegates the
13  * <CODE>startElement()</CODE> method call to the underlying delegate object. This
14  * delegate implementation is usefull to contain the handler of the root element of
15  * an XML document.
16  *
17  * @see HandlerStateIF
18  * @see StatefullSAXHandler
19  * @author Jean-Cedric Desrochers
20  *
21  * <dl>
22  * <dt><b>Copyright:</b><dd>Copyright &#169; 2002-2003 <a HREF="http://www.sapia-oss.org">Sapia Open Source Software</a>. All Rights Reserved.</dd></dt>
23  * <dt><b>License:</b><dd>Read the license.txt file of the jar or visit the
24  * <a HREF="http://www.sapia-oss.org/license.html">license page</a> at the Sapia OSS web site</dd></dt>
25  * </dl>
26  */

27 public class DelegateHandlerContext implements HandlerStateIF {
28   /////////////////////////////////////////////////////////////////////////////////////////
29
///////////////////////////////// INSTANCE ATTRIBUTES /////////////////////////////////
30
/////////////////////////////////////////////////////////////////////////////////////////
31
private HandlerStateIF _theDelegate;
32
33   /////////////////////////////////////////////////////////////////////////////////////////
34
//////////////////////////////////// CONSTRUCTORS /////////////////////////////////////
35
/////////////////////////////////////////////////////////////////////////////////////////
36

37   /**
38    *
39    */

40   public DelegateHandlerContext(HandlerStateIF aDelegate) {
41     _theDelegate = aDelegate;
42   }
43
44   /////////////////////////////////////////////////////////////////////////////////////////
45
/////////////////////////////// INTERACE IMPLEMENTATION ///////////////////////////////
46
/////////////////////////////////////////////////////////////////////////////////////////
47

48   /**
49    * Receives the notification of the the start of an element.
50    *
51    * @param aContext The handler context.
52    * @param anUri The namespace URI associated with the element
53    * @param aLocalName The element type local name.
54    * @param aQualifiedName The element type qualified name.
55    * @param someAttributes The specified or defaulted attributes.
56    * @exception SAXException If an exception occurs.
57    */

58   public void startElement(HandlerContextIF aContext, String JavaDoc anUri,
59     String JavaDoc aLocalName, String JavaDoc aQualifiedName, Attributes JavaDoc someAttributes)
60     throws SAXException JavaDoc {
61     // Delegating the parsing of the element to the handler
62
aContext.setCurrentState(_theDelegate, anUri, aLocalName, aQualifiedName,
63       someAttributes);
64   }
65
66   /**
67    * Receives the notification of the the end of an element.
68    *
69    * @param aContext The handler context.
70    * @param anUri The namespace URI associated with the element
71    * @param aLocalName The element type local name.
72    * @param aQualifiedName The element type qualified name.
73    * @exception SAXException If an exception occurs.
74    */

75   public void endElement(HandlerContextIF aContext, String JavaDoc anUri,
76     String JavaDoc aLocalName, String JavaDoc aQualifiedName) throws SAXException JavaDoc {
77   }
78
79   /**
80    * Receives the notification of character data inside an element.
81    *
82    * @param aContext The handler context.
83    * @param someChars The characters.
84    * @param anOffset The start position in the character array.
85    * @param aLength The number of characters to use from the character array.
86    * @exception SAXException If an exception occurs.
87    */

88   public void characters(HandlerContextIF aContext, char[] someChars,
89     int anOffset, int aLength) throws SAXException JavaDoc {
90   }
91
92   /**
93    * Receives the notification of ignorable whitespace in element content.
94    *
95    * @param aContext The handler context.
96    * @param someChars The whitespace characters.
97    * @param anOffset The start position in the character array.
98    * @param aLength The number of characters to use from the character array.
99    * @exception SAXException If an exception occurs.
100    */

101   public void ignorableWhitespace(HandlerContextIF aContext, char[] someChars,
102     int anOffset, int aLength) throws SAXException JavaDoc {
103   }
104 }
105
Popular Tags