org.basex.api.xqj
Class BXQConnection

java.lang.Object
  extended by org.basex.api.xqj.BXQDataFactory
      extended by org.basex.api.xqj.BXQConnection
All Implemented Interfaces:
XQConnection, XQDataFactory

public final class BXQConnection
extends BXQDataFactory
implements XQConnection

Java XQuery API - Connection.

Author:
Workgroup DBIS, University of Konstanz 2005-08, ISC License, Andreas Weiler

Constructor Summary
BXQConnection()
          Constructor.
 
Method Summary
 void close()
          Closes the class.
 void commit()
          Makes all changes made in the current transaction permanent and releases any locks held by the datasource.
 XQExpression createExpression()
          Creates a new XQExpression object that can be used to perform execute immediate operations with XQuery expressions.
 XQExpression createExpression(XQStaticContext sc)
          Creates a new XQExpression object that can be used to perform execute immediate operations with XQuery expressions.
 boolean getAutoCommit()
          Gets the auto-commit attribute of this connection
 XQMetaData getMetaData()
          Gets the metadata for this connection.
 XQStaticContext getStaticContext()
          Gets an XQStaticContext representing the default values for all expression properties.
 boolean isClosed()
          Returns the closed flag.
 XQPreparedExpression prepareExpression(java.io.InputStream is)
          Prepares an expression for execution.
 XQPreparedExpression prepareExpression(java.io.InputStream is, XQStaticContext sc)
          Prepares an expression for execution.
 XQPreparedExpression prepareExpression(java.io.Reader r)
          Prepares an expression for execution.
 XQPreparedExpression prepareExpression(java.io.Reader r, XQStaticContext sc)
          Prepares an expression for execution.
 XQPreparedExpression prepareExpression(java.lang.String query)
          Prepares an expression for execution.
 XQPreparedExpression prepareExpression(java.lang.String query, XQStaticContext sc)
          Prepares an expression for execution.
 void rollback()
          Undoes all changes made in the current transaction and releases any locks held by the datasource.
 void setAutoCommit(boolean ac)
          Sets the auto-commit attribute to the given state.
 void setStaticContext(XQStaticContext sc)
          Sets the default values for all expression properties.
 
Methods inherited from class org.basex.api.xqj.BXQDataFactory
createAtomicType, createAtomicType, createAttributeType, createAttributeType, createCommentType, createDocumentElementType, createDocumentSchemaElementType, createDocumentType, createElementType, createElementType, createItem, createItemFromAtomicValue, createItemFromBoolean, createItemFromByte, createItemFromDocument, createItemFromDocument, createItemFromDocument, createItemFromDocument, createItemFromDocument, createItemFromDocument, createItemFromDouble, createItemFromFloat, createItemFromInt, createItemFromLong, createItemFromNode, createItemFromObject, createItemFromShort, createItemFromString, createItemType, createNodeType, createProcessingInstructionType, createSchemaAttributeType, createSchemaElementType, createSequence, createSequence, createSequenceType, createTextType
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.xml.xquery.XQConnection
close, isClosed
 
Methods inherited from interface javax.xml.xquery.XQDataFactory
createAtomicType, createAtomicType, createAttributeType, createAttributeType, createCommentType, createDocumentElementType, createDocumentSchemaElementType, createDocumentType, createElementType, createElementType, createItem, createItemFromAtomicValue, createItemFromBoolean, createItemFromByte, createItemFromDocument, createItemFromDocument, createItemFromDocument, createItemFromDocument, createItemFromDocument, createItemFromDocument, createItemFromDouble, createItemFromFloat, createItemFromInt, createItemFromLong, createItemFromNode, createItemFromObject, createItemFromShort, createItemFromString, createItemType, createNodeType, createProcessingInstructionType, createSchemaAttributeType, createSchemaElementType, createSequence, createSequence, createSequenceType, createTextType
 

Constructor Detail

