org.apache.cocoon.transformation
Class SQLTransformer

java.lang.Object
  |
  +--org.apache.avalon.framework.logger.AbstractLoggable
        |
        +--org.apache.cocoon.xml.AbstractXMLProducer
              |
              +--org.apache.cocoon.xml.AbstractXMLPipe
                    |
                    +--org.apache.cocoon.transformation.AbstractTransformer
                          |
                          +--org.apache.cocoon.transformation.AbstractSAXTransformer
                                |
                                +--org.apache.cocoon.transformation.SQLTransformer
All Implemented Interfaces:
org.apache.avalon.framework.component.Component, org.apache.avalon.framework.component.Composable, org.apache.avalon.framework.configuration.Configurable, org.xml.sax.ContentHandler, org.apache.avalon.framework.activity.Disposable, org.xml.sax.ext.LexicalHandler, org.apache.avalon.framework.logger.Loggable, org.apache.avalon.excalibur.pool.Poolable, org.apache.avalon.excalibur.pool.Recyclable, SitemapModelComponent, Transformer, XMLConsumer, XMLPipe, XMLProducer

public class SQLTransformer
extends AbstractSAXTransformer
implements org.apache.avalon.framework.component.Composable, org.apache.avalon.framework.activity.Disposable, org.apache.avalon.framework.configuration.Configurable

Version:
CVS $Id: SQLTransformer.java,v 1.10.2.4 2002/11/14 15:30:59 cziegeler Exp $
Author:
Carsten Ziegeler
, Donald Ball , Giacomo Pati (PWR Organisation & Entwicklung) , Sven Beauprez

Field Summary
protected  XMLSerializer compiler
           
protected  int current_query_index
          The offset of the current query in the queries list
protected  int current_state
          The current state of the event receiving FSM
protected  org.apache.avalon.framework.component.ComponentSelector dbSelector
          The database selector
protected  java.util.Properties format
          The format for serializing xml
protected  XMLDeserializer interpreter
           
static java.lang.String MAGIC_ANCESTOR_VALUE
           
static java.lang.String MAGIC_ANCESTOR_VALUE_LEVEL_ATTRIBUTE
           
static java.lang.String MAGIC_ANCESTOR_VALUE_NAME_ATTRIBUTE
           
static java.lang.String MAGIC_CONNECTION
           
static java.lang.String MAGIC_DBURL
           
static java.lang.String MAGIC_DOC_ELEMENT
           
static java.lang.String MAGIC_ERROR
           
static java.lang.String MAGIC_ESCAPE_STRING
           
static java.lang.String MAGIC_EXECUTE_QUERY
          The SQL namespace element names
static java.lang.String MAGIC_IN_PARAMETER
           
static java.lang.String MAGIC_IN_PARAMETER_NR_ATTRIBUTE
           
static java.lang.String MAGIC_IN_PARAMETER_VALUE_ATTRIBUTE
           
static java.lang.String MAGIC_NAME_ATTRIBUTE
           
static java.lang.String MAGIC_NR_OF_ROWS
           
static java.lang.String MAGIC_NS_PREFIX_ELEMENT
           
static java.lang.String MAGIC_NS_URI_ELEMENT
           
static java.lang.String MAGIC_OUT_PARAMETER
           
static java.lang.String MAGIC_OUT_PARAMETER_NAME_ATTRIBUTE
           
static java.lang.String MAGIC_OUT_PARAMETER_NR_ATTRIBUTE
           
static java.lang.String MAGIC_OUT_PARAMETER_TYPE_ATTRIBUTE
           
static java.lang.String MAGIC_PASSWORD
           
static java.lang.String MAGIC_QUERY
           
static java.lang.String MAGIC_ROW_ELEMENT
           
static java.lang.String MAGIC_STORED_PROCEDURE_ATTRIBUTE
           
static java.lang.String MAGIC_SUBSTITUTE_VALUE
           
static java.lang.String MAGIC_SUBSTITUTE_VALUE_NAME_ATTRIBUTE
           
static java.lang.String MAGIC_UPDATE_ATTRIBUTE
           
static java.lang.String MAGIC_USERNAME
           
static java.lang.String MAGIC_VALUE
           
static java.lang.String NAMESPACE
          The SQL namespace
protected  java.lang.String outPrefix
          Namespace prefix to output
protected  java.lang.String outUri
          Namespace uri to output
protected  org.apache.avalon.excalibur.xml.Parser parser
           
protected  java.util.Vector queries
          The list of queries that we're currently working on
