List of usage examples for java.util ListIterator hasNext
boolean hasNext();
From source file:es.tid.fiware.rss.expenditureLimit.server.service.ExpenditureLimitDataChecker.java
/** * /* w w w . java 2 s . co m*/ * @param maxAmount * @param defaultProvThresholds */ private void checkNotificationLimits(Long maxAmount, List<Long> sNotifAmounts) throws RSSException { if ((maxAmount > 0) && (sNotifAmounts != null) && (sNotifAmounts.size() > 0)) { ListIterator<Long> litr = sNotifAmounts.listIterator(); while (litr.hasNext()) { long notifAmount = litr.next().longValue(); if (notifAmount > maxAmount) { String[] args = { "Amount notification (" + notifAmount + ") is greather than total limit (" + maxAmount + ")" }; throw new RSSException(UNICAExceptionType.INVALID_INPUT_VALUE, args); } } } }
From source file:mediathek.controller.IoXmlSchreiben.java
private void xmlSchreibenErsetzungstabelle() { ListIterator<String[]> iterator; iterator = Daten.mVReplaceList.liste.listIterator(); while (iterator.hasNext()) { String[] sa = iterator.next(); xmlSchreibenDaten(MVReplaceList.REPLACELIST, MVReplaceList.COLUMN_NAMES, sa, false); }/*www . j a v a2 s . co m*/ }
From source file:au.edu.ausstage.networks.SearchManager.java
/** * A method to take a group of collaborators and output JSON encoded text * Unchecked warnings are suppressed due to internal issues with the org.json.simple package * * @param collaborators the list of collaborators * @return the JSON encoded string *///from ww w. j av a2 s . com @SuppressWarnings("unchecked") private String createJSONOutput(LinkedList<Collaborator> collaborators) { // assume that all sorting and ordering has already been carried out // loop through the list of collaborators and add them to the new JSON objects ListIterator iterator = collaborators.listIterator(0); // declare helper variables JSONArray list = new JSONArray(); Collaborator collaborator = null; while (iterator.hasNext()) { // get the collaborator collaborator = (Collaborator) iterator.next(); // add the Json object to the array list.add(collaborator.toJsonObject()); } // return the JSON encoded string return list.toString(); }
From source file:com.platum.restflow.RestflowModel.java
/** * /* w ww.j ava 2 s . co m*/ * @param name * @return */ public RestflowModel removeResource(String name) { if (resources != null) { ListIterator<Resource> iterator = resources.listIterator(); while (iterator.hasNext()) { if (iterator.next().getName().equals(name)) { iterator.remove(); return this; } } } throw new RestflowNotExistsException("Resource does not exists."); }
From source file:com.platum.restflow.RestflowModel.java
/** * // www.ja va 2 s.c om * @param resource * @return */ public RestflowModel updateResource(Resource resource) { Validate.notNull(resource, "Cannot update a null resource."); Validate.notEmpty(resource.getName(), "Resource name cannot be null or empty."); if (resources != null) { ListIterator<Resource> iterator = resources.listIterator(); while (iterator.hasNext()) { if (iterator.next().getName().equals(resource.getName())) { iterator.set(resource); return this; } } } throw new RestflowNotExistsException("Resource 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()); }// w ww . j a v 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.yahoo.semsearch.fastlinking.DPSearch.java
/** * Run forward-backward algorithm on multiple entity candidates and returns a filtered list of coherent entities * Takes nbest list and/* w w w .j av a 2s.c o m*/ * @param nBestList an array of arraylists of wiki entities; for each entity span we have a list of candidate * wikilinks (nbest list) * @param entitySurfaceForms an array of entity spans * @return DPSearch object that contains lattice of paths and likelihood scores */ public DPSearch dynamicProgrammingSearch(List<String>[] nBestList, String[] entitySurfaceForms) { int sequenceLength = entitySurfaceForms.length; int nBestLength = MAXNBEST; double[][] logSimilarityOverall = new double[sequenceLength][nBestLength]; for (int i = 0; i < logSimilarityOverall.length; i++) { Arrays.fill(logSimilarityOverall[i], DEFAULT_LOG_LIKELIHOOD); } String[][] path = new String[sequenceLength][nBestLength]; for (int i = 0; i < path.length; i++) { Arrays.fill(path[i], ""); } ListIterator<String> it = nBestList[0].listIterator(); while (it.hasNext()) { //MAKE SURE to call NextIndex before Next int index = it.nextIndex(); String currentCandidate = it.next(); double entity2WordSim = gensimEntityEmbeddings.entity2WordSimilarity(prependWiki(currentCandidate), entitySurfaceForms[0].replace(" ", "_")); double lexicalSim = gensimEntityEmbeddings.lexicalSimilarity(currentCandidate.replace("_", " "), entitySurfaceForms[0]); logSimilarityOverall[0][index] = Math.max( Math.log((1 - LEXSIM_LAMBDA) * entity2WordSim + LEXSIM_LAMBDA * lexicalSim), DEFAULT_LOG_LIKELIHOOD); path[0][index] = currentCandidate; } ListIterator<String> currentCandidateIterator, previousCandidateIterator; for (int i = 1; i < sequenceLength; i++) { currentCandidateIterator = nBestList[i].listIterator(); while (currentCandidateIterator.hasNext()) { //MAKE SURE to call NextIndex before Next int currentCandidateIndex = currentCandidateIterator.nextIndex(); String currentCandidate = currentCandidateIterator.next(); double entity2WordSim = gensimEntityEmbeddings.entity2WordSimilarity(prependWiki(currentCandidate), entitySurfaceForms[i].replace(" ", "_")); double lexicalSim = gensimEntityEmbeddings.lexicalSimilarity(currentCandidate.replace("_", " "), entitySurfaceForms[i]); double candidateNBestSimilarity = Math .log((1 - LEXSIM_LAMBDA) * entity2WordSim + LEXSIM_LAMBDA * lexicalSim); double bestSimilarity = 0.0; double interCandidateSimilarity = 0.0; int previousBestCandidateIndex = -1; previousCandidateIterator = nBestList[i - 1].listIterator(); while (previousCandidateIterator.hasNext()) { //MAKE SURE to call NextIndex before Next int index = previousCandidateIterator.nextIndex(); String previousCandidate = previousCandidateIterator.next(); double entity2EntitySimilarity = gensimEntityEmbeddings .entity2EntitySimilarity(prependWiki(previousCandidate), prependWiki(currentCandidate)); double entity2EntityLexicalSimilarity = gensimEntityEmbeddings.lexicalSimilarity( previousCandidate.replace("_", " "), currentCandidate.replace("_", " ")); double jointSimilarity = (1 - LEXSIM_LAMBDA) * entity2EntitySimilarity + LEXSIM_LAMBDA * entity2EntityLexicalSimilarity; interCandidateSimilarity = Math.log(jointSimilarity); if (bestSimilarity == 0.0) { bestSimilarity = interCandidateSimilarity + logSimilarityOverall[i - 1][index]; previousBestCandidateIndex = index; } else if (interCandidateSimilarity + logSimilarityOverall[i - 1][index] > bestSimilarity) { bestSimilarity = interCandidateSimilarity + logSimilarityOverall[i - 1][index]; previousBestCandidateIndex = index; } } try { logSimilarityOverall[i][currentCandidateIndex] = Math .max(bestSimilarity + candidateNBestSimilarity, DEFAULT_LOG_LIKELIHOOD); path[i][currentCandidateIndex] = path[i - 1][previousBestCandidateIndex] + CANDIDATE_DELIMITER + currentCandidate; } catch (ArrayIndexOutOfBoundsException e) { e.getMessage(); } } } RealVector realVector = new ArrayRealVector(logSimilarityOverall[sequenceLength - 1]); int bestPathIndex = realVector.getMaxIndex(); DPSearch dpSearch = new DPSearch(logSimilarityOverall, path); return dpSearch; }
From source file:com.offbynull.coroutines.instrumenter.asm.InstructionUtils.java
/** * Clones an instruction list. All labels are remapped unless otherwise specified in {@code globalLabels}. * @param insnList instruction list to clone * @param globalLabels set of labels that should not be remapped * @throws NullPointerException if any argument is {@code null} * @return instruction list with cloned instructions *///from w w w . j a v a 2 s.co m public static InsnList cloneInsnList(InsnList insnList, Set<LabelNode> globalLabels) { Validate.notNull(insnList); // remap all labelnodes Map<LabelNode, LabelNode> labelNodeMapping = new HashMap<>(); ListIterator<AbstractInsnNode> it = insnList.iterator(); while (it.hasNext()) { AbstractInsnNode abstractInsnNode = it.next(); if (abstractInsnNode instanceof LabelNode) { LabelNode existingLabelNode = (LabelNode) abstractInsnNode; labelNodeMapping.put(existingLabelNode, new LabelNode()); } } // override remapping such that global labels stay the same for (LabelNode globalLabel : globalLabels) { labelNodeMapping.put(globalLabel, globalLabel); } // clone InsnList ret = new InsnList(); it = insnList.iterator(); while (it.hasNext()) { AbstractInsnNode abstractInsnNode = it.next(); ret.add(abstractInsnNode.clone(labelNodeMapping)); } return ret; }
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); }// w w w. j ava2 s.c o 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.replaymod.replaystudio.collection.PacketList.java
@Override public boolean equals(Object obj) { if (obj instanceof List) { PacketListIterator iter = this.listIterator(); ListIterator<?> other = ((List<?>) obj).listIterator(); while (other.hasNext() && iter.hasNext()) { if (!Objects.equals(other.next(), iter.next())) { return false; }/* w w w . j a v a 2 s. co m*/ } return !(other.hasNext() || iter.hasNext()); } return super.equals(obj); }