prefuse.data.util
Class TableIterator

java.lang.Object
  extended by prefuse.util.collections.AbstractLiteralIterator
      extended by prefuse.util.collections.IntIterator
          extended by prefuse.data.util.TableIterator
All Implemented Interfaces:
java.util.Iterator, LiteralIterator

public class TableIterator
extends IntIterator

An iterator over table rows, providing convenience methods for accessing and manipulating table data.

Author:
jeffrey heer

Field Summary
protected  int m_cur
           
 
Constructor Summary
TableIterator(Table table, IntIterator rows)
          Create a new TableIterator using a given iterator over table rows.
 
Method Summary
 boolean canGet(java.lang.String field, java.lang.Class type)
          Check if the get method for the given data field returns values that are compatible with a given target type.
 boolean canGetBoolean(java.lang.String field)
          Check if the given data field can return primitive boolean values.
 boolean canGetDate(java.lang.String field)
          Check if the given data field can return Date values.
 boolean canGetDouble(java.lang.String field)
          Check if the given data field can return primitive double values.
 boolean canGetFloat(java.lang.String field)
          Check if the given data field can return primitive float values.
 boolean canGetInt(java.lang.String field)
          Check if the given data field can return primitive int values.
 boolean canGetLong(java.lang.String field)
          Check if the given data field can return primitive long values.
 boolean canGetString(java.lang.String field)
          Check if the given data field can return String values.
 boolean canSet(java.lang.String field, java.lang.Class type)
          Check if the set method for the given data field can accept values of a given target type.
 boolean canSetBoolean(java.lang.String field)
          Check if the setBoolean method can safely be used for the given data field.
 boolean canSetDate(java.lang.String field)
          Check if the setDate method can safely be used for the given data field.
 boolean canSetDouble(java.lang.String field)
          Check if the setDouble method can safely be used for the given data field.
 boolean canSetFloat(java.lang.String field)
          Check if the setFloat method can safely be used for the given data field.
 boolean canSetInt(java.lang.String field)
          Check if the setInt method can safely be used for the given data field.
 boolean canSetLong(java.lang.String field)
          Check if the setLong method can safely be used for the given data field.
 boolean canSetString(java.lang.String field)
          Check if the setString method can safely be used for the given data field.
 java.lang.Object get(java.lang.String field)
          Get the data value at the given field as an Object.
 boolean getBoolean(java.lang.String field)
          Get the data value at the given field as a boolean.
 java.util.Date getDate(java.lang.String field)
          Get the data value at the given field as a Date.
 double getDouble(java.lang.String field)
          Get the data value at the given field as a double.
 float getFloat(java.lang.String field)
          Get the data value at the given field as a float.
 int getInt(java.lang.String field)
          Get the data value at the given field as an int.
 long getLong(java.lang.String field)
          Get the data value at the given field as a long.
 java.lang.String getString(java.lang.String field)
          Get the data value at the given field as a String.
 boolean hasNext()
           
protected  void modify()
          Tracks table modifications.
 int nextInt()
          Returns the next table row.
 void remove()
          Remove the current row, deleting it from the table.
 void set(java.lang.String field, java.lang.Object val)
          Set the value of a given data field.
 void setBoolean(java.lang.String field, boolean val)
          Set the data value of the given field with a boolean.
 void setDate(java.lang.String field, java.util.Date val)
          Set the data value of the given field with a Date.
 void setDouble(java.lang.String field, double val)
          Set the data value of the given field with a double.
 void setFloat(java.lang.String field, float val)
          Set the data value of the given field with a float.
 void setInt(java.lang.String field, int val)
          Set the data value of the given field with an int.
 void setLong(java.lang.String field, long val)
          Set the data value of the given field with a long.
 void setString(java.lang.String field, java.lang.String val)
          Set the data value of the given field with a String.
 
Methods inherited from class prefuse.util.collections.IntIterator
isDoubleSupported, isFloatSupported, isIntSupported, isLongSupported, next, nextDouble, nextFloat, nextLong
 
Methods inherited from class prefuse.util.collections.AbstractLiteralIterator
isBooleanSupported, nextBoolean
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_cur

