Java Doc for DBSubset.java in  » Groupware » hipergate » com » knowgate » dataobjs » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Groupware » hipergate » com.knowgate.dataobjs 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   com.knowgate.dataobjs.DBSubset

DBSubset
final public class DBSubset (Code)

A bidimensional array representing data readed from a database table.

The DBSubset object is used for reading a collection of registers from the database and kept them in memory for inmediate access. As hipergate reuses database connections by recycling them at the JDCConnectionPool , it is a good programming practice to read just the needed number of registers in a single step operation and then free the connection as soon as possible for being used by another processs. Another reason for this "read fast and leave" tactic is that some JDBC drivers have problems managing multiple open resultsets with pending results in a single connection.
author:
   Sergio Montoro Ten
version:
   3.0



Constructor Summary
public  DBSubset(String sTableName, String sColumnList, String sFilterClause, int iFetchSize)
    

Contructs a DBSubset.


Parameters:
  sTableName - Base table or tables, ie.

Method Summary
public  intcall(JDCConnection oConn)
    
public  intcall(JDCConnection oConn, int iSkip)
    
public  intcall(JDCConnection oConn, Object[] aFilterValues)
    

Execute a stored procedure returning a ResultSet


Parameters:
  oConn - Database Connection
Parameters:
  aFilterValues - Values to be binded and JDBC PreparedStatement query paramenters.
public  intcall(JDCConnection oConn, Object[] aFilterValues, int iSkip)
    
public  intclear(Connection oConn, Object[] aFilterValues)
    
public  voidensureCapacity(int nCols, int nRows)
    
public  booleaneof()
    
public  intfind(int iCol, Object oVal)
    

Find a value in a given column

Value is searched by brute force from the begining to the end of the column.
Trying to find a null value is allowed.
Find is case sensitive.

public  Objectget(int iCol, int iRow)
    
public  Objectget(String sCol, int iRow)
    
public  booleangetBoolean(int iCol, int iRow)
    
public  ListgetColumnAsList(int iCol)
    
public  intgetColumnCount()
    
public  StringgetColumnDelimiter()
    
public  String[]getColumnNames()
    
public  intgetColumnPosition(String sColumnName)
    
Parameters:
  sColumnName - Name of column witch position is to be returned.
public  java.util.DategetDate(int iCol, int iRow)
    
public  java.util.DategetDate(String sCol, int iRow)
    
public  StringgetDateFormated(int iCol, int iRow, String sFormat)
    
public  StringgetDateShort(int iCol, int iRow)
    
public  StringgetDateTime(int iCol, int iRow)
    
public  StringgetDateTime24(int iCol, int iRow)
    
public  BigDecimalgetDecimal(int iCol, int iRow)
    

Get pre-loaded value and tries to convert it into a BigDecimal

If column is NULL then null value is returned.
If base columnn is of type String then thsi function will try to parse the value into a BigDecimal.
public  BigDecimalgetDecimal(String sCol, int iRow)
    
public  StringgetDecimalFormated(int iCol, int iRow, String sPattern)
    
public  StringgetDecimalFormated(String sCol, int iRow, String sPattern)
    
public  doublegetDouble(int iCol, int iRow)
    
public  floatgetFloat(int iCol, int iRow)
    
public  floatgetFloat(String sCol, int iRow)
    
public  floatgetFloat(int iCol, int iRow, int iDecimals)
    
public  floatgetFloat(String sCol, int iRow, int iDecimals)
    
public  intgetInt(int iCol, int iRow)
    
public  intgetInt(String sCol, int iRow)
    
public  IntegergetInteger(int iCol, int iRow)
    
public  IntegergetInteger(String sCol, int iRow)
    
public  longgetIntervalMilis(int iCol, int iRow)
    

Return interval value in miliseconds

This method is only for PostgreSQL 8.0 or later
Parameters:
  iCol - Column position [0..getColumnCount()-1]
Parameters:
  iRow - Row position [0..getRowCount()-1] long Interval in miliseconds.
public  intgetMaxRows()
    
public  MoneygetMoney(int iCol, int iRow)
    
public  MoneygetMoney(String sCol, int iRow)
    
public  intgetQueryTimeout()
    
public  ListgetRowAsList(int iRow)
    
public  MapgetRowAsMap(int iRow)
    
public  VectorgetRowAsVector(int iRow)
    
public  intgetRowCount()
    
public  StringgetRowDelimiter()
    
public  java.sql.DategetSQLDate(int iCol, int iRow)
    
public  java.sql.DategetSQLDate(String sCol, int iRow)
    
public  java.sql.TimegetSQLTime(int iCol, int iRow)
    
public  java.sql.TimegetSQLTime(String sCol, int iRow)
    
public  shortgetShort(int iCol, int iRow)
    
public  StringgetString(int iCol, int iRow)
    
public  StringgetString(String sCol, int iRow)
    
public  StringgetStringNull(int iCol, int iRow, String sDef)
    
public  StringgetStringNull(String sCol, int iRow, String sDef)
    
public  StringgetTextQualifier()
    
public  longgetTimeMilis(int iCol, int iRow)
    
public  TimegetTimeOfDay(int iCol, int iRow)
    
public  TimestampgetTimestamp(int iCol, int iRow)
    
public  booleanisNull(int iCol, int iRow)
    
public  booleanisNull(String sCol, int iRow)
    
public  intload(JDCConnection oConn)
    
public  intload(JDCConnection oConn, int iSkip)
    

Execute a JDBC Statement and load query ResultSet in an internal bidimensional matrix


Parameters:
  oConn - Database Connection
