Problem in setting vector or string[] as the "value object" in hashmap

Hey I am new to this forum.
I am doing a project in which i need to store a array of strings as "value object" for a unique key in hashmap.
as I populate the hashmap from external file according to key and setting the string[]. The hashmap is taking the value field same for each entry i.e the last field as i keep updating the same variable and then putting it into hashmap.
Please give solution to my problem???
if question not clear,please tell me- i will add more information
Edited by: AnkitNahar on Apr 4, 2009 8:06 AM

I tried using the method suggested by you...but it is of same case as using the string[].
I need to loop the statements in which the hashmap is populating so cant change the variable names in the dd.put() statements. When the below code executes it shows the same set of string for both the keys, that was the problem i was facing with string[].
here is the example with two entries....same thing in looping.
HashMap<String,Set<String>> dd=new HashMap<String,Set<String>>();
String word = "Hello";
Set<String> alternativeWords = new HashSet<String>();
alternativeWords.add("Hi");
alternativeWords.add("Yo");
dd.put(word, alternativeWords);
alternativeWords.clear();
alternativeWords.add("hey");
word="yep";
dd.put(word,alternativeWords);
System.out.println(dd.get("Hello").toString());
System.out.println(dd.get("yep").toString());

Similar Messages

  • Introspection - getting  the value of a hashmap

    Hello is it possible to get the value of a hashmap by introspection :
    Here is my code that generate NoSuchFieldException :
    Class clazz = Class.forName("java.util.HashMap");
                        Object uneMap = clazz.newInstance();
                        Field champ = clazz.getField("value");
                        String val = (String)champ.get(uneMap);

    It's early in the morning for me, so I don't understand your motivation, but
    here's an example of making simple map code much harder ;-)
    import java.lang.reflect.*;
    import java.util.*;
    public class ReflectExample {
        public static void main(String[] args) throws Exception {
            Class cls = Class.forName("java.util.HashMap");
            Method put = cls.getMethod("put", Object.class, Object.class);
            Method get = cls.getMethod("get", Object.class);
            Object map = cls.newInstance();
            for(int i = 0; i < 10 ; ++i)
                put.invoke(map, i, i * i);
            for(int i = 0; i < 10 ; ++i) {
                Object value = get.invoke(map, i);
                System.out.format("map[%d] = %s%n", i, value);
    }

  • Is it worth while going down the Value Object design route

    When building large applications in flex and coldfusion and
    passing date to flex, I am trying to figure out if it is worth
    while going down the Value Object design route or just going with
    CF's structs variables?

    ... Value Object... or just ... CF's structs...?
    In my opinion, basically the same design idea. Under the
    hood, a struct is, loosely speaking, a value object. You can use
    the duplicate function to emulate serialization of a value object.

  • How to set List of String as variable value in BPEL

    I am using java embedding to invoke a method which returns a list of strings. I need to set these values in a variable in BPEL to be used later. I am getting following error while setting the value.
    <May 2, 2012 5:18:20 PM IST> <Error> <oracle.soa.bpel.engine.dispatch> <BEA-000000> <failed to handle message
    com.oracle.bpel.client.BPELFault: faultName: {{http://schemas.xmlsoap.org/ws/2003/03/business-process/}mismatchedAssignmentFailure}
    messageType: {{http://schemas.oracle.com/bpel/extension}RuntimeFaultMessage}
    parts: {{
    summary=<summary>Mismatch Assign.
    cannot set a nonelement value to an element-based variable.
    An attempt to assign a nonelement value to an element-based variable failed.
    Verify the BPEL source for invalid assign activities.
    </summary>}
    Following is the java code
    List<String> providers = Registory.getProviders("1");
    setVariableData("providerList", providers);
    I have defined a xml element in the wsdl defintion:
    <xsd:element name="providerList">
    <xsd:complexType>
    <xsd:sequence>
    <xsd:element name="providerId" type="xs:string" maxOccurs="unbounded" minOccurs="0" />
    </xsd:sequence>
    </xsd:complexType>
    </xsd:element>
    </xsd:schema>
    providerList variable is of type "providerList".
    What else do I need to do to convert the List to the xml elements ?

    Well I believe this is not officially mentioned anywhere, but this is the limitations for the java embedding activity. You can assign value to a single variable or to the single part element of variable only. I suggest you go with a java web service. you can check more details on java embedding activity @ http://docs.oracle.com/cd/E21764_01/integration.1111/e10224/bp_java.htm
    void setVariableData(String name, Object value)
    void setVariableData(String name, String part, Object value)
    void setVariableData(String name, String part, String query, Object value)

  • How can I refer to a value of the textfield1 into the textfield2 and set readonly textfield2, and join the value of various textfields in just one textfield multiline ?

    I am new in acroforms.
    I have a form with 5 pages, in the first page the user fill personal information, the fields are (names, addres, birtdate, ocupation,etc ) all are texboxes, I need to get the same value of every textboxes of the first page into the 2d and 3, 4 and 5 pages, I have created another textboxes in the 2, 3 .. pages with the same names in order to duplicate the value of each one, but if I make some of them readonly, every textboxes in every page are readonly...
    For that reaseon, I tried changin the name of the texboxes of the 2, 3, 4 and 5 pages to names1, names2, names3, names4, and so on for the other fields, I have written some scripts, but no lucky, because I used this line in every new textbox, as the following (for the textbox names1)
    this.getField("names").Value
    Without results, the textboxes apears in blank
    And also, in the last page I need to join some texboxes values in only one multiline textbox
    Please any advice will be welcome..
    Muchas gracias
    Rafsys

    For the information in the second text box to be the same as the first text box (i.e. - on later pages), simply give the fields the same name. The second on could be set to readonly and you could even remove the borders and such so it looked like it was just part of the page. This last trick would get around the need to combine the fields for the display as you mention. Combining the fields would have to be done with JavaScript.

  • Receiver SOAP Adapter Problem-soap fault: Server did not recognize the valu

    I have a scenario for service orders using async call : IDOC-XI-SOAP.
    I used the XML Spy tool to test the Service order's web services and it works fine. I imported the same WSDL file in XI. When I send a SOAP message from XI, I get a following error in the adapter engine.
    <i>MP: exception caught with cause com.sap.aii.af.ra.ms.api.RecoverableException: SOAP: response message contains an error XIAdapter/PARSING/ADAPTER.SOAP_EXCEPTION - soap fault: Server did not recognize the value of HTTP Header SOAPAction: AddUpdateCostObjectLevel1.</i>
    Can someone please help me...
    Thanks in advance!
    Mrudula

    This problem is resolved by me by passing the "http://company's URL/AddUpdateCostObjectLevel1" in the SOAP action.
    Thanks to all for your input.
    Mrudula

  • How to retreive String from the Connection object

    hi all,
    I am using HttpConnection to Connect to the server.I want to retreive string from the Connection.
    As like Connection.openInputStream() is there any method to get the String from the connection.In the server side also i want to send the String not the stream .
    Thanks in advance
    lakshman

    Just read the string from the stream.

  • Bug: setting ColumnChart type property breaks the chart object.

    PLease confirm if this Is this a bug or maybe ColumnChart
    type property is only applicable as MXML tag attribute?
    Description: Setting the
    type property of
    ColumnChart object other than "
    clustered" breaks the chart object. (i.e: series dissappear)
    Resetting to "clustered" wont restore the series.

    It breaks the chart when series have effects applied,
    otherwise it works fine.

  • How to get the value in a hashmap with a key of expression "123-456"?

    Hi all,
    I new to java and having a problem with getting values from a hashmap.here is the code which i wrote
    Map map = new HashMap();
    int m = 123;
    int n = 456;
    String key = String.valueOf(m) + "-" + String.valueOf(n);
        map.put(key, true);
        Now i am trying to get the value and i get an exception
    boolean b = map.get(String.valueOf(m) + "-" + String.valueOf(n));Can someone help me how to pass this expression as key in the hashamp

    Hi corlettk,
    Thanks for your reply. I have defined my map as Map<String, Boolean> selectedIds = new HashMap<String, Boolean>();
                selectedIds.put("123-456", true);           
                int m=123; int n=456;
                                     selectedIds.put(String.valueOf(m) + "-" + String.valueOf(n),true);
                boolean viv = selectedIds.get("String.valueOf(m)-String.valueOf(n)");
                System.out.println(viv);
                My problem is the hashmap key must be set dynamically ("123-456" is just an example) and when i get the value i should be able to pass those varibales in an expression correctly. Please let me know how can i pass an expression like the one above as a hashmap key. Please advise.

  • The values of a HashMap

    Hi,
    Why does the HashMap class enforce us to use a collection to get it's elements (HashMap.values() returns a Collection)? I want to wrap a Hashmap's elements into something that is serializable, is there anyway I can do this?

    iamBassas wrote:
    Sorry I don't understand your point very much. I already explained why I need an ArrayList, the reciever of the collection must be serializable because it's going to be sent through a socket, that is why I wrap the values in an ArrayList. Am I doing something wrong?You need a serializable collection. Therefore you need an ArrayList.
    Sorry, I don't understand that logic at all. In case you still don't see that it isn't logic, let me explain: there are many serializable collections. ArrayList is one of them. LinkedList is another. So why don't you need a LinkedList? It's quite likely that every collection in the java.util package is serializable, and it's quite likely that the one you're getting from the values() method is serializable too. So why bother copying the data from it into another collection?
    Of course if you find the values() method returns a collection which isn't serializable, then you would have to copy its contents into another one. But I wouldn't do that until I found it was necessary.

  • Fetch the value from a HashMap through EL

    Hi,
    I have this question,
    how can we get a value from a HashMap through EL. is there any way to do that.
    for example i have a hashmap in my bean and i want to place the value of of certain attributes on the page. specific to the key values in the hashmap.

    Just by the key.
    ${bean.map.key}roughly resolves to bean.getMap().get(key).

  • Problem using a vector of strings as patterns to search a text file

    Ideas? Goal is to use several patterns from one file to search for matches in a second file, one pattern at a time. I have added the file of patterns to a vector and created an iterator to grab each pattern successively. I also can effectively search for matches in the second file, but can't seem to find a way to combine them. I've tried nested while(s) in both orders without success.
    Thank you for any suggestions.

    It sounds to me like it should work. What does your search code look like?

  • Writing BOLD string to the PrintWriter object

    Hi,
    Following is my code:
    response.setContentType("application/vnd.ms-excel");
    PrintWriter pw = response.getWriter();
    String str = "Developer Forums";
    /* what manipulation is required to the string so that it can we converted to bold font..
    *.NO HTML tags are allowed.
    pw.print(str);

    Makrand.Ubale wrote:
    response.setContentType("application/vnd.ms-excel");Slow there! You can't simply write stuff to a Writer and hope that it's in the correct format for Excel.
    The problem is that Excel accepts some plain-text formats such as CSV as well and many then think that this approach produces a valid Excel file. It does not!
    Especially you can't have any kind of formatting (and I assume even equations) in a CSV file.

  • Problems with a PopUp to URL consisting 'The Value contained in the field'

    The Link text is the IP_ADDRESS of one of our Cameras.
    The only thing I want placed in the URL field of the browser is the IP_ADDRESS. (ie. 111.111.111.111)
    What I get is something like 'http://hostname:port/pls/apex/f?p=111.111.111.111'
    I've used popUps a lot, but I've never tried it for this purpose.
    Can someone offer some advice for me.
    Thanks- Gary

    Hi Gary,
    You need to ensure that you include the protocol in your call. Without this, the address you enter is seen as relative to the application.
    Use something like: javascript:popUp('http://#IP_ADDRESS#')
    Andy

  • How to get all the values from a HashMap? thanks

    hi
    can anyone tell me how to get all the keys and their values contained in a HashMap? thanks

    thanks to u all for ur response, i gues if i need to get both keys and values, i need to use keySet() to get a set of keys first and then using each key to get value. is there any other faster way to get both of them (key and value)? thanks again

Maybe you are looking for

  • Error configuring the Oracle 8.1.7 XA Thin driver with WLS 6.1 SP1

    I am trying to configure the Oracle 8.1.7.0 thin driver and am getting an SystemException when the pool tries to test the connection at server startup. It looks like the start() method is failing. I have put Oracle's Classes12.zip, jndi.zip, and the

  • Message monitoring of synchronous messages

    Guys, whenever I check a synchronous message in message monitoring, its audit log is correctly shown but the message (header and payload) are not shown, returning the message "The message was deleted to save memory" or something like that. Does anyon

  • Qosmio F10 - need recovery CD

    Hi guys, I lost my recovery CDs that came with my computer, and I'll really appreciate if somebody help me get one. Thanks in advance evalulo

  • Printer Driver CP1215 HP

    Please Help - I use both a PC and my new MacBook Pro - I wish to use both with an HP CP1215 colour laser printer - I can not find the driver? Is their one available? TY

  • Bootable backup and time machine/capsule

    Is it possible to create a bootable backup using time capsule?