org.jboss.cache.config.parsing
Class XmlConfigurationParser

java.lang.Object
  extended by org.jboss.cache.config.parsing.XmlParserBase
      extended by org.jboss.cache.config.parsing.XmlConfigurationParser

public class XmlConfigurationParser
extends XmlParserBase

Reads in XMLconfiguration files and spits out a Configuration object. By default this class uses a validating parser (configurable).

Following system properties can be used for customizing parser behavior:

This class is stateful and one instance should be used for parsing a single configuration file.

Since:
3.0
Author:
Mircea.Markus@jboss.com
See Also:
RootElementBuilder

Field Summary
 
Fields inherited from class org.jboss.cache.config.parsing.XmlParserBase
coreNamespace
 
Constructor Summary
XmlConfigurationParser()
          Constructs a parser having validation enabled with a ErrorHandler that only logs the parser errors.
XmlConfigurationParser(boolean validating, ErrorHandler errorHandler)
          Same as XmlConfigurationParser(org.xml.sax.ErrorHandler).
XmlConfigurationParser(ErrorHandler errorHandler)
          If validation is on (default) one can specify an error handler for handling validation errors.
 
Method Summary
 boolean isValidating()
           
 boolean isValidElementRoot(Element element)
          Tests whether the element passed in is a modern (3.0) config element rather than a legacy one.
 Configuration parseElement(Element root)
          Root should be the jbosscache element in the configuration file.
 Configuration parseElementIgnoringRoot(Element root)
           
 Configuration parseFile(String filename)
          Parses an XML file and returns a new configuration.
 Configuration parseStream(InputStream configStream)
          Similar to parseFile(String), just that it does not create the input stream.
 
Methods inherited from class org.jboss.cache.config.parsing.XmlParserBase
assertNotLegacyElement, existsAttribute, getAttributeValue, getBoolean, getInt, getLong, getSingleElement, getSingleElementInCoreNS
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XmlConfigurationParser

public XmlConfigurationParser(ErrorHandler errorHandler)
If validation is on (default) one can specify an error handler for handling validation errors. The default error handler just logs parsing errors received.


XmlConfigurationParser

public XmlConfigurationParser(boolean validating,
                              ErrorHandler errorHandler)
Same as XmlConfigurationParser(org.xml.sax.ErrorHandler).

Parameters:
validating - should the underlaying parser disable the validation?

XmlConfigurationParser

public XmlConfigurationParser()
Constructs a parser having validation enabled with a ErrorHandler that only logs the parser errors.

Method Detail

parseFile

public Configuration parseFile(String filename)
Parses an XML file and returns a new configuration. For looking up the file, FileLookup is used.

See Also:
FileLookup

parseStream

public Configuration parseStream(InputStream configStream)
Similar to parseFile(String), just that it does not create the input stream.


parseElement

public Configuration parseElement(Element root)
Root should be the jbosscache element in the configuration file.


parseElementIgnoringRoot

public Configuration parseElementIgnoringRoot(Element root)

isValidating

public boolean isValidating()

isValidElementRoot

public boolean isValidElementRoot(Element element)
Tests whether the element passed in is a modern (3.0) config element rather than a legacy one.

Parameters:
element - element to test
Returns:
true of the element is a modern one and can be parsed using the current parser.


Copyright © 2009 JBoss, a division of Red Hat. All Rights Reserved.