Parameters:
  iSkip - Number of rows to be skipped before reading.
public  intload(JDCConnection oConn, Object[] aFilterValues)
    

Execute a JDBC Statement and load query ResultSet in an internal bidimensional matrix


Parameters:
  oConn - Database Connection
Parameters:
  aFilterValues - Values to be binded and JDBC PreparedStatement query paramenters.
public  intload(JDCConnection oConn, Object[] aFilterValues, int iSkip)
    

Execute a JDBC Statement and load query ResultSet in an internal bidimensional matrix


Parameters:
  oConn - Database Connection
Parameters:
  aFilterValues - Values to be binded and JDBC PreparedStatement query paramenters.
Parameters:
  iSkip - Number of rows to be skipped before reading.
public  voidparseCSV(String sFilePath, String sCharSet)
    

Parse a delimited text file into DBSubset bi-dimensional array

The parsed file must have the same column structure as the column list set when the DBSubset constructor was called.
public  voidparseCSV(String sFilePath)
    

Parse a delimited text file into DBSubset bi-dimensional array

The parsed file must have the same column structure as the column list set when the DBSubset constructor was called.
public  voidparseCSV(char[] aData, String sCharSet)
    

Parse character data into DBSubset bi-dimensional array

The parsed file must have the same column structure as the column list set when the DBSubset constructor was called.
public  voidparseCSV(char[] aData)
    

Parse character data into DBSubset bi-dimensional array

The parsed file must have the same column structure as the column list set when the DBSubset constructor was called.
public  voidprint(Connection oConn, OutputStream oOutStrm)
    

Print DBSubset to an output stream

This method is quite different in behavior from toString() and toXML().

public  voidsetColumnDelimiter(String sDelim)
    
public  voidsetElementAt(Object oObj, int iCol, int iRow)
    
public  voidsetElementAt(Object oObj, String sCol, int iRow)
    
public  voidsetMaxRows(int iMax)
    

Maximum number of rows to be readed from database

The exact behavior of this property depends on the RDBMS used.

For PostgreSQL [LIMIT n] clause is appended to DBSubset query and all returned rows are readed.

For Microsoft SQL Server [OPTION FAST(n)] clause is appended to DBSubset query and then the number of readed rows is limited at client side fetching.

For Oracle there is no standard way of limiting the resultset size.

public  voidsetQueryTimeout(int iMaxSeconds)
    
public  voidsetRowDelimiter(String sDelim)
    
public  voidsetTextQualifier(String sQualifier)
    
public  voidsortBy(int iCol)
    

Sort in memory an already loaded ResultSet by a given column

A modified bubble sort algorithm is used.
public  SQLException[]store(JDCConnection oConn, Class oDBPersistSubclass, boolean bStopOnError)
    

Store full contents of this DBSubset at base table

This method takes all the dat contained in memory for this DBSubsets and stores it at the database.

public  Objectsum(int iCol)
    
public  StringtoString()
    
public  StringtoXML(String sIdent, String sNode, String sDateFormat, String sDecimalFormat)
    

Write DBSubset to an XML string


Parameters:
  sIdent - Initial space identations on the left for fields
Parameters:
  sNode - Name of top parent node.
public  StringtoXML(String sIdent, String sNode)
    

Write DBSubset to an XML string

Use default output format for date values: yyyy-MM-dd'T'hh:mm:ss
Parameters:
  sIdent - Initial space identations on the left for fields
Parameters:
  sNode - Name of top parent node.
public  voidunion(DBSubset oDbs)
    


Constructor Detail
DBSubset
public DBSubset(String sTableName, String sColumnList, String sFilterClause, int iFetchSize)(Code)

Contructs a DBSubset.


Parameters:
  sTableName - Base table or tables, ie. "k_products" or "k_products p, k_x_cat_objs x"
Parameters:
  sColumnList - Column list to be retirved from base tables i.e "p.gu_product,p.nm_product"
Parameters:
  sFilterClause - SQL filter clause or null if there is no filter clause to be applied.
Parameters:
  iFetchSize - Space for number of rows initailly allocated. Is DBSubset later loads more rowsthe buffer is automatically expanded. This parameter may also have a great effect on reducingnetwork round trips as the ResultSet.setFetchSize(iFetchSize) method is called prior to fetchingrows. Fetching rows in batches is much faster than doing so one by one. When iFetchSize is set,the JDBC driver may optimize accesses to fetched rows by reading bursts andcaching rows at client side.




Method Detail
call
public int call(JDCConnection oConn) throws SQLException(Code)

Execute a stored procedure returning a ResultSet


Parameters:
  oConn - Database Connection Number of rows retrieved
throws:
  SQLException -



call
public int call(JDCConnection oConn, int iSkip) throws SQLException, IllegalArgumentException, ArrayIndexOutOfBoundsException(Code)

Execute a stored procedure returning a ResultSet


Parameters:
  oConn - Database Connection
Parameters:
  iSkip - Number of rows to be skipped before reading Number of rows retrieved
throws:
  SQLException -
throws:
  IllegalArgumentException - if iSkip<0
throws:
  ArrayIndexOutOfBoundsException -



call
public int call(JDCConnection oConn, Object[] aFilterValues) throws SQLException(Code)

Execute a stored procedure returning a ResultSet


Parameters:
  oConn - Database Connection
Parameters:
  aFilterValues - Values to be binded and JDBC PreparedStatement query paramenters. Number of rows retrieved
throws:
  SQLException -



call
public int call(JDCConnection oConn, Object[] aFilterValues, int iSkip) throws SQLException, IllegalArgumentException, ArrayIndexOutOfBoundsException(Code)

