Example usage for java.util List listIterator

List of usage examples for java.util List listIterator

Introduction

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

Prototype

ListIterator<E> listIterator();

Source Link

Document

Returns a list iterator over the elements in this list (in proper sequence).

Usage

From source file:com.amazonaws.hbase.connector.HBaseEmitter.java

@Override
public List<Map<String, String>> emit(final UnmodifiableBuffer<Map<String, String>> buffer) throws IOException {
    List<Map<String, String>> records = buffer.getRecords();
    ListIterator<Map<String, String>> iterator = records.listIterator();
    List<Put> batch = new ArrayList<Put>();
    HashMap<String, String> hashMap = (HashMap<String, String>) iterator.next();
    while (iterator.hasNext()) {
        //start with the row key followed by column family
        batch.add(new Put(Bytes.toBytes(hashMap.get("username"))).add(Bytes.toBytes("user"),
                Bytes.toBytes("userid"), Bytes.toBytes(hashMap.get("userid"))));
        batch.add(new Put(Bytes.toBytes(hashMap.get("username"))).add(Bytes.toBytes("user"),
                Bytes.toBytes("firstname"), Bytes.toBytes(hashMap.get("firstname"))));
        batch.add(new Put(Bytes.toBytes(hashMap.get("username"))).add(Bytes.toBytes("user"),
                Bytes.toBytes("lastname"), Bytes.toBytes(hashMap.get("lastname"))));
        batch.add(new Put(Bytes.toBytes(hashMap.get("username"))).add(Bytes.toBytes("address"),
                Bytes.toBytes("city"), Bytes.toBytes(hashMap.get("city"))));
        batch.add(new Put(Bytes.toBytes(hashMap.get("username"))).add(Bytes.toBytes("address"),
                Bytes.toBytes("state"), Bytes.toBytes(hashMap.get("state"))));
        batch.add(new Put(Bytes.toBytes(hashMap.get("username"))).add(Bytes.toBytes("contact"),
                Bytes.toBytes("email"), Bytes.toBytes(hashMap.get("email"))));
        batch.add(new Put(Bytes.toBytes(hashMap.get("username"))).add(Bytes.toBytes("contact"),
                Bytes.toBytes("phone"), Bytes.toBytes(hashMap.get("phone"))));
        batch.add(new Put(Bytes.toBytes(hashMap.get("username"))).add(Bytes.toBytes("likes"),
                Bytes.toBytes("likesports"), Bytes.toBytes(hashMap.get("likesports"))));
        batch.add(new Put(Bytes.toBytes(hashMap.get("username"))).add(Bytes.toBytes("likes"),
                Bytes.toBytes("liketheatre"), Bytes.toBytes(hashMap.get("liketheatre"))));
        batch.add(new Put(Bytes.toBytes(hashMap.get("username"))).add(Bytes.toBytes("likes"),
                Bytes.toBytes("likeconcerts"), Bytes.toBytes(hashMap.get("likeconcerts"))));
        batch.add(new Put(Bytes.toBytes(hashMap.get("username"))).add(Bytes.toBytes("likes"),
                Bytes.toBytes("likejazz"), Bytes.toBytes(hashMap.get("likejazz"))));
        batch.add(new Put(Bytes.toBytes(hashMap.get("username"))).add(Bytes.toBytes("likes"),
                Bytes.toBytes("likeclassical"), Bytes.toBytes(hashMap.get("likeclassical"))));
        batch.add(new Put(Bytes.toBytes(hashMap.get("username"))).add(Bytes.toBytes("likes"),
                Bytes.toBytes("likeopera"), Bytes.toBytes(hashMap.get("likeopera"))));
        batch.add(new Put(Bytes.toBytes(hashMap.get("username"))).add(Bytes.toBytes("likes"),
                Bytes.toBytes("likerock"), Bytes.toBytes(hashMap.get("likerock"))));
        batch.add(new Put(Bytes.toBytes(hashMap.get("username"))).add(Bytes.toBytes("likes"),
                Bytes.toBytes("likevegas"), Bytes.toBytes(hashMap.get("likevegas"))));
        batch.add(new Put(Bytes.toBytes(hashMap.get("username"))).add(Bytes.toBytes("likes"),
                Bytes.toBytes("likebroadway"), Bytes.toBytes(hashMap.get("likebroadway"))));
        batch.add(new Put(Bytes.toBytes(hashMap.get("username"))).add(Bytes.toBytes("likes"),
                Bytes.toBytes("likemusicals"), Bytes.toBytes(hashMap.get("likemusicals"))));

        hashMap = (HashMap<String, String>) iterator.next();
    }/*  w ww .ja v  a 2  s.  c o m*/
    LOG.info("EMIT: " + "records ....." + batch.size());
    HBaseUtils.addRecords(hbaseTableName, emrPublicDns, hbaseRestPort, batch);
    return Collections.emptyList();
    //return records;
}

From source file:gov.nih.nci.ncicb.cadsr.common.jsp.tag.handler.AltQuestionText.java

private Question getQuestionFromList(String questionIdSeq, List questions) {
    ListIterator iterate = questions.listIterator();

    while (iterate.hasNext()) {
        Question question = (Question) iterate.next();

        if (question.getQuesIdseq().equals(questionIdSeq)) {
            return question;
        }//from  w w  w .  j a  v a  2  s. c  om
    }
    return null;
}

From source file:gov.nih.nci.ncicb.cadsr.common.jsp.tag.handler.AvailableValidValue.java

public List getNotListedValidValues(List questionVVList, List availableVVList) {
    List nonListedVVs = new ArrayList();
    ListIterator availableVVListIterate = availableVVList.listIterator();

    FormValidValue currFormValidValue = null;
    while (availableVVListIterate.hasNext()) {
        currFormValidValue = (FormValidValue) availableVVListIterate.next();
        //Valid Values may not be mapped to VD
        if (!questionVVList.contains(currFormValidValue)) {
            nonListedVVs.add(currFormValidValue);
        }/*from  www. j  a v a2  s  .  c o m*/
    }
    return nonListedVVs;
}

From source file:edu.harvard.mcz.imagecapture.ConfiguredBarcodePositionTemplateDetector.java

protected String detectTemplateForImage(File anImageFile, CandidateImageFile scannableFile, boolean quickCheck)
        throws UnreadableFileException {
    // Set default response if no template is found.
    String result = PositionTemplate.TEMPLATE_NO_COMPONENT_PARTS;

    // Read the image file, if possible, otherwise throw exception.
    if (!anImageFile.canRead()) {
        throw new UnreadableFileException("Unable to read " + anImageFile.getName());
    }//from  ww  w .  ja va 2s.com

    BufferedImage image = null;
    try {
        image = ImageIO.read(anImageFile);
    } catch (IOException e) {
        throw new UnreadableFileException("IOException trying to read " + anImageFile.getName());
    }

    // iterate through templates and check until the first template where a barcode is found
    List<String> templates = PositionTemplate.getTemplateIds();
    ListIterator<String> i = templates.listIterator();
    boolean found = false;
    while (i.hasNext() && !found) {
        try {
            // get the next template from the list
            PositionTemplate template = new PositionTemplate((String) i.next());
            log.debug("Testing template: " + template.getTemplateId());
            if (template.getTemplateId().equals(PositionTemplate.TEMPLATE_NO_COMPONENT_PARTS)) {
                // skip, this is the default result if no other is found.
            } else {
                if (image.getWidth() == template.getImageSize().getWidth()) {
                    // Check to see if the barcode is in the part of the template
                    // defined by getBarcodeULPosition and getBarcodeSize.
                    String text;
                    if (scannableFile == null) {
                        text = CandidateImageFile.getBarcodeTextFromImage(image, template, quickCheck);
                    } else {
                        text = scannableFile.getBarcodeText(template);
                    }
                    log.debug("Found:[" + text + "] ");
                    if (text.length() > 0) {
                        // a barcode was scanned 
                        // Check to see if it matches the expected pattern.
                        // Use the configured barcode matcher.
                        if (Singleton.getSingletonInstance().getBarcodeMatcher().matchesPattern(text)) {
                            found = true;
                            log.debug("Match to:" + template.getTemplateId());
                            result = template.getTemplateId();
                        }
                    }
                } else {
                    log.debug("Skipping as template " + template.getTemplateId()
                            + " is not same size as image. ");
                }
            }
        } catch (NoSuchTemplateException e) {
            // Ending up here means a serious error in PositionTemplate
            // as the list of position templates returned by getTemplates() includes
            // an entry that isn't recognized as a valid template.  
            log.fatal(
                    "Fatal error.  PositionTemplate.getTemplates() includes an item that isn't a valid template.");
            log.trace(e);
            ImageCaptureApp.exit(ImageCaptureApp.EXIT_ERROR);
        }
    }
    return result;
}

