example
Class TableExample
java.lang.Object
example.TableExample
public class TableExample
- extends java.lang.Object
A class for showing how to test table-like objects.
This idea can be used to fill different kind of data
structures for test.
- Author:
- vesal
|
Field Summary |
private java.util.Map<java.lang.String,java.lang.String> |
items
|
|
Method Summary |
void |
add(java.lang.String key,
java.lang.String value)
Add new value with key to the table. |
java.lang.String |
get(java.lang.String key)
Finds the value for key. |
static void |
main(java.lang.String[] args)
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
items
private java.util.Map<java.lang.String,java.lang.String> items
TableExample
public TableExample()
add
public void add(java.lang.String key,
java.lang.String value)
- Add new value with key to the table.
Key is caseinsensitive.
- Parameters:
key - key to use for valuevalue - value to add- Example:
TableExample table = new TableExample();
table.add("1","red");
table.add("2","blue");
table.add("b","blue");
table.add("B","BLUE");
table.get("1") === "red";
table.get("b") === "BLUE";
get
public java.lang.String get(java.lang.String key)
- Finds the value for key. Key is caseinsensitive.
- Parameters:
key - for what the value is looked for
- Returns:
- the value for key, null if no value for key.
- Example:
TableExample table = new TableExample();
table.add("$key","$value");
$key | $value
-------------------
1 | red
2 | blue
3 | green
5 | yellow
Y | YELLOW
y | yellow
red | red
RED | RED
table.get($key) === $result;
$key | $result
-------------------
"1" | "red"
"2" | "blue"
"4" | null
"5" | "yellow"
"y" | "yellow"
"Y" | "yellow"
"red" | "RED"
"RED" | "RED"
"" | null
null | null
main
public static void main(java.lang.String[] args)
- Parameters:
args -