com.partnersoft.formats.xml
Class XmlParser

java.lang.Object
  extended by com.partnersoft.formats.xml.XmlParser

public class XmlParser
extends java.lang.Object

A simplified XML parsing framework.

This is a lightweight wrapper around the org.xml.sax framework. It simplifies some of the method calls, takes care of setup, and handles and logs exceptions.

Copyright 2006 Partner Software, Inc.

Version:
$Id: XmlParser.java 2139 2009-10-03 00:04:53Z paul $
Author:
Paul Reavis

Constructor Summary
XmlParser(java.io.Reader input, XmlActor actor)
          Create a new XMLParser with the given input and actor.
XmlParser(java.lang.String context, java.io.Reader input, XmlActor actor)
          Create a new XMLParser with the given context (generally a file path), input and actor.
XmlParser(VfsFile file, XmlActor actor)
          Create a new XMLParser with the given VfsFile and actor.
 
Method Summary
 void addFeature(java.lang.String name, boolean value)
           
 void addProperty(java.lang.String name, java.lang.String value)
           
 Naming<java.lang.String> getFeatures()
           
 boolean getSucceeded()
          Returns true if the last parse() was successful, and false otherwise (e.g.
 boolean isValidating()
           
 boolean isValidatingAgainstSchema()
           
 boolean parse()
          Parse through the XML file.
 void setFeatures(Naming<java.lang.String> features)
           
 void setValidating(boolean validating)
           
 void setValidatingAgainstSchema(boolean validatingAgainstSchema)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XmlParser

public XmlParser(java.lang.String context,
                 java.io.Reader input,
                 XmlActor actor)
Create a new XMLParser with the given context (generally a file path), input and actor.


XmlParser

public XmlParser(java.io.Reader input,
                 XmlActor actor)
Create a new XMLParser with the given input and actor.


XmlParser

public XmlParser(VfsFile file,
                 XmlActor actor)
          throws java.io.IOException
Create a new XMLParser with the given VfsFile and actor.

Throws:
java.io.IOException
Method Detail

parse

public boolean parse()
              throws java.io.IOException
Parse through the XML file. The actor will be notified at the beginning and end of each XML entity. Returns true if the parse was successful, and false if it failed for any reason. This is also available as getSucceeded().

Throws:
java.io.IOException

addProperty

public void addProperty(java.lang.String name,
                        java.lang.String value)

addFeature

public void addFeature(java.lang.String name,
                       boolean value)

isValidating

public boolean isValidating()

setValidating

public void setValidating(boolean validating)

isValidatingAgainstSchema

public boolean isValidatingAgainstSchema()

setValidatingAgainstSchema

public void setValidatingAgainstSchema(boolean validatingAgainstSchema)

getFeatures

public Naming<java.lang.String> getFeatures()

setFeatures

public void setFeatures(Naming<java.lang.String> features)

getSucceeded

public boolean getSucceeded()
Returns true if the last parse() was successful, and false otherwise (e.g. bad XML syntax).

Returns: