Java Doc for SAXBuilder.java in  » XML » jdom » org » jdom » input » 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 » jdom » org.jdom.input 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.jdom.input.SAXBuilder

SAXBuilder
public class SAXBuilder (Code)
Builds a JDOM document from files, streams, readers, URLs, or a SAX org.xml.sax.InputSource instance using a SAX parser. The builder uses a third-party SAX parser (chosen by JAXP by default, or you can choose manually) to handle the parsing duties and simply listens to the SAX events to construct a document. Details which SAX does not provide, such as whitespace outside the root element, are not represented in the JDOM document. Information about SAX can be found at http://www.saxproject.org.

Known issues: Relative paths for a DocType or EntityRef may be converted by the SAX parser into absolute paths.
version:
   $Revision: 1.89 $, $Date: 2004/09/03 18:24:28 $
author:
   Jason Hunter
author:
   Brett McLaughlin
author:
   Dan Schaffer
author:
   Philip Nelson
author:
   Alex Rosen




Constructor Summary
public  SAXBuilder()
     Creates a new SAXBuilder which will attempt to first locate a parser via JAXP, then will try to use a set of default SAX Drivers.
public  SAXBuilder(boolean validate)
     Creates a new SAXBuilder which will attempt to first locate a parser via JAXP, then will try to use a set of default SAX Drivers.
public  SAXBuilder(String saxDriverClass)
     Creates a new SAXBuilder using the specified SAX parser.
public  SAXBuilder(String saxDriverClass, boolean validate)
     Creates a new SAXBuilder using the specified SAX parser.

Method Summary
public  Documentbuild(InputSource in)
     This builds a document from the supplied input source.
public  Documentbuild(InputStream in)
    

This builds a document from the supplied input stream.

public  Documentbuild(File file)
    

This builds a document from the supplied filename.

public  Documentbuild(URL url)
    

This builds a document from the supplied URL.


Parameters:
  url - URL to read from.
public  Documentbuild(InputStream in, String systemId)
    

This builds a document from the supplied input stream.

public  Documentbuild(Reader characterStream)
    

This builds a document from the supplied Reader.

public  Documentbuild(Reader characterStream, String systemId)
    

This builds a document from the supplied Reader.

public  Documentbuild(String systemId)
    

This builds a document from the supplied URI.

protected  voidconfigureContentHandler(SAXHandler contentHandler)
     This configures the SAXHandler that will be used to build the Document.
protected  voidconfigureParser(XMLReader parser, SAXHandler contentHandler)
     This configures the XMLReader to be used for reading the XML document.

