com.ozdevworx.dtype
Interface DataHandler

All Known Implementing Classes:
KeyedList

public interface DataHandler

IMPORTANT NOTE: implementations should be synchronised.

This is a Data-Type interface for an indexed and labelled array of Objects similar to the PHP array concept.
Data should be stored with a String label.

Originally designed for handling resultSet data and query building in database intensive desktop applications.

Version:
1.0.0.7
Author:
Tim Gall (Oz-DevWorX)

Field Summary
static java.lang.String VERSION
           
 
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 key
or 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.
 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.
 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.
 

Field Detail

VERSION

static final java.lang.String VERSION
See Also:
Constant Field Values
Method Detail

addData

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 key
or setData(int i, Object d) to modify existing data by index.

Parameters:
n - String - key name
d - Object - data to add to this DataHandler.

clearData

void clearData()
Resets this DataHandler.


countMatches

int countMatches(java.lang.String n)
Counts the Elements with key names matching name n in this DataHandler.

Parameters:
n - The keys name to seek
Returns:
the number of matching keys in this DataHandler

hasData

boolean hasData(java.lang.String value)
Does this data exist in the set?
The usefulness of this function is questionable.

Parameters:
value - data to search the set for.
Returns:
true if the data is found, else false.

hasKey

boolean hasKey(java.lang.String value)
Does this key exist in the set?

Parameters:
value - key to search the set for.
Returns:
true if the key is found, else false.

hasKey

boolean hasKey(int index)
Does this key exist in the set?

Parameters:
index - key index to search the set for.
Returns:
true if the key is found, else false.

hasElement

boolean hasElement(java.lang.String key,
                   java.lang.String data)
Does this DataHandler Element exist in the set?

Parameters:
key - The Elements key String
data - The Elements data Object as a String
Returns:
true if this Element is found, else false.

getObjectByElement

java.lang.Object getObjectByElement(java.lang.String key,
                                    java.lang.String data)
Parameters:
key - The keys name to locate
data - The data to find a match for
Returns:
The data Object at key location (or null if none found)

getIndexByElement

int getIndexByElement(java.lang.String key,
                      java.lang.String data)
Parameters:
key - The keys name to locate
data - The data to find a match for
Returns:
The Objects index at key location (or -1 if none found)

getData

java.lang.Object getData(int i)
Alias function for getObject(int i)

Parameters:
i - int - keys index
Returns:
a data Object based on its key index i

getData

java.lang.Object getData(java.lang.String n)
Alias function for getObject(String n)

Parameters:
n - String - key name
Returns:
a data Object based on its keys name n

getIndex

int getIndex(java.lang.String n)
Get a keys index in this set from its name String

Parameters:
n - String - keys name
Returns:
The keys index.

getIndexes

int[] getIndexes(java.lang.String n)
Get all key indexes in this set from a key name String.

Parameters:
n - String - key name
Returns:
int[] with the matching key-indexes in this DataHandler matching n (keyName)

getDouble

double getDouble(int i)
                 throws IlegalNumberTypeException
Get the value at index i as a Double or throw an error if the data is not valid for this java Type.

Parameters:
i - The columns index to seek.
Returns:
Double value located at column index i.
Throws:
IlegalNumberTypeException - if value at i is not a Double.

getDouble

double getDouble(java.lang.String n)
                 throws IlegalNumberTypeException
Get the value at name n as a Double or throw an error if the data is not valid for this java Type.

Parameters:
n - The columns name to seek.
Returns:
Double value located at column name n.
Throws:
IlegalNumberTypeException - if value at n is not a Double.

getInt

int getInt(int i)
           throws IlegalNumberTypeException
Get the value at index i as an Integer or throw an error if the data is not valid for this java Type.

Parameters:
i - The columns index to seek.
Returns:
Integer value located at column index i.
Throws:
IlegalNumberTypeException - if value at i is not an Integer.

getInt

