List of usage examples for java.util ListIterator next
E next();
From source file:de.tudarmstadt.ukp.dkpro.core.api.io.ResourceCollectionReaderBase.java
@Override public void initialize(UimaContext aContext) throws ResourceInitializationException { super.initialize(aContext); // if an ExternalResourceLocator providing a custom ResourcePatternResolver // has been specified, use it, by default use PathMatchingResourcePatternresolver // If there are no patterns, then look for a pattern in the location itself. // If the source location contains a wildcard, split it up into a base and a pattern if (patterns == null) { int asterisk = sourceLocation.indexOf('*'); if (asterisk != -1) { patterns = new String[] { INCLUDE_PREFIX + sourceLocation.substring(asterisk) }; sourceLocation = sourceLocation.substring(0, asterisk); }// w w w. j a v a 2s. c om } // Parse the patterns and inject them into the FileSet List<String> includes = new ArrayList<String>(); List<String> excludes = new ArrayList<String>(); if (patterns != null) { for (String pattern : patterns) { if (pattern.startsWith(INCLUDE_PREFIX)) { includes.add(pattern.substring(INCLUDE_PREFIX.length())); } else if (pattern.startsWith(EXCLUDE_PREFIX)) { excludes.add(pattern.substring(EXCLUDE_PREFIX.length())); } else if (pattern.matches("^\\[.\\].*")) { throw new ResourceInitializationException(new IllegalArgumentException( "Patterns have to start with " + INCLUDE_PREFIX + " or " + EXCLUDE_PREFIX + ".")); } else { includes.add(pattern); } } } // These should be the same as documented here: http://ant.apache.org/manual/dirtasks.html if (useDefaultExcludes) { excludes.add("**/*~"); excludes.add("**/#*#"); excludes.add("**/.#*"); excludes.add("**/%*%"); excludes.add("**/._*"); excludes.add("**/CVS"); excludes.add("**/CVS/**"); excludes.add("**/.cvsignore"); excludes.add("**/SCCS"); excludes.add("**/SCCS/**"); excludes.add("**/vssver.scc"); excludes.add("**/.svn"); excludes.add("**/.svn/**"); excludes.add("**/.DS_Store"); excludes.add("**/.git"); excludes.add("**/.git/**"); excludes.add("**/.gitattributes"); excludes.add("**/.gitignore"); excludes.add("**/.gitmodules"); excludes.add("**/.hg"); excludes.add("**/.hg/**"); excludes.add("**/.hgignore"); excludes.add("**/.hgsub"); excludes.add("**/.hgsubstate"); excludes.add("**/.hgtags"); excludes.add("**/.bzr"); excludes.add("**/.bzr/**"); excludes.add("**/.bzrignore"); } try { if (sourceLocation == null) { ListIterator<String> i = includes.listIterator(); while (i.hasNext()) { i.set(locationToUrl(i.next())); } i = excludes.listIterator(); while (i.hasNext()) { i.set(locationToUrl(i.next())); } } else { sourceLocation = locationToUrl(sourceLocation); } resources = scan(sourceLocation, includes, excludes); // Get the iterator that will be used to actually traverse the FileSet. resourceIterator = resources.iterator(); getLogger().info("Found [" + resources.size() + "] resources to be read"); } catch (IOException e) { throw new ResourceInitializationException(e); } }
From source file:chat.viska.commons.pipelines.Pipeline.java
public void addTowardsInboundEnd(final Pipe previous, final String name, final Pipe pipe) { Completable.fromAction(() -> {/*w w w .j a v a 2 s .co m*/ pipeLock.writeLock().lockInterruptibly(); try { if (getIteratorOf(name) != null) { throw new IllegalArgumentException("Name collision: " + name); } ListIterator<Map.Entry<String, Pipe>> iterator = getIteratorOf(previous); if (iterator == null) { throw new NoSuchElementException(); } iterator.next(); iterator.add(new AbstractMap.SimpleImmutableEntry<>(name, pipe)); pipe.onAddedToPipeline(this); } finally { pipeLock.writeLock().unlock(); } }).onErrorComplete().subscribeOn(Schedulers.io()).subscribe(); }
From source file:com.smi.travel.monitor.MonitorGalileo.java
@Override void buildBookingPassenger(BookingAirline bAir) { String passengerTypes = new String(""); int costRefIndex = 0; String section = galileoMap.get("passenger name").getSection(); MGalileo airNo = galileoMap.get("airline number"); int lineNo = Integer.parseInt(airNo.getLine()); String line = lineData.get(lineNo); String ticketNoS1 = line.substring(airNo.getStartlength() - 1, airNo.getStartlength() - 1 + airNo.getLength()); MGalileo type = galileoMap.get("ticket type"); lineNo = Integer.parseInt(type.getLine()); line = lineData.get(lineNo);/*from w w w .ja v a 2 s . co m*/ String ticketType = line.substring(type.getStartlength() - 1, type.getStartlength() - 1 + type.getLength()); ArrayList<String> lines = (ArrayList<String>) sectionData.get(section); // System.out.println("Passenger " + lines.size()); ListIterator<String> iterator = lines.listIterator(); BookingPassenger bp = null; while (iterator.hasNext()) { line = iterator.next(); System.out.println("line-> " + line); String passengerName = getField("passenger name", line).trim(); String passengerType = getField("passenger type", line); if (StringUtils.isEmpty(passengerType) || (!("ADT".equalsIgnoreCase(passengerType)) && !("CHD".equalsIgnoreCase(passengerType)) && !("INF".equalsIgnoreCase(passengerType)))) { passengerType = "NON"; } String[] splitName = passengerName.split("/"); String lastName = splitName[0]; String firstName = splitName[1].substring(0, splitName[1].length() - 2); String initial = splitName[1].substring(splitName[1].length() - 2); String ticketSerial2 = getField("ticket serial2", line); String ticketSerial3 = getField("ticket serial3", line); String fareNo = getField("fare reference", line); String fareSection = galileoMap.get("ticket fare").getSection(); ArrayList<String> fareLines = (ArrayList<String>) sectionData.get(fareSection); String fareLine = fareLines.get(Integer.parseInt(fareNo) - 1); String currency = getField("currency", fareLine); String ticketFare = getTicketFare(currency, fareLine); String ticketTotalS = getField("ticket total", fareLine); ticketTotalS = stripNumberDecimalString(ticketTotalS); ticketFare = stripNumberDecimalString(ticketFare); int tax = Integer.parseInt(ticketTotalS.trim()) - Integer.parseInt(ticketFare.trim()); bp = new BookingPassenger(); bp.setFirstName(firstName); bp.setLastName(lastName); bp.setInitialName(initial); bp.setPassengerType(passengerType); bp.setTicketType(ticketType); bp.setTicketnoS1(ticketNoS1); bp.setTicketnoS2(ticketSerial2); bp.setTicketnoS3(ticketSerial3); bp.setTicketFare(Integer.valueOf(ticketFare.trim())); bp.setTicketTax(Integer.valueOf(tax)); bAir.getBookingPassengers().add(bp); bp.setBookingAirline(bAir); if (!passengerTypes.contains(passengerType)) { passengerTypes = passengerTypes + "," + passengerType; String costS = getField("cost", costRefIndex).trim(); String priceS = getField("price", costRefIndex).trim(); Integer cost = Integer.valueOf(costS); Integer price = Integer.valueOf(priceS); costRefIndex++; //Update cost,price,tax according to passengertype BookingFlight bf = this.getMostEarlyFlight(bAir.getBookingPnr()); if ("ADT".equalsIgnoreCase(passengerType)) { bf.setAdCost(cost); bf.setAdPrice(price); bf.setAdTax(tax); } else if ("CHD".equalsIgnoreCase(passengerType)) { bf.setChCost(cost); bf.setChPrice(price); bf.setChTax(tax); } else if ("INF".equalsIgnoreCase(passengerType)) { bf.setInCost(cost); bf.setInPrice(price); bf.setInTax(tax); } else { bf.setAdCost(cost); bf.setAdPrice(price); bf.setAdTax(tax); } // } } } return; }
From source file:vteaexploration.plottools.panels.XYChartPanel.java
private double getMinimumOfData(ArrayList alVolumes, int x) { ListIterator litr = alVolumes.listIterator(); //ArrayList<Number> al = new ArrayList<Number>(); Number low = getMaximumOfData(alVolumes, x); while (litr.hasNext()) { try {/*from w ww. ja va2s . c o m*/ MicroObjectModel volume = (MicroObjectModel) litr.next(); Number Corrected = processPosition(x, volume); if (Corrected.floatValue() < low.floatValue()) { low = Corrected; } } catch (NullPointerException e) { } } return low.longValue(); }
From source file:edu.cuny.cat.market.matching.LazyMaxVolumeShoutEngine.java
/** * <p>//from w ww . j av a2 s. c o m * Return a list of matched bids and asks. The list is of the form * </p> * <br> * ( b0, a0, b1, a1 .. bn, an )<br> * * <p> * where bi is the ith bid and a0 is the ith ask. A typical auctioneer would * clear by matching bi with ai for all i at some price. * </p> */ @Override public List<Shout> getMatchedShouts() { final ArrayList<Shout> result = new ArrayList<Shout>(sIn.size() + bIn.size()); // prettyPrint("sIn: ", sIn); // prettyPrint("bIn: ", bIn); // // prettyPrint("asks", asks); // prettyPrint("bid", bids); Shout sInTop = null; Shout bInTop = null; final ListIterator<Shout> sItor = sIn.listIterator(); final ListIterator<Shout> bItor = bIn.listIterator(); while (true) { if (sInTop == null) { if (sItor.hasNext()) { sInTop = sItor.next(); if (!asks.remove(sInTop)) { LazyMaxVolumeShoutEngine.logger.fatal("Failed to remove the matched ask !"); LazyMaxVolumeShoutEngine.logger.fatal(sInTop); } // logger.info(sInTop); } else { break; } } if (bInTop == null) { if (bItor.hasNext()) { bInTop = bItor.next(); if (!bids.remove(bInTop)) { LazyMaxVolumeShoutEngine.logger.fatal("Failed to remove the matched bid !"); LazyMaxVolumeShoutEngine.logger.fatal(bInTop); } // logger.info(bInTop); } else { LazyMaxVolumeShoutEngine.logger.fatal("Unempty bInTop expected !"); } } result.add(bInTop); result.add(sInTop); if (bInTop.getPrice() < sInTop.getPrice()) { LazyMaxVolumeShoutEngine.logger.fatal("Wrong match between ask and bid !"); LazyMaxVolumeShoutEngine.logger.fatal(bInTop); LazyMaxVolumeShoutEngine.logger.fatal(sInTop); } final int nS = sInTop.getQuantity(); final int nB = bInTop.getQuantity(); if (nS < nB) { // split the bid bInTop = bInTop.split(nB - nS); sInTop = null; } else if (nB < nS) { // split the ask sInTop = sInTop.split(nS - nB); bInTop = null; } else { bInTop = null; sInTop = null; } } if (bItor.hasNext()) { LazyMaxVolumeShoutEngine.logger .fatal("Inconsistent state of bIn in " + this + ". Empty bItor expected !"); } sIn.clear(); bIn.clear(); // randomize the matching pairs Shout bid, ask; int index; for (int i = result.size() / 2 - 1; i > 0; i--) { // pick a pair to be at the i(th) // TODO: check whether this can lead to mutual access or not. index = uniform.nextIntFromTo(0, i); bid = result.get(i * 2); ask = result.get(i * 2 + 1); result.set(i * 2, result.get(index * 2)); result.set(i * 2 + 1, result.get(index * 2 + 1)); result.set(index * 2, bid); result.set(index * 2 + 1, ask); } return result; }
From source file:chat.viska.commons.pipelines.Pipeline.java
private void processException(ListIterator<Map.Entry<String, Pipe>> iterator, Exception cause, boolean isReading) { while (isReading ? iterator.hasNext() : iterator.hasPrevious()) { final Pipe pipe = isReading ? iterator.next().getValue() : iterator.previous().getValue(); try {/*from www .j ava 2s .c o m*/ if (isReading) { pipe.catchInboundException(this, cause); } else { pipe.catchOutboundException(this, cause); } return; } catch (Exception rethrown) { cause = rethrown; } } triggerEvent(new ExceptionCaughtEvent(this, cause)); }
From source file:chat.viska.commons.pipelines.Pipeline.java
public void addTowardsInboundEnd(final String previous, final String name, final Pipe pipe) { Validate.notBlank(previous);// w w w . j av a 2s.c o m Completable.fromAction(() -> { pipeLock.writeLock().lockInterruptibly(); try { if (getIteratorOf(name) != null) { throw new IllegalArgumentException("Name collision: " + name); } ListIterator<Map.Entry<String, Pipe>> iterator = getIteratorOf(previous); if (iterator == null) { throw new NoSuchElementException(previous); } iterator.next(); iterator.add(new AbstractMap.SimpleImmutableEntry<>(name, pipe)); pipe.onAddedToPipeline(this); } finally { pipeLock.writeLock().unlock(); } }).onErrorComplete().subscribeOn(Schedulers.io()).subscribe(); }
From source file:com.smi.travel.monitor.MonitorAmadeus.java
private void buildMap() { listAmadeus = mAmadeusService.getAmadeusList(); ListIterator<MAmadeus> iterator = listAmadeus.listIterator(); amadeusMap = new HashMap(); while (iterator.hasNext()) { MAmadeus ama = iterator.next(); // System.out.println("Listing " + ama.getName()); amadeusMap.put(ama.getName(), ama); }/*from w ww . j a v a2 s .c o m*/ }
From source file:at.pagu.soldockr.core.query.Criteria.java
/** * get the QueryString used for executing query * /* w ww .j a v a 2 s . com*/ * @return */ public String createQueryString() { StringBuilder query = new StringBuilder(StringUtils.EMPTY); ListIterator<Criteria> chainIterator = this.criteriaChain.listIterator(); while (chainIterator.hasNext()) { Criteria chainedCriteria = chainIterator.next(); query.append(createQueryFragmentForCriteria(chainedCriteria)); if (chainIterator.hasNext()) { query.append(chainIterator.next().getConjunctionOperator()); chainIterator.previous(); } } return query.toString(); }
From source file:chat.viska.commons.pipelines.Pipeline.java
@SchedulerSupport(SchedulerSupport.IO) public Maybe<Pipe> replace(final String name, final Pipe newPipe) { Validate.notBlank(name);//from w ww.ja v a 2 s . c om return Maybe.fromCallable(() -> { pipeLock.writeLock().lockInterruptibly(); final Pipe oldPipe; try { final ListIterator<Map.Entry<String, Pipe>> iterator = getIteratorOf(name); if (iterator == null) { throw new NoSuchElementException(name); } oldPipe = iterator.next().getValue(); iterator.set(new AbstractMap.SimpleImmutableEntry<>(name, newPipe)); oldPipe.onRemovedFromPipeline(this); newPipe.onAddedToPipeline(this); } finally { pipeLock.writeLock().unlock(); } return oldPipe; }).subscribeOn(Schedulers.io()); }