com.ijchart.xychart.dataset
Class DefaultKeyValueDataset

java.lang.Object
  extended by com.ijchart.xychart.dataset.AbstractDataset
      extended by com.ijchart.xychart.dataset.DefaultKeyValueDataset
All Implemented Interfaces:
IDataset, IKeyValueDataset, IDatasetChangeListener, java.io.Serializable, java.lang.Cloneable, java.util.EventListener

public class DefaultKeyValueDataset
extends AbstractDataset
implements IKeyValueDataset, java.lang.Cloneable, java.io.Serializable

Title: IJChart

Description: a chart library for the Java(tm) platform.

The default implemention of IKeyValueDataset interface.The use of internal is List,so this dataset can not be too large.

Copyright: Copyright (c) 2013

Company:

Version:
1.0
Author:
zhang feng min,shanghai china. Contract me by email.
See Also:
Serialized Form

Constructor Summary
DefaultKeyValueDataset()
           No argument constructor.
DefaultKeyValueDataset(int initialCapacity)
           Constructs an empty dataset with the specified initial capacity.
 
Method Summary
 void addChartData(java.lang.Object key, IChartData value)
           Add a value associate a key to the storage list.
 java.lang.Object clone()
           Clone this object.
 boolean equals(java.lang.Object obj)
           Override equals method.
 java.util.List getAllKeys()
           Returns all the keys.
 java.util.List getData()
           Returns a list (possibly empty) of the values.The returned list should be unmodifiable.
 IChartData getDataByIndex(int index)
           Get chartdata by index,if index out of bound a Exception will be throw.
 IChartData getDataByKey(java.lang.Object key)
           Returns the data associate with this key.
 int getDataSize()
           Returns the keys count.
 int getKeyIndex(java.lang.Object key)
           Returns the index for a given key.
 int hashCode()
           Get hascode.
 boolean isThisDataType(java.lang.Class c)
           Test whether or not all data is Class c in this dataset.
 void removeAllChartData()
           Clear all data in the dataset.
 void removeChartDataByIndex(int index)
           Remove data by index.
 int removeChartDataByKey(java.lang.Object key)
           Remove data by key object.
 void setDataByIndex(int index, IChartData data)
           Sets chartdata by index,if index out of bound a Exception will be throw.
 boolean setDataByKey(java.lang.Object key, IChartData data)
           Sets chartdata by key.
 
Methods inherited from class com.ijchart.xychart.dataset.AbstractDataset
addChangeListener, datasetChanged, fireDatasetChanged, forceDataSetChanged, hasListener, notifyListeners, removeAllChangeListener, removeChangeListener
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.ijchart.xychart.dataset.IDataset
addChangeListener, forceDataSetChanged, removeAllChangeListener, removeChangeListener
 

Constructor Detail

DefaultKeyValueDataset

public DefaultKeyValueDataset()
No argument constructor.


DefaultKeyValueDataset

public DefaultKeyValueDataset(int initialCapacity)
Constructs an empty dataset with the specified initial capacity.

Parameters:
initialCapacity - int
Method Detail

getAllKeys

public java.util.List getAllKeys()
Returns all the keys.

Specified by:
getAllKeys in interface IKeyValueDataset
Returns:
All the keys list.

getDataByKey

public IChartData getDataByKey(java.lang.Object key)
Returns the data associate with this key.

Specified by:
getDataByKey in interface IKeyValueDataset
Parameters:
key - Object
Returns:
IChartData

getDataByIndex

public IChartData getDataByIndex(int index)
Get chartdata by index,if index out of bound a Exception will be throw.

Parameters:
index - int The data index
Returns:
IChartData

setDataByIndex

public void setDataByIndex(int index,
                           IChartData data)
Sets chartdata by index,if index out of bound a Exception will be throw.

Parameters:
index - int The data index
data - IChartData The IChartData object.

setDataByKey

public boolean setDataByKey(java.lang.Object key,
                            IChartData data)
Sets chartdata by key.

Parameters:
key - Object The key object (null not permitted).
data - IChartData The IChartData object.
Returns:
boolean If of not changed data.

getData

public java.util.List getData()
Returns a list (possibly empty) of the values.The returned list should be unmodifiable.

Returns:
List The list of values.

getDataSize

public int getDataSize()
Returns the keys count.

Specified by:
getDataSize in interface IKeyValueDataset
Returns:
int

getKeyIndex

public int getKeyIndex(java.lang.Object key)
Returns the index for a given key.

Specified by:
getKeyIndex in interface IKeyValueDataset
Parameters:
key - Object The key object.
Returns:
int The column index, or -1 if the key is unrecognised.

addChartData

public void addChartData(java.lang.Object key,
                         IChartData value)
Add a value associate a key to the storage list.

Parameters:
key - Object The key object (null not permitted).
value - Object The value object (null permitted).

removeChartDataByKey

public int removeChartDataByKey(java.lang.Object key)
Remove data by key object.

Parameters:
key - Object The key object,(null not permitted).
Returns:
int The key index in the collection,if not found then return -1.

removeChartDataByIndex

public void removeChartDataByIndex(int index)
Remove data by index.

Parameters:
index - int The index

removeAllChartData

public void removeAllChartData()
Clear all data in the dataset.


isThisDataType

public boolean isThisDataType(java.lang.Class c)
Test whether or not all data is Class c in this dataset.

Specified by:
isThisDataType in interface IDataset
Parameters:
c - Class A class (null not permitted).
Returns:
boolean Returns true if all data equals Class c in this dataset,false otherwise.

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Clone this object.

Overrides:
clone in class AbstractDataset
Returns:
Object
Throws:
java.lang.CloneNotSupportedException

equals

public boolean equals(java.lang.Object obj)
Override equals method.

Overrides:
equals in class AbstractDataset
Parameters:
obj - Object
Returns:
boolean

hashCode

public int hashCode()
Get hascode.

Overrides:
hashCode in class AbstractDataset
Returns:
int