protected int m_cur
Constructor Detail

TableIterator

public TableIterator(Table table,
                     IntIterator rows)
Create a new TableIterator using a given iterator over table rows.

Parameters:
table - the Table to iterate over
rows - the iteration over individual table rows
Method Detail

nextInt

public int nextInt()
Returns the next table row.

Specified by:
nextInt in interface LiteralIterator
Specified by:
nextInt in class IntIterator
See Also:
LiteralIterator.nextInt()

hasNext

public boolean hasNext()
See Also:
Iterator.hasNext()

remove

public void remove()
Remove the current row, deleting it from the table.

See Also:
Iterator.remove()

modify

protected void modify()
Tracks table modifications.


canGet

public final boolean canGet(java.lang.String field,
                            java.lang.Class type)
Check if the get method for the given data field returns values that are compatible with a given target type.

Parameters:
field - the data field to check
type - a Class instance to check for compatibility with the data field values.
Returns:
true if the data field is compatible with provided type, false otherwise. If the value is true, objects returned by the get(String) can be cast to the given type.
See Also:
get(String)

canSet

public final boolean canSet(java.lang.String field,
                            java.lang.Class type)
Check if the set method for the given data field can accept values of a given target type.

Parameters:
field - the data field to check
type - a Class instance to check for compatibility with the data field values.
Returns:
true if the data field is compatible with provided type, false otherwise. If the value is true, objects of the given type can be used as parameters of the set(String, Object) method.
See Also:
set(String, Object)

get

public final java.lang.Object get(java.lang.String field)
Get the data value at the given field as an Object.

Parameters:
field - the data field to retrieve
Returns:
the data value as an Object. The concrete type of this Object is dependent on the underlying data column used.
See Also:
canGet(String, Class), Table.getColumnType(String)

set

public final void set(java.lang.String field,
                      java.lang.Object val)
Set the value of a given data field.

Parameters:
field - the data field to set
val - the value for the field. If the concrete type of this Object is not compatible with the underlying data model, an Exception will be thrown. Use the canSet(String, Class) method to check the type-safety ahead of time.
See Also:
canSet(String, Class), Table.getColumnType(String)

canGetInt

public final boolean canGetInt(java.lang.String field)
Check if the given data field can return primitive int values.

Parameters:
field - the data field to check
Returns:
true if the data field can return primitive int values, false otherwise. If true, the getInt(String) method can be used safely.

canSetInt

public final boolean canSetInt(java.lang.String field)
Check if the setInt method can safely be used for the given data field.

Parameters:
field - the data field to check
Returns:
true if the setInt(String, int) method can safely be used for the given field, false otherwise.

getInt

public final int getInt(java.lang.String field)
Get the data value at the given field as an int.

Parameters:
field - the data field to retrieve
See Also:
canGetInt(String)

setInt

public final void setInt(java.lang.String field,
                         int val)
Set the data value of the given field with an int.

Parameters:
field - the data field to set
val - the value to set
See Also:
canSetInt(String)

canGetLong

public final boolean canGetLong(java.lang.String field)
Check if the given data field can return primitive long values.

Parameters:
field - the data field to check
Returns:
true if the data field can return primitive long values, false otherwise. If true, the getLong(String) method can be used safely.

canSetLong

public final boolean canSetLong(java.lang.String field)
Check if the setLong method can safely be used for the given data field.

Parameters:
field - the data field to check
Returns:
true if the setLong(String, long) method can safely be used for the given field, false otherwise.

getLong

public final long getLong(java.lang.String field)
Get the data value at the given field as a long.

Parameters:
field - the data field to retrieve
See Also:
canGetLong(String)

setLong

public final void setLong(java.lang.String field,
                          long val)
Set the data value of the given field with a long.

Parameters:
field - the data field to set
val - the value to set
See Also:
canSetLong(String)

canGetFloat

public final boolean canGetFloat(java.lang.String field)
Check if the given data field can return primitive float values.

Parameters:
field - the data field to check
Returns:
true if the data field can return primitive float values, false otherwise. If true, the getFloat(String) method can be used safely.

canSetFloat

