com.uwyn.rife.database
Class Xml2Datasources

java.lang.Object
  extended by org.xml.sax.helpers.DefaultHandler
      extended by com.uwyn.rife.xml.Xml2Data
          extended by com.uwyn.rife.database.Xml2Datasources
All Implemented Interfaces:
ContentHandler, DTDHandler, EntityResolver, ErrorHandler

public class Xml2Datasources
extends Xml2Data

This class parses an XML file to create a set of Datasource objects.

An example of the parsable datasource file:

<datasources>
  <datasource name="postgres">
    <driver>org.postgresql.Driver</driver>
    <url>jdbc:postgres://localhost/database</url>
    <user>username</user>
    <password>password</user>
    <poolsize>5</poolsize>
  </datasource>
</datasources>

An explaination of terms:

Multiple datasource definitions are supported and can be used at anytime.

Since:
1.0
Version:
$Revision: 3634 $
Author:
JR Boyens (jboyens[remove] at uwyn dot com), Geert Bevin (gbevin[remove] at uwyn dot com)

Constructor Summary
Xml2Datasources()
           
 
Method Summary
 void characters(char[] ch, int start, int length)
          Called when text data is encountered, usually between tags.
protected  void clear()
          Clears the information in this datasource.
 void endElement(String namespaceURI, String localName, String qName)
          Called when the end tag of an XML element is encountered
 HashMap<String,Datasource> getDatasources()
          Return the created datasources.
 void startDocument()
          Called when the beginng of the document to be parsed is found
 void startElement(String namespaceURI, String localName, String qName, Attributes atts)
          Called when the start tag of an XML element is encountered
 
Methods inherited from class com.uwyn.rife.xml.Xml2Data
createErrorRedirector, disableValidation, enableValidation, error, fatalError, getErrorRedirector, getResourceFinder, getXmlPath, processXml, processXml, processXml, warning
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
endDocument, endPrefixMapping, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, startPrefixMapping, unparsedEntityDecl
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Xml2Datasources

public Xml2Datasources()
Method Detail

getDatasources

public HashMap<String,Datasource> getDatasources()
Return the created datasources.

Returns:
the datasources created after parsing
Since:
1.0

clear

protected void clear()
Clears the information in this datasource.

Since:
1.0

startDocument

public void startDocument()
Called when the beginng of the document to be parsed is found

Specified by:
startDocument in interface ContentHandler
Overrides:
startDocument in class DefaultHandler
Since:
1.0

startElement

public void startElement(String namespaceURI,
                         String localName,
                         String qName,
                         Attributes atts)
Called when the start tag of an XML element is encountered

Specified by:
startElement in interface ContentHandler
Overrides:
startElement in class DefaultHandler
Parameters:
namespaceURI - the URI of the namespace of the start tag
localName - the local name of the starting element
qName - the qualified name of the starting element
atts - the attributes of the starting element
Since:
1.0

endElement

public void endElement(String namespaceURI,
                       String localName,
                       String qName)
Called when the end tag of an XML element is encountered

Specified by:
endElement in interface ContentHandler
Overrides:
endElement in class DefaultHandler
Parameters:
namespaceURI - the URI of the namespace of the ending element
localName - the local name of the ending element
qName - the qualified name of the ending element
Since:
1.0

characters

public void characters(char[] ch,
                       int start,
                       int length)
Called when text data is encountered, usually between tags.

Specified by:
characters in interface ContentHandler
Overrides:
characters in class DefaultHandler
Parameters:
ch - a character array of the encountered text content
start - the index in the array at which the content starts
length - the length of the data stored in the character array
Since:
1.0


Copyright © 2001-2007 Uwyn sprl/bvba. All Rights Reserved.