BXQConnection

public BXQConnection()
Constructor.

Method Detail

commit

public void commit()
            throws XQException
Description copied from interface: XQConnection
Makes all changes made in the current transaction permanent and releases any locks held by the datasource. This method should be used only when auto-commit mode is disabled. Any XQResultSequence, or XQResultItem may be implicitly closed upon commit, if the holdability property of the sequence is set to XQConstants.HOLDTYPE_CLOSE_CURSORS_AT_COMMIT.

Specified by:
commit in interface XQConnection
Throws:
XQException - if the connection is in a closed state or this connection is operating in auto-commit mode

createExpression

public XQExpression createExpression()
                              throws XQException
Description copied from interface: XQConnection
Creates a new XQExpression object that can be used to perform execute immediate operations with XQuery expressions. The properties of the connection's default XQStaticContext are copied to the returned XQExpression.

Specified by:
createExpression in interface XQConnection
Returns:
XQExpression that can be used to execute multiple expressions
Throws:
XQException - if the connection is in a closed state

createExpression

public XQExpression createExpression(XQStaticContext sc)
                              throws XQException
Description copied from interface: XQConnection
Creates a new XQExpression object that can be used to perform execute immediate operations with XQuery expressions. The properties of the specified XQStaticContext values are copied to the returned XQExpression.

Specified by:
createExpression in interface XQConnection
Parameters:
sc - XQStaticContext containing values of expression properties
Returns:
XQExpression that can be used to execute multiple expressions
Throws:
XQException - if (1) the connection is in a closed state, or (2) the specified argument is null

getAutoCommit

public boolean getAutoCommit()
Description copied from interface: XQConnection
Gets the auto-commit attribute of this connection

Specified by:
getAutoCommit in interface XQConnection
Returns:
the auto-commit attribute of this connection. true if the connection operates in auto-commit mode; otherwise false

getMetaData

public XQMetaData getMetaData()
                       throws XQException
Description copied from interface: XQConnection
Gets the metadata for this connection.

Specified by:
getMetaData in interface XQConnection
Returns:
XQMetadata representing the metadata of this connection
Throws:
XQException - if the connection is in a closed state

getStaticContext

public XQStaticContext getStaticContext()
                                 throws XQException
Description copied from interface: XQConnection
Gets an XQStaticContext representing the default values for all expression properties. In order to modify the defaults, it is not sufficient to modify the values in the returned XQStaticContext object; in addition setStaticContext should be called to make those new values effective.

Specified by:
getStaticContext in interface XQConnection
Returns:
XQStaticContext representing the default values for all expression properties
Throws:
XQException - if the connection is in a closed state

prepareExpression

public XQPreparedExpression prepareExpression(java.io.InputStream is,
                                              XQStaticContext sc)
                                       throws XQException
Description copied from interface: XQConnection
Prepares an expression for execution.

The properties of the specified XQStaticContext values are copied to the returned XQPreparedExpression.

Specified by:
prepareExpression in interface XQConnection
Parameters:
is - the XQuery expression as an InputStream. Cannot be null
sc - XQStaticContext containing values of expression properties
Returns:
the prepared XQuery expression
Throws:
XQException - if (1) the connection is in a closed state, or (2) the specified argument is null

prepareExpression

public XQPreparedExpression prepareExpression(java.io.InputStream is)
                                       throws XQException
Description copied from interface: XQConnection
Prepares an expression for execution.

The properties of the connection's default XQStaticContext are copied to the returned XQPreparedExpression.

Specified by:
prepareExpression in interface XQConnection
Parameters:
is - the XQuery expression as an InputStream. Cannot be null
Returns:
the prepared XQuery expression
Throws:
XQException - if (1) the connection is in a closed state, (2) there are errors preparing the expression or (3) the xquery parameter is null

prepareExpression

public XQPreparedExpression prepareExpression(java.io.Reader r,
                                              XQStaticContext sc)
                                       throws XQException