public final boolean canSetFloat(java.lang.String field)
Check if the setFloat method can safely be used for the given data field.

Parameters:
field - the data field to check
Returns:
true if the setFloat(String, float) method can safely be used for the given field, false otherwise.

getFloat

public final float getFloat(java.lang.String field)
Get the data value at the given field as a float.

Parameters:
field - the data field to retrieve
See Also:
canGetFloat(String)

setFloat

public final void setFloat(java.lang.String field,
                           float val)
Set the data value of the given field with a float.

Parameters:
field - the data field to set
val - the value to set
See Also:
canSetFloat(String)

canGetDouble

public final boolean canGetDouble(java.lang.String field)
Check if the given data field can return primitive double values.

Parameters:
field - the data field to check
Returns:
true if the data field can return primitive double values, false otherwise. If true, the getDouble(String) method can be used safely.

canSetDouble

public final boolean canSetDouble(java.lang.String field)
Check if the setDouble method can safely be used for the given data field.

Parameters:
field - the data field to check
Returns:
true if the setDouble(String, double) method can safely be used for the given field, false otherwise.

getDouble

public final double getDouble(java.lang.String field)
Get the data value at the given field as a double.

Parameters:
field - the data field to retrieve
See Also:
canGetDouble(String)

setDouble

public final void setDouble(java.lang.String field,
                            double val)
Set the data value of the given field with a double.

Parameters:
field - the data field to set
val - the value to set
See Also:
canSetDouble(String)

canGetBoolean

public final boolean canGetBoolean(java.lang.String field)
Check if the given data field can return primitive boolean values.

Parameters:
field - the data field to check
Returns:
true if the data field can return primitive boolean values, false otherwise. If true, the getBoolean(String) method can be used safely.

canSetBoolean

public final boolean canSetBoolean(java.lang.String field)
Check if the setBoolean method can safely be used for the given data field.

Parameters:
field - the data field to check
Returns:
true if the setBoolean(String, boolean) method can safely be used for the given field, false otherwise.

getBoolean

public final boolean getBoolean(java.lang.String field)
Get the data value at the given field as a boolean.

Parameters:
field - the data field to retrieve
See Also:
canGetBoolean(String)

setBoolean

public final void setBoolean(java.lang.String field,
                             boolean val)
Set the data value of the given field with a boolean.

Parameters:
field - the data field to set
val - the value to set
See Also:
canSetBoolean(String)

canGetString

public final boolean canGetString(java.lang.String field)
Check if the given data field can return String values.

Parameters:
field - the data field to check
Returns:
true if the data field can return String values, false otherwise. If true, the getString(String) method can be used safely.

canSetString

public final boolean canSetString(java.lang.String field)
Check if the setString method can safely be used for the given data field.

Parameters:
field - the data field to check
Returns:
true if the setString(String, String) method can safely be used for the given field, false otherwise.

getString

public final java.lang.String getString(java.lang.String field)
Get the data value at the given field as a String.

Parameters:
field - the data field to retrieve
See Also:
canGetString(String)

setString

public final void setString(java.lang.String field,
                            java.lang.String val)
Set the data value of the given field with a String.

Parameters:
field - the data field to set
val - the value to set
See Also:
canSetString(String)

canGetDate

public final boolean canGetDate(java.lang.String field)
Check if the given data field can return Date values.

Parameters:
field - the data field to check
Returns:
true if the data field can return Date values, false otherwise. If true, the getDate(String) method can be used safely.

canSetDate

public final boolean canSetDate(java.lang.String field)
Check if the setDate method can safely be used for the given data field.

Parameters:
field - the data field to check
Returns:
true if the setDate(String, Date) method can safely be used for the given field, false otherwise.

getDate

public final java.util.Date getDate(java.lang.String field)
Get the data value at the given field as a Date.

Parameters:
field - the data field to retrieve
See Also:
canGetDate(String)

setDate

public final void setDate(java.lang.String field,
                          java.util.Date val)
Set the data value of the given field with a Date.

Parameters:
field - the data field to set
val - the value to set
See Also:
canSetDate(String)


Copyright © 2007 Regents of the University of California