protected  boolean showNrOfRows
          Check if nr of rows need to be written out.
protected static int STATE_INSIDE_ANCESTOR_VALUE_ELEMENT
           
protected static int STATE_INSIDE_ESCAPE_STRING
           
protected static int STATE_INSIDE_EXECUTE_QUERY_ELEMENT
           
protected static int STATE_INSIDE_IN_PARAMETER_ELEMENT
           
protected static int STATE_INSIDE_OUT_PARAMETER_ELEMENT
           
protected static int STATE_INSIDE_QUERY_ELEMENT
           
protected static int STATE_INSIDE_SUBSTITUTE_VALUE_ELEMENT
           
protected static int STATE_INSIDE_VALUE_ELEMENT
           
protected static int STATE_OUTSIDE
          The states we are allowed to be in
 
Fields inherited from class org.apache.cocoon.transformation.AbstractSAXTransformer
context, defaultNamespaceURI, emptyAttributes, ignoreEmptyCharacters, ignoreEventsCount, ignoreHooksCount, ignoreWhitespaces, manager, namespaceURI, objectModel, parameters, recorderStack, request, resolver, response, source, stack
 
Fields inherited from class org.apache.cocoon.xml.AbstractXMLProducer
contentHandler, lexicalHandler, xmlConsumer
 
Fields inherited from interface org.apache.cocoon.transformation.Transformer
ROLE
 
Constructor Summary
SQLTransformer()
          Constructor
 
Method Summary
 void compose(org.apache.avalon.framework.component.ComponentManager manager)
          Composable
 void configure(org.apache.avalon.framework.configuration.Configuration conf)
          configure
 void dispose()
          dispose
protected  void endAncestorValueElement()
           
protected  void endEscapeStringElement()
           
protected  void endExecuteQueryElement()
           
protected  void endInParameterElement()
           
protected  void endOutParameterElement()
           
protected  void endQueryElement()
           
protected  void endSubstituteValueElement()
           
 void endTransformingElement(java.lang.String uri, java.lang.String name, java.lang.String raw)
          ContentHandler method
protected  void endValueElement()
           
protected  void executeQuery(int index)
          This will be the meat of SQLTransformer, where the query is run.
protected  org.apache.cocoon.transformation.SQLTransformer.Query getCurrentQuery()
           
protected  org.apache.cocoon.transformation.SQLTransformer.Query getQuery(int i)
           
protected static java.lang.String getStringValue(java.lang.Object object)
           
 org.apache.log.Logger getTheLogger()
           
protected  java.lang.String nsQualify(java.lang.String name, java.lang.String prefix)
          Qualifies an element name by giving it a prefix.
 void recycle()
          Recycle this component
 void setDocumentLocator(org.xml.sax.Locator locator)
          ContentHandler method
 void setup(SourceResolver resolver, java.util.Map objectModel, java.lang.String source, org.apache.avalon.framework.parameters.Parameters parameters)
          Setup for the current request
protected  void startAncestorValueElement(org.xml.sax.Attributes attributes)
           
protected  void startEscapeStringElement(org.xml.sax.Attributes attributes)
           
protected  void startExecuteQueryElement()
           
protected  void startInParameterElement(org.xml.sax.Attributes attributes)
           
protected  void startOutParameterElement(org.xml.sax.Attributes attributes)
           
protected  void startQueryElement(org.xml.sax.Attributes attributes)
           
protected  void startSubstituteValueElement(org.xml.sax.Attributes attributes)
           
 void startTransformingElement(java.lang.String uri, java.lang.String name, java.lang.String raw, org.xml.sax.Attributes attributes)
          ContentHandler method
protected  void startValueElement(java.lang.String name)
           
protected static void throwIllegalStateException(java.lang.String message)
           
 
Methods inherited from class org.apache.cocoon.transformation.AbstractSAXTransformer
addRecorder, characters, comment, endCDATA, endDocument, endDTD, endElement, endEntity, endParametersRecording, endParametersRecording, endPrefixMapping, endRecording, endSerializedXMLRecording, endTextRecording, ignorableWhitespace, processingInstruction, removeRecorder, sendEndElementEvent, sendEndPrefixMapping, sendEvents, sendParametersEvents, sendStartElementEvent, sendStartElementEvent, sendStartPrefixMapping, sendTextEvent, setupTransforming, skippedEntity, startCDATA, startDocument, startDTD, startElement, startEntity, startParametersRecording, startPrefixMapping, startRecording, startSerializedXMLRecording, startTextRecording
 
