Modifier and Type | Class and Description |
---|---|
class |
StringDict.Entry |
Constructor and Description |
---|
StringDict() |
StringDict(java.io.BufferedReader reader)
Read a set of entries from a Reader that has each key/value pair on
a single line, separated by a tab.
|
StringDict(int length)
Create a new lookup pre-allocated to a specific length.
|
StringDict(java.lang.String[][] pairs)
Constructor to allow (more intuitive) inline initialization, e.g.:
|
StringDict(java.lang.String[] keys,
java.lang.String[] values) |
StringDict(TableRow row)
Create a dictionary that maps between column titles and cell entries
in a TableRow.
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
Remove all entries.
|
StringDict |
copy()
Returns a duplicate copy of this object.
|
java.lang.Iterable<StringDict.Entry> |
entries() |
java.util.Iterator<StringDict.Entry> |
entryIterator() |
java.lang.String |
get(java.lang.String key)
Return a value for the specified key.
|
java.lang.String |
get(java.lang.String key,
java.lang.String alternate) |
boolean |
hasKey(java.lang.String key) |
int |
index(java.lang.String what) |
java.lang.String |
key(int index) |
java.lang.String[] |
keyArray()
Return a copy of the internal keys array.
|
java.lang.String[] |
keyArray(java.lang.String[] outgoing) |
java.util.Iterator<java.lang.String> |
keyIterator() |
java.lang.Iterable<java.lang.String> |
keys() |
void |
print() |
java.lang.String |
remove(java.lang.String key) |
java.lang.String |
removeIndex(int index) |
void |
resize(int length)
Resize the internal data, this can only be used to shrink the list.
|
void |
save(java.io.File file)
Save tab-delimited entries to a file (TSV format, UTF-8 encoding)
|
void |
set(java.lang.String key,
java.lang.String value) |
void |
setIndex(int index,
java.lang.String key,
java.lang.String value) |
int |
size() |
void |
sortKeys()
Sort the keys alphabetically (ignoring case).
|
void |
sortKeysReverse() |
void |
sortValues()
Sort by values in descending order (largest value will be at [0]).
|
void |
sortValuesReverse() |
void |
swap(int a,
int b) |
java.lang.String |
toJSON()
Return this dictionary as a String in JSON format.
|
java.lang.String |
toString() |
java.lang.String |
value(int index) |
java.lang.String[] |
valueArray()
Create a new array and copy each of the values into it.
|
java.lang.String[] |
valueArray(java.lang.String[] array)
Fill an already-allocated array with the values (more efficient than
creating a new array each time).
|
java.util.Iterator<java.lang.String> |
valueIterator() |
java.lang.Iterable<java.lang.String> |
values() |
void |
write(java.io.PrintWriter writer)
Write tab-delimited entries to a PrintWriter
|
public StringDict()
public StringDict(int length)
public StringDict(java.io.BufferedReader reader)
public StringDict(java.lang.String[] keys, java.lang.String[] values)
public StringDict(java.lang.String[][] pairs)
new StringDict(new String[][] { { "key1", "value1" }, { "key2", "value2" } });It's no Python, but beats a static { } block with HashMap.put() statements.
public StringDict(TableRow row)
public int size()
public void resize(int length)
public void clear()
public java.lang.Iterable<StringDict.Entry> entries()
public java.util.Iterator<StringDict.Entry> entryIterator()
public java.lang.String key(int index)
public java.lang.Iterable<java.lang.String> keys()
public java.util.Iterator<java.lang.String> keyIterator()
public java.lang.String[] keyArray()
public java.lang.String[] keyArray(java.lang.String[] outgoing)
public java.lang.String value(int index)
public java.lang.Iterable<java.lang.String> values()
public java.util.Iterator<java.lang.String> valueIterator()
public java.lang.String[] valueArray()
public java.lang.String[] valueArray(java.lang.String[] array)
public java.lang.String get(java.lang.String key)
public java.lang.String get(java.lang.String key, java.lang.String alternate)
public void set(java.lang.String key, java.lang.String value)
public void setIndex(int index, java.lang.String key, java.lang.String value)
public int index(java.lang.String what)
public boolean hasKey(java.lang.String key)
public java.lang.String remove(java.lang.String key)
public java.lang.String removeIndex(int index)
public void swap(int a, int b)
public void sortKeys()
public void sortKeysReverse()
public void sortValues()
public void sortValuesReverse()
public StringDict copy()
public void print()
public void save(java.io.File file)
public void write(java.io.PrintWriter writer)
public java.lang.String toJSON()
public java.lang.String toString()
toString
in class java.lang.Object