Source Code Cross Referenced for ContentHandler.java in  » XML » Piccolo » org » xml » sax » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » XML » Piccolo » org.xml.sax 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        // ContentHandler.java - handle main document content.
002:        // http://www.saxproject.org
003:        // Written by David Megginson
004:        // NO WARRANTY!  This class is in the public domain.
005:
006:        // $Id: ContentHandler.java,v 1.1.1.1 2002/05/03 23:29:40 yuvalo Exp $
007:
008:        package org.xml.sax;
009:
010:        /**
011:         * Receive notification of the logical content of a document.
012:         *
013:         * <blockquote>
014:         * <em>This module, both source code and documentation, is in the
015:         * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
016:         * See <a href='http://www.saxproject.org'>http://www.saxproject.org</a>
017:         * for further information.
018:         * </blockquote>
019:         *
020:         * <p>This is the main interface that most SAX applications
021:         * implement: if the application needs to be informed of basic parsing 
022:         * events, it implements this interface and registers an instance with 
023:         * the SAX parser using the {@link org.xml.sax.XMLReader#setContentHandler 
024:         * setContentHandler} method.  The parser uses the instance to report 
025:         * basic document-related events like the start and end of elements 
026:         * and character data.</p>
027:         *
028:         * <p>The order of events in this interface is very important, and
029:         * mirrors the order of information in the document itself.  For
030:         * example, all of an element's content (character data, processing
031:         * instructions, and/or subelements) will appear, in order, between
032:         * the startElement event and the corresponding endElement event.</p>
033:         *
034:         * <p>This interface is similar to the now-deprecated SAX 1.0
035:         * DocumentHandler interface, but it adds support for Namespaces
036:         * and for reporting skipped entities (in non-validating XML
037:         * processors).</p>
038:         *
039:         * <p>Implementors should note that there is also a Java class
040:         * {@link java.net.ContentHandler ContentHandler} in the java.net
041:         * package; that means that it's probably a bad idea to do</p>
042:         *
043:         * <blockquote>
044:         * import java.net.*;
045:         * import org.xml.sax.*;
046:         * </blockquote>
047:         *
048:         * <p>In fact, "import ...*" is usually a sign of sloppy programming
049:         * anyway, so the user should consider this a feature rather than a
050:         * bug.</p>
051:         *
052:         * @since SAX 2.0
053:         * @author David Megginson
054:         * @version 2.0.1 (sax2r2)
055:         * @see org.xml.sax.XMLReader
056:         * @see org.xml.sax.DTDHandler
057:         * @see org.xml.sax.ErrorHandler
058:         */
059:        public interface ContentHandler {
060:
061:            /**
062:             * Receive an object for locating the origin of SAX document events.
063:             *
064:             * <p>SAX parsers are strongly encouraged (though not absolutely
065:             * required) to supply a locator: if it does so, it must supply
066:             * the locator to the application by invoking this method before
067:             * invoking any of the other methods in the ContentHandler
068:             * interface.</p>
069:             *
070:             * <p>The locator allows the application to determine the end
071:             * position of any document-related event, even if the parser is
072:             * not reporting an error.  Typically, the application will
073:             * use this information for reporting its own errors (such as
074:             * character content that does not match an application's
075:             * business rules).  The information returned by the locator
076:             * is probably not sufficient for use with a search engine.</p>
077:             *
078:             * <p>Note that the locator will return correct information only
079:             * during the invocation of the events in this interface.  The
080:             * application should not attempt to use it at any other time.</p>
081:             *
082:             * @param locator An object that can return the location of
083:             *                any SAX document event.
084:             * @see org.xml.sax.Locator
085:             */
086:            public void setDocumentLocator(Locator locator);
087:
088:            /**
089:             * Receive notification of the beginning of a document.
090:             *
091:             * <p>The SAX parser will invoke this method only once, before any
092:             * other event callbacks (except for {@link #setDocumentLocator 
093:             * setDocumentLocator}).</p>
094:             *
095:             * @exception org.xml.sax.SAXException Any SAX exception, possibly
096:             *            wrapping another exception.
097:             * @see #endDocument
098:             */
099:            public void startDocument() throws SAXException;
100:
101:            /**
102:             * Receive notification of the end of a document.
103:             *
104:             * <p>The SAX parser will invoke this method only once, and it will
105:             * be the last method invoked during the parse.  The parser shall
106:             * not invoke this method until it has either abandoned parsing
107:             * (because of an unrecoverable error) or reached the end of
108:             * input.</p>
109:             *
110:             * @exception org.xml.sax.SAXException Any SAX exception, possibly
111:             *            wrapping another exception.
112:             * @see #startDocument
113:             */
114:            public void endDocument() throws SAXException;
115:
116:            /**
117:             * Begin the scope of a prefix-URI Namespace mapping.
118:             *
119:             * <p>The information from this event is not necessary for
120:             * normal Namespace processing: the SAX XML reader will 
121:             * automatically replace prefixes for element and attribute
122:             * names when the <code>http://xml.org/sax/features/namespaces</code>
123:             * feature is <var>true</var> (the default).</p>
124:             *
125:             * <p>There are cases, however, when applications need to
126:             * use prefixes in character data or in attribute values,
127:             * where they cannot safely be expanded automatically; the
128:             * start/endPrefixMapping event supplies the information
129:             * to the application to expand prefixes in those contexts
130:             * itself, if necessary.</p>
131:             *
132:             * <p>Note that start/endPrefixMapping events are not
133:             * guaranteed to be properly nested relative to each other:
134:             * all startPrefixMapping events will occur immediately before the
135:             * corresponding {@link #startElement startElement} event, 
136:             * and all {@link #endPrefixMapping endPrefixMapping}
137:             * events will occur immediately after the corresponding
138:             * {@link #endElement endElement} event,
139:             * but their order is not otherwise 
140:             * guaranteed.</p>
141:             *
142:             * <p>There should never be start/endPrefixMapping events for the
143:             * "xml" prefix, since it is predeclared and immutable.</p>
144:             *
145:             * @param prefix The Namespace prefix being declared.
146:             *	An empty string is used for the default element namespace,
147:             *	which has no prefix.
148:             * @param uri The Namespace URI the prefix is mapped to.
149:             * @exception org.xml.sax.SAXException The client may throw
150:             *            an exception during processing.
151:             * @see #endPrefixMapping
152:             * @see #startElement
153:             */
154:            public void startPrefixMapping(String prefix, String uri)
155:                    throws SAXException;
156:
157:            /**
158:             * End the scope of a prefix-URI mapping.
159:             *
160:             * <p>See {@link #startPrefixMapping startPrefixMapping} for 
161:             * details.  These events will always occur immediately after the
162:             * corresponding {@link #endElement endElement} event, but the order of 
163:             * {@link #endPrefixMapping endPrefixMapping} events is not otherwise
164:             * guaranteed.</p>
165:             *
166:             * @param prefix The prefix that was being mapping.
167:             *	This is the empty string when a default mapping scope ends.
168:             * @exception org.xml.sax.SAXException The client may throw
169:             *            an exception during processing.
170:             * @see #startPrefixMapping
171:             * @see #endElement
172:             */
173:            public void endPrefixMapping(String prefix) throws SAXException;
174:
175:            /**
176:             * Receive notification of the beginning of an element.
177:             *
178:             * <p>The Parser will invoke this method at the beginning of every
179:             * element in the XML document; there will be a corresponding
180:             * {@link #endElement endElement} event for every startElement event
181:             * (even when the element is empty). All of the element's content will be
182:             * reported, in order, before the corresponding endElement
183:             * event.</p>
184:             *
185:             * <p>This event allows up to three name components for each
186:             * element:</p>
187:             *
188:             * <ol>
189:             * <li>the Namespace URI;</li>
190:             * <li>the local name; and</li>
191:             * <li>the qualified (prefixed) name.</li>
192:             * </ol>
193:             *
194:             * <p>Any or all of these may be provided, depending on the
195:             * values of the <var>http://xml.org/sax/features/namespaces</var>
196:             * and the <var>http://xml.org/sax/features/namespace-prefixes</var>
197:             * properties:</p>
198:             *
199:             * <ul>
200:             * <li>the Namespace URI and local name are required when 
201:             * the namespaces property is <var>true</var> (the default), and are
202:             * optional when the namespaces property is <var>false</var> (if one is
203:             * specified, both must be);</li>
204:             * <li>the qualified name is required when the namespace-prefixes property
205:             * is <var>true</var>, and is optional when the namespace-prefixes property
206:             * is <var>false</var> (the default).</li>
207:             * </ul>
208:             *
209:             * <p>Note that the attribute list provided will contain only
210:             * attributes with explicit values (specified or defaulted):
211:             * #IMPLIED attributes will be omitted.  The attribute list
212:             * will contain attributes used for Namespace declarations
213:             * (xmlns* attributes) only if the
214:             * <code>http://xml.org/sax/features/namespace-prefixes</code>
215:             * property is true (it is false by default, and support for a 
216:             * true value is optional).</p>
217:             *
218:             * <p>Like {@link #characters characters()}, attribute values may have
219:             * characters that need more than one <code>char</code> value.  </p>
220:             *
221:             * @param uri The Namespace URI, or the empty string if the
222:             *        element has no Namespace URI or if Namespace
223:             *        processing is not being performed.
224:             * @param localName The local name (without prefix), or the
225:             *        empty string if Namespace processing is not being
226:             *        performed.
227:             * @param qName The qualified name (with prefix), or the
228:             *        empty string if qualified names are not available.
229:             * @param atts The attributes attached to the element.  If
230:             *        there are no attributes, it shall be an empty
231:             *        Attributes object.
232:             * @exception org.xml.sax.SAXException Any SAX exception, possibly
233:             *            wrapping another exception.
234:             * @see #endElement
235:             * @see org.xml.sax.Attributes
236:             */
237:            public void startElement(String uri, String localName,
238:                    String qName, Attributes atts) throws SAXException;
239:
240:            /**
241:             * Receive notification of the end of an element.
242:             *
243:             * <p>The SAX parser will invoke this method at the end of every
244:             * element in the XML document; there will be a corresponding
245:             * {@link #startElement startElement} event for every endElement 
246:             * event (even when the element is empty).</p>
247:             *
248:             * <p>For information on the names, see startElement.</p>
249:             *
250:             * @param uri The Namespace URI, or the empty string if the
251:             *        element has no Namespace URI or if Namespace
252:             *        processing is not being performed.
253:             * @param localName The local name (without prefix), or the
254:             *        empty string if Namespace processing is not being
255:             *        performed.
256:             * @param qName The qualified XML 1.0 name (with prefix), or the
257:             *        empty string if qualified names are not available.
258:             * @exception org.xml.sax.SAXException Any SAX exception, possibly
259:             *            wrapping another exception.
260:             */
261:            public void endElement(String uri, String localName, String qName)
262:                    throws SAXException;
263:
264:            /**
265:             * Receive notification of character data.
266:             *
267:             * <p>The Parser will call this method to report each chunk of
268:             * character data.  SAX parsers may return all contiguous character
269:             * data in a single chunk, or they may split it into several
270:             * chunks; however, all of the characters in any single event
271:             * must come from the same external entity so that the Locator
272:             * provides useful information.</p>
273:             *
274:             * <p>The application must not attempt to read from the array
275:             * outside of the specified range.</p>
276:             *
277:             * <p>Individual characters may consist of more than one Java
278:             * <code>char</code> value.  There are two important cases where this
279:             * happens, because characters can't be represented in just sixteen bits.
280:             * In one case, characters are represented in a <em>Surrogate Pair</em>,
281:             * using two special Unicode values. Such characters are in the so-called
282:             * "Astral Planes", with a code point above U+FFFF.  A second case involves
283:             * composite characters, such as a base character combining with one or
284:             * more accent characters. </p>
285:             *
286:             * <p> Your code should not assume that algorithms using
287:             * <code>char</code>-at-a-time idioms will be working in character
288:             * units; in some cases they will split characters.  This is relevant
289:             * wherever XML permits arbitrary characters, such as attribute values,
290:             * processing instruction data, and comments as well as in data reported
291:             * from this method.  It's also generally relevant whenever Java code
292:             * manipulates internationalized text; the issue isn't unique to XML.</p>
293:             *
294:             * <p>Note that some parsers will report whitespace in element
295:             * content using the {@link #ignorableWhitespace ignorableWhitespace}
296:             * method rather than this one (validating parsers <em>must</em> 
297:             * do so).</p>
298:             *
299:             * @param ch The characters from the XML document.
300:             * @param start The start position in the array.
301:             * @param length The number of characters to read from the array.
302:             * @exception org.xml.sax.SAXException Any SAX exception, possibly
303:             *            wrapping another exception.
304:             * @see #ignorableWhitespace 
305:             * @see org.xml.sax.Locator
306:             */
307:            public void characters(char ch[], int start, int length)
308:                    throws SAXException;
309:
310:            /**
311:             * Receive notification of ignorable whitespace in element content.
312:             *
313:             * <p>Validating Parsers must use this method to report each chunk
314:             * of whitespace in element content (see the W3C XML 1.0 recommendation,
315:             * section 2.10): non-validating parsers may also use this method
316:             * if they are capable of parsing and using content models.</p>
317:             *
318:             * <p>SAX parsers may return all contiguous whitespace in a single
319:             * chunk, or they may split it into several chunks; however, all of
320:             * the characters in any single event must come from the same
321:             * external entity, so that the Locator provides useful
322:             * information.</p>
323:             *
324:             * <p>The application must not attempt to read from the array
325:             * outside of the specified range.</p>
326:             *
327:             * @param ch The characters from the XML document.
328:             * @param start The start position in the array.
329:             * @param length The number of characters to read from the array.
330:             * @exception org.xml.sax.SAXException Any SAX exception, possibly
331:             *            wrapping another exception.
332:             * @see #characters
333:             */
334:            public void ignorableWhitespace(char ch[], int start, int length)
335:                    throws SAXException;
336:
337:            /**
338:             * Receive notification of a processing instruction.
339:             *
340:             * <p>The Parser will invoke this method once for each processing
341:             * instruction found: note that processing instructions may occur
342:             * before or after the main document element.</p>
343:             *
344:             * <p>A SAX parser must never report an XML declaration (XML 1.0,
345:             * section 2.8) or a text declaration (XML 1.0, section 4.3.1)
346:             * using this method.</p>
347:             *
348:             * <p>Like {@link #characters characters()}, processing instruction
349:             * data may have characters that need more than one <code>char</code>
350:             * value. </p>
351:             *
352:             * @param target The processing instruction target.
353:             * @param data The processing instruction data, or null if
354:             *        none was supplied.  The data does not include any
355:             *        whitespace separating it from the target.
356:             * @exception org.xml.sax.SAXException Any SAX exception, possibly
357:             *            wrapping another exception.
358:             */
359:            public void processingInstruction(String target, String data)
360:                    throws SAXException;
361:
362:            /**
363:             * Receive notification of a skipped entity.
364:             * This is not called for entity references within markup constructs
365:             * such as element start tags or markup declarations.  (The XML
366:             * recommendation requires reporting skipped external entities.
367:             * SAX also reports internal entity expansion/non-expansion, except
368:             * within markup constructs.)
369:             *
370:             * <p>The Parser will invoke this method each time the entity is
371:             * skipped.  Non-validating processors may skip entities if they
372:             * have not seen the declarations (because, for example, the
373:             * entity was declared in an external DTD subset).  All processors
374:             * may skip external entities, depending on the values of the
375:             * <code>http://xml.org/sax/features/external-general-entities</code>
376:             * and the
377:             * <code>http://xml.org/sax/features/external-parameter-entities</code>
378:             * properties.</p>
379:             *
380:             * @param name The name of the skipped entity.  If it is a 
381:             *        parameter entity, the name will begin with '%', and if
382:             *        it is the external DTD subset, it will be the string
383:             *        "[dtd]".
384:             * @exception org.xml.sax.SAXException Any SAX exception, possibly
385:             *            wrapping another exception.
386:             */
387:            public void skippedEntity(String name) throws SAXException;
388:        }
389:
390:        // end of ContentHandler.java
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.