Execute a stored procedure returning a ResultSet


Parameters:
  oConn - Database Connection
Parameters:
  aFilterValues - Values to be binded and JDBC PreparedStatement query paramenters.
Parameters:
  iSkip - Number of rows to be skipped before reading Number of rows retrieved,the maximum number of rows to be retrieved is determined by calling methodsetMaxRows(), if setMaxRows() is not called before call() then all rows existing are retrieved.
throws:
  SQLException -
throws:
  IllegalArgumentException -
throws:
  ArrayIndexOutOfBoundsException -



clear
public int clear(Connection oConn, Object[] aFilterValues) throws SQLException(Code)
Delete rows from base table
Parameters:
  oConn - Connection
Parameters:
  aFilterValues - Object[] Parameters for sFilter parameter specified at constructor int Number of rows deleted
throws:
  SQLException -



ensureCapacity
public void ensureCapacity(int nCols, int nRows)(Code)
Pre-allocate a given number of empty rows and columns
Parameters:
  nCols - Number of columns per row
Parameters:
  nRows - Number of rows to allocate
since:
   2.2



eof
public boolean eof()(Code)
true if call() or load() methods readed all available rows,false if more rows where pending of reading when getMaxRows() wasreached.
Also, after calling store(), eof() is true if all rows were storedsuccessfully or false if any row failed to be inserted or updated.



find
public int find(int iCol, Object oVal)(Code)

Find a value in a given column

Value is searched by brute force from the begining to the end of the column.
Trying to find a null value is allowed.
Find is case sensitive.
Parameters:
  iCol - Column to be searched [0..getColumnCount()-1]
Parameters:
  oVal - Value searched Row where seached value was found or -1 is value was not found.




get
public Object get(int iCol, int iRow) throws ArrayIndexOutOfBoundsException(Code)

Get pre-loaded field


Parameters:
  iCol - Column position [0..getColumnCount()-1]
Parameters:
  iRow - Row position [0..getRowCount()-1]
throws:
  ArrayIndexOutOfBoundsException -



get
public Object get(String sCol, int iRow) throws ArrayIndexOutOfBoundsException(Code)

Get pre-loaded field by name


Parameters:
  sCol - Column name
Parameters:
  iRow - Row position [0..getRowCount()-1]
throws:
  ArrayIndexOutOfBoundsException - If no column with such name was found



getBoolean
public boolean getBoolean(int iCol, int iRow) throws ClassCastException, ArrayIndexOutOfBoundsException, NullPointerException(Code)

Get pre-loaded value for a Boolean field


Parameters:
  iCol - Column position [0..getColumnCount()-1]
Parameters:
  iRow - Row position [0..getRowCount()-1] boolean value for field.
throws:
  ClassCastException -
throws:
  ArrayIndexOutOfBoundsException -
throws:
  NullPointerException -



getColumnAsList
public List getColumnAsList(int iCol) throws ArrayIndexOutOfBoundsException, IllegalStateException(Code)
Get DBSubset column as a List interface
Parameters:
  iCol - int Column position [0..getColumnCount()-1] List
throws:
  ArrayIndexOutOfBoundsException -
throws:
  IllegalStateException - if DBSubset has not been loaded



getColumnCount
public int getColumnCount()(Code)
Number of columns retrieved.



getColumnDelimiter
public String getColumnDelimiter()(Code)
Column delimiter for print() and toString() methods.



getColumnNames
public String[] getColumnNames()(Code)

Get column names

String[] An array with names of columns from the most recently SQL SELECT sentence.
since:
   3.0



getColumnPosition
public int getColumnPosition(String sColumnName)(Code)

Parameters:
  sColumnName - Name of column witch position is to be returned. Column names are case insensitive. Column position or -1 if no column with such name exists.



getDate
public java.util.Date getDate(int iCol, int iRow) throws ClassCastException, ArrayIndexOutOfBoundsException(Code)

Get pre-loaded value for a Date field


Parameters:
  iCol - Column position [0..getColumnCount()-1]
Parameters:
  iRow - Row position [0..getRowCount()-1]
throws:
  ClassCastException -
throws:
  ArrayIndexOutOfBoundsException -
version:
   3.1



getDate
public java.util.Date getDate(String sCol, int iRow) throws ArrayIndexOutOfBoundsException(Code)

Get pre-loaded value for a Date field


Parameters:
  sCol - Column name
Parameters:
  iRow - Row position [0..getRowCount()-1]
throws:
  ClassCastException -
throws:
  ArrayIndexOutOfBoundsException - if column is not found



getDateFormated
public String getDateFormated(int iCol, int iRow, String sFormat) throws ArrayIndexOutOfBoundsException, ClassCastException(Code)

Get pre-loaded value for a Date field formated with a used defind formar


Parameters:
  iCol - Column position [0..getColumnCount()-1]
Parameters:
  iRow - Row position [0..getRowCount()-1]
Parameters:
  sFormat - Date Format (like "yyyy-MM-dd HH:mm:ss")
throws:
  ClassCastException -
throws:
  ArrayIndexOutOfBoundsException - Date value formated as String.
See Also:   java.text.SimpleDateFormat



getDateShort
public String getDateShort(int iCol, int iRow)(Code)

Get pre-loaded value for a Date field formated as a short Date "yyyy-MM-dd"


Parameters:
  iCol - Column position [0..getColumnCount()-1]
Parameters:
  iRow - Row position [0..getRowCount()-1] String with format "yyyy-MM-dd" or null.
throws:
  ClassCastException -