The default implementation sets various options on the given XMLReader, such as validation, DTD resolution, entity handlers, etc., according to the options that were set (e.g.

protected  SAXHandlercreateContentHandler()
     This creates the SAXHandler that will be used to build the Document.
protected  XMLReadercreateParser()
     This creates the XMLReader to be used for reading the XML document.

The default behavior is to (1) use the saxDriverClass, if it has been set, (2) try to obtain a parser from JAXP, if it is available, and (3) if all else fails, use a hard-coded default parser (currently the Xerces parser).

public  DTDHandlergetDTDHandler()
     Returns the DTDHandler assigned, or null if none.
public  StringgetDriverClass()
     Returns the driver class assigned in the constructor, or null if none.
public  EntityResolvergetEntityResolver()
     Returns the EntityResolver assigned, or null if none.
public  ErrorHandlergetErrorHandler()
     Returns the ErrorHandler assigned, or null if none.
public  booleangetExpandEntities()
     Returns whether or not entities are being expanded into normal text content.
public  JDOMFactorygetFactory()
     Returns the current org.jdom.JDOMFactory in use.
public  booleangetIgnoringElementContentWhitespace()
     Returns whether element content whitespace is to be ignored during the build.
public  booleangetReuseParser()
     Returns whether the contained SAX parser instance is reused across multiple parses.
public  booleangetValidation()
     Returns whether validation is to be performed during the build.
public  XMLFiltergetXMLFilter()
     Returns the XMLFilter used during parsing, or null if none.
public  voidsetDTDHandler(DTDHandler dtdHandler)
     This sets custom DTDHandler for the Builder.
public  voidsetEntityResolver(EntityResolver entityResolver)
     This sets custom EntityResolver for the Builder.
public  voidsetErrorHandler(ErrorHandler errorHandler)
     This sets custom ErrorHandler for the Builder.
public  voidsetExpandEntities(boolean expand)
    

This sets whether or not to expand entities for the builder. A true means to expand entities as normal content.

public  voidsetFactory(JDOMFactory factory)
     This sets a custom JDOMFactory for the builder.
public  voidsetFeature(String name, boolean value)
     This sets a feature on the SAX parser.
public  voidsetIgnoringElementContentWhitespace(boolean ignoringWhite)
     Specifies whether or not the parser should elminate whitespace in element content (sometimes known as "ignorable whitespace") when building the document.
public  voidsetProperty(String name, Object value)
     This sets a property on the SAX parser.
public  voidsetReuseParser(boolean reuseParser)
     Specifies whether this builder shall reuse the same SAX parser when performing subsequent parses or allocate a new parser for each parse.
public  voidsetValidation(boolean validate)
     This sets validation for the builder.
public  voidsetXMLFilter(XMLFilter xmlFilter)
     This sets a custom org.xml.sax.XMLFilter for the builder.


Constructor Detail
SAXBuilder
public SAXBuilder()(Code)
Creates a new SAXBuilder which will attempt to first locate a parser via JAXP, then will try to use a set of default SAX Drivers. The underlying parser will not validate.



SAXBuilder
public SAXBuilder(boolean validate)(Code)
Creates a new SAXBuilder which will attempt to first locate a parser via JAXP, then will try to use a set of default SAX Drivers. The underlying parser will validate or not according to the given parameter.
Parameters:
  validate - boolean indicating ifvalidation should occur.



SAXBuilder
public SAXBuilder(String saxDriverClass)(Code)
Creates a new SAXBuilder using the specified SAX parser. The underlying parser will not validate.
Parameters:
  saxDriverClass - String name of SAX Driverto use for parsing.



SAXBuilder
public SAXBuilder(String saxDriverClass, boolean validate)(Code)
Creates a new SAXBuilder using the specified SAX parser. The underlying parser will validate or not according to the given parameter.
Parameters:
  saxDriverClass - String name of SAX Driverto use for parsing.
Parameters:
  validate - boolean indicating ifvalidation should occur.




Method Detail
build
public Document build(InputSource in) throws JDOMException, IOException(Code)
This builds a document from the supplied input source.
Parameters:
  in - InputSource to read from Document resultant Document object
throws:
  JDOMException - when errors occur in parsing
throws:
  IOException - when an I/O error prevents a documentfrom being fully parsed



build
public Document build(InputStream in) throws JDOMException, IOException(Code)

This builds a document from the supplied input stream.


Parameters:
  in - InputStream to read from Document resultant Document object
throws:
  JDOMException - when errors occur in parsing
throws:
  IOException - when an I/O error prevents a documentfrom being fully parsed.



build
public Document build(File file) throws JDOMException, IOException(Code)

This builds a document from the supplied filename.


Parameters:
  file - File to read from Document resultant Document object
throws:
  JDOMException - when errors occur in parsing
throws:
  IOException - when an I/O error prevents a documentfrom being fully parsed



build
public Document build(URL url) throws JDOMException, IOException(Code)

This builds a document from the supplied URL.


Parameters:
  url - URL to read from. Document - resultant Document object.
throws:
  JDOMException - when errors occur in parsing
throws:
  IOException - when an I/O error prevents a documentfrom being fully parsed.



build
public Document build(InputStream in, String systemId) throws JDOMException, IOException(Code)

This builds a document from the supplied input stream.


Parameters:
  in - InputStream to read from.
Parameters:
  systemId - base for resolving relative URIs Document resultant Document object
throws:
  JDOMException - when errors occur in parsing
throws:
  IOException - when an I/O error prevents a documentfrom being fully parsed



build
public Document build(Reader characterStream) throws JDOMException, IOException(Code)

This builds a document from the supplied Reader. It's the programmer's responsibility to make sure the reader matches the encoding of the file. It's often easier and safer to use an InputStream rather than a Reader, and to let the parser auto-detect the encoding from the XML declaration.


Parameters:
  characterStream - Reader to read from Document resultant Document object
throws:
  JDOMException - when errors occur in parsing
throws:
  IOException - when an I/O error prevents a documentfrom being fully parsed



build
public Document build(Reader characterStream, String systemId) throws JDOMException, IOException(Code)

This builds a document from the supplied Reader. It's the programmer's responsibility to make sure the reader matches the encoding of the file. It's often easier and safer to use an InputStream rather than a Reader, and to let the parser auto-detect the encoding from the XML declaration.


Parameters:
  characterStream - Reader to read from.
Parameters:
  systemId - base for resolving relative URIs Document resultant Document object
throws:
  JDOMException - when errors occur in parsing
throws:
  IOException - when an I/O error prevents a documentfrom being fully parsed



build
public Document build(String systemId) throws JDOMException, IOException(Code)

This builds a document from the supplied URI.


Parameters:
  systemId - URI for the input Document resultant Document object
throws:
  JDOMException - when errors occur in parsing
throws:
  IOException - when an I/O error prevents a documentfrom being fully parsed



configureContentHandler
protected void configureContentHandler(SAXHandler contentHandler)(Code)
This configures the SAXHandler that will be used to build the Document.

The default implementation simply passes through some configuration settings that were set on the SAXBuilder: setExpandEntities() and setIgnoringElementContentWhitespace().




configureParser
protected void configureParser(XMLReader parser, SAXHandler contentHandler) throws JDOMException(Code)
This configures the XMLReader to be used for reading the XML document.

The default implementation sets various options on the given XMLReader, such as validation, DTD resolution, entity handlers, etc., according to the options that were set (e.g. via setEntityResolver) and set various SAX properties and features that are required for JDOM internals. These features may change in future releases, so change this behavior at your own risk.




createContentHandler
protected SAXHandler createContentHandler()(Code)
This creates the SAXHandler that will be used to build the Document. SAXHandler - resultant SAXHandler object.



createParser
protected XMLReader createParser() throws JDOMException(Code)
This creates the XMLReader to be used for reading the XML document.

The default behavior is to (1) use the saxDriverClass, if it has been set, (2) try to obtain a parser from JAXP, if it is available, and (3) if all else fails, use a hard-coded default parser (currently the Xerces parser). Subclasses may override this method to determine the parser to use in a different way.

XMLReader - resultant XMLReader object.



getDTDHandler
public DTDHandler getDTDHandler()(Code)
Returns the DTDHandler assigned, or null if none. the DTDHandler assigned



getDriverClass
public String getDriverClass()(Code)
Returns the driver class assigned in the constructor, or null if none. the driver class assigned in the constructor



getEntityResolver
public EntityResolver getEntityResolver()(Code)
Returns the EntityResolver assigned, or null if none. the EntityResolver assigned



getErrorHandler
public ErrorHandler getErrorHandler()(Code)
Returns the ErrorHandler assigned, or null if none. the ErrorHandler assigned, or null if none



getExpandEntities
public boolean getExpandEntities()(Code)
Returns whether or not entities are being expanded into normal text content. whether entities are being expanded



getFactory
public JDOMFactory getFactory()(Code)
Returns the current org.jdom.JDOMFactory in use. the factory in use



getIgnoringElementContentWhitespace
public boolean getIgnoringElementContentWhitespace()(Code)
Returns whether element content whitespace is to be ignored during the build. whether element content whitespace is to be ignored during thebuild



getReuseParser
public boolean getReuseParser()(Code)
Returns whether the contained SAX parser instance is reused across multiple parses. The default is true. whether the contained SAX parser instance is reused acrossmultiple parses



getValidation
public boolean getValidation()(Code)
Returns whether validation is to be performed during the build. whether validation is to be performed during the build



getXMLFilter
public XMLFilter getXMLFilter()(Code)
Returns the XMLFilter used during parsing, or null if none. the XMLFilter used during parsing



setDTDHandler
public void setDTDHandler(DTDHandler dtdHandler)(Code)
This sets custom DTDHandler for the Builder.
Parameters:
  dtdHandler - DTDHandler



setEntityResolver
public void setEntityResolver(EntityResolver entityResolver)(Code)
This sets custom EntityResolver for the Builder.
Parameters:
  entityResolver - EntityResolver



setErrorHandler
public void setErrorHandler(ErrorHandler errorHandler)(Code)
This sets custom ErrorHandler for the Builder.
Parameters:
  errorHandler - ErrorHandler



setExpandEntities
public void setExpandEntities(boolean expand)(Code)

This sets whether or not to expand entities for the builder. A true means to expand entities as normal content. A false means to leave entities unexpanded as EntityRef objects. The default is true.

When this setting is false, the internal DTD subset is retained; when this setting is true, the internal DTD subset is not retained.

Note that Xerces (at least up to 1.4.4) has a bug where entities in attribute values will be misreported if this flag is turned off, resulting in entities to appear within element content. When turning entity expansion off either avoid entities in attribute values, or use another parser like Crimson. http://nagoya.apache.org/bugzilla/show_bug.cgi?id=6111


Parameters:
  expand - boolean indicating whether entity expansionshould occur.



setFactory
public void setFactory(JDOMFactory factory)(Code)
This sets a custom JDOMFactory for the builder. Use this to build the tree with your own subclasses of the JDOM classes.
Parameters:
  factory - JDOMFactory to use



setFeature
public void setFeature(String name, boolean value)(Code)
This sets a feature on the SAX parser. See the SAX documentation for

NOTE: SAXBuilder requires that some particular features of the SAX parser be set up in certain ways for it to work properly. The list of such features may change in the future. Therefore, the use of this method may cause parsing to break, and even if it doesn't break anything today it might break parsing in a future JDOM version, because what JDOM parsers require may change over time. Use with caution.


Parameters:
  name - The feature name, which is a fully-qualified URI.
Parameters:
  value - The requested state of the feature (true or false).



setIgnoringElementContentWhitespace
public void setIgnoringElementContentWhitespace(boolean ignoringWhite)(Code)
Specifies whether or not the parser should elminate whitespace in element content (sometimes known as "ignorable whitespace") when building the document. Only whitespace which is contained within element content that has an element only content model will be eliminated (see XML Rec 3.2.1). For this setting to take effect requires that validation be turned on. The default value of this setting is false.
Parameters:
  ignoringWhite - Whether to ignore ignorable whitespace



setProperty
public void setProperty(String name, Object value)(Code)
This sets a property on the SAX parser. See the SAX documentation for more information.

NOTE: SAXBuilder requires that some particular properties of the SAX parser be set up in certain ways for it to work properly. The list of such properties may change in the future. Therefore, the use of this method may cause parsing to break, and even if it doesn't break anything today it might break parsing in a future JDOM version, because what JDOM parsers require may change over time. Use with caution.


Parameters:
  name - The property name, which is a fully-qualified URI.
Parameters:
  value - The requested value for the property.



setReuseParser
public void setReuseParser(boolean reuseParser)(Code)
Specifies whether this builder shall reuse the same SAX parser when performing subsequent parses or allocate a new parser for each parse. The default value of this setting is true (parser reuse).

Note: As SAX parser instances are not thread safe, the parser reuse feature should not be used with SAXBuilder instances shared among threads.


Parameters:
  reuseParser - Whether to reuse the SAX parser.



setValidation
public void setValidation(boolean validate)(Code)
This sets validation for the builder.
Parameters:
  validate - boolean indicating whether validationshould occur.



setXMLFilter
public void setXMLFilter(XMLFilter xmlFilter)(Code)
This sets a custom org.xml.sax.XMLFilter for the builder.
Parameters:
  xmlFilter - the filter to use



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.