1 /*
2 * File: DefaultHandler.java
3 * Created: 16-dub-06 10:52:17
4 *
5 * Copyright 2006 Michal Burda.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21 package net.sf.webmancer.util.xml.sax;
22
23 import org.xml.sax.Attributes;
24 import org.xml.sax.ContentHandler;
25 import org.xml.sax.Locator;
26 import org.xml.sax.SAXException;
27
28 /**
29 * This class is a convenient implementation of the {@link org.xml.sax.ContentHandler} interface that simply does
30 * nothing in all its methods except {@link #setDocumentLocator(Locator)}. The class could be used as a parent of some
31 * other handlers so that the descendants have not to implement all methods form the {@link org.xml.sax.ContentHandler}
32 * interface.
33 *
34 * @author Michal Burda
35 */
36 public class DefaultHandler implements ContentHandler {
37 /**
38 * The actual locator set by the {@link #setDocumentLocator(Locator)} method
39 */
40 protected Locator locator;
41
42 /**
43 * Constructor that sets the {@link #locator} to <code>null</code>.
44 */
45 public DefaultHandler() {
46 super();
47 this.locator = null;
48 }
49
50 /**
51 * Sets the {@link #locator} to given parameter value.
52 *
53 * @param locator
54 * The locator that has to be saved
55 * @see org.xml.sax.ContentHandler#setDocumentLocator(org.xml.sax.Locator)
56 */
57 public void setDocumentLocator(final Locator locator) {
58 this.locator = locator;
59 }
60
61 /**
62 * This method simply does nothing.
63 *
64 * @see org.xml.sax.ContentHandler#startDocument()
65 */
66 @SuppressWarnings("unused")
67 public void startDocument() throws SAXException {
68 }
69
70 /**
71 * This method simply does nothing.
72 *
73 * @see org.xml.sax.ContentHandler#endDocument()
74 */
75 @SuppressWarnings("unused")
76 public void endDocument() throws SAXException {
77 }
78
79 /**
80 * This method simply does nothing.
81 *
82 * @see org.xml.sax.ContentHandler#startPrefixMapping(java.lang.String, java.lang.String)
83 */
84 @SuppressWarnings("unused")
85 public void startPrefixMapping(final String prefix, final String uri) throws SAXException {
86 }
87
88 /**
89 * This method simply does nothing.
90 *
91 * @see org.xml.sax.ContentHandler#endPrefixMapping(java.lang.String)
92 */
93 @SuppressWarnings("unused")
94 public void endPrefixMapping(final String prefix) throws SAXException {
95 }
96
97 /**
98 * This method simply does nothing.
99 *
100 * @see org.xml.sax.ContentHandler#startElement(java.lang.String, java.lang.String, java.lang.String,
101 * org.xml.sax.Attributes)
102 */
103 @SuppressWarnings("unused")
104 public void startElement(final String uri, final String localName, final String qName, final Attributes atts) throws SAXException {
105 }
106
107 /**
108 * This method simply does nothing.
109 *
110 * @see org.xml.sax.ContentHandler#endElement(java.lang.String, java.lang.String, java.lang.String)
111 */
112 @SuppressWarnings("unused")
113 public void endElement(final String uri, final String localName, final String qName) throws SAXException {
114 }
115
116 /**
117 * This method simply does nothing.
118 *
119 * @see org.xml.sax.ContentHandler#characters(char[], int, int)
120 */
121 @SuppressWarnings("unused")
122 public void characters(final char[] ch, final int start, final int length) throws SAXException {
123 }
124
125 /**
126 * This method simply does nothing.
127 *
128 * @see org.xml.sax.ContentHandler#ignorableWhitespace(char[], int, int)
129 */
130 @SuppressWarnings("unused")
131 public void ignorableWhitespace(final char[] ch, final int start, final int length) throws SAXException {
132 }
133
134 /**
135 * This method simply does nothing.
136 *
137 * @see org.xml.sax.ContentHandler#processingInstruction(java.lang.String, java.lang.String)
138 */
139 @SuppressWarnings("unused")
140 public void processingInstruction(final String target, final String data) throws SAXException {
141 }
142
143 /**
144 * This method simply does nothing.
145 *
146 * @see org.xml.sax.ContentHandler#skippedEntity(java.lang.String)
147 */
148 @SuppressWarnings("unused")
149 public void skippedEntity(final String name) throws SAXException {
150 }
151 }