1

I have a Hashtable<String, Hashtable<String, String>> where I want to get the hashtable with a key, but it returns the value for the other key. Here is the code:

Hashtable<String, Hashtable<String, String>> testFormProperties = 
         formProperties.getFormProperties();

Hashtable<String, String> treeProps = 
        (Hashtable<String, String>)testFormProperties.get("clusterTreeItem");

now treeProps contains

freeTextLabel= {
     guiType=TreeItem, 
     label=freeText, 
     path=/data[at0001]/items[openEHR-EHR-CLUSTER.cluster_test_data_types.v1]/items[at0001]
}

instead of

clusterTreeItem={
    guiType=TreeItem,
    label=freeText, 
    path=/data[at0001]/items[openEHR-EHR-CLUSTER.cluster_test_data_types.v1]/items[at0001]
}

here the content of the testFormProperties Hashtable as per debugger:

{
   freeTextLabel =
     {guiType=TreeItem, label=freeText, path=/data[at0001]/items[openEHR-EHR-CLUSTER.cluster_test_data_types.v1]/items[at0001]
     }, 
  clusterTreeItem = 
     {guiType=TreeItem, label=freeText, path=/data[at0001]/items[openEHR-EHR-CLUSTER.cluster_test_data_types.v1]/items[at0001]
     }
}

I got the same results with Properties<String, Hashtable<String, String>

Can someone explain what is wrong and why?

GavinBrelstaff
  • 3,016
  • 2
  • 21
  • 39
  • 1
    Your post is way too dirty to read. Please purify it first. – Alex Suo Oct 28 '14 at 03:21
  • Both the keys `freeTextLabel` and `clusterTreeItem` have the same values. How do you know its returning the value for the other key? – Neo Oct 28 '14 at 05:37
  • this is another bug when i put the values the values added first are overwritten. still checking for that – charlie schindler Oct 28 '14 at 06:05
  • I resolved that bug Neo mentioned. I also changed to HashMap based on the discussion in this forum. – charlie schindler Oct 28 '14 at 07:20
  • Now it works correct. but still wondering: the keys are different, why does it matter that values are the same... keys `freeTextLabel` versus `clusterTreeItem`... – charlie schindler Oct 28 '14 at 07:30
  • The question is not clear. Please use code that we can run and see for ourselves what the output is and state what you expected the output to be. – user1803551 Oct 28 '14 at 10:47

0 Answers0