From source file:com.itesm.test.servlets.TasksServlet.java

protected void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    String[] description = request.getParameterValues("description");
    String[] priority = request.getParameterValues("priority");
    String[] task_time = request.getParameterValues("task_time");
    String[] end_time = request.getParameterValues("end_time");
    PersonaVO personavo = (PersonaVO) request.getSession().getAttribute("persona");
    TaskManager taskManager = new TaskManager();
    for (int i = 0; i < priority.length; i++) {
        TaskVO wh = new TaskVO();
        SimpleDateFormat sdf = new SimpleDateFormat("hh:mm");
        SimpleDateFormat sdfTimeStamp = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm");
        Date durationDate = null;
        Date end_date = null;//from www. j  a va 2 s .c o m
        try {
            durationDate = sdf.parse(task_time[i]);
            end_date = sdfTimeStamp.parse(end_time[i]);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        wh.setDuration(new Time(durationDate.getTime()));
        wh.setEnd_date(new Timestamp(end_date.getTime()));
        wh.setDescription(description[i]);
        wh.setPriority(Integer.parseInt(priority[i]));
        wh.setAgenda_id(personavo.getAgenda_id());
        System.out.println(wh.toString());
        taskManager.agregar(wh);
    }
    CreateSchedule createSchedule = new CreateSchedule(personavo);
    createSchedule.createSchedule();
    TaskDAO taskDAO = new TaskDAO();
    List<TaskVO> task_list = taskDAO.findByAgenda(personavo.getAgenda_id());
    ListIterator listIterator = task_list.listIterator();
    while (listIterator.hasNext()) {
        TaskVO task = (TaskVO) listIterator.next();
        if (task.getWork_hours_id() == null) {
            listIterator.remove();
        }
    }

    WorkHoursManager workHoursManager = new WorkHoursManager();
    List<WorkHoursVO> worksHours_list = workHoursManager.consultarPorAgenda(personavo.getAgenda_id());
    request.setAttribute("tasks", task_list);
    request.setAttribute("works", worksHours_list);
    RequestDispatcher rd = getServletContext().getRequestDispatcher("/schedule.jsp");
    rd.forward(request, response);

}

From source file:com.apigee.sdk.apm.http.impl.client.cache.CacheEntryUpdater.java

private void removeCacheEntry1xxWarnings(List<Header> cacheEntryHeaderList, HttpCacheEntry entry) {
    ListIterator<Header> cacheEntryHeaderListIter = cacheEntryHeaderList.listIterator();

    while (cacheEntryHeaderListIter.hasNext()) {
        String cacheEntryHeaderName = cacheEntryHeaderListIter.next().getName();

        if (HeaderConstants.WARNING.equals(cacheEntryHeaderName)) {
            for (Header cacheEntryWarning : entry.getHeaders(HeaderConstants.WARNING)) {
                if (cacheEntryWarning.getValue().startsWith("1")) {
                    cacheEntryHeaderListIter.remove();
                }/*from   w  ww . j a v  a  2s .c  o m*/
            }
        }
    }
}