int getInt(java.lang.String n)
           throws IlegalNumberTypeException
Get the value at name n as an Integer or throw an error if the data is not valid for this java Type.

Parameters:
n - The columns name to seek.
Returns:
Integer value located at column name n.
Throws:
IlegalNumberTypeException - if value at n is not an Integer.

getKey

java.lang.String getKey(int i)
Get the keys name at index i.

Parameters:
i - The columns index to seek.
Returns:
the keys name

length

int length()
Count all Elements in this DataHandler.

Returns:
the size of this DataHandler

getString

java.lang.String getString(int i)
Get the Object at column index i as a String.

Parameters:
i - The columns index to seek.
Returns:
a data String based on its keys index

getString

java.lang.String getString(java.lang.String n)
Get the Object at column name n as a String.

Parameters:
n - The columns name to seek.
Returns:
a data String based on its keys name

getFloat

float getFloat(int i)
               throws IlegalNumberTypeException
Get the value at index i as a Float or throw an error if the data is not valid for this java Type.

Parameters:
i - The columns index to seek.
Returns:
Float value located at column i.
Throws:
IlegalNumberTypeException - if value at i is not a Float.

getFloat

float getFloat(java.lang.String n)
               throws IlegalNumberTypeException
Get the value at name n as a Float or throw an error if the data is not valid for this java Type.

Parameters:
n - The columns name to seek.
Returns:
Float value located at column name n.
Throws:
IlegalNumberTypeException - if value at n is not a Float.

getObject

java.lang.Object getObject(int i)
Get the Object at column index i.

Parameters:
i - The columns index to seek.
Returns:
Object located at column i.

getObject

java.lang.Object getObject(java.lang.String n)
Get the Object at column name n.

Parameters:
n - The columns name to seek.
Returns:
Object located at column name n.

getLong

long getLong(int i)
             throws IlegalNumberTypeException
Get the value at index i as a Long or throw an error if the data is not valid for this java Type.

Parameters:
i - The columns index to seek.
Returns:
Long value located at column i.
Throws:
IlegalNumberTypeException - if value at i is not a Long.

getLong

long getLong(java.lang.String n)
             throws IlegalNumberTypeException
Get the value at name n as a Long or throw an error if the data is not valid for this java Type.

Parameters:
n - The columns name to seek.
Returns:
Long value located at column name n.
Throws:
IlegalNumberTypeException - if value at i is not a Long.

getShort

java.lang.Short getShort(int i)
                         throws IlegalNumberTypeException
Get the value at index i as a Short or throw an error if the data is not valid for this java Type.

Parameters:
i - The columns index to seek.
Returns:
Short value located at column i.
Throws:
IlegalNumberTypeException - if value at i is not a Short.

getShort

java.lang.Short getShort(java.lang.String n)
                         throws IlegalNumberTypeException
Get the value at name n as a Short or throw an error if the data is not valid for this java Type.

Parameters:
n - The columns name to seek.
Returns:
Short value located at column name n.
Throws:
IlegalNumberTypeException - if value at n is not a Short.

isEmpty

boolean isEmpty()
Determines if this DataHandler contains Elements.

Returns:
true if this DataHandler does not contain Elements else returns false

removeByIndex

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.

Parameters:
i - Element index to remove from this DataHandler.

removeByKey

void removeByKey(java.lang.String n)
Removes the Element at name n and shrinks this DataHandler by one Element.

Parameters:
n - Elements name to remove from this DataHandler.

setData

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.

Parameters:
n - The Elements name.
d - the Data to update/add to this DataHandler.

setData

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.

Parameters:
i - The Elements index.
d - the Data to update index i with.

setData

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.

Parameters:
key - The first Element with name matching key.
newKey - the new key for the Element.
newObj - the Data to update the Element with.

setData

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.

Parameters:
index - The Element at index we want to update.
newKey - the new key for the Element.
newObj - the Data to update the Element with.