Methods inherited from class org.apache.cocoon.xml.AbstractXMLProducer
setConsumer, setContentHandler, setLexicalHandler
 
Methods inherited from class org.apache.avalon.framework.logger.AbstractLoggable
getLogger, setLogger, setupLogger, setupLogger, setupLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.cocoon.xml.XMLProducer
setConsumer
 

Field Detail

NAMESPACE

public static final java.lang.String NAMESPACE
The SQL namespace

See Also:
Constant Field Values

MAGIC_EXECUTE_QUERY

public static final java.lang.String MAGIC_EXECUTE_QUERY
The SQL namespace element names

See Also:
Constant Field Values

MAGIC_CONNECTION

public static final java.lang.String MAGIC_CONNECTION
See Also:
Constant Field Values

MAGIC_DBURL

public static final java.lang.String MAGIC_DBURL
See Also:
Constant Field Values

MAGIC_USERNAME

public static final java.lang.String MAGIC_USERNAME
See Also:
Constant Field Values

MAGIC_PASSWORD

public static final java.lang.String MAGIC_PASSWORD
See Also:
Constant Field Values

MAGIC_NR_OF_ROWS

public static final java.lang.String MAGIC_NR_OF_ROWS
See Also:
Constant Field Values

MAGIC_QUERY

public static final java.lang.String MAGIC_QUERY
See Also:
Constant Field Values

MAGIC_VALUE

public static final java.lang.String MAGIC_VALUE
See Also:
Constant Field Values

MAGIC_DOC_ELEMENT

public static final java.lang.String MAGIC_DOC_ELEMENT
See Also:
Constant Field Values

MAGIC_ROW_ELEMENT

public static final java.lang.String MAGIC_ROW_ELEMENT
See Also:
Constant Field Values

MAGIC_IN_PARAMETER

public static final java.lang.String MAGIC_IN_PARAMETER
See Also:
Constant Field Values

MAGIC_IN_PARAMETER_NR_ATTRIBUTE

public static final java.lang.String MAGIC_IN_PARAMETER_NR_ATTRIBUTE
See Also:
Constant Field Values

MAGIC_IN_PARAMETER_VALUE_ATTRIBUTE

public static final java.lang.String MAGIC_IN_PARAMETER_VALUE_ATTRIBUTE
See Also:
Constant Field Values

MAGIC_OUT_PARAMETER

public static final java.lang.String MAGIC_OUT_PARAMETER
See Also:
Constant Field Values

MAGIC_OUT_PARAMETER_NAME_ATTRIBUTE

public static final java.lang.String MAGIC_OUT_PARAMETER_NAME_ATTRIBUTE
See Also:
Constant Field Values

MAGIC_OUT_PARAMETER_NR_ATTRIBUTE

public static final java.lang.String MAGIC_OUT_PARAMETER_NR_ATTRIBUTE
See Also:
Constant Field Values

MAGIC_OUT_PARAMETER_TYPE_ATTRIBUTE

public static final java.lang.String MAGIC_OUT_PARAMETER_TYPE_ATTRIBUTE
See Also:
Constant Field Values

MAGIC_ESCAPE_STRING

public static final java.lang.String MAGIC_ESCAPE_STRING
See Also:
Constant Field Values

MAGIC_ERROR

public static final java.lang.String MAGIC_ERROR
See Also:
Constant Field Values

MAGIC_NS_URI_ELEMENT

public static final java.lang.String MAGIC_NS_URI_ELEMENT
See Also:
Constant Field Values

MAGIC_NS_PREFIX_ELEMENT

public static final java.lang.String MAGIC_NS_PREFIX_ELEMENT
See Also:
Constant Field Values

MAGIC_ANCESTOR_VALUE

public static final java.lang.String MAGIC_ANCESTOR_VALUE
See Also:
Constant Field Values

MAGIC_ANCESTOR_VALUE_LEVEL_ATTRIBUTE

public static final java.lang.String MAGIC_ANCESTOR_VALUE_LEVEL_ATTRIBUTE
See Also:
Constant Field Values

MAGIC_ANCESTOR_VALUE_NAME_ATTRIBUTE

public static final java.lang.String MAGIC_ANCESTOR_VALUE_NAME_ATTRIBUTE
See Also:
Constant Field Values

MAGIC_SUBSTITUTE_VALUE

public static final java.lang.String MAGIC_SUBSTITUTE_VALUE
See Also:
Constant Field Values

MAGIC_SUBSTITUTE_VALUE_NAME_ATTRIBUTE