Description copied from interface: XQConnection
Prepares an expression for execution.

The properties of the specified XQStaticContext values are copied to the returned XQPreparedExpression.

Specified by:
prepareExpression in interface XQConnection
Parameters:
r - the XQuery expression as a Reader. Cannot be null
sc - XQStaticContext containing values of expression properties
Returns:
the prepared XQuery expression
Throws:
XQException - if (1) the connection is in a closed state, or (2) the specified argument is null

prepareExpression

public XQPreparedExpression prepareExpression(java.io.Reader r)
                                       throws XQException
Description copied from interface: XQConnection
Prepares an expression for execution.

The properties of the connection's default XQStaticContext are copied to the returned XQPreparedExpression.

Specified by:
prepareExpression in interface XQConnection
Parameters:
r - the XQuery expression as a Reader. Cannot be null
Returns:
the prepared XQuery expression
Throws:
XQException - if (1) the connection is in a closed state, (2) there are errors preparing the expression, or (3) the xquery parameter is null

prepareExpression

public XQPreparedExpression prepareExpression(java.lang.String query,
                                              XQStaticContext sc)
                                       throws XQException
Description copied from interface: XQConnection
Prepares an expression for execution.

The properties of the specified XQStaticContext values are copied to the returned XQPreparedExpression.

Specified by:
prepareExpression in interface XQConnection
Parameters:
query - the XQuery expression as a String. Cannot be null
sc - XQStaticContext containing values of expression properties.
Returns:
the prepared XQuery expression
Throws:
XQException - if (1) the connection is in a closed state, or (2) the specified argument is null

prepareExpression

public XQPreparedExpression prepareExpression(java.lang.String query)
                                       throws XQException
Description copied from interface: XQConnection
Prepares an expression for execution.

The properties of the connection's default XQStaticContext are copied to the returned XQPreparedExpression.

Specified by:
prepareExpression in interface XQConnection
Parameters:
query - the XQuery expression as a String. Cannot be null
Returns:
the prepared XQuery expression
Throws:
XQException - if (1) the connection is in a closed state, (2) there are errors preparing the expression, or (3) the xquery parameter is null

rollback

public void rollback()
              throws XQException
Description copied from interface: XQConnection
Undoes all changes made in the current transaction and releases any locks held by the datasource. This method should be used only when auto-commit mode is disabled.

Specified by:
rollback in interface XQConnection
Throws:
XQException - if the connection is in a closed state or this connection is operating in auto-commit mode

setAutoCommit

public void setAutoCommit(boolean ac)
                   throws XQException
Description copied from interface: XQConnection
Sets the auto-commit attribute to the given state. If a connection is in auto-commit mode, each xquery is executed and committed in an individual transaction. When auto-commit mode is disabled, xqueries are grouped in a transaction that must be ended explicitly by the application calling commit() or rollback().
By default, new connections are in auto-commit mode.
If the value of auto-commit is changed in the middle of a transaction, the transaction is committed. If setAutoCommit is called and the auto-commit attribute is not changed from its current value, the request is treated as a no-op.

Specified by:
setAutoCommit in interface XQConnection
Parameters:
ac - true to enable auto-commit mode; false to disable it
Throws:
XQException - if (1) the connection is in a closed state, or (2) auto-commit is turned off but the implementation doesn't support transactions

setStaticContext

public void setStaticContext(XQStaticContext sc)
                      throws XQException
Description copied from interface: XQConnection
Sets the default values for all expression properties. The implementation will read out all expression properties from the specified XQStaticContext and update its private copy.

Specified by:
setStaticContext in interface XQConnection
Parameters:
sc - XQStaticContext containing values of expression properties
Throws:
XQException - if the connection is in a closed state

close

public final void close()
Closes the class.


isClosed

public final boolean isClosed()
Returns the closed flag.

Returns:
flag