Example usage for java.util ListIterator next

List of usage examples for java.util ListIterator next

Introduction

In this page you can find the example usage for java.util ListIterator next.

Prototype

E next();

Source Link

Document

Returns the next element in the list and advances the cursor position.

Usage

From source file:com.platum.restflow.RestflowModel.java

/**
 * //from w  w w.ja  va2s  . c o m
 * @param datasource
 * @return
 */
public RestflowModel updateFileSystem(FileSystemDetails fs) {
    Validate.notNull(fs, "Cannot update a null filesystem.");
    Validate.notEmpty(fs.getName(), "Filesystem name cannot be null or empty.");
    if (resources != null) {
        ListIterator<FileSystemDetails> iterator = fileSystems.listIterator();
        while (iterator.hasNext()) {
            if (iterator.next().getName().equals(fs.getName())) {
                iterator.set(fs);
                return this;
            }
        }
    }
    throw new RestflowNotExistsException("Datasource does not exists.");
}

From source file:com.platum.restflow.RestflowModel.java

/**
 * /*from  www  . j a v  a2s  .c  om*/
 * @param datasource
 * @return
 */
public RestflowModel updateDatasource(DatasourceDetails datasource) {
    Validate.notNull(datasource, "Cannot update a null datasource.");
    Validate.notEmpty(datasource.getName(), "Datasource name cannot be null or empty.");
    if (resources != null) {
        ListIterator<DatasourceDetails> iterator = datasources.listIterator();
        while (iterator.hasNext()) {
            if (iterator.next().getName().equals(datasource.getName())) {
                iterator.set(datasource);
                return this;
            }
        }
    }
    throw new RestflowNotExistsException("Datasource does not exists.");
}

From source file:net.sf.jasperreports.olap.xmla.Olap4jXmlaQueryExecuter.java

protected void parseAxes(CellSet result) {
    // Cycle over AxisInfo-Elements
    Iterator<CellSetAxis> itAxis = result.getAxes().iterator();
    log.debug("# axes: " + result.getAxes().size());
    while (itAxis.hasNext()) {
        CellSetAxis itAxisElement = itAxis.next();
        Axis axis = itAxisElement.getAxisMetaData().getAxisOrdinal();
        if (axis.axisOrdinal() == Axis.FILTER.axisOrdinal()) {
            if (log.isDebugEnabled()) {
                log.debug("skipping filter axis: " + axis.name() + ", ordinal: " + axis.axisOrdinal());
            }/*from  www  .j av  a 2 s . c  o m*/
            continue;
        }

        JRXmlaResultAxis xmlaAxis = new JRXmlaResultAxis(axis.name());
        xmlaResult.addAxis(xmlaAxis);

        if (log.isDebugEnabled()) {
            log.debug("adding axis: " + axis.name() + ", ordinal: " + axis.axisOrdinal());
        }
        handleHierInfo(xmlaAxis, itAxisElement.getAxisMetaData());

        ListIterator<Position> positionsIt = itAxisElement.iterator();
        while (positionsIt.hasNext()) {
            Position p = positionsIt.next();
            if (log.isDebugEnabled()) {
                log.debug("adding pos : " + p.getOrdinal() + ", with member size: " + p.getMembers().size());
            }
            handlePosition(xmlaAxis, itAxisElement, p);
        }

    }
}

From source file:com.mirth.connect.server.util.DatabaseConnection.java

public CachedRowSet executeCachedQuery(String expression, List<Object> parameters) throws SQLException {
    PreparedStatement statement = null;

    try {/*from   ww  w.j  a  v a 2 s .  c o  m*/
        statement = connection.prepareStatement(expression);
        logger.debug("executing prepared statement:\n" + expression);

        ListIterator<Object> iterator = parameters.listIterator();

        while (iterator.hasNext()) {
            int index = iterator.nextIndex() + 1;
            Object value = iterator.next();
            logger.debug("adding parameter: index=" + index + ", value=" + value);
            statement.setObject(index, value);
        }

        ResultSet result = statement.executeQuery();
        CachedRowSetImpl crs = new CachedRowSetImpl();
        crs.populate(result);
        DbUtils.closeQuietly(result);
        return crs;
    } catch (SQLException e) {
        throw e;
    } finally {
        DbUtils.closeQuietly(statement);
    }
}