getDateTime
public String getDateTime(int iCol, int iRow) throws ClassCastException, ArrayIndexOutOfBoundsException(Code)

Get pre-loaded value for a Date field formated as a DateTime "yyyy-MM-dd hh:mm:ss"


Parameters:
  iCol - Column position [0..getColumnCount()-1]
Parameters:
  iRow - Row position [0..getRowCount()-1]
throws:
  ClassCastException -
throws:
  ArrayIndexOutOfBoundsException - String with format "yyyy-MM-dd hh:mm:ss" or null.



getDateTime24
public String getDateTime24(int iCol, int iRow)(Code)

Get pre-loaded value for a Date field formated as a DateTime "yyyy-MM-dd HH:mm:ss"


Parameters:
  iCol - Column position [0..getColumnCount()-1]
Parameters:
  iRow - Row position [0..getRowCount()-1] String with format "yyyy-MM-dd HH:mm:ss" or null.
throws:
  ClassCastException -
since:
   2.1



getDecimal
public BigDecimal getDecimal(int iCol, int iRow) throws java.lang.ClassCastException, java.lang.NumberFormatException(Code)

Get pre-loaded value and tries to convert it into a BigDecimal

If column is NULL then null value is returned.
If base columnn is of type String then thsi function will try to parse the value into a BigDecimal. A single dot '.' is used as decimal delimiter no matter which is the current locale. All comma characters ',' are removed before parsing String into BigDecimal.
Parameters:
  iCol - Column position [0..getColumnCount()-1]
Parameters:
  iRow - Row position [0..getRowCount()-1] Field value converted to BigDecimal or null if field was NULL.
throws:
  java.lang.ClassCastException -
throws:
  java.lang.NumberFormatException -



getDecimal
public BigDecimal getDecimal(String sCol, int iRow) throws ArrayIndexOutOfBoundsException(Code)

Get pre-loaded value and tries to convert it into a BigDecimal


Parameters:
  sCol - Column name
Parameters:
  iRow - Row position [0..getRowCount()-1] Field value converted to BigDecimal or null if field was NULL.
throws:
  ArrayIndexOutOfBoundsException - if column is not found



getDecimalFormated
public String getDecimalFormated(int iCol, int iRow, String sPattern) throws java.lang.ClassCastException, java.lang.NumberFormatException, java.lang.NullPointerException, java.lang.IllegalArgumentException(Code)

Get decimal formated as a String using the given pattern and the symbols for the default locale


Parameters:
  iCol - Column position [0..getColumnCount()-1]
Parameters:
  iRow - Row position [0..getRowCount()-1]
Parameters:
  sPattern - A non-localized pattern string, for example: "#0.00" String decimal value formated according to sPatern or null
throws:
  ClassCastException -
throws:
  NumberFormatException -
throws:
  NullPointerException - if sPattern is null
throws:
  IllegalArgumentException - if sPattern is invalid



getDecimalFormated
public String getDecimalFormated(String sCol, int iRow, String sPattern) throws java.lang.ClassCastException, java.lang.NumberFormatException, java.lang.NullPointerException, java.lang.IllegalArgumentException, java.lang.ArrayIndexOutOfBoundsException(Code)

Get decimal formated as a String using the given pattern and the symbols for the default locale


Parameters:
  sCol - Column name
Parameters:
  iRow - Row position [0..getRowCount()-1]
Parameters:
  sPattern - A non-localized pattern string, for example: "#0.00" String decimal value formated according to sPatern or null
throws:
  ClassCastException -
throws:
  NumberFormatException -
throws:
  NullPointerException - if sPattern is null
throws:
  IllegalArgumentException - if sPattern is invalid
throws:
  ArrayIndexOutOfBoundsException - if column is not found



getDouble
public double getDouble(int iCol, int iRow) throws NullPointerException, ArrayIndexOutOfBoundsException(Code)

Get pre-loaded value and tries to convert it into a double


Parameters:
  iCol - Column position [0..getColumnCount()-1]
Parameters:
  iRow - Row position [0..getRowCount()-1]
throws:
  NullPointerException - If field value is null
throws:
  ArrayIndexOutOfBoundsException -



getFloat
public float getFloat(int iCol, int iRow) throws NullPointerException, ArrayIndexOutOfBoundsException(Code)

Get pre-loaded value and tries to convert it into a float


Parameters:
  iCol - Column position [0..getColumnCount()-1]
Parameters:
  iRow - Row position [0..getRowCount()-1]
throws:
  NullPointerException - If field value is null
throws:
  ArrayIndexOutOfBoundsException -



getFloat
public float getFloat(String sCol, int iRow) throws NullPointerException, ArrayIndexOutOfBoundsException(Code)

Get pre-loaded value and tries to convert it into a Short


Parameters:
  sCol - Column name
Parameters:
  iRow - Row position [0..getRowCount()-1]
throws:
  ArrayIndexOutOfBoundsException - if column is not found
throws:
  NullPointerException - If field value is null



getFloat
public float getFloat(int iCol, int iRow, int iDecimals) throws NullPointerException, ArrayIndexOutOfBoundsException(Code)

Get pre-loaded value and tries to convert it into a float


Parameters:
  iCol - Column position [0..getColumnCount()-1]
Parameters:
  iRow - Row position [0..getRowCount()-1]
Parameters:
  iDecimals - Decimal places for float value
throws:
  ArrayIndexOutOfBoundsException - if column is not found
throws:
  NullPointerException - If field value is null



getFloat
public float getFloat(String sCol, int iRow, int iDecimals) throws ArrayIndexOutOfBoundsException, NullPointerException(Code)

