Rauf Khan

Greenhorn
+ Follow
since Aug 11, 2010
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Rauf Khan

This logic works to select the lower key from the TreeMap with Java 1.5

13 years ago
Hi,

Can anyone please tell me how to do the same kind of check w.r.t Java 1.5 as lowerKey method is part of 1.6, as my application supports only 1.5

Thanks in Advance
Khan
13 years ago
Yes, finally I did with TreeMap only. I have mentioned in the above post.

Thanks a lot 2 everyone for looking into this issue.
13 years ago
Am developing a component which will be place in the application as a JAR. The application will call my method and pass input data in format (Map<String, Object> inputData)and i need to process this data.

I got the first break through to get the values but still couldnt get the output as expected. Can anyone please help me out to get the exact output.



Expected output:


Actual Output
13 years ago
Its throwing the below exception:
Exception in thread "main" java.lang.ClassCastException: java.util.HashMap$KeySet cannot be cast to java.util.TreeSet

Instead of HashMap if its a TreeMap then I can use the "lowerKey" function to get the nearest value.

13 years ago
Rob, thanks for the response.

That thread is somthing different. Its just acting like a counter.

My problem is:



Suppose if I pass 0.49 to method displayRating() then its should display 80
suppose if I pass 0.94534 to method displayRating() then its should display 90, because we dont have the value in the map for 0.94534. So it should consider a value 0.94534<1 but 0.94534>0.72
13 years ago
Hi,

Can you please help me to select the score value which must be rounded down to the nearest score if its not found.

I need to write a method taking score as input and return its value, if the value is not found need to return the nearest value
i.e suppose if the input value is 0.49 then its needs to return 80.
suppose if the input value is 0.94534 then we dont have the value in the map. So then since the input is <1 but >0.72 so it should consider 0.72 as input and return 90.

Thanks in Advance
Khan
13 years ago
Stephan thanks for the response.

I cannot create a Customer class. Am getting the data from the third party and I need to process through that data and get the values. I get the data in the format HashMap<String, Object> only. I have no idea what is present in the Map. I just need to iterate and get the data.
13 years ago
Pillai thanks for the reply.

But here I cant create any class, how will I know what is the input Map data. The values Customers, Customer, Addresses, .... are Map Key values. There might be something in java how to read such type of data. The one which I have shown is the sample. The same map can contain extra data also.



Output:

13 years ago
Am struck in a problem please let me know if you have any idea how to proceed on this.

I have a method myMethod(Map<String, Object> inputData) this Object can be a String/PrimitiveWrapper/Map/Collection i.e List/Vector. I need to get the values from this Object in the format given below.

If the Object is a Map. If it’s a simple Map its fine but this one is a complex Map. This Map can contain any type of data.
Suppose if it contains the data as shown below:



I need to iterate the eight Map i.e in backward direction and values should be read as below. The big question is how do I know what is there in the Object. As this Object can contain any data structure.

Description of the above values:
Customers is the key of eight map that contains seven
Customer is the key of seven that contains a list six so it should be index form Customer[0], Customer[1]
fiveA is part of six at index 0,
Addresses is the key of fiveA, that contains Map four
Address is the key of four that contains a list three, so it should be index for Address[0], Address[1].
AddressLine1 is the key of one and has value House 1
so the final value from the top looks like this:

Now I need to get the values in the above way and put the same in another map.


There will be no XML data as input, only it will be of the form myMethod(Map<String, Object> inputData) and this Object can be a String/PrimitiveWrapper/Map/Collection i.e List/Vector. Now the inputData I have to process is: myMethod(Map<String, Object> eight)

Thanks in Advance
Khan

13 years ago