prickett 2002/10/24 21:29:42 Modified: periodicity/conf/database/developers databases.xml Added: periodicity/src/plugins-build/database/src/java/org/apache/commons/periodicity/database DriverContentHandler.java Log: Changed the representation of driver schemes from <scheme>jdbc:database</scheme> <protocol> <scheme>jdbc:database</scheme> </protocol> A scheme should no longer be put directly in <driver> element. It must be nested in a protocol element inside the driver element. Added a SAX content handler to parse driver information out of the databases.xml file. Revision Changes Path 1.4 +19 -7 jakarta-commons-sandbox/periodicity/conf/database/developers/databases.xml Index: databases.xml =================================================================== RCS file: /home/cvs/jakarta-commons-sandbox/periodicity/conf/database/developers/databases.xml,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- databases.xml 21 Oct 2002 14:06:16 -0000 1.3 +++ databases.xml 25 Oct 2002 04:29:42 -0000 1.4 @@ -106,16 +106,20 @@ by Mark Matthews who is now affiliated with MySQL AB</description> <web-url>http://mmmysql.sourceforge.net</web-url> <class-name>org.gjt.mm.mysql.Driver</class-name> - <scheme>jdbc:mysql</scheme> + <protocol> + <scheme>jdbc:mysql</scheme> + </protocol> </driver> <driver name="postgresql.default"> <short-description>PostgreSQL JDBC Driver</short-description> <description>The PostgreSQL JDBC driver is an open source JDBC driver - for the POstgreSQL database. It is developed and maintained by the + for the PostgreSQL database. It is developed and maintained by the PostgreSQL development team.</description> <class-name>org.postgresql.Driver</class-name> - <scheme>jdbc:postgresql</scheme> + <protocol> + <scheme>jdbc:postgresql</scheme> + </protocol> </driver> <driver name="oracle.default"> @@ -125,7 +129,9 @@ and maintained by Oracle Corporation.</description> <web-url>http://otn.oracle.com/tech/java/sqlj_jdbc/htdocs</web-url> <class-name>oracle.jdbc.driver.OracleDriver</class-name> - <scheme>jdbc:oracle:thin</scheme> + <protocol> + <scheme>jdbc:oracle:thin</scheme> + </protocol> </driver> <driver name="axion.default"> @@ -136,12 +142,16 @@ community</description> <web-url>http://axion.tigris.org/quickstart.html</web-url> <class-name>org.axiondb.jdbc.AxionDriver</class-name> - <scheme>jdbc:axiondb</scheme> + <protocol> + <scheme>jdbc:axiondb</scheme> + </protocol> </driver> <driver name="cloudscape.default"> <class-name>com.ibm.db2j.jdbc.DB2jDriver</class-name> - <scheme>jdbc:db2j</scheme> + <protocol> + <scheme>jdbc:db2j</scheme> + </protocol> </driver> <driver name="hypersonic.default"> @@ -171,7 +181,9 @@ Borland Software Corporation</description> <web-url>http://www.interbase.com</web-url> <class-name>interbase.interclient.Driver</class-name> - <scheme>jdbc:interbase</scheme> + <protocol> + <scheme>jdbc:interbase</scheme> + </protocol> </driver> </drivers> 1.1 jakarta-commons-sandbox/periodicity/src/plugins-build/database/src/java/org/apache/commons/periodicity/database/DriverContentHandler.java Index: DriverContentHandler.java =================================================================== package org.apache.commons.periodicity.database; /* * $Header: /home/cvs/jakarta-commons-sandbox/periodicity/src/plugins-build/database/src/java/org/apache/commons/periodicity/database/DriverContentHandler.java,v 1.1 2002/10/25 04:29:42 prickett Exp $ * $Revision: 1.1 $ * $Date: 2002/10/25 04:29:42 $ * * ==================================================================== * * The Apache Software License, Version 1.1 * * Copyright (c) 2000-2002 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, if * any, must include the following acknowlegement: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowlegement may appear in the software itself, * if and wherever such third-party acknowlegements normally appear. * * 4. The names "The Jakarta Project", "Commons", and "Apache Software * Foundation" must not be used to endorse or promote products derived * from this software without prior written permission. For written * permission, please contact [EMAIL PROTECTED] * * 5. Products derived from this software may not be called "Apache" * nor may "Apache" appear in their names without prior written * permission of the Apache Group. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * <http://www.apache.org/>. * */ import org.xml.sax.Attributes; import org.xml.sax.SAXException; import org.xml.sax.helpers.DefaultHandler; public class DriverContentHandler extends DefaultHandler { /** The qualified name of the drivers element */ public static final String DRIVERS_ELEMENT_QNAME = "drivers"; /** The qualified name of the driver element */ public static final String DRIVER_ELEMENT_QNAME = "driver"; /** The qualified name of the short description element */ public static final String SHORT_DESC_QNAME = "short-description"; /** The qualified name of the description element */ public static final String DESCRIPTION_QNAME = "description"; /** The qualified name of the web url element */ public static final String WEB_URL_QNAME = "web-url"; /** The qualified name of the driver class name element */ public static final String DRIVER_CLASS_QNAME = "class-name"; /** The qualified name of the url scheme element */ public static final String SCHEME_QNAME = "scheme"; /** The qualified name of the protocol element */ public static final String PROTOCOL_ELEMENT_QNAME = "protocol"; /** The qualified name of the name attribute for drivers and protocols */ public static final String NAME_QNAME_ATTRIBUTE = "name"; /** A flag to tell us whether we should be looking to add new drivers */ private boolean lookForDrivers = false; /** A flag to tell us whether we should process protocols */ private boolean processProtocol = false; /** A variable to hold the current jdbc driver's name */ private String name = null; /** A variable to hold the short description for the current jdbc driver */ private String shortDescription = null; /** A variable to hold the description for the current jdbc driver */ private String description = null; /** A variable to hold the name of the current jdbc class */ private String driverClassName = null; /** A variable to hold the url to the current driver's website */ private String webUrl = null; /** A variable to hold the url scheme for the current jdbc driver */ private String scheme = null; /** A buffer to hold the current character information until it is stored in its respective variable */ private StringBuffer buffy = null; public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { if(!lookForDrivers && qName != null && qName.equals(DRIVERS_ELEMENT_QNAME)) { lookForDrivers = true; } else if(lookForDrivers && qName != null && qName.equals(DRIVER_ELEMENT_QNAME)) { if(attributes != null) { String rawName = attributes.getValue(NAME_QNAME_ATTRIBUTE); if(rawName != null) { name = rawName; } else if(rawName == null) { throw new SAXException( "The name attribute in the driver element is null."); } else { throw new SAXException("UNEXPECTED EXCEPTION"); } } else if(attributes == null) { throw new SAXException( "The attributes of the driver element are null."); } else { throw new SAXException("UNEXPECTED EXCEPTION"); } } else if(lookForDrivers && qName != null) { buffy = new StringBuffer(); } else if(qName == null) { throw new SAXException("qName == null"); } else { throw new SAXException("UNEXPECTED EXCEPTION"); } } public void endElement(String uri, String localName, String qName) throws SAXException { try { if(lookForDrivers && processProtocol && qName != null && qName.equals(PROTOCOL_ELEMENT_QNAME)) { addProtocol(); processProtocol = false; } else if(lookForDrivers && processProtocol && qName != null && qName.equals(SCHEME_QNAME)) { scheme = buffy.toString(); } else if(lookForDrivers && !processProtocol && qName != null && qName.equals(DRIVER_ELEMENT_QNAME)) { addDriverToDriverService(); } else if(lookForDrivers && !processProtocol && qName != null && qName.equals(SHORT_DESC_QNAME)) { shortDescription = buffy.toString(); } else if(lookForDrivers && !processProtocol && qName != null && qName.equals(DESCRIPTION_QNAME)) { description = buffy.toString(); } else if(lookForDrivers && !processProtocol && qName != null && qName.equals(WEB_URL_QNAME)) { webUrl = buffy.toString(); } else if(lookForDrivers && !processProtocol && qName != null && qName.equals(DRIVER_CLASS_QNAME)) { driverClassName = buffy.toString(); } else if(!lookForDrivers && processProtocol) { throw new SAXException( "We should not be processing protocols if we are not " + "looking for drivers."); } else if(qName == null) { throw new SAXException("qName == null"); } else { throw new SAXException("Unrecognized driver element \n" + "qName = \"" + qName + "\"."); } } finally { buffy = null; } } public void characters(char[] ch, int start, int length) { if(buffy != null) { buffy.append(ch, start, length); } } private void addProtocol() { } private void addDriverToDriverService() { } }
-- To unsubscribe, e-mail: <mailto:commons-dev-unsubscribe@;jakarta.apache.org> For additional commands, e-mail: <mailto:commons-dev-help@;jakarta.apache.org>