public static final java.lang.String MAGIC_SUBSTITUTE_VALUE_NAME_ATTRIBUTE
See Also:
Constant Field Values

MAGIC_NAME_ATTRIBUTE

public static final java.lang.String MAGIC_NAME_ATTRIBUTE
See Also:
Constant Field Values

MAGIC_STORED_PROCEDURE_ATTRIBUTE

public static final java.lang.String MAGIC_STORED_PROCEDURE_ATTRIBUTE
See Also:
Constant Field Values

MAGIC_UPDATE_ATTRIBUTE

public static final java.lang.String MAGIC_UPDATE_ATTRIBUTE
See Also:
Constant Field Values

STATE_OUTSIDE

protected static final int STATE_OUTSIDE
The states we are allowed to be in

See Also:
Constant Field Values

STATE_INSIDE_EXECUTE_QUERY_ELEMENT

protected static final int STATE_INSIDE_EXECUTE_QUERY_ELEMENT
See Also:
Constant Field Values

STATE_INSIDE_VALUE_ELEMENT

protected static final int STATE_INSIDE_VALUE_ELEMENT
See Also:
Constant Field Values

STATE_INSIDE_QUERY_ELEMENT

protected static final int STATE_INSIDE_QUERY_ELEMENT
See Also:
Constant Field Values

STATE_INSIDE_ANCESTOR_VALUE_ELEMENT

protected static final int STATE_INSIDE_ANCESTOR_VALUE_ELEMENT
See Also:
Constant Field Values

STATE_INSIDE_SUBSTITUTE_VALUE_ELEMENT

protected static final int STATE_INSIDE_SUBSTITUTE_VALUE_ELEMENT
See Also:
Constant Field Values

STATE_INSIDE_IN_PARAMETER_ELEMENT

protected static final int STATE_INSIDE_IN_PARAMETER_ELEMENT
See Also:
Constant Field Values

STATE_INSIDE_OUT_PARAMETER_ELEMENT

protected static final int STATE_INSIDE_OUT_PARAMETER_ELEMENT
See Also:
Constant Field Values

STATE_INSIDE_ESCAPE_STRING

protected static final int STATE_INSIDE_ESCAPE_STRING
See Also:
Constant Field Values

queries

protected java.util.Vector queries
The list of queries that we're currently working on


current_query_index

protected int current_query_index
The offset of the current query in the queries list


current_state

protected int current_state
The current state of the event receiving FSM


showNrOfRows

protected boolean showNrOfRows
Check if nr of rows need to be written out.


outPrefix

protected java.lang.String outPrefix
Namespace prefix to output


outUri

protected java.lang.String outUri
Namespace uri to output


dbSelector

protected org.apache.avalon.framework.component.ComponentSelector dbSelector
The database selector


format

protected java.util.Properties format
The format for serializing xml


compiler

protected XMLSerializer compiler

interpreter

protected XMLDeserializer interpreter

parser

protected org.apache.avalon.excalibur.xml.Parser parser
Constructor Detail

SQLTransformer

public SQLTransformer()
Constructor

Method Detail

compose

public void compose(org.apache.avalon.framework.component.ComponentManager manager)
Composable

Specified by:
compose in interface org.apache.avalon.framework.component.Composable
Overrides:
compose in class AbstractSAXTransformer
Parameters:
manager - The Avalon Component Manager

recycle

public void recycle()
Recycle this component

Specified by:
recycle in interface org.apache.avalon.excalibur.pool.Recyclable
Overrides:
recycle in class AbstractSAXTransformer

dispose

public void dispose()
dispose

Specified by:
dispose in interface org.apache.avalon.framework.activity.Disposable

configure

public void configure(org.apache.avalon.framework.configuration.Configuration conf)
               throws org.apache.avalon.framework.configuration.ConfigurationException
configure

Specified by:
configure in interface org.apache.avalon.framework.configuration.Configurable
Overrides:
configure in class AbstractSAXTransformer
org.apache.avalon.framework.configuration.ConfigurationException

setup

public void setup(SourceResolver resolver,
                  java.util.Map objectModel,
                  java.lang.String source,
                  org.apache.avalon.framework.parameters.Parameters parameters)
           throws ProcessingException,
                  org.xml.sax.SAXException,
                  java.io.IOException
Setup for the current request

Specified by:
setup in interface SitemapModelComponent
Overrides:
setup in class AbstractSAXTransformer
Parameters:
resolver - The current SourceResolver
objectModel - The objectModel of the environment.
source - The value of the src attribute in the sitemap.
parameters - The parameters from the sitemap.
ProcessingException
org.xml.sax.SAXException
java.io.IOException

