froehlich 01/11/29 03:28:51
Added: apps/db/src/java/org/apache/avalon/db/server/lxsql
AbstractLXSQLParser.java
Log:
preparing structure for javacc invasion
Revision Changes Path
1.1
jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/server/lxsql/AbstractLXSQLParser.java
Index: AbstractLXSQLParser.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE file.
*/
package org.apache.avalon.db.server.lxsql;
import org.apache.avalon.db.server.AbstractParser;
import org.apache.avalon.cornerstone.services.dom.DocumentBuilderFactory;
import org.apache.avalon.framework.component.ComponentException;
import org.apache.avalon.framework.component.ComponentManager;
import org.apache.avalon.db.actions.ActionException;
import org.w3c.dom.Document;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.ParserConfigurationException;
import java.io.StringReader;
import java.io.IOException;
/**
* Class BCELSQLParser
*
*
* @author Paul Hammant <a href="mailto:[EMAIL PROTECTED]">[EMAIL
PROTECTED]</a>
* @version $Revision: 1.13 $
*/
public abstract class AbstractLXSQLParser extends AbstractParser {
private DocumentBuilderFactory mDocumentBuilderFactory;
private DocumentBuilder mDocumentBuilder;
private final String XMLHDR = "<?xml version=\"1.0\"
encoding=\"UTF-8\"?>\n";
/**
* Method compose
*
*
* @param componentManager
*
* @throws ComponentException
*
*/
public void compose(ComponentManager componentManager) throws
ComponentException {
mDocumentBuilderFactory =
(DocumentBuilderFactory)
componentManager.lookup(DocumentBuilderFactory.class.getName());
try
{
mDocumentBuilder = mDocumentBuilderFactory.newDocumentBuilder();
}
catch (ParserConfigurationException pce)
{
throw new ComponentException("ParserConfiguration Exception in
compose()",pce);
}
super.compose(componentManager);
}
public Document parseLXSQLString(String lxsql) throws ActionException {
String docStr = XMLHDR + lxsql;
System.out.println("lxStr=" + docStr);
StringReader sr = new StringReader(docStr);
InputSource is = new InputSource(sr);
try {
return mDocumentBuilder.parse(is);
} catch (SAXException se) {
throw new ActionException(se.getMessage());
} catch (IOException ioe) {
throw new ActionException(ioe.getMessage());
}
}
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>