Example usage for java.util HashMap size

List of usage examples for java.util HashMap size

Introduction

In this page you can find the example usage for java.util HashMap size.

Prototype

int size

To view the source code for java.util HashMap size.

Click Source Link

Document

The number of key-value mappings contained in this map.

Usage

From source file:ffx.algorithms.mc.RosenbluthChiAllMove.java

public RosenbluthChiAllMove(MolecularAssembly mola, Residue target, int testSetSize, ForceFieldEnergy ffe,
        double temperature, boolean writeSnapshots, int moveNumber, boolean verbose) {
    if (System.getProperty("cbmc-type") != null) {
        mode = MODE.valueOf(System.getProperty("cbmc-type"));
    } else {//from   w w w.  j  ava2s  .  c om
        logger.severe("CBMC: must specify a bias type.");
        mode = MODE.CHEAP;
    }
    this.startTime = System.nanoTime();
    this.mola = mola;
    this.target = target;
    this.testSetSize = testSetSize;
    this.ffe = ffe;
    this.beta = 1 / (BOLTZMANN * temperature);
    this.moveNumber = moveNumber;
    this.verbose = verbose;
    origState = target.storeState();
    if (writeSnapshots) {
        snapshotWriter = new SnapshotWriter(mola, false);
    }
    doChi[0] = System.getProperty("cbmc-doChi0") != null ? true : false;
    doChi[1] = System.getProperty("cbmc-doChi1") != null ? true : false;
    doChi[2] = System.getProperty("cbmc-doChi2") != null ? true : false;
    doChi[3] = System.getProperty("cbmc-doChi3") != null ? true : false;
    if (!doChi[0] && !doChi[1] && !doChi[2] && !doChi[3]) {
        doChi[0] = true;
        doChi[1] = true;
        doChi[2] = true;
        doChi[3] = true;
    }
    updateAll();
    origEnergy = totalEnergy();
    if (torsionSampling) {
        logger.info(" Torsion Sampler engaged!");
        HashMap<Integer, BackBondedList> map = createBackBondedMap(AminoAcid3.valueOf(target.getName()));
        List<Torsion> allTors = new ArrayList<>();
        for (int i = 0; i < map.size(); i++) {
            Torsion tors = map.get(i).torsion;
            allTors.add(tors);
        }
        torsionSampler(allTors);
        System.exit(0);
    }
    try {
        switch (mode) {
        case EXPENSIVE:
            engage_expensive();
            break;
        case CHEAP:
            engage_cheap();
            break;
        case CHEAPINDIV:
            logger.severe("CBMC: this bias type is not yet supported.");
            engage_cheap();
            break;
        case CHEAPDIFFS:
            logger.severe("CBMC: this bias type is not yet supported.");
            engage_diffs();
            break;
        case CONTROL:
            logger.severe("CBMC: Use CTRL_ALL validation instead.");
            engage_control();
            break;
        case CTRL_ALL:
            engage_controlAll();
            break;
        default:
            logger.severe("CBMC: Unknown biasing type requested.");
            break;
        }
    } catch (ArithmeticException ex) {
        target.revertState(origState);
        accepted = false;
        return;
    }
}

From source file:com.happyuno.controller.StartGame.java

/**
 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
 *//* w  ww .  jav a  2  s  .  c  om*/
protected void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    // TODO Auto-generated method stub
    response.setContentType("text/html;charset=utf-8");
    request.setCharacterEncoding("utf-8");

    //?tableId
    String tableId = (String) request.getParameter("tableId");

    System.out.println(tableId);
    //?userId
    String userId = (String) request.getSession().getAttribute("userId");

    //
    ServletContext application = request.getSession().getServletContext();
    HashMap<Integer, GameTable> gameTableMap = (HashMap<Integer, GameTable>) application
            .getAttribute("gameTableMap");

    String resultMessage = "??";

    //User??Player
    ArrayList<Player> players = new ArrayList<Player>();

    int tindex = Integer.parseInt(tableId);
    GameTable gt = gameTableMap.get(tindex);
    ArrayList<User> userList = gt.getUserList();

    resultMessage = "??";
    //????
    gt.setStateStart(true);
    System.out.println(userList.size() + "changdu");
    for (int i = 0; i < userList.size(); i++) {
        //Playerid,nameUser?
        System.out.println(i + "position");
        String curUserId = ((User) userList.get(i)).getId();
        System.out.println("UserId" + curUserId);
        int cUserId = Integer.parseInt(curUserId);
        String curUserName = ((User) userList.get(i)).getName();
        Player curPlayer = new Player(cUserId, curUserName);
        players.add(curPlayer);
    }
    gt.getCurrentGame().initGame(players);

    HttpSession session = request.getSession();
    session.setAttribute("tableId", tindex);
    session.setAttribute("players", players);
    session.setAttribute("curPlayerId", Integer.parseInt(userId));

    //
    application.setAttribute("gameTableMap", gameTableMap);

    //tableMap?
    application.setAttribute("tatoNum", gameTableMap.size());

    RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/table.jsp");
    dispatcher.forward(request, response);

}

From source file:de.adorsys.forge.gwt.GWTPlugin.java

private void generateWidget(JavaResource resouce, String sufix, String javaTemplate, String uiTemplate,
        final PipeOut out) {
    try {//from  w w w  .j  a v a  2 s .c  o  m
        JavaSource<?> javaSource = resouce.getJavaSource();
        if (javaSource instanceof JavaClass) {
            ResourceFacet resources = project.getFacet(ResourceFacet.class);
            JavaSourceFacet java = project.getFacet(JavaSourceFacet.class);
            GWTFacet gwtFacet = project.getFacet(GWTFacet.class);

            VelocityContext velocityContext = gwtFacet.createVelocityContext(null);

            HashMap<String, String> msgCollector = new HashMap<String, String>();
            velocityContext.put("msgCollector", msgCollector);
            velocityContext.put("javaSource", javaSource);

            StringWriter stringWriter;
            if (uiTemplate != null) {
                stringWriter = new StringWriter();
                velocityEngine.mergeTemplate(uiTemplate, "UTF-8", velocityContext, stringWriter);
                String fqViewName = java.getBasePackage().concat(".widgets.").concat(javaSource.getName())
                        .concat(sufix).concat("Widget");
                resources.createResource(stringWriter.toString().toCharArray(),
                        fqViewName.replace('.', '/') + ".ui.xml");
            }

            if (javaTemplate != null) {
                stringWriter = new StringWriter();
                velocityEngine.mergeTemplate(javaTemplate, "UTF-8", velocityContext, stringWriter);
                JavaType<?> serviceClass = JavaParser.parse(JavaType.class, stringWriter.toString());
                java.saveJavaSource(serviceClass);
            }

            if (!msgCollector.isEmpty()) {
                ShellMessages.info(out,
                        String.format("Collecting %s new messages from UI template", msgCollector.size()));
                gwtFacet.addMessages(msgCollector);
            }
        }
    } catch (FileNotFoundException e) {
        ShellMessages.error(out, "Bean source not found!" + e);
    }
}

From source file:jp.co.opentone.bsol.linkbinder.service.correspon.impl.CorresponWorkflowServiceImpl.java

/**
 * Checker/Approver????./*from  ww  w .  j  a va2 s.c  o  m*/
 * @param workflows 
 * @throws ServiceAbortException ????
 */
private void checkDuplicatedUser(List<Workflow> workflows) throws ServiceAbortException {
    // List?
    HashMap<String, String> workflowHash = new HashMap<>();
    for (Workflow w : workflows) {
        if (!(workflowHash.size() == 0)) {
            if (workflowHash.containsKey(w.getUser().getEmpNo())) {
                if (WorkflowType.CHECKER.equals(w.getWorkflowType())) {
                    throw new ServiceAbortException(ApplicationMessageCode.DUPLICATED_CHECKER,
                            (Object) w.getUser().getEmpNo());
                } else {
                    throw new ServiceAbortException(ApplicationMessageCode.DUPLICATED_CHECKER_APPROVER,
                            (Object) w.getUser().getEmpNo());
                }
            }
        }
        workflowHash.put(w.getUser().getEmpNo(), String.valueOf(w.getWorkflowType()));
    }
}

From source file:gsn.webservice.standard.GSNWebServiceSkeleton.java

private void gcStaleSessions() {
    ServiceContext serviceContext = MessageContext.getCurrentMessageContext().getServiceContext();
    HashMap<String, QuerySession> sessions = (HashMap<String, QuerySession>) serviceContext
            .getProperty(SESSIONS);/*ww  w.  j ava 2 s  .c om*/
    // Gc Stale sessions
    Integer reqNb = (Integer) serviceContext.getProperty(REQ_NB);
    reqNb++;
    serviceContext.setProperty(REQ_NB, reqNb);
    Long currentTime = System.currentTimeMillis();
    //
    if (reqNb % INTERVAL_BETWEEN_STALE_SESION_GC == 0) {
        Iterator<Map.Entry<String, QuerySession>> iter = sessions.entrySet().iterator();
        while (iter.hasNext()) {
            Map.Entry<String, QuerySession> entry = iter.next();
            if (entry.getValue().lastAccessTime + MAX_IDLE_TIME < currentTime)
                iter.remove();
        }
        serviceContext.setProperty(SESSIONS, sessions);
        logger.debug("Nb Of req: " + reqNb + " Nb of sessions: " + sessions.size());
    }
}

From source file:com.rovemonteux.silvertunnel.netlib.layer.tor.directory.Directory.java

/**
 * Get Map with all Routers which are valid and not excluded by Config and matches the given flags.
 * @return a Map with valid routers//from   w w  w .j ava  2s.  c  om
 */
public Map<Fingerprint, Router> getValidRoutersByFlags(final RouterFlags flags) {
    HashMap<Fingerprint, Router> result = new HashMap<Fingerprint, Router>(validRoutersByFingerprint);
    Iterator<Entry<Fingerprint, Router>> itRouter = result.entrySet().iterator();
    while (itRouter.hasNext()) {
        Router router = itRouter.next().getValue();
        if (!TorConfig.isCountryAllowed(router.getCountryCode())) {
            itRouter.remove();
        } else {
            if (!router.getRouterFlags().match(flags)) {
                itRouter.remove();
            }
        }
    }
    LOG.debug("routers found for given flags (" + flags.toString() + ") {}", result.size());
    return result;
}

From source file:communicator.doMove.java

/**
 * Processes requests for both HTTP <code>GET</code> and <code>POST</code>
 * methods./*w ww . ja v a2 s.  c  om*/
 *
 * @param request servlet request
 * @param response servlet response
 * @throws ServletException if a servlet-specific error occurs
 * @throws IOException if an I/O error occurs
 */
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    response.setContentType("text/html;charset=UTF-8");

    PrintWriter out = null;
    JSONObject outputObject = new JSONObject();
    try {

        HashMap<String, String> bigItemIds = new HashMap<>();
        Iterator mIterator = bigItemIds.keySet().iterator();
        out = response.getWriter();
        // Create a factory for disk-based file items
        DiskFileItemFactory factory = new DiskFileItemFactory();

        // Configure a repository (to ensure a secure temp location is used)
        ServletContext servletContext = this.getServletConfig().getServletContext();
        File repository = (File) servletContext.getAttribute("javax.servlet.context.tempdir");
        factory.setRepository(repository);

        // Create a new file upload handler
        ServletFileUpload upload = new ServletFileUpload(factory);
        // Parse the request
        List<FileItem> items = upload.parseRequest(request);

        final String moveId = UUID.randomUUID().toString();
        final MovesDb movesDb = new MovesDb();
        // Process the uploaded items
        Iterator<FileItem> iter = items.iterator();
        while (iter.hasNext()) {
            FileItem item = iter.next();

            if (item.isFormField()) {

                System.out.println("Form field" + item.getString());

                bigItemIds = processFormField(new JSONObject(item.getString()), out, moveId, movesDb);
                mIterator = bigItemIds.keySet().iterator();
                System.out.println("ITEM ID SIZE " + bigItemIds.size());

            } else {
                //processUploadedFile(item);
                System.out.print("Photo Field");
                String key = (String) mIterator.next();
                File mFile = new File(bigItemIds.get(key));
                item.write(mFile);

            }
        }
        new Thread() {

            public void run() {
                pushMovetoMailQueue moveToMailQueue = new pushMovetoMailQueue();
                moveToMailQueue.pushMoveToMailQueue(movesDb);
            }
        }.start();
        outputObject = new JSONObject();
        try {
            outputObject.put(Constants.JSON_STATUS, Constants.JSON_SUCCESS);
            outputObject.put(Constants.JSON_MSG, Constants.JSON_GET_QUOTE);
        } catch (JSONException ex1) {
            Logger.getLogger(doSignUp.class.getName()).log(Level.SEVERE, null, ex1);
        }

        out.println(outputObject.toString());

    } catch (Exception ex) {

        outputObject = new JSONObject();
        try {
            outputObject.put(Constants.JSON_STATUS, Constants.JSON_FAILURE);
            outputObject.put(Constants.JSON_MSG, Constants.JSON_EXCEPTION);
        } catch (JSONException ex1) {
            Logger.getLogger(doSignUp.class.getName()).log(Level.SEVERE, null, ex1);
        }

        out.println(outputObject.toString());
        Logger.getLogger(doSignUp.class.getName()).log(Level.SEVERE, null, ex);
    } finally {
        out.close();
    }
}

From source file:edu.ku.brc.web.ParsePaleo.java

/**
 * //from   w  w  w .  j av a 2 s.c o m
 */
private void process() {

    Pattern p = Pattern.compile("\"([^\"]*)\"");

    try {
        pw = new PrintWriter("filedownload.sh");

        Connection conn = dbConn.getConnection();

        createStrats();
        createAges();

        String pStr = "INSERT INTO data (citation, georange, paleodist, remarks, taxonId) VALUES(?,?,?,?,?)";
        PreparedStatement pStmt = dbS3Conn.prepareStatement(pStr, Statement.RETURN_GENERATED_KEYS);

        String pStrStrat = "INSERT INTO data_strat (dataId, stratId, formation) VALUES(?,?,?)";
        PreparedStatement pStmtStrat = dbS3Conn.prepareStatement(pStrStrat);

        String pStrAges = "INSERT INTO data_ages (dataId, stratId) VALUES(?,?)";
        PreparedStatement pStmtAges = dbS3Conn.prepareStatement(pStrAges);

        String pStrAttach = "INSERT INTO attach (imgname, url, caption, type) VALUES(?,?,?,?)";
        PreparedStatement pStmtAttach = dbS3Conn.prepareStatement(pStrAttach);

        String pStrTaxonAttach = "INSERT INTO taxon_attach (taxonId, attachId) VALUES(?,?)";
        PreparedStatement pStmtTaxonAttach = dbS3Conn.prepareStatement(pStrTaxonAttach);

        Statement stmt = conn.createStatement();
        Statement stmt2 = conn.createStatement();

        HashMap<String, String> values = new HashMap<String, String>();
        String sql = "SELECT p.ID FROM wp_xuub_posts p where p.post_type LIKE '%_page'";
        Vector<Integer> ids = BasicSQLUtils.queryForInts(sql);
        for (int recId : ids) {
            values.clear();
            sql = String.format(
                    "SELECT pm.meta_key, pm.meta_value FROM wp_xuub_posts p INNER JOIN wp_xuub_postmeta pm ON p.ID = pm.post_id WHERE ID = %d AND (NOT (pm.meta_key LIKE '\\_%c'))",
                    recId, '%');
            Vector<Object[]> data = BasicSQLUtils.query(sql);
            for (Object[] row : data) {
                if (row[1] != null) {
                    values.put(row[0].toString(), row[1].toString());
                }
            }

            System.out.println(values);
            if (values.size() == 0) {
                System.out.println(sql);
                continue;
            }

            String phylum = values.get("phylum");
            String clazz = values.get("class");
            String family = values.get("family");
            String genus = values.get("genus");
            String species = values.get("species");
            String[] names = { phylum, clazz, family, genus, species };
            int len = 0;
            while (len < names.length && names[len] != null) {
                len++;
            }
            TreeNode node = getTreeNode(rootNode, names, 0, len);
            if (node == null) {
                node = getTreeNode(rootNode, names, 0, len);
                throw new RuntimeException("Could find tree node" + names);
            }

            int i = 1;
            pStmt.setString(i++, getStrValue(values, "cite", recId));
            pStmt.setString(i++, getStrValue(values, "geo_range", recId));
            pStmt.setString(i++, getStrValue(values, "paleo_dist", recId));
            pStmt.setString(i++, getStrValue(values, "remarks", recId));
            pStmt.setInt(i++, node.recId);

            if (pStmt.executeUpdate() == 0) {
                System.err.println("Error inserting record.");
            }

            Integer dataId = BasicSQLUtils.getInsertedId(pStmt);

            String agesStr = values.get("ages");
            if (isNotEmpty(agesStr)) {
                Matcher m = p.matcher(agesStr);

                while (m.find()) {
                    String age = replace(m.group(), "\"", "");
                    Integer stratId = ages.get(age);
                    if (stratId == null) {
                        System.out.println(String.format("[%s][%s]", m.group(), age));
                        stratId = 0;
                    }

                    pStmtAges.setInt(1, dataId);
                    pStmtAges.setInt(2, stratId);
                    if (pStmtAges.executeUpdate() == 0) {
                        System.err.println("Error inserting record.");
                    }
                }
            }

            int index = 0;
            for (String stratKey : stratKeys) {
                String stratStr = values.get(stratKey);
                if (isNotEmpty(stratStr) && index > 0) {
                    Matcher m = p.matcher(stratStr);
                    while (m.find()) {
                        String strat = replace(m.group(), "\"", "");
                        pStmtStrat.setInt(1, dataId);
                        pStmtStrat.setInt(2, index);
                        pStmtStrat.setString(3, strat);
                        if (pStmtStrat.executeUpdate() == 0) {
                            System.err.println("Error inserting record.");
                        }
                    }
                }
                index++;
            }

            sql = String.format(
                    "SELECT p.ID, post_title, p.post_name, p.post_type, pm.meta_value FROM wp_xuub_posts p "
                            + "INNER JOIN wp_xuub_postmeta pm ON p.ID = pm.post_id "
                            + "WHERE post_parent = %d AND post_type = 'attachment' AND NOT (pm.meta_value LIKE 'a:%c')",
                    recId, '%', '%');
            System.out.println(sql);
            ResultSet rsId = stmt2.executeQuery(sql);
            while (rsId.next()) {
                int pId = rsId.getInt(1);
                String title = rsId.getString(2);
                if (title.contains("2000px"))
                    continue;

                sql = "SELECT p.ID, p.post_title, pm.meta_value, p.guid FROM wp_xuub_posts p INNER JOIN wp_xuub_postmeta pm ON p.ID = pm.post_id WHERE pm.meta_key = '_wp_attached_file' AND p.ID = "
                        + pId;
                ResultSet rs = stmt.executeQuery(sql);
                while (rs.next()) {
                    String fileName = rs.getString(3);
                    String url = rs.getString(4);

                    if (fileName.contains("Early") || fileName.contains("Middle")
                            || fileName.contains("Late")) {
                        continue;
                    }

                    String path = "/Users/rods/Documents/XCodeProjects/DigitalAtlasAcientLife/DigitalAtlasAcientLife/Resources/images/"
                            + fileName;
                    File file = new File(path);
                    if (!file.exists()) {
                        pw.println(String.format("curl %s > %s", url, fileName));
                    }

                    //String captKey = String.format("%s_%dc", nm, j);
                    //String captVal = values.get(captKey);

                    pStmtAttach.setString(1, fileName);
                    pStmtAttach.setString(2, url);
                    pStmtAttach.setString(3, "");
                    pStmtAttach.setInt(4, 0); // Type

                    if (pStmtAttach.executeUpdate() == 0) {
                        System.err.println("Error inserting record.");
                    }

                    Integer attachId = BasicSQLUtils.getInsertedId(pStmtAttach);
                    if (attachId == null) {
                        throw new RuntimeException("Error saving attachment record.");
                    }

                    pStmtTaxonAttach.setInt(1, node.recId);
                    pStmtTaxonAttach.setInt(2, attachId);
                    if (pStmtTaxonAttach.executeUpdate() == 0) {
                        System.err.println("Error inserting record.");
                    }
                }
                rs.close();
            }
            rsId.close();

            /*
            for (int k=0;k<1;k++)
            {
            String nm = k == 0 ? "photo" : "map";
            for (int j=1;j<9;j++)
            {
                String key = String.format("%s_%dd", nm, j);
                String val = values.get(key);
                if (isNotEmpty(val))
                {
                    System.out.println(String.format("%d [%s][%s]", recId, val, key));
                            
                    sql = "SELECT p.ID, p.post_title, pm.meta_value, p.guid FROM wp_xuub_posts p INNER JOIN wp_xuub_postmeta pm ON p.ID = pm.post_id WHERE pm.meta_key = '_wp_attached_file' AND p.ID = " + val;
                    ResultSet rs   = stmt.executeQuery(sql);
                    while (rs.next())
                    {
                        //int    pId      = rs.getInt(1);
                        //String title    = rs.getString(2);
                        String fileName = rs.getString(3);
                        String url      = rs.getString(4);
                                
                        pw.println(String.format("curl %s > %s", url, fileName));
                                
                        String captKey = String.format("%s_%dc", nm, j);
                        String captVal = values.get(captKey);
                                
                        pStmtAttach.setString(1, fileName);
                        pStmtAttach.setString(2, url);
                        pStmtAttach.setString(3, k == 0 ? captVal : "");
                        pStmtAttach.setInt(4, k); // Type
                                
                        if (pStmtAttach.executeUpdate() == 0)
                        {
                            System.err.println("Error inserting record.");
                        }
                                
                        Integer attachId = BasicSQLUtils.getInsertedId(pStmtAttach);
                        if (attachId == null)
                        {
                            throw new RuntimeException("Error saving attachment record.");
                        }
                                
                        pStmtTaxonAttach.setInt(1, node.recId);
                        pStmtTaxonAttach.setInt(2, attachId);
                        if (pStmtTaxonAttach.executeUpdate() == 0)
                        {
                            System.err.println("Error inserting record.");
                        }
                    }
                }
            }
            }*/

            // a:5:{s:5:"width";i:3300;s:6:"height";i:2550;s:4:"file";s:38:"Polygona_maxwelli_EarlyPleistocene.jpg";s:5:"sizes";
            //  a:2:{s:9:"thumbnail";
            //   a:4:{s:4:"file";s:46:"Polygona_maxwelli_EarlyPleistocene-250x250.jpg";s:5:"width";i:250;s:6:"height";i:250;s:9:"mime-type";s:10:"image/jpeg";}
            // s:6:"medium";a:4:{s:4:"file";s:48:"Polygona_maxwelli_EarlyPleistocene-2000x1545.jpg";s:5:"width";i:2000;s:6:"height";i:1545;s:9:"mime-type";s:10:"image/jpeg";}}
            //s:10:"image_meta";a:10:{s:8:"aperture";i:0;s:6:"credit";s:0:"";s:6:"camera";s:0:"";s:7:"caption";s:0:"";s:17:"created_timestamp";i:0;s:9:"copyright";s:0:"";s:12:"focal_length";i:0;s:3:"iso";i:0;s:13:"shutter_speed";i:0;s:5:"title";s:0:"";}}
            //                sql = "SELECT p.ID, p.post_title, pm.meta_value, p.guid FROM wp_xuub_posts p " +
            //                     "INNER JOIN wp_xuub_postmeta pm ON p.ID = pm.post_id WHERE pm.meta_key = '_wp_attached_file' AND p.ID = " + recId;
            //                ResultSet rs   = stmt.executeQuery(sql);
            //                while (rs.next())
            //                {
            //                    int    pId      = rs.getInt(1);
            //                    String title    = rs.getString(2);
            //                    String fileName = rs.getString(3);
            //                    String url      = rs.getString(4);
            //                }

        }
        dbS3Conn.commit();

        //recurseForAttachments(pStmtTaxonAttach, rootNode);

        stmt.close();
        stmt2.close();
        pStmt.close();
        pStmtStrat.close();
        pStmtAges.close();
        pStmtAttach.close();
        pStmtTaxonAttach.close();
        stmt.close();

        dbS3Conn.commit();

        pw.close();

        System.out.println("Done");

    } catch (Exception ex) {
        ex.printStackTrace();
    }
}

From source file:com.yahoo.ycsb.workloads.MailAppCassandraWorkload.java

public void doTransactionPop(DB db) throws WorkloadException {
    printDebug("------------POP Read Transaction-------------");
    //choose a random key
    int keynum = nextKeynum();

    String keynameInbox = buildKeyName(keynum, inboxSuffix);

    HashSet<String> fields = null;

    HashSet<String> counterColumnNames = new HashSet<String>();
    counterColumnNames.add(messagecountfieldkey);
    counterColumnNames.add(mailboxsizefieldkey);

    HashMap<String, ByteIterator> counterResult = new HashMap<String, ByteIterator>();
    HashMap<String, ByteIterator> uidlResult = new HashMap<String, ByteIterator>();
    HashMap<String, ByteIterator> result = new HashMap<String, ByteIterator>();

    HashSet<String> retrievedMessageIDList = new HashSet<String>();

    long st = System.nanoTime();

    //read counter Table (POP3 STAT Command)
    db.read(incrementTag + countertable, keynameInbox, counterColumnNames, counterResult);
    int statCount = Integer.valueOf(counterResult.get(messagecountfieldkey).toString());

    if (statCount <= 0) {

        long en = System.nanoTime();
        printDebug("POP Read: Inbox empty, closing...");
        Measurements.getMeasurements().measure("POP-Transaction", (int) ((en - st) / 1000));
        return;/*w ww  .j av  a 2  s  . co m*/
    }
    //get UIDL/List-List
    printDebug("POP Read: reading uidl-List");
    db.read(sizetable, keynameInbox, fields, uidlResult);
    //Retr x Messages
    printDebug("POP Read: setting up retrieve count generator...");
    int retrieveCount = getMessageRetrieveCountGenerator(1, uidlResult.size()).nextInt();
    Iterator<Entry<String, ByteIterator>> uidlResultIterator = uidlResult.entrySet().iterator();
    printDebug("POP Read: reading " + retrieveCount + " messages. #messages in Inbox: " + uidlResult.size());
    for (int i = 0; i < retrieveCount; i++) {

        //request one message by key and single column name
        String columnName = uidlResultIterator.next().getKey();
        printDebug("POP Read: requesting column with name: " + columnName);
        HashSet<String> requestColumn = new HashSet<String>();
        requestColumn.add(columnName);
        db.read(mailboxtable, keynameInbox, requestColumn, result);
        printDebug("POP Read: retrieved: " + columnName + " row: " + keynameInbox + " result #columns: "
                + result.size());
        retrievedMessageIDList.add(columnName);
    }

    //---

    long en = System.nanoTime();
    Measurements.getMeasurements().measure("POP-Transaction", (int) ((en - st) / 1000));

}

From source file:com.ipc.service.UploadDocumentService.java

public void saveFile(HashMap<String, List<MultipartFile>> fileList, String root_path, UpLoadDocVo upv,
        HttpServletRequest request) throws IOException {
    System.out.println();/*from  ww  w .  j a va2s.co m*/
    String date = ss.getToday(1);

    upv.setResident_registration("resident_registration" + date + "."
            + CreateFileUtils.getFileType(fileList.get("resident_registration").get(0).getOriginalFilename()));
    upv.setCertificate("certificate" + date + "."
            + CreateFileUtils.getFileType(fileList.get("certificate").get(0).getOriginalFilename()));
    upv.setBusiness_license("business_license" + date + "."
            + CreateFileUtils.getFileType(fileList.get("business_license").get(0).getOriginalFilename()));

    CreateFileUtils createFileObj = new CreateFileUtils();
    createFileObj.CreateFile(fileList.get("resident_registration").get(0), request,
            "resources/uploadimgs/uploadDocument/", "resident_registration" + date + "." + CreateFileUtils
                    .getFileType(fileList.get("resident_registration").get(0).getOriginalFilename()));
    createFileObj.CreateFile(fileList.get("certificate").get(0), request,
            "resources/uploadimgs/uploadDocument/", "certificate" + date + "."
                    + CreateFileUtils.getFileType(fileList.get("certificate").get(0).getOriginalFilename()));
    createFileObj.CreateFile(fileList.get("business_license").get(0), request,
            "resources/uploadimgs/uploadDocument/", "business_license" + date + "." + CreateFileUtils
                    .getFileType(fileList.get("business_license").get(0).getOriginalFilename()));

    if (fileList.size() == 4) {
        upv.setSmallsale("smallsale" + date + "."
                + CreateFileUtils.getFileType(fileList.get("smallsale").get(0).getOriginalFilename()));
        createFileObj.CreateFile(fileList.get("smallsale").get(0), request,
                "resources/uploadimgs/uploadDocument/", "smallsale" + date + "."
                        + CreateFileUtils.getFileType(fileList.get("smallsale").get(0).getOriginalFilename()));
    }
    saveDocToDb(upv);
    changeIsComplete(upv.getRid());
}