Get pre-loaded value and tries to convert it into a float


Parameters:
  sCol - Column name
Parameters:
  iRow - Row position [0..getRowCount()-1]
Parameters:
  iDecimals - Decimal places for float value
throws:
  ArrayIndexOutOfBoundsException - if column is not found
throws:
  NullPointerException - If field value is null



getInt
public int getInt(int iCol, int iRow) throws NullPointerException, ArrayIndexOutOfBoundsException(Code)

Get pre-loaded value and tries to convert it into a int


Parameters:
  iCol - Column position [0..getColumnCount()-1]
Parameters:
  iRow - Row position [0..getRowCount()-1]
throws:
  NullPointerException - If field value is null
throws:
  ArrayIndexOutOfBoundsException -



getInt
public int getInt(String sCol, int iRow) throws ArrayIndexOutOfBoundsException, NullPointerException(Code)

Get pre-loaded value and tries to convert it into a Short


Parameters:
  sCol - Column name
Parameters:
  iRow - Row position [0..getRowCount()-1]
throws:
  ArrayIndexOutOfBoundsException - if column is not found
throws:
  NullPointerException - If field value is null



getInteger
public Integer getInteger(int iCol, int iRow) throws ArrayIndexOutOfBoundsException(Code)

Get pre-loaded value and tries to convert it into an Integer


Parameters:
  iCol - Column position [0..getColumnCount()-1]
Parameters:
  iRow - Row position [0..getRowCount()-1] Field value converted to Integer or null if field was NULL.



getInteger
public Integer getInteger(String sCol, int iRow) throws ArrayIndexOutOfBoundsException(Code)

Get pre-loaded value and tries to convert it into an Integer


Parameters:
  sCol - Column name
Parameters:
  iRow - Row position [0..getRowCount()-1] Field value converted to Integer or null if field was NULL.
throws:
  ArrayIndexOutOfBoundsException - if column is not found



getIntervalMilis
public long getIntervalMilis(int iCol, int iRow) throws ArrayIndexOutOfBoundsException, ClassCastException(Code)

Return interval value in miliseconds

This method is only for PostgreSQL 8.0 or later
Parameters:
  iCol - Column position [0..getColumnCount()-1]
Parameters:
  iRow - Row position [0..getRowCount()-1] long Interval in miliseconds. If interval is null then zero is returned.
For Postgres 7.4 and earlier versions this method always return zeroeven if the interval column is not null.
throws:
  ArrayIndexOutOfBoundsException -
throws:
  ClassCastException -
since:
   v2.2



getMaxRows
public int getMaxRows()(Code)
Maximum number of rows to be readed from database



getMoney
public Money getMoney(int iCol, int iRow) throws ArrayIndexOutOfBoundsException, NumberFormatException(Code)

Get value of a VARCHAR field that holds a money+currency amount

Money values are stored with its currency sign embedded inside, like "26.32 USD" or "$48.3" or "35.44 €"
Parameters:
  iCol - int Column position [0..getColumnCount()-1]
Parameters:
  iRow - int Row position [0..getRowCount()-1] com.knowgate.math.Money
throws:
  ArrayIndexOutOfBoundsException -
throws:
  NumberFormatException -
since:
   3.0




getMoney
public Money getMoney(String sCol, int iRow) throws ArrayIndexOutOfBoundsException, NumberFormatException(Code)

Get value of a VARCHAR field that holds a money+currency amount

Money values are stored with its currency sign embedded inside, like "26.32 USD" or "$48.3" or "35.44 €"
Parameters:
  iCol - int Column position [0..getColumnCount()-1]
Parameters:
  iRow - int Row position [0..getRowCount()-1] com.knowgate.math.Money
throws:
  ArrayIndexOutOfBoundsException - if column is not found
throws:
  NumberFormatException -
since:
   3.0




getQueryTimeout
public int getQueryTimeout()(Code)
Maximum amount of time in seconds that a query may run before being cancelled.



getRowAsList
public List getRowAsList(int iRow) throws ArrayIndexOutOfBoundsException, IllegalStateException(Code)
Get DBSubset row as a List interface
Parameters:
  iRow - int Row position [0..getRowCount()-1] List
throws:
  ArrayIndexOutOfBoundsException -
throws:
  IllegalStateException - if DBSubset has not been loaded



getRowAsMap
public Map getRowAsMap(int iRow) throws ArrayIndexOutOfBoundsException, IllegalStateException(Code)
Get DBSubset row as a Map interface
Parameters:
  iRow - int Row position [0..getRowCount()-1] Map
throws:
  ArrayIndexOutOfBoundsException -
throws:
  IllegalStateException - if DBSubset has not been loaded



getRowAsVector
public Vector getRowAsVector(int iRow) throws ArrayIndexOutOfBoundsException, IllegalStateException(Code)
Get DBSubset row as a Vector
Parameters:
  iRow - int Row position [0..getRowCount()-1] Vector
throws:
  ArrayIndexOutOfBoundsException -
throws:
  IllegalStateException - if DBSubset has not been loaded
since:
   3.0



getRowCount
public int getRowCount()(Code)
number of rows retrieved by last call() or load() method invocation.



getRowDelimiter
public String getRowDelimiter()(Code)
Row delimiter for print() and toString() methods.



getSQLDate
public java.sql.Date getSQLDate(int iCol, int iRow) throws ClassCastException, ArrayIndexOutOfBoundsException(Code)

Get pre-loaded value for a Date field


Parameters:
  iCol - Column position [0..getColumnCount()-1]
