List of usage examples for java.util ListIterator hasNext
boolean hasNext();
From source file:org.reunionemu.jreunion.server.Command.java
public void GoToPos(Player player, Position position) { Client client = player.getClient();//from ww w . j av a 2 s.co m SessionList<Session> exit = player.getInterested().getSessions(); exit.exit(player); SessionList<Session> entry = player.getPosition().getLocalMap().GetSessions(position); player.setPosition(position); ListIterator<Session> newSession = entry.listIterator(); while (newSession.hasNext()) { Session newSessionObj = newSession.next(); if (!newSessionObj.getOwner().equals(player)) { newSessionObj.enter(player, false); newSessionObj.getOwner().getClient().sendPacket(Type.IN_CHAR, player, true); } } player.update(); client.sendPacket(Type.GOTO, position); }
From source file:mediathek.controller.IoXmlSchreiben.java
private void xmlSchreibenProg(Daten daten) { ListIterator<DatenPset> iterator; //Proggruppen schreiben DatenPset datenPset;// ww w . ja v a 2 s . co m ListIterator<DatenProg> it; iterator = daten.listePset.listIterator(); while (iterator.hasNext()) { datenPset = iterator.next(); xmlSchreibenDaten(DatenPset.PROGRAMMSET, DatenPset.COLUMN_NAMES_, datenPset.arr, false); it = datenPset.getListeProg().listIterator(); while (it.hasNext()) { xmlSchreibenDaten(DatenProg.PROGRAMM, DatenProg.COLUMN_NAMES_, it.next().arr, false); } } }
From source file:com.berinchik.sip.FlexibleCommunicationServlet.java
@Override protected void doRegister(SipServletRequest request) throws ServletException, IOException { logger.trace("Got REGISTER:\n" + request); normaliseRegisterRequest(request);//w w w. ja va2 s. com logger.trace("normalisation performed"); logMessageInfo(request); Registrar registrar = CommonUtils.getRegistrarHelper(request); URI toURI = request.getTo().getURI(); ListIterator<Address> contacts = request.getAddressHeaders(CommonUtils.SC_CONTACT_HEADER); Address firstContact = null; if (contacts.hasNext()) { firstContact = contacts.next(); contacts.previous(); logger.trace("contact: " + firstContact); } SipServletResponse resp = null; try { logger.info("trying to register"); if (registrar == null) { logger.error("registrar not initialised!!!"); throw new RuntimeException("Registrar is not initialised"); } if (!registrar.isPrimary(toURI.toString())) { logger.debug("Primary user " + toURI + " not found during registration"); resp = request.createResponse(SC_NOT_FOUND, "No such user"); } else if (firstContact == null) { logger.debug("No contact headers during registration to " + toURI + "\nReturning all bindings"); resp = registrar.createRegisterSuccessResponse(request); } else if (firstContact.isWildcard()) { logger.debug("First contact is Wildcard"); if (request.getExpires() == 0) { logger.debug("Contact = *, Expire = 0: complete de registration"); registrar.deregisterUser(toURI.toString()); resp = request.createResponse(SC_OK, "Ok"); resp.removeHeader(CommonUtils.SC_EXPIRES_HEADER); } else { logger.debug("Contact = *, Expire != 0: request could not be understood"); resp = request.createResponse(SC_BAD_REQUEST, "Bad request"); } } else if (request.getExpires() == 0) { logger.info("Request is recognized as de registration" + "\ncontact - " + firstContact + "\nuser - " + toURI); registrar.deregisterUser(toURI.toString(), firstContact.getURI().toString()); resp = request.createResponse(SC_OK, "Ok"); resp.removeHeader(CommonUtils.SC_EXPIRES_HEADER); } else { logger.debug("Request is recognized as registration request"); while (contacts.hasNext()) { Address nextContact = contacts.next(); logger.trace("Trying to register contact " + nextContact.getURI() + " to user " + toURI); int expires = CommonUtils.getExpires(nextContact, request); registrar.registerUser(toURI.toString(), nextContact.getURI().toString(), expires); } resp = registrar.createRegisterSuccessResponse(request); } } catch (SQLException e) { logger.error("SQL Exception durin registration", e); resp = request.createResponse(SC_SERVER_INTERNAL_ERROR, "Server internal error"); } catch (RuntimeException e) { logger.error("Runtime exception", e); resp = request.createResponse(SC_SERVER_INTERNAL_ERROR, "Server internal error"); } logger.trace("Sending response: \n" + resp); resp.send(); }
From source file:org.powertac.householdcustomer.persons.Person.java
/** * This function fills out the daily routine with the leisure activity of the * day, if there is one for the person in question for the certain weekday. * /*from w w w. j a v a 2 s. co m*/ * @param weekday * @param gen * @return */ void addLeisure(int weekday) { // Create auxiliary variables ListIterator<Integer> iter = leisureVector.listIterator(); Status st; while (iter.hasNext()) { if (iter.next() == weekday) { int start = VillageConstants.START_OF_LEISURE + gen.nextInt(VillageConstants.LEISURE_WINDOW); for (int i = start; i < start + leisureDuration; i++) { st = Status.Leisure; dailyRoutine.set(i, st); if (i == VillageConstants.QUARTERS_OF_DAY - 1) break; } } } }
From source file:marytts.unitselection.analysis.ProsodyAnalyzer.java
/** * For debugging, generate Praat PitchTier, which can be used for PSOLA-based manipulation in Praat. * /*from w w w .ja v a 2 s. c o m*/ * @param fileName * of the PitchTier to be generated * @throws IOException */ public void writePraatPitchTier(String fileName) throws IOException { // initialize times and values: ArrayList<Double> times = new ArrayList<Double>(); ArrayList<Double> values = new ArrayList<Double>(); // cumulative time pointer: double time = 0; // iterate over phones, skipping the initial silence: ListIterator<Phone> phoneIterator = phones.listIterator(1); while (phoneIterator.hasNext()) { Phone phone = phoneIterator.next(); double[] frameTimes = phone.getRealizedFrameDurations(); double[] frameF0s = phone.getUnitFrameF0s(); for (int f = 0; f < frameF0s.length; f++) { time += frameTimes[f]; times.add(time); values.add(frameF0s[f]); } } // open file for writing: File durationTierFile = new File(fileName); PrintWriter out = new PrintWriter(durationTierFile); // print header: out.println("\"ooTextFile\""); out.println("\"PitchTier\""); out.println(String.format("0 %f %d", time, times.size())); // print points (times and values): for (int i = 0; i < times.size(); i++) { out.println(String.format("%.16f %f", times.get(i), values.get(i))); } // flush and close: out.close(); }
From source file:com.opengamma.elsql.ElSqlParser.java
private void parseContainerSection(ContainerSqlFragment container, ListIterator<Line> lineIterator, int indent) { while (lineIterator.hasNext()) { Line line = lineIterator.next(); if (line.isComment()) { lineIterator.remove();/*from www . ja v a 2 s . c o m*/ continue; } if (line.indent() <= indent) { lineIterator.previous(); return; } String trimmed = line.lineTrimmed(); if (trimmed.startsWith("@NAME")) { Matcher nameMatcher = NAME_PATTERN.matcher(trimmed); if (nameMatcher.matches() == false) { throw new IllegalArgumentException("@NAME found with invalid format: " + line); } NameSqlFragment nameFragment = new NameSqlFragment(nameMatcher.group(1)); parseContainerSection(nameFragment, lineIterator, line.indent()); if (nameFragment.getFragments().size() == 0) { throw new IllegalArgumentException("@NAME found with no subsequent indented lines: " + line); } container.addFragment(nameFragment); _namedFragments.put(nameFragment.getName(), nameFragment); } else if (indent < 0) { throw new IllegalArgumentException( "Invalid fragment found at root level, only @NAME is permitted: " + line); } else if (trimmed.startsWith("@PAGING")) { Matcher pagingMatcher = PAGING_PATTERN.matcher(trimmed); if (pagingMatcher.matches() == false) { throw new IllegalArgumentException("@PAGING found with invalid format: " + line); } PagingSqlFragment whereFragment = new PagingSqlFragment(pagingMatcher.group(1), pagingMatcher.group(2)); parseContainerSection(whereFragment, lineIterator, line.indent()); if (whereFragment.getFragments().size() == 0) { throw new IllegalArgumentException("@PAGING found with no subsequent indented lines: " + line); } container.addFragment(whereFragment); } else if (trimmed.startsWith("@WHERE")) { if (trimmed.equals("@WHERE") == false) { throw new IllegalArgumentException("@WHERE found with invalid format: " + line); } WhereSqlFragment whereFragment = new WhereSqlFragment(); parseContainerSection(whereFragment, lineIterator, line.indent()); if (whereFragment.getFragments().size() == 0) { throw new IllegalArgumentException("@WHERE found with no subsequent indented lines: " + line); } container.addFragment(whereFragment); } else if (trimmed.startsWith("@AND")) { Matcher andMatcher = AND_PATTERN.matcher(trimmed); if (andMatcher.matches() == false) { throw new IllegalArgumentException("@AND found with invalid format: " + line); } AndSqlFragment andFragment = new AndSqlFragment(andMatcher.group(1), StringUtils.strip(andMatcher.group(2), " =")); parseContainerSection(andFragment, lineIterator, line.indent()); if (andFragment.getFragments().size() == 0) { throw new IllegalArgumentException("@AND found with no subsequent indented lines: " + line); } container.addFragment(andFragment); } else if (trimmed.startsWith("@OR")) { Matcher orMatcher = OR_PATTERN.matcher(trimmed); if (orMatcher.matches() == false) { throw new IllegalArgumentException("@OR found with invalid format: " + line); } OrSqlFragment orFragment = new OrSqlFragment(orMatcher.group(1), StringUtils.strip(orMatcher.group(2), " =")); parseContainerSection(orFragment, lineIterator, line.indent()); if (orFragment.getFragments().size() == 0) { throw new IllegalArgumentException("@OR found with no subsequent indented lines: " + line); } container.addFragment(orFragment); } else if (trimmed.startsWith("@IF")) { Matcher ifMatcher = IF_PATTERN.matcher(trimmed); if (ifMatcher.matches() == false) { throw new IllegalArgumentException("@IF found with invalid format: " + line); } IfSqlFragment ifFragment = new IfSqlFragment(ifMatcher.group(1), StringUtils.strip(ifMatcher.group(2), " =")); parseContainerSection(ifFragment, lineIterator, line.indent()); if (ifFragment.getFragments().size() == 0) { throw new IllegalArgumentException("@IF found with no subsequent indented lines: " + line); } container.addFragment(ifFragment); } else { parseLine(container, line); } } }
From source file:com.caricah.iotracah.datastore.ignitecache.internal.impl.SubscriptionFilterHandler.java
public Observable<IotSubscriptionFilter> getTopicFilterTree(String partition, List<String> topicFilterTreeRoute) { return Observable.create(observer -> { List<Long> collectingParentIdList = new ArrayList<>(); collectingParentIdList.add(0l);//w w w . j a v a 2 s . co m List<String> growingTitles = new ArrayList<>(); ListIterator<String> pathIterator = topicFilterTreeRoute.listIterator(); try { while (pathIterator.hasNext()) { String topicPart = pathIterator.next(); log.debug(" getTopicFilterTree : current path in tree is : {}", topicPart); growingTitles.add(topicPart); List<Long> parentIdList = new ArrayList<>(collectingParentIdList); collectingParentIdList.clear(); for (Long parentId : parentIdList) { log.debug(" getTopicFilterTree : Dealing with parent id : {} and titles is {}", parentId, growingTitles); if (Constant.MULTI_LEVEL_WILDCARD.equals(topicPart)) { getMultiLevelWildCard(observer, partition, parentId); } else if (Constant.SINGLE_LEVEL_WILDCARD.equals(topicPart)) { String query = "partitionId = ? AND parentId = ? "; Object[] params = { partition, parentId }; getByQuery(IotSubscriptionFilter.class, query, params).toBlocking() .forEach(subscriptionFilter -> { log.debug(" getTopicFilterTree : Found matching single level filter : {}", subscriptionFilter); if (pathIterator.hasNext()) { collectingParentIdList.add(subscriptionFilter.getId()); } else { observer.onNext(subscriptionFilter); } }); } else { String query = "partitionId = ? AND parentId = ? AND name = ? "; String joinedTopicName = String.join(Constant.PATH_SEPARATOR, growingTitles); Object[] params = new Object[] { partition, parentId, joinedTopicName }; getByQuery(IotSubscriptionFilter.class, query, params).toBlocking() .forEach(subscriptionFilter -> { log.debug(" getTopicFilterTree : Found matching point filter : {}", subscriptionFilter); if (pathIterator.hasNext()) { collectingParentIdList.add(subscriptionFilter.getId()); } else { observer.onNext(subscriptionFilter); } }); } } } observer.onCompleted(); } catch (Exception e) { observer.onError(e); } }); }
From source file:vteaexploration.plotgatetools.gates.PolygonGate.java
@Override public Path2D createPath2DInChartSpace() { Point2D p;//from w ww .ja v a 2 s . c o m Path2D.Double polygon = new Path2D.Double(); ListIterator<Point2D.Double> itr = verticesInChartSpace.listIterator(); p = (Point2D) verticesInChartSpace.get(0); //System.out.println(verticesInChartSpace.size() + " Gate points"); //System.out.println("First Point: " + p); polygon.moveTo(p.getX(), p.getY()); while (itr.hasNext()) { p = (Point2D) itr.next(); //System.out.println("Next Point: " + p); polygon.lineTo(p.getX(), p.getY()); } polygon.closePath(); return polygon; }
From source file:net.flamefeed.ftb.modpackupdater.FileOperator.java
/** * Goes through every file in the deleteQueue and removes it from the file system *///from w w w. j a v a 2 s . c om public void executeDeleteQueue() { ListIterator<String> deleteQueueIterator = deleteQueue.listIterator(); while (deleteQueueIterator.hasNext()) { new File(pathMinecraft + "/" + deleteQueueIterator.next()).delete(); } }
From source file:mediathek.controller.IoXmlSchreiben.java
private void xmlSchreibenPset(DatenPset[] psetArray) { ListIterator<DatenProg> it; for (DatenPset pset : psetArray) { xmlSchreibenDaten(DatenPset.PROGRAMMSET, DatenPset.COLUMN_NAMES_, pset.arr, false); it = pset.getListeProg().listIterator(); while (it.hasNext()) { xmlSchreibenDaten(DatenProg.PROGRAMM, DatenProg.COLUMN_NAMES_, it.next().arr, false); }/* w w w . j ava 2 s.c o m*/ } }