Package io.inversion.utils
Class Rows.Row
java.lang.Object
io.inversion.utils.Rows.Row
- Enclosing class:
Rows
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.
-
Nested Class Summary
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAddsvalueas the last columnasList()voidclear()Sets all values to null, but does not modify RowKeys or change the length ofvalues.booleancontainsKey(Object key) booleancontainsValue(Object value) entrySet()get(int index) Gets the value for the key/column.booleangetBoolean(int index) booleangetBoolean(String key) floatgetFloat(int index) floatintgetInt(int index) intgetKey(int index) longgetLong(int index) longgetString(int index) intbooleanisEmpty()keySet()Translateskeyinto a column index and insertsvalueat that index.voidSets the value forkeyOrIndexto null.voidSets theindexth column tovalueintsize()toString()values()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, equals, forEach, getOrDefault, hashCode, merge, putIfAbsent, remove, replace, replace, replaceAll
-
Constructor Details
-
Row
public Row()
-
-
Method Details
-
getKey
- Parameters:
index- the column key to get- Returns:
- the key/column name for the given index
-
getString
- Parameters:
index- the column number to get- Returns:
- the value at
indexstringified if it exists
-
getString
- 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
- 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
- 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
- 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
- Parameters:
key- the key of the value to get- Returns:
- the value for
keystringified and parsed as a boolean if it exists
-
toString
-
size
public int size() -
isEmpty
public boolean isEmpty() -
containsKey
- Specified by:
containsKeyin interfaceMap<String,Object>
-
indexOf
-
containsValue
- Specified by:
containsValuein interfaceMap<String,Object>
-
get
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
- Parameters:
index- the column number to get- Returns:
- the value at
index - Throws:
ArrayIndexOutOfBoundsException- if index is >= values.length()
-
get
-
set
Sets theindexth column tovalue- Parameters:
index- the column number to setvalue- the value to set
-
add
Addsvalueas the last column- Parameters:
value- the value to add
-
put
Translateskeyinto a column index and insertsvalueat that index.If
keydoes not exists, it is add to the shared RowKeys as the last column. -
remove
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.
-
putAll
-
clear
public void clear()Sets all values to null, but does not modify RowKeys or change the length ofvalues. -
keySet
-
values
-
asList
-
entrySet
-