Parameters:
  iRow - Row position [0..getRowCount()-1] java.sql.Date
throws:
  ClassCastException -
throws:
  ArrayIndexOutOfBoundsException -
since:
   3.0



getSQLDate
public java.sql.Date getSQLDate(String sCol, int iRow) throws ArrayIndexOutOfBoundsException(Code)

Get pre-loaded value for a Date field


Parameters:
  sCol - String Column name
Parameters:
  iRow - Row position [0..getRowCount()-1] java.sql.Date
throws:
  ClassCastException -
throws:
  ArrayIndexOutOfBoundsException -
since:
   3.0



getSQLTime
public java.sql.Time getSQLTime(int iCol, int iRow) throws ClassCastException, ArrayIndexOutOfBoundsException(Code)

Get pre-loaded value for a Time field


Parameters:
  iCol - Column position [0..getColumnCount()-1]
Parameters:
  iRow - Row position [0..getRowCount()-1]
throws:
  ClassCastException -
throws:
  ArrayIndexOutOfBoundsException -
since:
   3.0



getSQLTime
public java.sql.Time getSQLTime(String sCol, int iRow) throws ClassCastException, ArrayIndexOutOfBoundsException(Code)

Get pre-loaded value for a Time field


Parameters:
  sCol - Column name
Parameters:
  iRow - Row position [0..getRowCount()-1] Time
throws:
  ClassCastException -
throws:
  ArrayIndexOutOfBoundsException -
since:
   3.0



getShort
public short getShort(int iCol, int iRow) throws NullPointerException, ArrayIndexOutOfBoundsException(Code)

Get pre-loaded value and tries to convert it into a Short


Parameters:
  iCol - Column position [0..getColumnCount()-1]
Parameters:
  iRow - Row position [0..getRowCount()-1]
throws:
  NullPointerException - If field value is null
throws:
  ArrayIndexOutOfBoundsException -



getString
public String getString(int iCol, int iRow) throws ArrayIndexOutOfBoundsException(Code)

Get toString() form of pre-loaded value


Parameters:
  iCol - Column position [0..getColumnCount()-1]
Parameters:
  iRow - Row position [0..getRowCount()-1] Field value converted to String or null if field was NULL.
throws:
  ArrayIndexOutOfBoundsException -



getString
public String getString(String sCol, int iRow) throws ArrayIndexOutOfBoundsException(Code)

Get toString() form of pre-loaded value


Parameters:
  sCol - Column name
Parameters:
  iRow - Row position [0..getRowCount()-1] Field value converted to String or null if field was NULL.
throws:
  ArrayIndexOutOfBoundsException - if column is not found



getStringNull
public String getStringNull(int iCol, int iRow, String sDef) throws ArrayIndexOutOfBoundsException(Code)

Get toString() form of pre-loaded value


Parameters:
  iCol - Column position [0..getColumnCount()-1]
Parameters:
  iRow - Row position [0..getRowCount()-1]
Parameters:
  sDef - Default value Field value converted to String default value sDef if field was NULL.



getStringNull
public String getStringNull(String sCol, int iRow, String sDef) throws ArrayIndexOutOfBoundsException(Code)

Get toString() form of pre-loaded value


Parameters:
  sCol - Column name
Parameters:
  iRow - Row position [0..getRowCount()-1]
Parameters:
  sDef - Default value Field value converted to String default value sDef if field was NULL.
throws:
  ArrayIndexOutOfBoundsException - if column is not found



getTextQualifier
public String getTextQualifier()(Code)
Text qualifier for quoting fields in print() and toString() methods.



getTimeMilis
public long getTimeMilis(int iCol, int iRow) throws ArrayIndexOutOfBoundsException, ClassCastException(Code)
Returns the number of milliseconds since January 1, 1970, 00:00:00 GMT
Parameters:
  iCol - Column position [0..getColumnCount()-1]
Parameters:
  iRow - Row position [0..getRowCount()-1] long Miliseconds or zero if column is null
throws:
  ArrayIndexOutOfBoundsException -
throws:
  ClassCastException -
since:
   2.2



getTimeOfDay
public Time getTimeOfDay(int iCol, int iRow) throws ArrayIndexOutOfBoundsException, ClassCastException(Code)
Get Time column
Parameters:
  iCol - Column position [0..getColumnCount()-1]
Parameters:
  iRow - Row position [0..getRowCount()-1] java.sql.Time
throws:
  ArrayIndexOutOfBoundsException -
throws:
  ClassCastException -
since:
   3.0



getTimestamp
public Timestamp getTimestamp(int iCol, int iRow) throws ArrayIndexOutOfBoundsException, ClassCastException(Code)
Get Timestamp columnn
Parameters:
  iCol - Column position [0..getColumnCount()-1]
Parameters:
  iRow - Row position [0..getRowCount()-1] java.sql.Timestamp
throws:
  ArrayIndexOutOfBoundsException -
throws:
  ClassCastException -
since:
   2.2



isNull
public boolean isNull(int iCol, int iRow) throws ArrayIndexOutOfBoundsException(Code)

Parameters:
  iCol - Column position [0..getColumnCount()-1]
Parameters:
  iRow - Row position [0..getRowCount()-1] true if pre-load field is null, false otherwise.
throws:
  ArrayIndexOutOfBoundsException -



isNull
public boolean isNull(String sCol, int iRow) throws ArrayIndexOutOfBoundsException(Code)

Parameters:
  sCol - Column name
Parameters:
  iRow - Row position [0..getRowCount()-1] true if pre-load field is null, false otherwise.
throws:
  ArrayIndexOutOfBoundsException - if column is not found



