Package io.inversion.utils
Class Rows.Row
- java.lang.Object
-
- io.inversion.utils.Rows.Row
-
- All Implemented Interfaces:
java.util.Map<java.lang.String,java.lang.Object>
- Enclosing class:
- Rows
public static class Rows.Row extends java.lang.Object implements java.util.Map<java.lang.String,java.lang.Object>Represents a single row in a database result set where values can be accessed by a zero based integer index or by a case insensitive key/column name.It is not possible to implement both List and Map but that is the practical purpose of this class.
-
-
Constructor Summary
Constructors Constructor Description Row()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(java.lang.Object value)Addsvalueas the last columnjava.util.List<java.lang.Object>asList()voidclear()Sets all values to null, but does not modify RowKeys or change the length ofvalues.booleancontainsKey(java.lang.Object key)booleancontainsValue(java.lang.Object value)java.util.Set<java.util.Map.Entry<java.lang.String,java.lang.Object>>entrySet()java.lang.Objectget(int index)java.lang.Objectget(java.lang.Object keyOrIndex)java.lang.Objectget(java.lang.String key)Gets the value for the key/column.booleangetBoolean(int index)booleangetBoolean(java.lang.String key)floatgetFloat(int index)floatgetFloat(java.lang.String key)intgetInt(int index)intgetInt(java.lang.String key)java.lang.StringgetKey(int index)longgetLong(int index)longgetLong(java.lang.String key)java.lang.StringgetString(int index)java.lang.StringgetString(java.lang.String key)intindexOf(java.lang.String key)booleanisEmpty()java.util.Set<java.lang.String>keySet()java.lang.Objectput(java.lang.String key, java.lang.Object value)Translateskeyinto a column index and insertsvalueat that index.voidputAll(java.util.Map<? extends java.lang.String,? extends java.lang.Object> m)java.lang.Objectremove(java.lang.Object key)Sets the value forkeyOrIndexto null.voidset(int index, java.lang.Object value)Sets theindexth column tovalueintsize()java.lang.StringtoString()java.util.Collection<java.lang.Object>values()
-
-
-
Method Detail
-
getKey
public java.lang.String getKey(int index)
- Parameters:
index- the column key to get- Returns:
- the key/column name for the given index
-
getString
public java.lang.String getString(int index)
- Parameters:
index- the column number to get- Returns:
- the value at
indexstringified if it exists
-
getString
public java.lang.String getString(java.lang.String key)
- Parameters:
key- the column name to get- Returns:
- the value for
keystringified if it exists
-
getInt
public int getInt(int index)
- Parameters:
index- the column number to get- Returns:
- the value at
indexstringified and parsed as an int if it exists
-
getInt
public int getInt(java.lang.String key)
- Parameters:
key- the column name to get- Returns:
- the value for
keystringified and parsed as an int if it exists
-
getLong
public long getLong(int index)
- Parameters:
index- the column value to get- Returns:
- the value at
indexstringified and parsed as a long if it exists
-
getLong
public long getLong(java.lang.String key)
- Parameters:
key- the columnn name to get- Returns:
- the value for
keystringified and parsed as a long if it exists
-
getFloat
public float getFloat(int index)
- Parameters:
index- the column number to get- Returns:
- the value at
indexstringified and parsed as a float if it exists
-
getFloat
public float getFloat(java.lang.String key)
- Parameters:
key- the column name to get- Returns:
- the value for
keystringified and parsed as a float if it exists
-
getBoolean
public boolean getBoolean(int index)
- Parameters:
index- the column number to get- Returns:
- the value at
indexstringified and parsed as a boolean if it exists
-
getBoolean
public boolean getBoolean(java.lang.String key)
- Parameters:
key- the key of the value to get- Returns:
- the value for
keystringified and parsed as a boolean if it exists
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
size
public int size()
- Specified by:
sizein interfacejava.util.Map<java.lang.String,java.lang.Object>
-
isEmpty
public boolean isEmpty()
- Specified by:
isEmptyin interfacejava.util.Map<java.lang.String,java.lang.Object>
-
containsKey
public boolean containsKey(java.lang.Object key)
- Specified by:
containsKeyin interfacejava.util.Map<java.lang.String,java.lang.Object>
-
indexOf
public int indexOf(java.lang.String key)
-
containsValue
public boolean containsValue(java.lang.Object value)
- Specified by:
containsValuein interfacejava.util.Map<java.lang.String,java.lang.Object>
-
get
public java.lang.Object get(java.lang.String key)
Gets the value for the key/column.- Parameters:
key- the column name to get- Returns:
- the value at the index associate with
keyif it exists, otherwise null.
-
get
public java.lang.Object get(int index) throws java.lang.ArrayIndexOutOfBoundsException- Parameters:
index- the column number to get- Returns:
- the value at
index - Throws:
java.lang.ArrayIndexOutOfBoundsException- if index is >= values.length()
-
get
public java.lang.Object get(java.lang.Object keyOrIndex)
- Specified by:
getin interfacejava.util.Map<java.lang.String,java.lang.Object>- Parameters:
keyOrIndex- the String key or an Integer index to retrieve- Returns:
- the value at keyOrIndex as an Integer index or the value for keyOrIndex as a String key
-
set
public void set(int index, java.lang.Object value)Sets theindexth column tovalue- Parameters:
index- the column number to setvalue- the value to set
-
add
public void add(java.lang.Object value)
Addsvalueas the last column- Parameters:
value- the value to add
-
put
public java.lang.Object put(java.lang.String key, java.lang.Object value)Translateskeyinto a column index and insertsvalueat that index.If
keydoes not exists, it is add to the shared RowKeys as the last column.- Specified by:
putin interfacejava.util.Map<java.lang.String,java.lang.Object>- Parameters:
key- the column name to setvalue- the column value to set
-
remove
public java.lang.Object remove(java.lang.Object key)
Sets the value forkeyOrIndexto null.It does not actually remove the key from RowKeys or remove the Row list element because RowKeys is shared across all Row instances and the iteration order and number of keys/columns needs to be the same for all of them.
- Specified by:
removein interfacejava.util.Map<java.lang.String,java.lang.Object>- Parameters:
key- the String key or an Integer index to remove.- Returns:
- the previous value for the column
-
putAll
public void putAll(java.util.Map<? extends java.lang.String,? extends java.lang.Object> m)
- Specified by:
putAllin interfacejava.util.Map<java.lang.String,java.lang.Object>
-
clear
public void clear()
Sets all values to null, but does not modify RowKeys or change the length ofvalues.- Specified by:
clearin interfacejava.util.Map<java.lang.String,java.lang.Object>
-
keySet
public java.util.Set<java.lang.String> keySet()
- Specified by:
keySetin interfacejava.util.Map<java.lang.String,java.lang.Object>- Returns:
- the RowKeys keySet which is common to all Row instances in this Rows.
- See Also:
Rows.RowKeys.keySet()
-
values
public java.util.Collection<java.lang.Object> values()
- Specified by:
valuesin interfacejava.util.Map<java.lang.String,java.lang.Object>
-
asList
public java.util.List<java.lang.Object> asList()
-
entrySet
public java.util.Set<java.util.Map.Entry<java.lang.String,java.lang.Object>> entrySet()
- Specified by:
entrySetin interfacejava.util.Map<java.lang.String,java.lang.Object>- Returns:
- a new LinkedHashSet of key/value pairs preserving column iteration order.
-
-