Hashmap's empty

Hi dudes
I start at the beginning^^
I'm quite new in java and I have to write an application as a practice in java, which analyses txt files in a lot of zip files about their DayLightSaving handling (^^) . There are 4 types of txt files ... (ceva.txt / ice.txt / ...) and I have for each type a seperate button/method... I have a method which goes through all Zip Files and reads out the txt files and store them in a Vector of ZipEntries and returns it.
an other class (the GUI class) will get this information for editing... So if i want to reaccess these txt files I have to create a new stream for the zip files because the zipentries don't know from which file it comes^^ .
So for this I made a HashMap with the entries <ZipEntry, String (pathOfZipFile)>
this map will be filled when the application reads out the zip files at the first time. The hashmap fill in works ( saw it in debug mode ) but as soon as the process stops and the GUI will be visible again the Hashmap is lost.
Does anybody know why this happens or another/better way to do what I want to do?
I hope u can understand what I wrote^^

By the way, am I missing something with the pairs of carets (^^) all over the >place? Is this a new lingo the kids are using nowadays? :)I use this as an emoticon :) but you can ignore it anyway
I hope this part is useful , thank you for the quick response
     private HashMap<ZipEntry, String> hashmapEntryZip; //declaration of the Hashmap
     public AnalyserCore()
          mainZipDir = new File(AnalyserGUI.ZIP_DIR);
          zipFileList = mainZipDir.listFiles();          
          hashmapEntryZip = new HashMap<ZipEntry, String>();
        /** Method which reads out the zips and stores the txt's in the vector and hashmap*/
     public Vector<ZipEntry> analyzeData(String mode)
          //StringBuffer tempBuffer = new StringBuffer();     //AnalyseArea Output         // buffered buffer^^ for temporarly saving the data ...
          //StringBuffer textBuffer = new StringBuffer();     //temp File Output               //... and write it to this buffer
          Long dateBevor = Calendar.getInstance().getTimeInMillis(); //(start time) for time used statistics
          Vector<ZipEntry> fileArray = new Vector<ZipEntry>();
          ZipEntry entry ;
          fileTemporaryOutput = new File("ch/schann/analyse/" + mode + ".txt");
          try
               fileTemporaryOutput.createNewFile(); //Create the temporary File
               //FileWriter writer = new FileWriter(fileTemporaryOutput);               
               for ( int p = 0; p < zipFileList.length; p++ )
                    String str = new String();
                    str += "\n[ zip ] File: " + (p+1) + "(" + zipFileList[p].getName() + ") ...\n";
                    str += "-------------------------\n";
                    // File reading whithin the Zipfile
                    zipReading = new ZipInputStream(new FileInputStream(zipFileList[p]));
                    entry = zipReading.getNextEntry();
                    int fileIndex = 0;
                    while (entry != null)
                         String filePath = entry.getName();
                         int lastSlashPos = filePath.lastIndexOf("\\");
                         String fileName = filePath.substring(lastSlashPos + 1);
                         String meterReadout = fileName.substring(0, 2);
                         if (meterReadout.equalsIgnoreCase(mode))
                              fileIndex++;
                              fileArray.add(entry);
                              this.hashmapEntryZip.put(entry, zipFileList[p].getAbsolutePath());
                              str += "[ txt ]File " + fileIndex + ":" + filePath + "...\n";
                         entry = zipReading.getNextEntry();
                    str += "[* NO MORE ELEMENTS *]\n";
                    //writer.write(str);
                    //writer.flush();
                    System.out.println(str);
                    zipReading.close();
               Long dateAfter = Calendar.getInstance().getTimeInMillis();//(end time) for time used statistics
               System.out.println("Time Used: " + (dateAfter - dateBevor) + "ms");
          catch(Exception e)
               System.out.println("\n--------------\n" + e.getMessage());
               e.printStackTrace();
          /*catch(FileNotFoundException ex)
               System.out.println("[File Not Found:] " + ex.getMessage());
          catch ( IOException e)
               System.out.println("[IO -ERROR:] " + e.getMessage());
          return fileArray;
     }

Similar Messages

  • Getting xml serializer exception

    dont know what this mean, did anybody got this exception before.
    Searched on google but got few results only which were not helpful.
    Frustrated posting this here . if anybody has seen this and resolved this , give me tips on how to get this working or atleast what could be cause of this problem.
    java.lang.NullPointerException
    at org.apache.xml.serialize.OutputFormat.whichMethod(Unknown Source)
    at org.apache.xml.serialize.OutputFormat.<init>(Unknown Source)
    at com.tibco.portalservices.administrator.AbstractDOMDeploymentDescriptorEditor.update(AbstractDOMDeploymentDesc
    riptorEditor.java:125)
    at com.tibco.wfc.AbstractContainer.update(AbstractContainer.java:32)
    at com.tibco.wfc.AbstractContainer.update(AbstractContainer.java:32)
    at com.tibco.administrator.consoles.deploymentconfiguration.ServiceDetailPane.update(ServiceDetailPane.java:94)
    at com.tibco.wfc.AbstractContainer.update(AbstractContainer.java:32)
    at com.tibco.wfc.AbstractContainer.update(AbstractContainer.java:32)
    at com.tibco.wfc.AbstractFrame.update(AbstractFrame.java:101)
    at com.tibco.wfc.FramesetComponent.update(FramesetComponent.java:186)
    at com.tibco.wfc.AbstractContainer.update(AbstractContainer.java:32)
    at com.tibco.wfc.AbstractFrame.update(AbstractFrame.java:101)
    at com.tibco.wfc.FrameManager.a(FrameManager.java:235)
    at com.tibco.wfc.FrameManager.service(FrameManager.java:142)
    at com.tibco.administrator.AdministratorServlet.service(AdministratorServlet.java:843)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
    at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
    at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2416)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
    at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
    at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
    at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
    at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:577)
    at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
    at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
    at org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:1040)
    at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1151)
    at java.lang.Thread.run(Thread.java:595)

    There is no HashMap in your ArrayList. Take a look at this line:
    selectedDataList.add(searchList);I think a object f type SearchBean is added to the list here. This is no HashMap I presume.
    Please use code tags when posting code. This looks lke this:
    public String getSelectedItems() {
    // Get selected items.
    HashMap map = new HashMap();
    DeleteContentDialog deleteContentDialog = new DeleteContentDialog();
    selectedDataList = new ArrayList();
    for (SearchBean searchList : searchResultdetails) {
    System.out.println("Inside getSelectedItems.........Inside for"+searchList);
    if (searchList.isSelected()) {
    System.out.println("Inside getSelectedItems........searchList."+searchList);
    selectedDataList.add(searchList);
    searchList.setSelected(false); // Reset.
    try {
    for(int i=0;i<selectedDataList.size();i++){
    System.out.println("Inside the delete Method");
    System.out.println("selectedDataList is "+selectedDataList.get(i));
    if (selectedDataList.size() != 0)
    System.out.println("Array List is having = "selectedDataList.size()" records");
    //printValuesTest(medianList);
    System.out.println("**************THESE ARE THE VALUES OF THE HASHMAP AT THE INDEX = "+i);
    map = (HashMap)selectedDataList.get(i);
    if (map.size() != 0)
    Iterator iterator = map.keySet().iterator();
    while (iterator.hasNext())
    String key = (String) iterator.next();
    String value = (String) map.get(key);
    System.out.println("Key = "key " and Value = "+value);
    deleteContentDialog.init(map);
    else
    System.out.println("Hashmap is empty");
    catch(Exception e){
    e.printStackTrace();
    return "deletedFile"; // Navigation case.
    }

  • Get the data from servlet...

    Hello friends!
    I have one problem: On my LoginServlet I'm write users sessions in HashMap. How can I get the data from this HashMap in another servlet? I did this HashMap as public and tried to take this HashMap from another servlet, but the HashMap was empty.

    u might be knowing the things in web application can be shared using either request object, Httpsession or ServletContext.
    and the scope of all 3 is different.
    things shared using the request will b availble 4 that request.
    things shared using the session will b availble 4 all the requests in that Session.
    things shared using the request will b availble 4 all the servet or jsp in that web application.
    so u r problem will be solved by using the servletContext..
    code is
    ServletContext cnt.=confg.getServletContext();
    cnt.SetAttribute("map", h);
    cnt.getAttribute("map");

  • Content Adding/Updating/Deleting

    Does anyone have anyone have a portlet/code that can update/delete/add content in the repository that they are willing to share or know where I can buy it? We are trying to get away from letting users into the portal admin console for ease of use....

    k.. it looks like it works but I am having an issue with the createContent portlet.... I was able to fix the tag rewrite problem but when I submit the form the action form hashmap is empty.... Any ideas? Is this something that has changed from 9.2 - 10? If you want to see what I am talking about you can download the example from the above link and then import it into BEA and then it will convert it for you... once that is done all you need to to is change \WEB-INF\tags\rewriteName.tag to below and then try to create a content....
    &lt;%@ tag import="org.apache.beehive.netui.core.urls.URLRewriterService" %&gt;
    &lt;%@ tag import="org.apache.beehive.netui.pageflow.PageFlowUtils"%&gt;
    &lt;%@ tag import="java.util.Map, java.util.HashMap"%&gt;
    &lt;%@ attribute name="name" type="java.lang.String" required="true" %&gt;
    &lt;%
    // This tag willsurround the parameter with { } characters. This enables
    // a form element to be submitted to an action with a Map as the action's
    // parameter (serving as a form bean.) We use this because the netui
    // datasource attribute doesn't accept an expression as an argument. For
    // example we can't do:
    //     &lt;netui:hidden datasource="actionForm.Property_Name_${loopStatus.count}"&gt;
    // This tag allows use to use a standard input field and pass a name which
    // the page flow processor understands to be used for an actionForm.
    String paramName = "{" + name + "}";
    String rewrittenName = URLRewriterService.getNamePrefix(request.getSession().getServletContext(),request,paramName) + paramName;
    %&gt;&lt;%= rewrittenName%&gt;

  • Marshalling HashMap with JAXB 2.0 - empty tags & ill schema

    Hi all,
    I expected JAXB 2.0 to be capable to handle basic classes like HashMap, but it does not look so. I have two classes: SimpleNegotiationManager which has a property HashMap in which are stored the instances of SimpleInitiatedConversation:
    package xml;
    import javax.xml.bind.annotation.*;
    import java.util.HashMap;
    @XmlAccessorType(AccessType.FIELD)
    @XmlRootElement
    public class SimpleNegotiationManager {
        @XmlElement
        protected HashMap<String, SimpleInitiatedConversation> initiatedConversations;
        public SimpleNegotiationManager() {
        public HashMap<String, SimpleInitiatedConversation> getInitiatedConversations() {
            if (initiatedConversations == null) {
                initiatedConversations = new HashMap();
            return initiatedConversations;
        public void setInitiatedConversations(HashMap<String, SimpleInitiatedConversation> initiatedConversations) {
            this.initiatedConversations = initiatedConversations;
    }and
    package xml;
    import javax.xml.bind.annotation.*;
    import java.util.ArrayList;
    import java.util.List;
    @XmlAccessorType(AccessType.FIELD)
    @XmlType
    public class SimpleInitiatedConversation {
        @XmlElement
        protected List<String> messages;
        protected String conversationID;
        protected int protocolState;
        public SimpleInitiatedConversation() {
        public List<String> getMessages() {
            if (messages == null) {
                messages = new ArrayList();
            return messages;
        public void setMessages(List<String> messages) {
            this.messages = messages;
        public int getProtocolState() {
            return protocolState;
        public void setProtocolState(int protocolState) {
            this.protocolState = protocolState;
        public String getConversationID() {
            return conversationID;
        public void setConversationID(String conversationID) {
            this.conversationID = conversationID;
    }When I marshalled SimpleNegotiationManager while the HashMap was filled with several <String,SimpleInitiatedConversation> entries, in the output were empty tags initiatedConversations:
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <simpleNegotiationManager>
      <initiatedConversations>
      </initiatedConversations>
    </simpleNegotiationManager>When I used schemagen to generate a schema, it produced:
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <xs:schema version="1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema">
      <xs:complexType name="simpleInitiatedConversation">
        <xs:sequence>
          <xs:element name="messages" type="xs:string" maxOccurs="unbounded" minOccurs="0"/>
          <xs:element name="conversationID" type="xs:string" minOccurs="0"/>
          <xs:element name="protocolState" type="xs:int"/>
        </xs:sequence>
      </xs:complexType>
      <xs:element name="simpleNegotiationManager" type="simpleNegotiationManager"/>
      <xs:complexType name="simpleNegotiationManager">
        <xs:sequence>
          <xs:element name="initiatedConversations" type="hashMap" minOccurs="0"/>
        </xs:sequence>
      </xs:complexType>
      <xs:complexType name="hashMap">
        <xs:complexContent>
          <xs:extension base="abstractMap">
            <xs:sequence/>
          </xs:extension>
        </xs:complexContent>
      </xs:complexType>
      <xs:complexType name="abstractMap" abstract="true"/>
    </xs:schema>Particularly the description of HashMap seems ill - there is not specified that the HashMap has keys String and values SimpleInitiatedConversation.
    Unfortunatelly, the j2s-xmlAdapter-field example available with JAXB 2.0 is more complicated than I need. I just need to store/load HashMap into/from XML and I do not care what it looks like. Is it possible to avoid extending XmlJavaTypeAdaptor for a simple storing a HashMap into XML? Perhaps I use improper annotations in the source code, but I cannot get it working. Any clue?

    Ok i figured out one way of doing this by using some classes from JAXP...
    SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
    Schema s = null;
    try{
        s = sf.newSchema(new File("Sources/schema/test.xsd"));                    
    }catch(Exception e){
        System.err.println("Exception e: " + e.getMessage());
    marshaller.setSchema(s);
    //MyValidationHandler class implements the ValidationEventHandler interface
    MyValidationHandler gv = new MyValidationHandler();
    marshaller.setEventHandler(gv);If anyone has something to add let me know!!

  • Using HashMap's ContainsKey() in JSTL

    Can we use HashMap's containsKey() in JSTL <c:if > statement
    I tried with the sample
    <html:select property="Type" multiple = "true" size = "3">
    <option value='<c:out value="${key}"/>'
    <c:if test="${requestScope.test.containsKey(key)}">
    selected
    </c:if>     
    <c:out value="${value}"/></option>
    </html:select >
    When i executed the above code i encountered JSP Error
    Can any one please let me know the correct code

    You can't call java methods from JSTL. It uses the EL - not java.
    However there is a solution.
    You access maps using the square brackets [ ] notation.
    ie ${test[key]}
    is the same as test.get(key)
    try
    <c:if test="${ not empty test[key] }"/>
    However seeing as you are using the struts tags, doesn't that automatically take care of this for you? Why don't you use the struts tags for the options list as well as the select? Just a thought :-)
    Cheers,
    evnafets

  • Returning a HashMap K, M from a method of a class typed M

    So, this is what I have. I have a class parameterized for a bean type of a collection it receives, and in a method of the class, I need (would like) to return a HashMap typed as <K, M> as in:
    public class MyClass<M> {
       private Collection<M> beanList;
       public HashMap<K, M> getMap(  /* what do I do here */ );
    }I tried to cheat from looking at the Collections.sort method, knowing it uses the List type in its return type as in:
    public static <T extends Comparable<? super T>> void sort(List<T> list)So, I am trying:
    public HashMap<K, M> getMap(Class<K> keyType)But, it is telling me I need to create class K.
    So... how does the Collections.sort method get away with it and I can't????
    I suppose I could write the method as:
    public HashMap<Object, M> getMap()but became somewhat challenged by my first guess.
    Any ideas... or just go with the HashMap with the untyped key?

    ejp wrote:
    provided K is inferable from the arguments.Or from the assignment context:
    Set<String> empty = Collections.emptySet();
    Otherwise you have to parameterise the class on <K, M>.You may also specifically provide K when you use the method if the context doesn't give the compiler enough information or if you want to override it.
    Example:
    Set<Object> singleton1 = Collections.singleton("Hello"); //error
    Set<Object> singleton2 = Collections.<Object>singleton("Hello"); //fineEdited by: endasil on 14-May-2010 4:13 PM

  • Nulls from HashMap.get(Object)

    I understand that I get the nulls because the Object is not in the map. But is there some elegant way to have it default to the empty String?
    Right now, after I grab all my data into variable with HashMap.get(Object), I go and check each once for null, and assign it the empty String instead. This is a lot of lines of code for something that is so basic.
    I know i could initialize them all to the empty string, and then for each variable, check the HashMap with containsKey(Object) before assigning with HashMap.get(Object). Now, would I be correct in assuming the compiler would optimize this for me and not actually check the HashMap twice for the same Object? And... even if that is the case, its still just as many lines of code.
    Is there perhaps some more elegant way?
    String exchange = parameterMap.get("exchange");
    String messageType = parameterMap.get("messagetype");
    String traderTimeStamp = parameterMap.get("traderTimeStamp");
    String exchangeTimeStamp = parameterMap.get("exchangeTimeStamp");
    String sequence = parameterMap.get("sequence");
    String product = parameterMap.get("product");
    String quantity = parameterMap.get("quantity");
    String price = parameterMap.get("price");
    if (exchange == null)
    exchange = "";
    if (messageType == null)
    messageType = "";
    if (traderTimeStamp == null)
    traderTimeStamp = "";
    if (exchangeTimeStamp == null)
    exchangeTimeStamp = "";
    if (sequence == null)
    sequence = "";
    if (product == null)
    product = "";
    if (quantity == null)
    quantity = "";
    if (price == null)
    price = "";

    You could first put "" for all potential keys.
    Or you could create a helper method
    public String nonNull(String s) {
      return (s != null) ? s : "";
    String exchange = nonNull(parameterMap.get("exchange"));

  • Hashmap problem

    Hi I am getting only last value from hashmap
    codes are below.
    Then I used iterator and getting
    Required string is null or empty
    jsp code
    <bean efine id="a" name="b" property="c"/>
    <bean efine id="e" name="b" property="d"/>
    <%
    java.util.HashMap params = new java.util.HashMap();
    params.put("a",a);
    params.put("b",e);
    session.setAttribute("paramsName", params);
    %>
    action classs code
    Map paramsName = new HashMap();
    paramsName=(HashMap)session.getAttribute("paramsName");
    if (paramsName!=null)
    { Iterator pIter = paramsName.keySet().iterator();
    while(pIter.hasNext()){
    a=(String)pIter.next();}

    How about the following:
    create a class with instance variables of ints to be your counters:
    public int inserts = 0;
    public int updates = 0;
    public int deletes = 0;name the class something... Tally maybe.
    Might be nice to put in methods to increment each like so:
    public void incrementInserts() {
          inserts ++;
    }and so on for the other instance variables.
    then you create one of these and increment its values appropriately, then put it in the hash.
    Code would look something like this:
    Map myMap = new HashMap();
    while ( logfileIterator.hasNext()) {
         String tableName = null;
         boolean lineIsDelete;
         boolean lineIsInsert;
         boolean lineIsUpdate;
          /* put your code here to analyze the line to find out what the table name is,
              whether it's a delete, insert or update, and set above vars accordingly */
          Tally myTally = null;
          if (myMap.containsKey(tableName)) {
                       /* code for second and subsequent times you see this table name*/
                     myTally = (Tally) myMap.get(tableName);
          } else {
                     /* code for first time you see this table name */
                     myTally = new Tally();
                     myMap.put (tableName, myTally);
          if (lineIsDelete) myTally.incrementDeletes();
          /* or if you didn't write that method you could just use [u]myTally.deletes++;[/u] */
          if (lineIsInsert) myTally.incrementInserts();
          if (lineIsUpdate) myTally.incrementUpdates();
    }

  • Checking an object in Arraylist against empty string

    Hi all,
    Im storing a collection of objects in Arraylist.Among them , one of the objects has an empty string.How can i check whether an object contains empty string.I tried to check using the follwing snippet:
    ArrayList idList=new ArrayList();
    if((idList.get(0)) == null || idList.get(0) == "")
            Debug.log("*****ARRAY LIST IS BLANK 1********");Please help

    Here is a bit more deeper code:
    HashMap lookupMap= null;
    try {
              Object obj = util.lookUp(pid,attributeId,params); // The lookUp method returns an object.
                 Debug.log(11, " obj type: " + obj.getClass().getName());
            lookupMap = (HashMap) obj;
    Collection mapkeys = lookupMap.keySet();
    Iterator itKeySet = mapkeys.iterator();
    ArrayList idList = new ArrayList();
    ArrayList descList = new ArrayList();
    ArrayList lookupKeys = new ArrayList();
    while(itKeySet.hasNext())
            lookupKeys.add(itKeySet.next());
    for(int i=0; i<lookupKeys.size(); i++)
            String key = (String)lookupKeys.get(i);
        if(key != null && key.startsWith("1_"))
              idList =(ArrayList)lookupMap.get(lookupKeys.get(i));
            if(key != null && key.startsWith("2_"))
              descList=(ArrayList)lookupMap.get(lookupKeys.get(i));
            if(key != null && key.startsWith("1_") && (size == 1))
               descList=(ArrayList)lookupMap.get(lookupKeys.get(i));
    ArrayList id1=new ArrayList();
    int x=0;
          do
         if(!(idList.get(x)).equals(null) || !(idList.get(x)).equals(""))
                    id1.add(idList.get(x));
                    Debug.log("*****idList.get(x)********"+idList.get(x));
                    Debug.log("*****added to idlist.get(0)********");
                    break;
                  else
                    x++;
         }while(id1.size() == 0);

  • EntryProcessor invokeAll returning empty ConverterMap{}

    Hi All,
    I am trying to write a custom entryprocessor and whatever I return from the invokeAll method in the entryprocessor, I am always getting a empty ConverterMap{}. The code for the entryprocessor is as below:
    public class CustomEP implements PortableObject, EntryProcessor {
         public CustomEP (){
    public Map processAll(Set entries) {
              Map results=new HashMap ();
    results.put ("1", "1");
    System.out.println("Inside process All method");
              return results;
    public Object process(Entry arg0) {
              Map results=new HashMap ();
    results.put ("1", "1");
    System.out.println("Inside process method");
              return results;
    The client code to invoke this entryprocessor is as below:
    Map results=cache.invokeAll(AlwaysFilter.INSTANCE, new CustomEP());
    The processAll method on the Coherence nodes is invoked but if the print the results on the client side it return empty ConverterMap{}
    On the other hand, if I invoke process method of CustomEP as below:
    Map results=(Map) cache.invoke(AlwaysFilter.INSTANCE, new CustomEP());
    I get the desired results. Please help me with the details why it is happening this way when the return type of the processAll is a Map.
    Thanks a lot!
    Regards,
    S

    911767 wrote:
    Hi Robert and JK,
    Thank you for your reply and time!
    I could not find these details in any of the documentation that specifies keys passed in the result should be subset of the keys passed to the processAll method. Anyways, my problem is to invoke server-side code (avoid de-serialization) by passing a filter and then create a entirely new map (key and value will be different from the entries extracted from the passed filter) by reading the data from the passed entries. How can I implement it?
    I am thinking to use aggregator as they are read-only and faster but again how to implement it using:
    public Object aggregate(Set entries){
    Again, I am getting an empty Map so is it necessary that the object returned should have keys matching the set of the entries passed to this method.
    Secondly, there are other methods such as, finalizeResult() and init() if I extend AbstractAggregator, do I need to implement them and if yes, how? The entries set passed to the aggregate() method may not reside on the same node.
    Please advise!
    Regards,
    SHi S,
    the process() return value object, or the entry value objects in the map returned by processAll() can be arbitrary objects. So you just return a map from process(), and return a map as the entry value in the result map from processAll().
    The AbstractAggregator has a fairly badly documented contract in the Javadoc (does not properly cover the values received in different scenarios for invocation). You should probably read the section about it in the Coherence book, that explains leveraging AbstractAggregator in significantly more details. It also happens to be in the sample chapter, but I recommend reading the entire book.
    I am not sure about the issues relating to posting links to PDFs on Packt's webpage, so I won't do that. Please go to Packt's webpage (http://www.packtpub.com ), look for the Coherence book there and download the sample chapter (or order the book).
    In short, all 3 to-be-implemented methods (init(), process(), finalizeResult()) in AbstractAggregator are called both on the server and on the caller side. You can distinguish which side you are on from looking at both the passed in fFinal boolean parameter and the m_fParallel attribute tof the aggregator instance.
    There are 3 cases:
    - non-parallel aggregation processing extracted values (m_fParallel is false, I don't remember what fFinal is in this case),
    - parallel aggregation storage side processing extracted values (if I correctly remember, m_fParallel is true, fFinal is false),
    - parallel aggregation caller side processing parallel results (m_fParallel and fFinal are both true).
    Depending on which side you are on, the process method takes different object types (on server side it receievs the extracted value, on caller side it receives a parallel result object instance).
    You SHOULD NOT override any of the other methods (e.g. aggregate() which you mentioned).
    The advantage of this approach is that the AbstractAggregator subclass instance can pass itself off as a parallel-aggregator instance.
    You should put together a temporary result in a member attribute of the AbstractAggregator subclass, which also means that it will likely not be thread-safe, but at the moment it is not necessary for it to be thread-safe either as it is called only on a single-thread.
    Best regards,
    Robert
    Edited by: robvarga on Feb 3, 2012 10:38 AM

  • Merging 2 Hashmaps into 1

    What is the easyiest way to merge 2 Hashmaps into 1?
    So Say h1, h2 and hashmaps with data in, h3 is a empty hashmap that i want to contain all the values of h1 and h2.
    Only way I know how is to loop through each Hashmap and add the value pairs to the new hashmap.
    Is there a way to do this much easyier like
        h3 += h1;
        h3 += h2;or some method ?
        h3.add(h1);
        h3.add(h2);TIA, Dale

    Sorry maybe I didn't make it clear, i was quessing what the method to do what i wanted was.
    I'll try putAll, sounds like what im after.

  • Hashmap in Hashmap as Key?

    Can anybofy let me know, what could be the possible disastrous outcome of keeping Hashmap in Hashmap as Key?
    Could it lead to inconsistent behaviour?
    If its not a good idea to use Hashmap as key in a Hashmap what other data structure we can use for the same?
    Thanks,
    Amit G.

    Hello Amit,
    I have a question - "Will the contents of the HashMap, which is the key to your second HashMap, change over a period of time.".
    See sample below -
    import java.util.HashMap;
    import java.util.Map;
    public class Foo {
         private Map<Map, String> mainMP = new HashMap<Map, String>();
         private Map<String, String> one = new HashMap<String, String>();
         public static void main(String[] args) {
              Foo f = new Foo();
         Foo() {
              mainMP.put(one, "SomeStr");
              String str = mainMP.get(one);
              System.out.println("First Time : " + str);
              one.put("hello", "where");
              str = mainMP.get(one);
              System.out.println("Second Time : " + str);
    }When you run the program the result will be -
    First Time : SomeStr
    Second Time : null
    The reason is that the hashCode for a Map object depends on its contents. So Map one will have a different hashCode when it is empty and another one when it has the String "hello". So if you add or remove any object from within a Map, the hashCode will change.
    Having a HashMap as a key (which changes over time) to another HashMap is a sure recipe for disaster.
    If you could tell the scenarion where you are using it, maybe I could suggest a different data structure.

  • ArrayList clears when placed in HashMap

    I have a series of ArrayLists (argValues), to be used as the values in a HashMap. They are not empty when they are placed in the table, but when I try to get one of them out, the ArrayList that is returned is empty. Here is the part of my code that has the problem. I'm parsing an XML file beforehand (doc_cmd is the Document into which the XML was parsed):
               NodeList nl_cmd = doc_cmd.getElementsByTagName("RFSW_CMD_PKT");
               if (doc_cmd != null) {
                   for(int i = 0; i < nl_cmd.getLength(); i++) {
                        if (!nl_cmd.item(i).getNodeName().equals("#text")) {
                            String key = nl_cmd.item(i).getAttributes().getNamedItem("NAME").getNodeValue();
                            //   System.out.println(key);
                            Element currentCmd = (Element) nl_cmd.item(i);
                            NodeList nlChildren = currentCmd.getChildNodes();
                            ArrayList argValues = new ArrayList();
                            for (int j = 0; j<nlChildren.getLength(); j++) {
                                if (!nlChildren.item(j).getNodeName().equals("#text")) {
                                    nodeName = nlChildren.item(j).getNodeName();
                                    if (!nodeName.equals("BITFIELD") && !nodeName.equals("UNION"))
                                        argName = nlChildren.item(j).getAttributes().getNamedItem("NAME").getNodeValue();
                                    else
                                        argName = "";
                                    value = nodeName + "_" + argName;
                                    argValues.add(value);
                            // THIS IS WHERE THE PROBLEM IS
                            System.out.println("ARGVALUES SIZE = " + argValues.size());
                            hashcmds.put(key, argValues);
                            argValues.clear();
                            ArrayList yo = (ArrayList)hashcmds.get(key);
                            System.out.println("SIZE = " + yo.size());

    Note that you're calling the clear method on the
    object you've inserted, not a copy of it. You should
    clone() itIn this case I there is no point in cloning the ArrayList because it goes out of scope. He isn't resuing it and there was never a reason to clear it anyway. The solution is to just not clear the ArrayList.
    If one were attempting to reuse it in that manner, cloning an ArrayList and clearing it to use again is less efficient than just creating a new one and letting the old one go out of scope.
    The steps required to fill clone and reuse.
    1. create new ArrayList
    2. copy references
    3. clear entries
    4. insert n refereneces
    The steps required to just create new
    1. create new ArrayList
    2. insert n references
    By clearing the ArrayList here, you are just doing more work.

  • UISelectMany - Conversion error with HashMap Property

    Hi,
    I have a Backing Bean with a HashMap Property.
    public HashMap getItem()
    public void setItem(HashMap map)
    so I bind a Value of an UIInputText Component like that:
    <h:inputText id="txtname" value="#{MyBean.item['myKey']}" />
    this works pretty well.
    But when I try to do the same with an <h:selectManyCheckbox> Component I got a "Conversion Error".
    For what reason? I expected an Array or List Object.
    Thanks for help
    Ralph

    I solved the problem by creating a custom converter, which checks if the current valueBinding is null.
    If so, it replace the valueBinding with an empty ArrayList().
    public class MultiValueConverter implements Converter {
         public final static String CONVERTER_ID = "org.imixs.workflow.j2ee.faces.MultiValueConverter";
         public Object getAsObject(FacesContext context, UIComponent component, String value) throws ConverterException {
    // no changes
    return value;
         public String getAsString(FacesContext context, UIComponent component, Object value) throws ConverterException {
    // Check if current value Binding is bind to an null-Object
    javax.faces.el.ValueBinding valueBinding=component.getValueBinding("value");
    if (valueBinding!=null && valueBinding.getValue(context)==null) {
    // replace binding with empty ArrayList
    valueBinding.setValue(context,new ArrayList());
    // no changes
    return value.toString();
    you can find the full code under www.imixs.org (an open source project for a EJB based workflow engine)

Maybe you are looking for

  • Using Bind Variable in a procedure

    Hello all, Aim - I wanted to set the value of a bind variable in a procedure I was unsuccessful in doing so, pls help me (pls let me know if u need more info). I have pasted the commands I executed in a SQL SQL> VARIABLE x NUMBER; SQL> EXEC :x := 5;

  • Is it possible to give each page within one pdf document a specific set of print settings?

    I have a complex document (catalogue) that requires printing. There are several different printer settings required and each one is specific to each page within the document. For instance pg 1 is single sided in colour, page 2-3 is duplexed in b&w, p

  • Canon EOS Movie Plugin Inop

    Canon EOS Movie plug in for Final Cut Pro is inoperative. The log and transfer window inadvertently got changed so just the screen viewer shows. I can not see the thumb views of the clips or the queue window The arrows that usually allow adjusting of

  • How to obtain row number when a new row is created (without commit)?

    I have this: <NamedData NDName="LineaNro" NDValue="#{bindings.VOIpmDistribucionManualEBS1.currentRowIndex}" NDType="oracle.jbo.domain.Number"/> When I push the New button, the value shows -1. If I push again, the value shows 0... but for third time a

  • How to display icon files in mac

    In JLabel how to add icon files with ext .ico from MAC OSX