load
public int load(JDCConnection oConn) throws SQLException, ArrayIndexOutOfBoundsException, NullPointerException(Code)

Execute a JDBC Statement and load query ResultSet in an internal bidimensional matrix


Parameters:
  oConn - Database Connection Number of rows retrievedthe maximum number of rows to be retrieved is determined by calling methodsetMaxRows(), if setMaxRows() is not called before call() then all rows existing are retrieved.
throws:
  SQLException -



load
public int load(JDCConnection oConn, int iSkip) throws SQLException, IllegalArgumentException, ArrayIndexOutOfBoundsException, NullPointerException(Code)

Execute a JDBC Statement and load query ResultSet in an internal bidimensional matrix


Parameters:
  oConn - Database Connection
Parameters:
  iSkip - Number of rows to be skipped before reading. On database systems that support anOFFSET clause (such as PostgreSQL) the native offset feature of the DBMS is used, in case thatthe DBMS does not provide offset capabilities, the data is fetched and discarded at client sidebefore returning the DBSubset. Care must be taken when skipping a large number of rows in clientside mode as it may cause heavy network traffic and round trips to the database. Number of rows retrievedthe maximum number of rows to be retrieved is determined by calling methodsetMaxRows(), if setMaxRows() is not called before call() then all rows existing are retrieved.
throws:
  SQLException -
throws:
  IllegalArgumentException - if iSkip<0
throws:
  ArrayIndexOutOfBoundsException -
throws:
  NullPointerException -



load
public int load(JDCConnection oConn, Object[] aFilterValues) throws SQLException, ArrayIndexOutOfBoundsException, NullPointerException(Code)

Execute a JDBC Statement and load query ResultSet in an internal bidimensional matrix


Parameters:
  oConn - Database Connection
Parameters:
  aFilterValues - Values to be binded and JDBC PreparedStatement query paramenters. Number of rows retrievedthe maximum number of rows to be retrieved is determined by calling methodsetMaxRows(), if setMaxRows() is not called before call() then all rows existing are retrieved.
throws:
  SQLException -



load
public int load(JDCConnection oConn, Object[] aFilterValues, int iSkip) throws SQLException, IllegalArgumentException, ArrayIndexOutOfBoundsException, NullPointerException(Code)

Execute a JDBC Statement and load query ResultSet in an internal bidimensional matrix


Parameters:
  oConn - Database Connection
Parameters:
  aFilterValues - Values to be binded and JDBC PreparedStatement query paramenters.
Parameters:
  iSkip - Number of rows to be skipped before reading. On database systems that support anOFFSET clause (such as PostgreSQL) the native offset feature of the DBMS is used, in case thatthe DBMS does not provide offset capabilities, the data is fetched and discarded at client sidebefore returning the DBSubset. Care must be taken when skipping a large number of rows in clientside mode as it may cause heavy network traffic and round trips to the database. Number of rows retrievedthe maximum number of rows to be retrieved is determined by calling methodsetMaxRows(), if setMaxRows() is not called before call() then all rows existing are retrieved.
throws:
  SQLException -
throws:
  IllegalArgumentException - if iSkip<0



parseCSV
public void parseCSV(String sFilePath, String sCharSet) throws ArrayIndexOutOfBoundsException, IOException, FileNotFoundException, RuntimeException, NullPointerException, IllegalArgumentException(Code)

Parse a delimited text file into DBSubset bi-dimensional array

The parsed file must have the same column structure as the column list set when the DBSubset constructor was called.
Parameters:
  sFilePath - File Path
Parameters:
  sCharSet - Character set encoding for file
throws:
  IOException -
throws:
  FileNotFoundException -
throws:
  ArrayIndexOutOfBoundsException - Delimited values for a file is greaterthan columns specified at descriptor.
throws:
  RuntimeException - If delimiter is not one of { ',' ';' or '\t' }
throws:
  NullPointerException - if sFileDescriptor is null
throws:
  IllegalArgumentException - if sFileDescriptor is ""



parseCSV
public void parseCSV(String sFilePath) throws ArrayIndexOutOfBoundsException, IOException, FileNotFoundException, RuntimeException, NullPointerException, IllegalArgumentException(Code)

Parse a delimited text file into DBSubset bi-dimensional array

The parsed file must have the same column structure as the column list set when the DBSubset constructor was called.
Parameters:
  sFilePath - File Path



parseCSV
public void parseCSV(char[] aData, String sCharSet) throws ArrayIndexOutOfBoundsException, RuntimeException, NullPointerException, IllegalArgumentException, UnsupportedEncodingException(Code)

Parse character data into DBSubset bi-dimensional array

The parsed file must have the same column structure as the column list set when the DBSubset constructor was called.
Parameters:
  sFilePath - Character Data to be parsed
Parameters:
  sCharSet - Character set encoding for file



parseCSV
public void parseCSV(char[] aData) throws ArrayIndexOutOfBoundsException, RuntimeException, NullPointerException, IllegalArgumentException, UnsupportedEncodingException(Code)

Parse character data into DBSubset bi-dimensional array

The parsed file must have the same column structure as the column list set when the DBSubset constructor was called.
Parameters:
  sFilePath - Character Data to be parsed



print
public void print(Connection oConn, OutputStream oOutStrm) throws SQLException(Code)

Print DBSubset to an output stream

This method is quite different in behavior from toString() and toXML(). In toString() and toXML() methods data is first pre-loaded by invoking call() or load() methods and then written to a string buffer. For toString() and toXML() memory consumption depends on how many rows are pre-loaded in memory. print() method directly writes readed data to the output stream without creating the bidimimensional internal array for holding readed data. This way data is directly piped from database to output stream.
Parameters:
  oConn - Database Connection