From source file:com.mirth.connect.server.util.DatabaseConnection.java

public CachedRowSet executeUpdateAndGetGeneratedKeys(String expression, List<Object> parameters)
        throws SQLException {
    PreparedStatement statement = null;

    try {/*  w w w  . ja  v a 2  s .c om*/
        statement = connection.prepareStatement(expression, Statement.RETURN_GENERATED_KEYS);
        logger.debug("executing prepared statement:\n" + expression);

        ListIterator<Object> iterator = parameters.listIterator();

        while (iterator.hasNext()) {
            int index = iterator.nextIndex() + 1;
            Object value = iterator.next();
            logger.debug("adding parameter: index=" + index + ", value=" + value);
            statement.setObject(index, value);
        }

        statement.executeUpdate();
        CachedRowSetImpl crs = new CachedRowSetImpl();
        crs.populate(statement.getGeneratedKeys());
        return crs;
    } catch (SQLException e) {
        throw e;
    } finally {
        DbUtils.closeQuietly(statement);
    }
}

From source file:com.github.vanroy.springdata.jest.CriteriaFilterProcessor.java

QueryBuilder createFilterFromCriteria(Criteria criteria) {
    List<QueryBuilder> fbList = new LinkedList<QueryBuilder>();
    QueryBuilder filter = null;/*from  ww w.j  a va2 s.  c o  m*/

    ListIterator<Criteria> chainIterator = criteria.getCriteriaChain().listIterator();

    while (chainIterator.hasNext()) {
        QueryBuilder fb = null;
        Criteria chainedCriteria = chainIterator.next();
        if (chainedCriteria.isOr()) {
            fb = QueryBuilders.boolQuery();
            for (QueryBuilder f : createFilterFragmentForCriteria(chainedCriteria)) {
                ((BoolQueryBuilder) fb).should(f);
            }
            fbList.add(fb);
        } else if (chainedCriteria.isNegating()) {
            List<QueryBuilder> negationFilters = buildNegationFilter(criteria.getField().getName(),
                    criteria.getFilterCriteriaEntries().iterator());

            if (!negationFilters.isEmpty()) {
                fbList.addAll(negationFilters);
            }
        } else {
            fbList.addAll(createFilterFragmentForCriteria(chainedCriteria));
        }
    }

    if (!fbList.isEmpty()) {
        if (fbList.size() == 1) {
            filter = fbList.get(0);
        } else {
            filter = QueryBuilders.boolQuery();
            for (QueryBuilder f : fbList) {
                ((BoolQueryBuilder) filter).must(f);
            }
        }
    }
    return filter;
}

From source file:de.uhh.l2g.plugins.guest.OpenAccessVideos.java

@Override
public void serveResource(ResourceRequest resourceRequest, ResourceResponse resourceResponse)
        throws IOException, PortletException {
    String resourceID = resourceRequest.getResourceID();
    String cmd = ParamUtil.getString(resourceRequest, Constants.CMD);
    if (cmd.equals("get_search_words")) {
        getSearchWords(resourceRequest, resourceResponse);
    }//from   ww w.ja  v  a 2s . co m

    try {
        if (resourceID.equals("showSegments")) {
            String vId = ParamUtil.getString(resourceRequest, "videoId");
            Long vID = new Long(vId);
            com.liferay.portal.kernel.json.JSONArray ja = JSONFactoryUtil.createJSONArray();
            //get segments for video and convert to json array
            try {
                List<Segment> sl = SegmentLocalServiceUtil.getSegmentsByVideoId(vID);
                ListIterator<Segment> sIt = sl.listIterator();
                while (sIt.hasNext()) {
                    Segment s = sIt.next();
                    JSONObject jo = JSONFactoryUtil.createJSONObject();
                    jo.put("chapter", s.getChapter());
                    jo.put("description", s.getDescription());
                    jo.put("end", s.getEnd());
                    jo.put("image", s.getImage());
                    jo.put("number", s.getNumber());
                    jo.put("segmentId", s.getPrimaryKey());
                    jo.put("seconds", s.getSeconds());
                    jo.put("start", s.getStart());
                    jo.put("title", s.getTitle());
                    jo.put("userId", s.getUserId());
                    jo.put("videoId", s.getVideoId());
                    jo.put("previousSegmentId", SegmentLocalServiceUtil.getPreviusSegmentId(s.getSegmentId()));
                    ja.put(jo);
                }

            } catch (PortalException e) {
                e.printStackTrace();
            } catch (SystemException e) {
                e.printStackTrace();
            }
            writeJSON(resourceRequest, resourceResponse, ja);
        }
    } catch (NullPointerException npe) {
    }

}

