/Users/lyon/j4p/src/classUtils/pack/util/xml/configuration/Configurator.java

1    package classUtils.pack.util.xml.configuration; 
2     
3    import org.xml.sax.Attributes; 
4    import org.xml.sax.ContentHandler; 
5    import org.xml.sax.DTDHandler; 
6    import org.xml.sax.EntityResolver; 
7    import org.xml.sax.ErrorHandler; 
8    import org.xml.sax.SAXException; 
9     
10   /** 
11    * A Configurator is a SAX Content handler which receives SAX events pertaining  
12    * <i>only</i> to a specific element in an XML document (and typically reacts  
13    * incrementally configuring an associated object, hence the name). 
14    * <p> 
15    * For example, when parsing the following XML 
16    * <pre> 
17    * &lt;?xml version=&quot;1.0&quot;?&gt; 
18    *  &lt;elem1&gt; 
19    *   &lt;sub-elem1&gt; 
20    *     ... 
21    *   &lt;/sub-elem1&gt; 
22    *   &lt;sub-elem2&gt; 
23    *     ... 
24    *   &lt;/sub-elem2&gt; 
25    *  &lt;/elem1&gt; 
26    * &gt; 
27    * </pre> 
28    * we might want to handle <tt>sub-elem1</tt> and <tt>sub-elem2</tt> 
29    * with specific classes rather than into a single big SAX ContentHandler. 
30    * <p> 
31    * A Configurator is usually associated to an XML tag via some name  
32    * transformation. For example, parsing the XML via a SAX parser  
33    * by using a {@link DispatcherHandler DispatcherHandler}, 
34    * a Configurator class can be associated to each element, which will 
35    * receive only SAX events pertaining to that element. 
36    * </pre> 
37    *  
38    * @author Cristiano Sadun 
39    */ 
40   public interface Configurator extends ContentHandler { 
41    
42       /** 
43        * Return the object resulting from the parsing of the specific XML element 
44        * handled by this configurator, or <b>null</b>. 
45        */ 
46       public Object getConfiguredObject(); 
47        
48       /** 
49        * Return the text nodes resulting from the parsing of the specific XML element (if any) 
50        * handled by this configurator, or <b>null</b>. 
51        */ 
52       public String getText(); 
53    
54       public void startElement( 
55           String namespaceURI, 
56           String localName, 
57           String qName, 
58           Attributes atts) 
59           throws SAXException; 
60    
61       public void endElement( 
62           String namespaceURI, 
63           String localName, 
64           String qName); 
65   } 
66