From source file:org.apache.sling.testing.clients.interceptors.StickyCookieInterceptor.java

public void process(HttpRequest httpRequest, HttpContext httpContext) throws HttpException, IOException {
    final HttpClientContext clientContext = HttpClientContext.adapt(httpContext);
    List<Cookie> cookies = clientContext.getCookieStore().getCookies();
    boolean set = (null != StickyCookieHolder.getTestStickySessionCookie());
    boolean found = false;
    ListIterator<Cookie> it = cookies.listIterator();
    while (it.hasNext()) {
        Cookie cookie = it.next();/* w w w. j  ava 2s . co m*/
        if (cookie.getName().equals(StickyCookieHolder.COOKIE_NAME)) {
            found = true;
            if (set) {
                // set the cookie with the value saved for each thread using the rule
                it.set(StickyCookieHolder.getTestStickySessionCookie());
            } else {
                // if the cookie is not set in TestStickySessionRule, remove it from here
                it.remove();
            }
        }
    }
    // if the cookie needs to be set from TestStickySessionRule but did not exist in the client cookie list, add it here.
    if (!found && set) {
        cookies.add(StickyCookieHolder.getTestStickySessionCookie());
    }
    BasicCookieStore cs = new BasicCookieStore();
    cs.addCookies(cookies.toArray(new Cookie[cookies.size()]));
    httpContext.setAttribute(HttpClientContext.COOKIE_STORE, cs);
}

From source file:code.lucamarrocco.hoptoad.Backtrace.java

private final List<String> filter(final List<String> backtrace) {
    final ListIterator<String> iterator = backtrace.listIterator();
    while (iterator.hasNext()) {
        String string = iterator.next();
        if (mustBeIgnored(string)) {
            continue;
        }//from   ww  w .j  a  v  a2s. c  o m
        if (not(validBacktrace()).matches(string)) {
            string = removeDobuleDot(string);
        }
        filteredBacktrace.add(string);
    }

    return filteredBacktrace;
}

From source file:com.espertech.esper.epl.core.ResultSetProcessorFactoryFactory.java

private static List<OrderByItem> expandColumnNames(SelectClauseElementCompiled[] selectionList,
        OrderByItem[] orderByUnexpanded) {
    if (orderByUnexpanded.length == 0) {
        return Collections.emptyList();
    }// w  w w . j a v  a  2s. c  o  m

    // copy list to modify
    List<OrderByItem> expanded = new ArrayList<OrderByItem>();
    for (OrderByItem item : orderByUnexpanded) {
        expanded.add(item.copy());
    }

    // expand
    for (SelectClauseElementCompiled selectElement : selectionList) {
        // process only expressions
        if (!(selectElement instanceof SelectClauseExprCompiledSpec)) {
            continue;
        }
        SelectClauseExprCompiledSpec selectExpr = (SelectClauseExprCompiledSpec) selectElement;

        String name = selectExpr.getAssignedName();
        if (name != null) {
            ExprNode fullExpr = selectExpr.getSelectExpression();
            for (ListIterator<OrderByItem> iterator = expanded.listIterator(); iterator.hasNext();) {
                OrderByItem orderByElement = iterator.next();
                ExprNode swapped = ColumnNamedNodeSwapper.swap(orderByElement.getExprNode(), name, fullExpr);
                OrderByItem newOrderByElement = new OrderByItem(swapped, orderByElement.isDescending());
                iterator.set(newOrderByElement);
            }
        }
    }

    return expanded;
}

From source file:de.fhg.iais.asc.ui.MyCortexStarter.java

/**
 * Configures this object according to a list of command line arguments.
 * //from  w  ww .j  a  v a  2 s. co  m
 * @param args
 * @see #configure(ListIterator) The list of applicable command line
 *      arguments
 */
private void configure(String[] args) {
    List<String> argList = Arrays.asList(args);
    configure(argList.listIterator());
}