org.apache.derbyDemo.vtis.core
Class XmlVTI

java.lang.Object
  extended by org.apache.derbyDemo.vtis.core.VTITemplate
      extended by org.apache.derbyDemo.vtis.core.StringColumnVTI
          extended by org.apache.derbyDemo.vtis.core.XmlVTI
All Implemented Interfaces:
java.sql.ResultSet, java.sql.Wrapper
Direct Known Subclasses:
ApacheServerLogVTI, DerbyJiraReportVTI

public class XmlVTI
extends StringColumnVTI

This is a VTI designed to read XML files which are structured like row sets.


Nested Class Summary
 
Nested classes/interfaces inherited from class org.apache.derbyDemo.vtis.core.StringColumnVTI
StringColumnVTI.SimpleBlob, StringColumnVTI.SimpleClob
 
Field Summary
private  javax.xml.parsers.DocumentBuilder _builder
           
private  java.lang.String[] _currentRow
           
private  org.w3c.dom.NodeList _rawRows
           
private  int _rowCount
           
private  int _rowIdx
           
private  java.lang.String _rowTag
           
private  java.lang.String _xmlResourceName
           
 
Fields inherited from interface java.sql.ResultSet
CLOSE_CURSORS_AT_COMMIT, CONCUR_READ_ONLY, CONCUR_UPDATABLE, FETCH_FORWARD, FETCH_REVERSE, FETCH_UNKNOWN, HOLD_CURSORS_OVER_COMMIT, TYPE_FORWARD_ONLY, TYPE_SCROLL_INSENSITIVE, TYPE_SCROLL_SENSITIVE
 
Constructor Summary
XmlVTI(java.lang.String xmlResourceName, java.lang.String rowTag, java.lang.String[] childTags)
           Build a XmlVTI given the name of an xml resource, the tag of the row element, and an array of attribute-names/element-tags underneath the row element
 
Method Summary
 void close()
           
 java.sql.ResultSetMetaData getMetaData()
           
protected  java.lang.String getRawColumn(int columnNumber)
           Get the string value of the column in the current row identified by the 1-based columnNumber.
static java.sql.ResultSet instantiateVTI(java.lang.String xmlResourceName)
           Create a VTI ResultSet.
 boolean next()
           
private  void parseRow(int rowNumber)
           Parse a row into columns.
private  void readRows()
           Fault in the list of rows.
static void registerVTI(java.lang.reflect.Method method)
           Register a method as a Derby Table Function.
static void registerXMLRowVTIs(java.lang.String className)
           Register all of the XMLRow table functions in a class.
private  java.lang.String squeezeText(org.w3c.dom.Element node)
           Squeeze the text out of an Element.
 
Methods inherited from class org.apache.derbyDemo.vtis.core.StringColumnVTI
findColumn, getAsciiStream, getBigDecimal, getBinaryStream, getBlob, getBoolean, getByte, getBytes, getClob, getColumnNames, getDate, getDouble, getFloat, getInt, getLong, getShort, getString, getTime, getTimestamp, setWasNull, wasNull
 
