Resultset (getter/setter class) object not deleting old values at 2nd Time execution in swin

Posted by user2384525 on Stack Overflow See other posts from Stack Overflow or by user2384525
Published on 2013-06-28T10:19:39Z Indexed on 2013/06/28 10:21 UTC
Read the original article Hit count: 227

Filed under:
|
|

I have summarizeData() method and called so many time for value retrieve. but first time is working file but 2nd time execution value is increasing in HashMap.

    void summarizeData() {

    HashMap outerMap = new HashMap();

    ArrayList list = new ArrayList(dataClass.getData());


    for (int indx = 0; indx < list.size(); indx++) {
        System.out.println("indx : " + indx);
        Resultset rs = new Resultset();
        rs = (Resultset) list.get(indx);


        if (rs != null) {

            int id = rs.getTestCaseNumber();
            if (id > 0) {
                Object isExists = outerMap.get(id);

                if (isExists != null) {
                    //System.out.println("found entry so updating");
                    Resultset inRs = new Resultset();
                    inRs = (Resultset) isExists;

                    if (inRs != null) {
                        int totExec = inRs.getTestExecution();
                        int totPass = inRs.getTestCasePass();
                        int totFail = inRs.getTestCaseFail();

                        //     System.out.println("totE :" + totExec + "  totP:" + totPass + "  totF:" + totFail);

                        int newRsStat = rs.getTestCasePass();

                        if (newRsStat == 1) {
                            totPass++;
                            inRs.setTestCasePass(totPass);
                        } else {
                            totFail++;
                            inRs.setTestCaseFail(totFail);
                        }
                        totExec++;

                        //      System.out.println("id : "+id+"  totPass: "+totPass+"  totFail:"+totFail);
                        //       System.out.println("key : " + id + "  val : " + inRs.getTestCaseNumber() + " " + inRs.getTestCasePass() + "  " + inRs.getTestCaseFail());

                        inRs.setTestExecution(totExec);
                        outerMap.put(id, inRs);
                    }

                } else {

                    //    System.out.println("not exist so new entry" + " totE:" + rs.getTestExecution() + "  totP:" + rs.getTestCasePass() + "  totF:" + rs.getTestCaseFail());
                    outerMap.put(id, rs);
                }
            }
        } else {
            System.out.println("rs null");
        }


    }

Output at 1st Execution: indx : 0 indx : 1 indx : 2 indx : 3 indx : 4 indx : 5 indx : 6 indx : 7 indx : 8 indx : 9 indx : 10 totE :1 totP:1 totF:0 indx : 11 totE :1 totP:1 totF:0 indx : 12 totE :1 totP:1 totF:0 indx : 13 totE :1 totP:1 totF:0 indx : 14 totE :1 totP:1 totF:0 indx : 15 totE :1 totP:1 totF:0 indx : 16 totE :1 totP:1 totF:0 indx : 17 totE :1 totP:1 totF:0 indx : 18 totE :1 totP:1 totF:0 indx : 19 totE :1 totP:1 totF:0

Output at 2nd Execution: indx : 0 indx : 1 indx : 2 indx : 3 indx : 4 indx : 5 indx : 6 indx : 7 indx : 8 indx : 9 indx : 10 totE :2 totP:2 totF:0 indx : 11 totE :2 totP:2 totF:0 indx : 12 totE :2 totP:2 totF:0 indx : 13 totE :2 totP:2 totF:0 indx : 14 totE :2 totP:2 totF:0 indx : 15 totE :2 totP:2 totF:0 indx : 16 totE :2 totP:2 totF:0 indx : 17 totE :2 totP:2 totF:0 indx : 18 totE :2 totP:2 totF:0 indx : 19 totE :2 totP:2 totF:0

while i required same output on every execution.

© Stack Overflow or respective owner

Related posts about java

Related posts about swing