Parameters:
  oOutStrm - Output Stream
throws:
  SQLException -




setColumnDelimiter
public void setColumnDelimiter(String sDelim)(Code)

Parameters:
  sDelim - Column delimiter for print() and toString() methods.The default delimiter is '`' character



setElementAt
public void setElementAt(Object oObj, int iCol, int iRow) throws ArrayIndexOutOfBoundsException(Code)
Set an element for a loaded DBSubset
Parameters:
  oObj - Object Reference
Parameters:
  iCol - Column Index [0..getColumnCount()-1]
Parameters:
  iRow - Row Index [0..getRowCount()-1]
throws:
  ArrayIndexOutOfBoundsException -



setElementAt
public void setElementAt(Object oObj, String sCol, int iRow) throws ArrayIndexOutOfBoundsException(Code)
Set an element for a loaded DBSubset
Parameters:
  oObj - Object Reference
Parameters:
  sCol - Column Name
Parameters:
  iRow - Row Index [0..getColumnCount()-1]
throws:
  ArrayIndexOutOfBoundsException -



setMaxRows
public void setMaxRows(int iMax)(Code)

Maximum number of rows to be readed from database

The exact behavior of this property depends on the RDBMS used.

For PostgreSQL [LIMIT n] clause is appended to DBSubset query and all returned rows are readed.

For Microsoft SQL Server [OPTION FAST(n)] clause is appended to DBSubset query and then the number of readed rows is limited at client side fetching.

For Oracle there is no standard way of limiting the resultset size. The number of readed rows is just limited at client side fetching.




setQueryTimeout
public void setQueryTimeout(int iMaxSeconds)(Code)
Maximum number of seconds that a query can be executing before raising a timeout exception
Parameters:
  iMaxSeconds -



setRowDelimiter
public void setRowDelimiter(String sDelim)(Code)

Parameters:
  sDelim - Row delimiter for print() and toString() methods.The default delimiter is '¨' character



setTextQualifier
public void setTextQualifier(String sQualifier)(Code)

Parameters:
  sQualifier - Text qualifier for quoting fields in print() and toString() methods.



sortBy
public void sortBy(int iCol) throws ArrayIndexOutOfBoundsException, ClassCastException(Code)

Sort in memory an already loaded ResultSet by a given column

A modified bubble sort algorithm is used. Resulting in a O(n²) worst case and O(n) best case if the ResultSet was already sorted by the given column.
Parameters:
  iCol - int Column Index [0..getColumnCount()-1]
throws:
  ArrayIndexOutOfBoundsException -
throws:
  ClassCastException -
since:
   3.0



store
public SQLException[] store(JDCConnection oConn, Class oDBPersistSubclass, boolean bStopOnError) throws SQLException, IllegalAccessException, InstantiationException, ArrayIndexOutOfBoundsException(Code)

Store full contents of this DBSubset at base table

This method takes all the dat contained in memory for this DBSubsets and stores it at the database. For each row, if it does not exist then it is inserted, if it exists then it is updated.
Parameters:
  oConn - JDBC Database Connection
Parameters:
  oDBPersistSubclass - DBPersist subclass for rows. DBSubset will call theproper DBPersist.store() derived method for each row, executing specific codefor the subclass such as automatic GUID at modification date generation.
Parameters:
  bStopOnError - true if process should stop if any SQLException isthrown, false if process must continue upon an SQLException and leavereturn addional information throught SQLException[] array. An array with a SQLException object per stored row, if no SQLExceptionwas trown for a row then the entry at the array for that row is null.
eof() property is set to true if all rows were inserted successfully,and, thus, all entries of the returned SQLException array are null; if any rowfailed to be inserted or updated then eof() is set to false
throws:
  SQLException - Only if bStopOnError is true
throws:
  IllegalAccessException -
throws:
  InstantiationException -




sum
public Object sum(int iCol) throws NumberFormatException, ArrayIndexOutOfBoundsException(Code)



toString
public String toString()(Code)

Write DBSubset to a delimited text string using the column and row delimiters stablished at setColumnDelimiter() and setRowDelimiter() properties.

String dump of the whole DBSubset pre-loaded data.



toXML
public String toXML(String sIdent, String sNode, String sDateFormat, String sDecimalFormat)(Code)

Write DBSubset to an XML string


Parameters:
  sIdent - Initial space identations on the left for fields
Parameters:
  sNode - Name of top parent node. If null then main table namefor this DBSubset is used.
Parameters:
  sDateFormat - Output format for date values
Parameters:
  sDecimalFormat - Output format for decimal and floating point values XML string dump of the whole DBSubset pre-loaded data.



toXML
public String toXML(String sIdent, String sNode)(Code)

Write DBSubset to an XML string

Use default output format for date values: yyyy-MM-dd'T'hh:mm:ss
Parameters:
  sIdent - Initial space identations on the left for fields
Parameters:
  sNode - Name of top parent node. If null then main table namefor this DBSubset is used. XML string dump of the whole DBSubset pre-loaded data.



union
public void union(DBSubset oDbs) throws ArrayIndexOutOfBoundsException, NullPointerException(Code)

Append rows from given DBSubset to this DBSubset


Parameters:
  oDbs - DBSubset An already loaded DBSubset
throws:
  ArrayIndexOutOfBoundsException - If both DBSubsets do not have the same number of columns
throws:
  NullPointerException - If oDbs is null
since:
   3.0



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.