Methods inherited from class org.apache.derbyDemo.vtis.core.VTITemplate
absolute, afterLast, beforeFirst, cancelRowUpdates, clearWarnings, deleteRow, first, getArray, getArray, getAsciiStream, getBigDecimal, getBigDecimal, getBigDecimal, getBinaryStream, getBlob, getBoolean, getByte, getBytes, getCharacterStream, getCharacterStream, getClob, getConcurrency, getCursorName, getDate, getDate, getDate, getDouble, getFetchDirection, getFetchSize, getFloat, getInt, getLong, getObject, getObject, getObject, getObject, getRef, getRef, getRow, getShort, getStatement, getString, getTime, getTime, getTime, getTimestamp, getTimestamp, getTimestamp, getType, getUnicodeStream, getUnicodeStream, getURL, getURL, getWarnings, insertRow, isAfterLast, isBeforeFirst, isFirst, isLast, last, moveToCurrentRow, moveToInsertRow, previous, refreshRow, relative, rowDeleted, rowInserted, rowUpdated, setFetchDirection, setFetchSize, updateArray, updateArray, updateAsciiStream, updateAsciiStream, updateBigDecimal, updateBigDecimal, updateBinaryStream, updateBinaryStream, updateBlob, updateBlob, updateBoolean, updateBoolean, updateByte, updateByte, updateBytes, updateBytes, updateCharacterStream, updateCharacterStream, updateClob, updateClob, updateDate, updateDate, updateDouble, updateDouble, updateFloat, updateFloat, updateInt, updateInt, updateLong, updateLong, updateNull, updateNull, updateObject, updateObject, updateObject, updateObject, updateRef, updateRef, updateRow, updateShort, updateShort, updateString, updateString, updateTime, updateTime, updateTimestamp, updateTimestamp
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.sql.ResultSet
getHoldability, getNCharacterStream, getNCharacterStream, getNClob, getNClob, getNString, getNString, getRowId, getRowId, getSQLXML, getSQLXML, isClosed, updateAsciiStream, updateAsciiStream, updateBinaryStream, updateBinaryStream, updateBlob, updateBlob, updateCharacterStream, updateCharacterStream, updateClob, updateClob, updateNCharacterStream, updateNCharacterStream, updateNClob, updateNClob, updateNClob, updateNClob, updateNString, updateNString, updateRowId, updateRowId, updateSQLXML, updateSQLXML
 
Methods inherited from interface java.sql.Wrapper
isWrapperFor, unwrap
 

Field Detail

_rowTag

private java.lang.String _rowTag

_xmlResourceName

private java.lang.String _xmlResourceName

_rowIdx

private int _rowIdx

_rowCount

private int _rowCount

_currentRow

private java.lang.String[] _currentRow

_builder

private javax.xml.parsers.DocumentBuilder _builder

_rawRows

private org.w3c.dom.NodeList _rawRows
Constructor Detail

XmlVTI

public XmlVTI(java.lang.String xmlResourceName,
              java.lang.String rowTag,
              java.lang.String[] childTags)

Build a XmlVTI given the name of an xml resource, the tag of the row element, and an array of attribute-names/element-tags underneath the row element

Method Detail

registerXMLRowVTIs

public static void registerXMLRowVTIs(java.lang.String className)
                               throws java.lang.Exception

Register all of the XMLRow table functions in a class. This method is exposed as a database procedure.

Throws:
java.lang.Exception

getRawColumn

protected java.lang.String getRawColumn(int columnNumber)
                                 throws java.sql.SQLException

Get the string value of the column in the current row identified by the 1-based columnNumber.

Specified by:
getRawColumn in class StringColumnVTI
Throws:
java.sql.SQLException

close

public void close()
           throws java.sql.SQLException
Throws:
java.sql.SQLException

getMetaData

public java.sql.ResultSetMetaData getMetaData()
                                       throws java.sql.SQLException
Throws:
java.sql.SQLException

next

public boolean next()
             throws java.sql.SQLException
Throws:
java.sql.SQLException

registerVTI

public static void registerVTI(java.lang.reflect.Method method)
                        throws java.lang.Exception

Register a method as a Derby Table Function. We assume the following:

Throws:
java.lang.Exception

instantiateVTI

public static java.sql.ResultSet instantiateVTI(java.lang.String xmlResourceName)
                                         throws java.sql.SQLException

Create a VTI ResultSet. It is assumed that our caller is an XMLRow-annotated method with one String argument. It is assumed that ResultSet is an instance of vtiClass and that vtiClass extends XmlVTI and has a constructor with the same arguments as the constructor of XmlVTI.

Throws:
java.sql.SQLException

readRows

private void readRows()
               throws java.lang.Exception

Fault in the list of rows.

Throws:
java.lang.Exception

parseRow

private void parseRow(int rowNumber)
               throws java.lang.Exception

Parse a row into columns.

Throws:
java.lang.Exception

squeezeText

private java.lang.String squeezeText(org.w3c.dom.Element node)
                              throws java.lang.Exception

Squeeze the text out of an Element.

Throws:
java.lang.Exception