it.gotoandplay.smartfoxserver.db
Class DataRow

java.lang.Object
  extended by it.gotoandplay.smartfoxserver.db.DataRow

public class DataRow
extends java.lang.Object

The DataRow class contains data coming from a database query which can be indexed numerically or by field name.

Author:
(c) 2004-2007 gotoAndPlay() -- www.gotoandplay.it
See Also:
DbManager

Field Summary
static int DATAROW_INTKEY
          constant that identifies a numerically indexed DataRow
static int DATAROW_STRINGKEY
          constant that identifies a String key indexed DataRow
 
Constructor Summary
DataRow()
          Construct the object with the default type = DataRow.DATAROW_INTKEY
DataRow(int type)
          Allows to construct the object specifying the type
DATAROW_INTKEY: allows to retrieve data by field index (starting at zero) DATAROW_STRINGKEY: allows to retrieve data by
 
Method Summary
 void addItem(java.lang.String s)
          Add an item to the row in DATAROW_INTKEY mode
 void addItem(java.lang.String key, java.lang.String s)
          Add an item to the row in DATAROW_STRINGKEY mode
 java.lang.Object getData()
          This is a utility method used exclusively by dynamic languages ( Javascript / Python )
 java.util.List getDataAsList()
          Get the row data as a List
 java.util.Map getDataAsMap()
          Get the row data as a Map
 java.lang.String getItem(int key)
          Get an item from the row using field indexes (starting at zero)
 java.lang.String getItem(java.lang.String key)
          Get an item from the row using field names
 int getType()
          Get the type of dataRow.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DATAROW_INTKEY

public static final int DATAROW_INTKEY
constant that identifies a numerically indexed DataRow

See Also:
Constant Field Values

DATAROW_STRINGKEY

public static final int DATAROW_STRINGKEY
constant that identifies a String key indexed DataRow

See Also:
Constant Field Values
Constructor Detail

DataRow

public DataRow()
Construct the object with the default type = DataRow.DATAROW_INTKEY


DataRow

public DataRow(int type)
Allows to construct the object specifying the type

Parameters:
type -
Method Detail

addItem

public void addItem(java.lang.String s)
Add an item to the row in DATAROW_INTKEY mode

Parameters:
s - the data

addItem

public void addItem(java.lang.String key,
                    java.lang.String s)
Add an item to the row in DATAROW_STRINGKEY mode

Parameters:
key - the key
s - the value

getItem

public java.lang.String getItem(int key)
Get an item from the row using field indexes (starting at zero)

Parameters:
key - the index
Returns:
the value

getItem

public java.lang.String getItem(java.lang.String key)
Get an item from the row using field names

Parameters:
key - the field name
Returns:
the value

getType

public int getType()
Get the type of dataRow. Can be one of the static constant DATAROW_INTKEY, DATAROW_STRINGKEY

Returns:
the type of datarow

getDataAsMap

public java.util.Map getDataAsMap()
Get the row data as a Map

Returns:
a Map

getDataAsList

public java.util.List getDataAsList()
Get the row data as a List

Returns:
a List

getData

public java.lang.Object getData()
This is a utility method used exclusively by dynamic languages ( Javascript / Python )