|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.ozdevworx.dtype.impl.KeyedList
public class KeyedList
A List based array. Access DataHandlers Data via a String label or a numeric index.
A DataHandler is an Object itself so support for multidimensional DataHandler Objects is generic to this implementation.
This DataHandler implementation uses synchronisation as specified by the DataHandler interface.
The core abstract implementation for this DataHandler implementation is ArrayList.
We are using dual synchronised ArrayList's that work in strict unison to maintain data integrity
and maximise the flexibility and dynamics in this Data Type.
ArrayList is one of the better performing List implementations.
The synchronisation abilities of the ArrayList is
handled by this class as ArrayList is not a synchronised Object by default.
Field Summary | |
---|---|
static java.lang.String |
VERSION
static version number of this class |
Constructor Summary | |
---|---|
KeyedList()
Create a case sensitive DataHandler of initial capacity 10. Initial capacity is 10 with an expansion rate of 10 when the DataHandler is growing. Empty place holders are ignored when manipulating and querying data. EG: length() returns the actual size and does not include placeholders related to this DataHandlers growth rate. isEmpty() does not count placeholders, only actual Elements that were added to the DataHandler. etc. |
|
KeyedList(boolean lowerCaseKeys)
Create a case insensitive DataHandler of initial capacity incSize. Initial capacity is 10 with an expansion rate of 10 when the DataHandler is growing. Empty place holders are ignored when manipulating and querying data. EG: getSize() returns the actual Element count and does not include placeholders related to this DataHandlers growth rate. isEmpty() does not count placeholders, only actual Elements that were added to the DataHandler. etc. |
|
KeyedList(int incSize)
Create a case sensitive DataHandler of initial capacity incSize. Initial capacity is incSize with an expansion rate of incSize when the DataHandler is growing. Empty place holders are ignored when manipulating and querying data. EG: getSize() returns the actual Element count and does not include placeholders related to this DataHandlers growth rate. isEmpty() does not count placeholders, only actual Elements that were added to the DataHandler. etc. |
|
KeyedList(int incSize,
boolean lowerCaseKeys)
Create a case insensitive DataHandler of initial capacity incSize. Initial capacity is incSize with an expansion rate of incSize when the DataHandler is growing. Empty place holders are ignored when manipulating and querying data. EG: getSize() returns the actual Element count and does not include placeholders related to this DataHandlers growth rate. isEmpty() does not count placeholders, only actual Elements that were added to the DataHandler. etc. |
Method Summary | |
---|---|
void |
addData(java.lang.String n,
java.lang.Object d)
Adds Elements to this DataHandler Object. If the key is null or the equivalent of, the Element will not be added to this DataHandler. NOTE: Use setData(String n, Object d) to modify existing data by keyor setData(int i, Object d) to modify existing data by index. |
void |
clearData()
Resets this DataHandler. |
int |
countMatches(java.lang.String n)
Counts the Elements with key names matching name n in this DataHandler. |
protected java.lang.String |
fixCase(java.lang.String n)
Correct the CaSe for DataHandler keys. NOTE: we use Locale.ENGLISH as recommended
by the java.util.Locale documentation
to preserve the programatic sense of the keys name. |
java.lang.Object |
getData(int i)
Alias function for getObject(int i) |
java.lang.Object |
getData(java.lang.String n)
Alias function for getObject(String n) |
double |
getDouble(int i)
Get the value at index i as a Double or throw an error if the data is not valid for this java Type. |
double |
getDouble(java.lang.String n)
Get the value at name n as a Double or throw an error if the data is not valid for this java Type. |
float |
getFloat(int i)
Get the value at index i as a Float or throw an error if the data is not valid for this java Type. |
float |
getFloat(java.lang.String n)
Get the value at name n as a Float or throw an error if the data is not valid for this java Type. |
int |
getIndex(java.lang.String n)
Get a keys index in this set from its name String |
int |
getIndexByElement(java.lang.String key,
java.lang.String data)
|
int[] |
getIndexes(java.lang.String n)
Get all key indexes in this set from a key name String. |
int |
getInt(int i)
Get the value at index i as an Integer or throw an error if the data is not valid for this java Type. |
int |
getInt(java.lang.String n)
Get the value at name n as an Integer or throw an error if the data is not valid for this java Type. |
protected java.lang.Object |
getItem(int i,
boolean notNull)
Gets Elements from any List implementation based on the Elements index i. Allows missing keys and missing indexes to be handled gracefully and discreetly. |
java.lang.String |
getKey(int i)
Get the keys name at index i. |
long |
getLong(int i)
Get the value at index i as a Long or throw an error if the data is not valid for this java Type. |
long |
getLong(java.lang.String n)
Get the value at name n as a Long or throw an error if the data is not valid for this java Type. |
java.lang.Object |
getObject(int i)
Get the Object at column index i. |
java.lang.Object |
getObject(java.lang.String n)
Get the Object at column name n. |
java.lang.Object |
getObjectByElement(java.lang.String key,
java.lang.String data)
|
java.lang.Short |
getShort(int i)
Get the value at index i as a Short or throw an error if the data is not valid for this java Type. |
java.lang.Short |
getShort(java.lang.String n)
Get the value at name n as a Short or throw an error if the data is not valid for this java Type. |
java.lang.String |
getString(int i)
Get the Object at column index i as a String. |
java.lang.String |
getString(java.lang.String n)
Get the Object at column name n as a String. |
boolean |
hasData(java.lang.String value)
Does this data exist in the set? The usefulness of this function is questionable. |
boolean |
hasElement(java.lang.String key,
java.lang.String data)
Does this DataHandler Element exist in the set? |
boolean |
hasKey(int index)
Does this key exist in the set? |
boolean |
hasKey(java.lang.String value)
Does this key exist in the set? |
boolean |
isEmpty()
Determines if this DataHandler contains Elements. |
int |
length()
Count all Elements in this DataHandler. |
void |
removeByIndex(int i)
Removes the Element at index and shrinks this DataHandler so that Element index+1 will be positioned at index after the original Element at index is removed. |
void |
removeByKey(java.lang.String n)
Removes the Element at name n and shrinks this DataHandler by one Element. |
void |
setData(int i,
java.lang.Object d)
Update the Element at index i with data d. No action is taken if index i is greater than this DataHandlers size. |
void |
setData(int index,
java.lang.String newKey,
java.lang.Object newObj)
Update the Element at index with a new key and new data. No action is taken if index is greater than this DataHandlers size. |
void |
setData(java.lang.String n,
java.lang.Object d)
Update the Element at name n with data d or add a new Element if key name n doesnt exist. USE: addData(String n, Object d) to add new data or data with duplicate keys to this DataHandler. |
void |
setData(java.lang.String key,
java.lang.String newKey,
java.lang.Object newObj)
Update the Element at name key with a new key and new data or add a new Element if name key doesnt exist. NOTE: Use addData(String n, Object d) to add new data or data with duplicate keys to this DataHandler. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String VERSION
Constructor Detail |
---|
public KeyedList()
public KeyedList(boolean lowerCaseKeys)
lowerCaseKeys
- boolean. If true, keys all use lower case,
if false keys all use upper case.public KeyedList(int incSize)
incSize
- int. This value affects the initial size
and the expansion rate when the DataHandler is growing.public KeyedList(int incSize, boolean lowerCaseKeys)
incSize
- int. This value affects the initial size
and the expansion rate when the DataHandler is growing.lowerCaseKeys
- boolean. If true, keys all use lower case,
if false keys all use upper case.Method Detail |
---|
public void addData(java.lang.String n, java.lang.Object d)
DataHandler
setData(String n, Object d)
to modify existing data by keysetData(int i, Object d)
to modify existing data by index.
addData
in interface DataHandler
n
- String - key named
- Object - data to add to this DataHandler.DataHandler.addData(java.lang.String, java.lang.Object)
public void clearData()
DataHandler
clearData
in interface DataHandler
DataHandler.clearData()
public int countMatches(java.lang.String n)
DataHandler
countMatches
in interface DataHandler
n
- The keys name to seek
DataHandler.countMatches(java.lang.String)
public java.lang.Object getData(int i)
DataHandler
getData
in interface DataHandler
i
- int - keys index
DataHandler.getData(int)
public java.lang.Object getData(java.lang.String n)
DataHandler
getData
in interface DataHandler
n
- String - key name
DataHandler.getData(java.lang.String)
public double getDouble(int i) throws IlegalNumberTypeException
DataHandler
getDouble
in interface DataHandler
i
- The columns index to seek.
IlegalNumberTypeException
- if value at i is not a Double.DataHandler.getDouble(int)
public double getDouble(java.lang.String n) throws IlegalNumberTypeException
DataHandler
getDouble
in interface DataHandler
n
- The columns name to seek.
IlegalNumberTypeException
- if value at n is not a Double.DataHandler.getDouble(java.lang.String)
public float getFloat(int i) throws IlegalNumberTypeException
DataHandler
getFloat
in interface DataHandler
i
- The columns index to seek.
IlegalNumberTypeException
- if value at i is not a Float.DataHandler.getFloat(int)
public float getFloat(java.lang.String n) throws IlegalNumberTypeException
DataHandler
getFloat
in interface DataHandler
n
- The columns name to seek.
IlegalNumberTypeException
- if value at n is not a Float.DataHandler.getFloat(java.lang.String)
public int getIndex(java.lang.String n)
DataHandler
getIndex
in interface DataHandler
n
- String - keys name
DataHandler.getIndex(java.lang.String)
public int getIndexByElement(java.lang.String key, java.lang.String data)
getIndexByElement
in interface DataHandler
key
- The keys name to locatedata
- The data to find a match for
DataHandler.getIndexByElement(java.lang.String, java.lang.String)
public int[] getIndexes(java.lang.String n)
DataHandler
getIndexes
in interface DataHandler
n
- String - key name
DataHandler.getIndexes(java.lang.String)
public int getInt(int i) throws IlegalNumberTypeException
DataHandler
getInt
in interface DataHandler
i
- The columns index to seek.
IlegalNumberTypeException
- if value at i is not an Integer.DataHandler.getInt(int)
public int getInt(java.lang.String n) throws IlegalNumberTypeException
DataHandler
getInt
in interface DataHandler
n
- The columns name to seek.
IlegalNumberTypeException
- if value at n is not an Integer.DataHandler.getInt(java.lang.String)
public java.lang.String getKey(int i)
DataHandler
getKey
in interface DataHandler
i
- The columns index to seek.
DataHandler.getKey(int)
public long getLong(int i) throws IlegalNumberTypeException
DataHandler
getLong
in interface DataHandler
i
- The columns index to seek.
IlegalNumberTypeException
- if value at i is not a Long.DataHandler.getLong(int)
public long getLong(java.lang.String n) throws IlegalNumberTypeException
DataHandler
getLong
in interface DataHandler
n
- The columns name to seek.
IlegalNumberTypeException
- if value at i is not a Long.DataHandler.getLong(java.lang.String)
public java.lang.Object getObject(int i)
DataHandler
getObject
in interface DataHandler
i
- The columns index to seek.
DataHandler.getObject(int)
public java.lang.Object getObject(java.lang.String n)
DataHandler
getObject
in interface DataHandler
n
- The columns name to seek.
DataHandler.getObject(java.lang.String)
public java.lang.Object getObjectByElement(java.lang.String key, java.lang.String data)
getObjectByElement
in interface DataHandler
key
- The keys name to locatedata
- The data to find a match for
DataHandler.getObjectByElement(java.lang.String, java.lang.String)
public java.lang.Short getShort(int i) throws IlegalNumberTypeException
DataHandler
getShort
in interface DataHandler
i
- The columns index to seek.
IlegalNumberTypeException
- if value at i is not a Short.DataHandler.getShort(int)
public java.lang.Short getShort(java.lang.String n) throws IlegalNumberTypeException
DataHandler
getShort
in interface DataHandler
n
- The columns name to seek.
IlegalNumberTypeException
- if value at n is not a Short.DataHandler.getShort(java.lang.String)
public java.lang.String getString(int i)
DataHandler
getString
in interface DataHandler
i
- The columns index to seek.
DataHandler.getString(int)
public java.lang.String getString(java.lang.String n)
DataHandler
getString
in interface DataHandler
n
- The columns name to seek.
DataHandler.getString(java.lang.String)
public boolean hasData(java.lang.String value)
DataHandler
hasData
in interface DataHandler
value
- data to search the set for.
DataHandler.hasData(java.lang.String)
public boolean hasElement(java.lang.String key, java.lang.String data)
DataHandler
hasElement
in interface DataHandler
key
- The Elements key Stringdata
- The Elements data Object as a String
DataHandler.hasElement(java.lang.String, java.lang.String)
public boolean hasKey(int index)
DataHandler
hasKey
in interface DataHandler
index
- key index to search the set for.
DataHandler.hasKey(int)
public boolean hasKey(java.lang.String value)
DataHandler
hasKey
in interface DataHandler
value
- key to search the set for.
DataHandler.hasKey(java.lang.String)
public boolean isEmpty()
DataHandler
isEmpty
in interface DataHandler
DataHandler.isEmpty()
public int length()
DataHandler
length
in interface DataHandler
DataHandler.length()
public void removeByIndex(int i)
DataHandler
removeByIndex
in interface DataHandler
i
- Element index to remove from this DataHandler.DataHandler.removeByIndex(int)
public void removeByKey(java.lang.String n)
DataHandler
removeByKey
in interface DataHandler
n
- Elements name to remove from this DataHandler.DataHandler.removeByKey(java.lang.String)
public void setData(int i, java.lang.Object d)
DataHandler
setData
in interface DataHandler
i
- The Elements index.d
- the Data to update index i with.DataHandler.setData(int, java.lang.Object)
public void setData(int index, java.lang.String newKey, java.lang.Object newObj)
DataHandler
setData
in interface DataHandler
index
- The Element at index we want to update.newKey
- the new key for the Element.newObj
- the Data to update the Element with.DataHandler.setData(int, java.lang.String, java.lang.Object)
public void setData(java.lang.String n, java.lang.Object d)
DataHandler
addData(String n, Object d)
to add new data or data with duplicate keys to this DataHandler.
setData
in interface DataHandler
n
- The Elements name.d
- the Data to update/add to this DataHandler.DataHandler.setData(java.lang.String, java.lang.Object)
public void setData(java.lang.String key, java.lang.String newKey, java.lang.Object newObj)
DataHandler
addData(String n, Object d)
to add new data or data with duplicate keys to this DataHandler.
setData
in interface DataHandler
key
- The first Element with name matching key.newKey
- the new key for the Element.newObj
- the Data to update the Element with.DataHandler.setData(java.lang.String, java.lang.String, java.lang.Object)
protected java.lang.String fixCase(java.lang.String n)
Locale.ENGLISH
as recommended
by the java.util.Locale
documentation
to preserve the programatic sense of the keys name.
Particularly String wrappers and special characters.
n
- A DataHandler key of unknown character CaSe.
protected java.lang.Object getItem(int i, boolean notNull)
i
- int - List-indexnotNull
- - boolean
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |