Example usage for java.util List iterator

List of usage examples for java.util List iterator

Introduction

In this page you can find the example usage for java.util List iterator.

Prototype

Iterator<E> iterator();

Source Link

Document

Returns an iterator over the elements in this list in proper sequence.

Usage

From source file:edu.isi.karma.util.FileUtil.java

static public File downloadFileFromHTTPRequest(HttpServletRequest request, String destinationDirString) {
    // Download the file to the upload file folder

    File destinationDir = new File(destinationDirString);
    logger.debug("File upload destination directory: " + destinationDir.getAbsolutePath());

    DiskFileItemFactory fileItemFactory = new DiskFileItemFactory();

    // Set the size threshold, above which content will be stored on disk.
    fileItemFactory.setSizeThreshold(1 * 1024 * 1024); //1 MB

    //Set the temporary directory to store the uploaded files of size above threshold.
    fileItemFactory.setRepository(destinationDir);

    ServletFileUpload uploadHandler = new ServletFileUpload(fileItemFactory);

    File uploadedFile = null;/*from   w w w  . j  a  v  a  2s . c o m*/
    try {
        // Parse the request
        @SuppressWarnings("rawtypes")
        List items = uploadHandler.parseRequest(request);
        @SuppressWarnings("rawtypes")
        Iterator itr = items.iterator();
        while (itr.hasNext()) {
            FileItem item = (FileItem) itr.next();

            // Ignore Form Fields.
            if (item.isFormField()) {
                // Do nothing
            } else {
                //Handle Uploaded files. Write file to the ultimate location.
                uploadedFile = new File(destinationDir, item.getName());
                if (item instanceof DiskFileItem) {
                    DiskFileItem t = (DiskFileItem) item;
                    if (!t.getStoreLocation().renameTo(uploadedFile))
                        item.write(uploadedFile);
                } else
                    item.write(uploadedFile);
            }
        }
    } catch (FileUploadException ex) {
        logger.error("Error encountered while parsing the request", ex);
    } catch (Exception ex) {
        logger.error("Error encountered while uploading file", ex);
    }
    return uploadedFile;
}

From source file:lucee.runtime.img.Metadata.java

private static void set(List<? extends IImageMetadataItem> items, Struct data1, Struct data2) {
    Iterator<? extends IImageMetadataItem> it = items.iterator();
    Item item;/*w ww  .  j a  v  a2s.  c  o m*/
    while (it.hasNext()) {
        item = (Item) it.next();

        data1.setEL(item.getKeyword(), StringUtil.unwrap(item.getText()));
        if (data2 != null)
            data2.setEL(item.getKeyword(), StringUtil.unwrap(item.getText()));
    }
}

From source file:com.googlecode.starflow.engine.xml.NodeUtil.java

/**
 * ??//from  w  w  w  .  ja  v  a  2 s  . co  m
 */
@SuppressWarnings("rawtypes")
public static List<Participant> getActParticipants(Element actEl) {
    List<Participant> participants = new LinkedList<Participant>();
    List list = actEl.selectNodes(StarFlowNames.ACT_CHILD_PARTICIPANT);
    Iterator iter = list.iterator();
    while (iter.hasNext()) {
        Element el = (Element) iter.next();
        Participant p = new Participant();
        p.setParticipant(el.attributeValue(StarFlowNames.ACT_CHILD_PARTICIPANT_ID));
        p.setParticipant2(el.attributeValue(StarFlowNames.ACT_CHILD_PARTICIPANT_NAME));
        p.setParticType(el.attributeValue(StarFlowNames.ACT_CHILD_PARTICIPANT_TYPE));
        participants.add(p);
    }
    return participants;
}

From source file:com.krawler.spring.crm.emailMarketing.crmEmailMarketingHandler.java

public static JSONObject getcampEmailMarketingStatusJson(List ll, int totalSize) {
    JSONObject jobj = new JSONObject();
    JSONArray jarr = new JSONArray();
    boolean isExists = false;
    try {//from w w w  .j  a  v  a  2s  .c  om
        Iterator ite = ll.iterator();
        int firstlist = totalSize;
        for (int cnt = 0; cnt < firstlist; cnt++) {
            Object row[] = (Object[]) ite.next();
            String obj = (String) row[0];
            String obj2 = (String) row[1];
            Long obj3 = Long.parseLong(row[2].toString());
            Long obj4 = Long.parseLong(row[3].toString());
            String marketingId = (String) row[4];
            Long usercount = Long.parseLong(row[5].toString());
            JSONObject tmpObj = new JSONObject();
            tmpObj.put("marketingid", marketingId);
            tmpObj.put("marketingname", obj);
            tmpObj.put("campaignname", obj2);
            tmpObj.put("viewed", obj3);
            tmpObj.put("sentmail", obj4);
            tmpObj.put("usercount", usercount);
            jarr.put(tmpObj);
        }

        while (ite.hasNext()) {
            Object row[] = (Object[]) ite.next();
            String obj = (String) row[0];
            String obj2 = (String) row[1];
            Long obj3 = Long.parseLong(row[2].toString());
            Long obj4 = Long.parseLong(row[3].toString());
            String marketingId = (String) row[4];
            Long usercount = Long.parseLong(row[5].toString());

            isExists = isAlreadyExists(jarr, marketingId);
            if (!isExists) {
                JSONObject tmpObj = new JSONObject();
                tmpObj.put("marketingid", marketingId);
                tmpObj.put("marketingname", obj);
                tmpObj.put("campaignname", obj2);
                tmpObj.put("viewed", obj3);
                tmpObj.put("sentmail", obj4);
                tmpObj.put("usercount", usercount);
                jarr.put(tmpObj);
            }
        }
        jobj.put("success", true);
        jobj.put("data", jarr);
        jobj.put("campaignReport", true);
        jobj.put("totalCount", totalSize);
    } catch (ServiceException e) {
        logger.warn(e.getMessage(), e);
    } catch (JSONException e) {
        logger.warn(e.getMessage(), e);
    }
    return jobj;
}

From source file:com.projity.server.data.mspdi.ModifiedMSPDIReader.java

public static void readAssignmentBaselinesAndTimephased(Assignment projityAssignment, List timePhasedList) {
    Iterator i = timePhasedList.iterator();
    TimephasedService service = TimephasedService.getInstance();

    boolean isPodServer = !Environment.isNoPodServer();
    if (isPodServer) {
        while (i.hasNext()) {
            service.readTimephased(projityAssignment, (TimephasedDataType) i.next());
        }//ww w  . ja v  a 2 s .co m
    } else {
        // JGao - 9/16/2009 Added logic to combine all time phased data on the same day
        // This way, the contour on pod is set correctly without worring about the calendar differences
        TimephasedDataTypeImpl tempData = null;
        while (i.hasNext()) {
            TimephasedDataType currentData = (TimephasedDataType) i.next();
            if (tempData == null) {
                tempData = new TimephasedDataTypeImpl();
                CloneTimephasedData(currentData, tempData);
                if (i.hasNext())
                    continue;

            } else {
                boolean dataCombined = CombineTimephasedDataIfOnSameDay(tempData, currentData);
                if (dataCombined && i.hasNext())
                    continue;
            }

            service.readTimephased(projityAssignment, tempData);

            tempData = null;
            tempData = new TimephasedDataTypeImpl();
            CloneTimephasedData(currentData, tempData);
            if (!i.hasNext()) {
                service.readTimephased(projityAssignment, tempData);
            }
        }
    }
    projityAssignment.makeFlatIfPossible(); // don't use a contour if it's
    // really flat
}

From source file:it.eng.spagobi.engines.worksheet.bo.WorkSheetDefinition.java

public static void addDomainValuesFilters(List<Attribute> toReturn, List<Attribute> sheetFilters) {
    Iterator<Attribute> it = sheetFilters.iterator();
    while (it.hasNext()) {
        Attribute aFilter = it.next();
        if (toReturn.contains(aFilter)) {
            int index = toReturn.indexOf(aFilter);
            Attribute previousFilter = toReturn.get(index);
            List<String> previousValues = previousFilter.getValuesAsList();
            List<String> newValues = aFilter.getValuesAsList();
            List<String> sum = ListUtils.sum(previousValues, newValues);
            previousFilter.setValues(sum);
        } else {/*from w w  w.  j a v  a2s  .c  om*/
            Attribute clone = aFilter.clone();
            toReturn.add(clone);
        }
    }
}

From source file:com.mycompany.asyncreq.Main.java

public static void ObjToCsv(Root tRoot, String reg) throws IOException {
    List<Tdataset> arForms = tRoot.dataset;
    List<ArrayList<String>> tradeDatas = new ArrayList<ArrayList<String>>();

    int count = 0;
    for (Iterator<Tdataset> j = arForms.iterator(); j.hasNext();) {

        Tdataset tmp = j.next();//ww  w .  ja  v a 2s  .  c  om
        DateFormat format = new SimpleDateFormat("yyyyMM");
        try {
            Date date = format.parse(tmp.getperiod());
            Ttradedata trade = new Ttradedata(tmp.getrtCode(), tmp.getptCode(), tmp.getrgCode(),
                    tmp.getqtCode(), tmp.getestCode(), date, tmp.getTradeQuantity(), tmp.getNetWeight(),
                    tmp.getTradeValue(), tmp.getcmdCode());

            tradeDatas.add(trade.setString());
            if (tradeDatas.size() % 10000 == 0) {
                writeToCSV(tradeDatas,
                        "data/" + tRoot.dataset.get(0).getptCode() + "_" + count + "_" + reg + ".csv");
                count++;
                tradeDatas.clear();
            }
        } catch (Exception e) {
            System.out.println(e.toString());
        }
    }

    writeToCSV(tradeDatas, "data/" + tRoot.dataset.get(0).getptCode() + "_" + reg + ".csv");
    tradeDatas.clear();
    System.out.println("ok!");

}

From source file:com.liangc.hq.base.service.permissions.BaseSessionInitializationStrategy.java

protected static Map<String, Boolean> loadUserPermissions(Integer sessionId, AuthzBoss authzBoss)
        throws SessionTimeoutException, SessionNotFoundException, PermissionException {
    // look up the user's permissions
    Map<String, Boolean> userOperationsMap = new HashMap<String, Boolean>();
    List<Operation> userOperations = authzBoss.getAllOperations(sessionId);

    for (Iterator<Operation> it = userOperations.iterator(); it.hasNext();) {
        Operation operation = it.next();

        userOperationsMap.put(operation.getName(), Boolean.TRUE);
    }//from  w  w w  .  j a v  a 2  s  . co  m

    return userOperationsMap;
}

From source file:at.newsagg.parser.Atom_0_3_Parser.java

private static String getValue(Element elt) {
    if (elt == null)
        return "";
    String typeElt = elt.getAttributeValue("type");
    String modeElt = elt.getAttributeValue("mode");
    String value;/* w  ww .ja  v a 2 s .c  om*/
    String unescapedValue = elt.getTextTrim();

    if (unescapedValue == null || unescapedValue.length() == 0) {
        // maybe value in a div ?
        java.util.List listContent = elt.getContent();
        Iterator iter = listContent.iterator();
        while (iter.hasNext()) {
            org.jdom.Content content = (org.jdom.Content) iter.next();
            logger.debug("getValue : element read = " + content);
            if (content instanceof Element) {
                unescapedValue = ((Element) content).getValue();
                logger.debug("elt found in type :" + unescapedValue);
            }
        }
    }
    value = unescapedValue;
    if ("base64".equals(modeElt)) {
        value = ParserUtils.decodeBase64(value);
    }
    if ("text/html".equals(typeElt) || "application/xhtml+xml".equals(typeElt)) {
        value = ParserUtils.unEscape(value);
    }

    return value;
}

From source file:net.bitnine.agensgraph.graph.property.JsonArray.java

public static JsonArray create(List<?> list) {
    JsonArray array = JsonArray.create();
    if (list == null || list.isEmpty())
        return array;

    Iterator<?> iter = list.iterator();
    while (iter.hasNext()) {
        Object value = iter.next();

        if (value == null)
            array.addNull();/*from   w ww  .jav  a  2  s  .c  o m*/
        else if (isJsonValue(value))
            array.add(value);
        else
            throw new IllegalArgumentException("invalid json value type: " + value.getClass());
    }

    return array;
}