executeQuery

protected void executeQuery(int index)
                     throws org.xml.sax.SAXException
This will be the meat of SQLTransformer, where the query is run.

org.xml.sax.SAXException

throwIllegalStateException

protected static void throwIllegalStateException(java.lang.String message)

startExecuteQueryElement

protected void startExecuteQueryElement()

startValueElement

protected void startValueElement(java.lang.String name)
                          throws org.xml.sax.SAXException
org.xml.sax.SAXException

startQueryElement

protected void startQueryElement(org.xml.sax.Attributes attributes)
                          throws org.xml.sax.SAXException
org.xml.sax.SAXException

endQueryElement

protected void endQueryElement()
                        throws ProcessingException,
                               org.xml.sax.SAXException
ProcessingException
org.xml.sax.SAXException

endValueElement

protected void endValueElement()
                        throws org.xml.sax.SAXException
org.xml.sax.SAXException

endExecuteQueryElement

protected void endExecuteQueryElement()
                               throws org.xml.sax.SAXException
org.xml.sax.SAXException

startAncestorValueElement

protected void startAncestorValueElement(org.xml.sax.Attributes attributes)
                                  throws ProcessingException,
                                         org.xml.sax.SAXException
ProcessingException
org.xml.sax.SAXException

endAncestorValueElement

protected void endAncestorValueElement()

startSubstituteValueElement

protected void startSubstituteValueElement(org.xml.sax.Attributes attributes)
                                    throws ProcessingException,
                                           org.xml.sax.SAXException
ProcessingException
org.xml.sax.SAXException

endSubstituteValueElement

protected void endSubstituteValueElement()

startEscapeStringElement

protected void startEscapeStringElement(org.xml.sax.Attributes attributes)
                                 throws ProcessingException,
                                        org.xml.sax.SAXException
ProcessingException
org.xml.sax.SAXException

endEscapeStringElement

protected void endEscapeStringElement()
                               throws org.xml.sax.SAXException
org.xml.sax.SAXException

startInParameterElement

protected void startInParameterElement(org.xml.sax.Attributes attributes)

endInParameterElement

protected void endInParameterElement()

startOutParameterElement

protected void startOutParameterElement(org.xml.sax.Attributes attributes)

endOutParameterElement

protected void endOutParameterElement()

getCurrentQuery

protected org.apache.cocoon.transformation.SQLTransformer.Query getCurrentQuery()

getQuery

protected org.apache.cocoon.transformation.SQLTransformer.Query getQuery(int i)

nsQualify

protected java.lang.String nsQualify(java.lang.String name,
                                     java.lang.String prefix)
Qualifies an element name by giving it a prefix.

Parameters:
name - the element name
prefix - the prefix to qualify with
Returns:
a namespace qualified name that is correct

setDocumentLocator

public void setDocumentLocator(org.xml.sax.Locator locator)
ContentHandler method

Specified by:
setDocumentLocator in interface org.xml.sax.ContentHandler
Overrides:
setDocumentLocator in class AbstractSAXTransformer
Parameters:
locator - An object that can return the location of any SAX document event.

startTransformingElement

public void startTransformingElement(java.lang.String uri,
                                     java.lang.String name,
                                     java.lang.String raw,
                                     org.xml.sax.Attributes attributes)
                              throws ProcessingException,
                                     org.xml.sax.SAXException
ContentHandler method

Overrides:
startTransformingElement in class AbstractSAXTransformer
Parameters:
uri - The namespace of the element.
name - The local name of the element.
raw - The qualified name of the element.
attributes - The attributes of the element.
ProcessingException
org.xml.sax.SAXException

endTransformingElement

public void endTransformingElement(java.lang.String uri,
                                   java.lang.String name,
                                   java.lang.String raw)
                            throws ProcessingException,
                                   java.io.IOException,
                                   org.xml.sax.SAXException
ContentHandler method

Overrides:
endTransformingElement in class AbstractSAXTransformer
Parameters:
uri - The namespace of the element.
name - The local name of the element.
raw - The qualified name of the element.
ProcessingException
java.io.IOException
org.xml.sax.SAXException

getStringValue

protected static java.lang.String getStringValue(java.lang.Object object)

getTheLogger

public final org.apache.log.Logger getTheLogger()


Copyright © 1999-2002 Apache Software Foundation. All Rights Reserved.