From source file:com.manydesigns.elements.options.DefaultSelectionProvider.java

public void ensureActive(Object... values) {
    Row row = null;/*from www .  j a va  2  s.co m*/
    ListIterator<Row> iterator = rows.listIterator();
    while (iterator.hasNext()) {
        Row current = iterator.next();
        boolean found = true;
        for (int i = 0; i < fieldCount; i++) {
            if (!ObjectUtils.equals(values[i], current.getValues()[i])) {
                found = false;
                break;
            }
        }
        if (found) {
            row = new Row(values, current.getLabels(), true);
            iterator.set(row);
            break;
        }
    }
    if (row == null) {
        String[] labels = new String[fieldCount];
        for (int i = 0; i < fieldCount; i++) {
            labels[i] = ObjectUtils.toString(values[i]);
        }
        row = new Row(values, labels, true);
        rows.add(row);
    }
}

From source file:com.projity.algorithm.buffer.GroupedCalculatedValues.java

public void mergeIn(GroupedCalculatedValues add) {
    ListIterator baseIterator = values.listIterator();
    ListIterator addIterator = add.values.listIterator();
    Point basePoint = baseIterator.hasNext() ? (Point) baseIterator.next() : null;
    long start = basePoint.date;
    Point previousAddPoint = null;
    Point addPoint = addIterator.hasNext() ? (Point) addIterator.next() : null;
    while (basePoint != null && addPoint != null) {
        //TODO handle overlaps
        if (basePoint.compareTo(addPoint) >= 0) {
            if (addPoint.date >= start) {
                basePoint.value += addPoint.value;
                if (basePoint.date == start && previousAddPoint != null) { // if first time
                    double proratedAmount = ((double) addPoint.date - start)
                            / (addPoint.date - previousAddPoint.date);
                    if (proratedAmount > 0)
                        basePoint.value += (previousAddPoint.value * proratedAmount);
                }/*ww  w . ja  va 2 s  .c  o  m*/
            }
            previousAddPoint = addPoint;
            addPoint = addIterator.hasNext() ? (Point) addIterator.next() : null;
            continue;
        }

        if (baseIterator.hasNext()) {
            basePoint = (Point) baseIterator.next();
        } else {
            if (previousAddPoint != null) {// handle end boundary
                double proratedAmount = ((double) (basePoint.date - previousAddPoint.date))
                        / (addPoint.date - previousAddPoint.date);
                if (proratedAmount > 0)
                    basePoint.value += (addPoint.value * proratedAmount);
            }
            basePoint = null;
        }
    }
}

From source file:com.card.loop.xyz.dao.LearningElementDAO.java

public ArrayList<String> getKeywords(String md5, String collection) throws UnknownHostException {
    Mongo mongo = new Mongo(AppConfig.mongodb_host, AppConfig.mongodb_port);
    DB db = mongo.getDB(AppConfig.DATABASE_LOOP);
    ArrayList<String> list = new ArrayList<>();
    GridFS le_gfs = new GridFS(db, collection);
    GridFSDBFile le_output = le_gfs.findOne(new BasicDBObject("md5", md5));
    ListIterator<Object> trustedList = ((BasicDBList) le_output.get("keywords")).listIterator();

    while (trustedList.hasNext()) {
        Object nextItem = trustedList.next();
        list.add(nextItem.toString());//from   w w  w .j a  va  2  s.  c om
    }
    return list;
}