org.apache.cocoon.components.flow.javascript
Class ScriptableConnection

java.lang.Object
  extended byorg.mozilla.javascript.ScriptableObject
      extended byorg.apache.cocoon.components.flow.javascript.ScriptableConnection
All Implemented Interfaces:
org.mozilla.javascript.debug.DebuggableObject, org.mozilla.javascript.Scriptable, Serializable

public class ScriptableConnection
extends org.mozilla.javascript.ScriptableObject

Wraps a JDBC connection and provides an API similar to JSTL A ScriptableConnection provides two methods:

If the fun argument is provided to query it will be called for each row returned (the row object will be passed as its argument). For example:
 var db = Database.getConnection(...);
 var queryVal = ...;
 var startRow = 0;
 var maxRows = 100; 

 db.query("select * from table where column = ?", 
          [queryVal], 
          startRow,
          maxRows,
          function(row) {
              print("column = " + row.column);
          });

 
If fun is undefined, an object containing the following properties will be returned instead: A ScriptableConnection is also a wrapper around a real JDBC Connection and thus provides all of methods of Connection as well

Version:
CVS $Id: ScriptableConnection.java 164373 2005-04-23 11:38:34Z antonio $
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.mozilla.javascript.ScriptableObject
DONTENUM, EMPTY, PERMANENT, READONLY
 
Fields inherited from interface org.mozilla.javascript.Scriptable
NOT_FOUND
 
Constructor Summary
ScriptableConnection()
           
ScriptableConnection(org.mozilla.javascript.Scriptable parent, Connection conn)
           
 
Method Summary
static void finishInit(org.mozilla.javascript.Scriptable proto)
           
 Object get(int index, org.mozilla.javascript.Scriptable start)
           
 Object get(String name, org.mozilla.javascript.Scriptable start)
           
 String getClassName()
           
 boolean has(int index, org.mozilla.javascript.Scriptable start)
           
 boolean has(String name, org.mozilla.javascript.Scriptable start)
           
static org.mozilla.javascript.Scriptable jsConstructor(org.mozilla.javascript.Context cx, Object[] args, org.mozilla.javascript.Function ctorObj, boolean inNewExpr)
           
 Object jsFunction_query(String sql, Object params, int startRow, int maxRows, Object funObj)
           
 int jsFunction_update(String sql, Object params)
           
 void put(String name, org.mozilla.javascript.Scriptable start, Object value)
           
 
Methods inherited from class org.mozilla.javascript.ScriptableObject
associateValue, callMethod, callMethod, defineClass, defineClass, defineFunctionProperties, defineProperty, defineProperty, defineProperty, defineProperty, delete, delete, deleteProperty, deleteProperty, equivalentValues, getAllIds, getAssociatedValue, getAttributes, getAttributes, getAttributes, getAttributes, getClassPrototype, getDefaultValue, getFunctionPrototype, getIds, getObjectPrototype, getParentScope, getProperty, getProperty, getPropertyIds, getPrototype, getTopLevelScope, getTopScopeValue, hasInstance, hasProperty, hasProperty, isSealed, put, putProperty, putProperty, sealObject, setAttributes, setAttributes, setAttributes, setAttributes, setParentScope, setPrototype
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ScriptableConnection

public ScriptableConnection()

ScriptableConnection

public ScriptableConnection(org.mozilla.javascript.Scriptable parent,
                            Connection conn)
Method Detail

getClassName

public String getClassName()

finishInit

public static void finishInit(org.mozilla.javascript.Scriptable proto)

jsConstructor

public static org.mozilla.javascript.Scriptable jsConstructor(org.mozilla.javascript.Context cx,
                                                              Object[] args,
                                                              org.mozilla.javascript.Function ctorObj,
                                                              boolean inNewExpr)
                                                       throws Exception
Throws:
Exception

jsFunction_query

public Object jsFunction_query(String sql,
                               Object params,
                               int startRow,
                               int maxRows,
                               Object funObj)
                        throws org.mozilla.javascript.JavaScriptException
Throws:
org.mozilla.javascript.JavaScriptException

jsFunction_update

public int jsFunction_update(String sql,
                             Object params)
                      throws org.mozilla.javascript.JavaScriptException
Throws:
org.mozilla.javascript.JavaScriptException

get

public Object get(String name,
                  org.mozilla.javascript.Scriptable start)

has

public boolean has(String name,
                   org.mozilla.javascript.Scriptable start)

has

public boolean has(int index,
                   org.mozilla.javascript.Scriptable start)

get

public Object get(int index,
                  org.mozilla.javascript.Scriptable start)

put

public void put(String name,
                org.mozilla.javascript.Scriptable start,
                Object value)


Copyright ? 1999-2005 The Apache Software Foundation. All Rights Reserved.