i have problem in TreeMap Contains method....
My treeMap name is Clienthistory(K,V)
where K = object (String clientName)
V = UserDefine LinkedList.
While appending the newClient.. if this new Client already Exist then i have to take the value(as a linkedList) and
append it in to the Exisiting LinkedList....Because before adding the client linkedlist in treemap it is already genereated..
every time i initialized the linked list for new client......
in my linkedList Add() method i used (Comparable obj) as an argument
************
public class LinkedList {
public void add (Comparable obj)
{
some statment for addition....
}
}
************
for creating treeMap ... i am using WriteRecord class....
I am usinf Sax parser for parse my xml document..
public class WriteRecord extends DefaultHandler{
private myDomain.LinkedList linkedRecordList = null;
----
--- some code ---
public void endElement(String uri, String localname, String qname)
throws SAXException {
---- some code ----
linkedRecordList.add(record); // --> for new client linkedlist is alreay generated
// i have to append in this linkedlist from exisiting treeMap...
if(qname.equals("client")){
bool = clientHistory.containsKey(clientName);
if (bool){
Object obj = clientHistory.get( clientName);
Comparable rec = (Comparable)obj; // because my LinkedList add method
// has Comparable obj argument
*************************************************************************************
here i got the classCast Exception.. i know that this casting is not allowed
But it is my requirement.........How i can do this...
*************************************************************************************
linkedRecordList.add(rec); // rec - Special Record type(contains date/discription/min)
// This linkedList contains (old + new) records for the client.....
clientHistory.remove(clientName); // for that client i remove the existing LinkedList
System.out.println("Record remove from tree map for the client = " + clientName);
}
clientHistory.put(clientName,linkedRecordList); // new linkedList contains (old+new) records
System.out.println("Record added for the client = " + clientName);
}
Your help is appriciated.....
ketan
My treeMap name is Clienthistory(K,V)
where K = object (String clientName)
V = UserDefine LinkedList.
While appending the newClient.. if this new Client already Exist then i have to take the value(as a linkedList) and
append it in to the Exisiting LinkedList....Because before adding the client linkedlist in treemap it is already genereated..
every time i initialized the linked list for new client......
in my linkedList Add() method i used (Comparable obj) as an argument
************
public class LinkedList {
public void add (Comparable obj)
{
some statment for addition....
}
}
************
for creating treeMap ... i am using WriteRecord class....
I am usinf Sax parser for parse my xml document..
public class WriteRecord extends DefaultHandler{
private myDomain.LinkedList linkedRecordList = null;
----
--- some code ---
public void endElement(String uri, String localname, String qname)
throws SAXException {
---- some code ----
linkedRecordList.add(record); // --> for new client linkedlist is alreay generated
// i have to append in this linkedlist from exisiting treeMap...
if(qname.equals("client")){
bool = clientHistory.containsKey(clientName);
if (bool){
Object obj = clientHistory.get( clientName);
Comparable rec = (Comparable)obj; // because my LinkedList add method
// has Comparable obj argument
*************************************************************************************
here i got the classCast Exception.. i know that this casting is not allowed
But it is my requirement.........How i can do this...
*************************************************************************************
linkedRecordList.add(rec); // rec - Special Record type(contains date/discription/min)
// This linkedList contains (old + new) records for the client.....
clientHistory.remove(clientName); // for that client i remove the existing LinkedList
System.out.println("Record remove from tree map for the client = " + clientName);
}
clientHistory.put(clientName,linkedRecordList); // new linkedList contains (old+new) records
System.out.println("Record added for the client = " + clientName);
}
Your help is appriciated.....
ketan