List of usage examples for java.util ListIterator hasNext
boolean hasNext();
From source file:br.com.ingenieux.mojo.beanstalk.env.ReplaceEnvironmentMojo.java
/** * Prior to Launching a New Environment, lets look and copy the most we can * * @param curEnv current environment// w w w . java 2s . co m */ private void copyOptionSettings(EnvironmentDescription curEnv) throws Exception { /** * Skip if we don't have anything */ if (null != this.optionSettings && this.optionSettings.length > 0) { return; } DescribeConfigurationSettingsResult configSettings = getService() .describeConfigurationSettings(new DescribeConfigurationSettingsRequest() .withApplicationName(applicationName).withEnvironmentName(curEnv.getEnvironmentName())); List<ConfigurationOptionSetting> newOptionSettings = new ArrayList<ConfigurationOptionSetting>( configSettings.getConfigurationSettings().get(0).getOptionSettings()); ListIterator<ConfigurationOptionSetting> listIterator = newOptionSettings.listIterator(); while (listIterator.hasNext()) { ConfigurationOptionSetting curOptionSetting = listIterator.next(); boolean bInvalid = harmfulOptionSettingP(curEnv.getEnvironmentId(), curOptionSetting); if (bInvalid) { getLog().info(format("Excluding Option Setting: %s:%s['%s']", curOptionSetting.getNamespace(), curOptionSetting.getOptionName(), CredentialsUtil.redact(curOptionSetting.getValue()))); listIterator.remove(); } else { getLog().info(format("Including Option Setting: %s:%s['%s']", curOptionSetting.getNamespace(), curOptionSetting.getOptionName(), CredentialsUtil.redact(curOptionSetting.getValue()))); } } Object __secGroups = project.getProperties().get("beanstalk.securityGroups"); if (null != __secGroups) { String securityGroups = StringUtils.defaultString(__secGroups.toString()); if (!StringUtils.isBlank(securityGroups)) { ConfigurationOptionSetting newOptionSetting = new ConfigurationOptionSetting( "aws:autoscaling:launchconfiguration", "SecurityGroups", securityGroups); newOptionSettings.add(newOptionSetting); getLog().info(format("Including Option Setting: %s:%s['%s']", newOptionSetting.getNamespace(), newOptionSetting.getOptionName(), newOptionSetting.getValue())); } } /* * Then copy it back */ this.optionSettings = newOptionSettings.toArray(new ConfigurationOptionSetting[newOptionSettings.size()]); }
From source file:com.nuodb.migrator.cli.parse.parser.ParserImpl.java
/** * Parse the withConnection.arguments according to the specified options and properties. * * @param arguments to parse.// ww w .j av a 2s . c o m * @param option sets the option to parse against. * @return the option setValue object. */ public OptionSet parse(String[] arguments, Option option) throws OptionException { if (logger.isTraceEnabled()) { logger.trace(format("Parsing options %s", join(asList(arguments), " "))); } List<String> list = Lists.newArrayList(arguments); CommandLine commandLine = new CommandLineImpl(option, list); // pick up any defaults from the meta option.defaults(commandLine); // withConnection the options as far as possible ListIterator<String> iterator = list.listIterator(); Object previous = null; while (option.canProcess(commandLine, iterator)) { // peek at the next item and backtrack String current = iterator.next(); iterator.previous(); // if we have just tried to process this instance if (current == previous) { // abort break; } previous = current; option.preProcess(commandLine, iterator); option.process(commandLine, iterator); } if (iterator.hasNext()) { throw new OptionException(format("Unexpected argument %s", iterator.next()), option); } option.postProcess(commandLine); return commandLine; }
From source file:com.amalto.core.history.accessor.record.DataRecordAccessor.java
@SuppressWarnings({ "unchecked", "rawtypes" }) @Override/*from ww w . j a v a 2s. c om*/ public void insert() { try { if (!exist()) { create(); } else { DataRecord current = dataRecord; ListIterator<PathElement> elements = getPath(dataRecord, path).listIterator(); PathElement pathElement = null; while (elements.hasNext()) { pathElement = elements.next(); if (!elements.hasNext()) { break; } if (pathElement.field instanceof ContainedTypeFieldMetadata) { Object o = current.get(pathElement.field); if (pathElement.field.isMany()) { List list = (List) o; current = (DataRecord) list.get(pathElement.index); } else { current = (DataRecord) o; } } } if (pathElement != null && pathElement.field.isMany()) { List list = (List) current.get(pathElement.field); list.add(pathElement.index, null); } } } finally { cachedExist = true; } }
From source file:org.generationcp.breeding.manager.crossingmanager.MakeCrossesTableComponent.java
/** * Crosses each item on first list with its counterpart (same index or position) * on second list. Assumes that checking if list sizes are equal was done beforehand. * The generated crossings are then added to Crossings Table. * //www . ja v a 2 s .c om * @param parents1 - list of GermplasmList entries as first parents * @param parents2 - list of GermplasmList entries as second parents * @param listnameMaleParent * @param listnameFemaleParent */ public void makeTopToBottomCrosses(List<GermplasmListEntry> parents1, List<GermplasmListEntry> parents2, Label listnameFemaleParent, Label listnameMaleParent) { ListIterator<GermplasmListEntry> iterator1 = parents1.listIterator(); ListIterator<GermplasmListEntry> iterator2 = parents2.listIterator(); tableCrossesMade .setVisibleColumns(new Object[] { PARENTAGE, FEMALE_PARENT_COLUMN, MALE_PARENT_COLUMN, SOURCE }); while (iterator1.hasNext()) { GermplasmListEntry parent1 = iterator1.next(); GermplasmListEntry parent2 = iterator2.next(); String caption1 = parent1.getDesignation(); String caption2 = parent2.getDesignation(); String caption3 = listnameFemaleParent.getValue().toString() + ":" + parent1.getEntryId() + "/" + listnameMaleParent.getValue().toString() + ":" + parent2.getEntryId(); CrossParents parents = new CrossParents(parent1, parent2); if (!crossAlreadyExists(parents)) { tableCrossesMade.addItem( new Object[] { CrossingManagerUtil.generateFemaleandMaleCrossName(caption1, caption2), caption1, caption2, caption3 }, parents); } } this.crossesMadeCountContainer.setCaption("Total Crosses: " + tableCrossesMade.size()); tableCrossesMade.setVisibleColumns(new Object[] { PARENTAGE, FEMALE_PARENT_COLUMN, MALE_PARENT_COLUMN }); tableCrossesMade.setPageLength(0); tableCrossesMade.requestRepaint(); }
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 w ww. j av a 2 s .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:com.smi.travel.monitor.MonitorGalileo.java
@Override void buildBookingFlight(BookingAirline bAir) { MGalileo flightNumber = galileoMap.get("flight number"); String section = flightNumber.getSection(); MGalileo source = galileoMap.get("source"); MGalileo destination = galileoMap.get("destination"); MGalileo departureDate = galileoMap.get("departure date"); MGalileo arrivalDate = galileoMap.get("arrive date"); MGalileo ticketDate = galileoMap.get("ticket date"); MGalileo deptTime = galileoMap.get("departure time"); MGalileo arrvTime = galileoMap.get("arrive time"); int lineNo = Integer.parseInt(ticketDate.getLine()); String lineT = lineData.get(lineNo); String ticketDateS = lineT.substring(ticketDate.getStartlength() - 1, ticketDate.getStartlength() - 1 + ticketDate.getLength()); String year = ticketDateS.substring(5); //Check how many rows there is. ArrayList<String> lines = (ArrayList<String>) sectionData.get(section); ListIterator<String> iterator = lines.listIterator(); BookingFlight bf = null;/*ww w .java 2s .c om*/ while (iterator.hasNext()) { String line = iterator.next(); System.out.println("BookingFlingt input line[" + line + "]"); String flightNo = bAir.getAirlineCode() + getField("flight number", line).trim(); // String flightNo = line.substring(flightNumber.getStartlength() - 1, flightNumber.getStartlength() - 1 + flightNumber.getLength()); String sourceCode = line.substring(source.getStartlength() - 1, source.getStartlength() - 1 + source.getLength()); String desCode = line.substring(destination.getStartlength() - 1, destination.getStartlength() - 1 + destination.getLength()); String deptDateS = line.substring(departureDate.getStartlength() - 1, departureDate.getStartlength() - 1 + departureDate.getLength()); String arrivalDateS = line.substring(arrivalDate.getStartlength() - 1, arrivalDate.getStartlength() - 1 + arrivalDate.getLength()); // String deptTimeS = line.substring(deptTime.getStartlength() - 1, deptTime.getStartlength() - 1 + deptTime.getLength()); String deptTimeS = getField("departure time", line); String arrvTimeS = line.substring(arrvTime.getStartlength() - 1, arrvTime.getStartlength() - 1 + arrvTime.getLength()); Date deptDate = convertStringToDate(deptDateS + year); Date arrvDate = convertStringToDate(deptDateS + year, Integer.parseInt(arrivalDateS)); String flightClass = getField("flight class", line); bf = new BookingFlight(flightNo, sourceCode, desCode, deptDate, arrvDate, flightClass); bf.setDepartTime(deptTimeS); bf.setArriveTime(arrvTimeS); bf.setAdCost(0); bf.setAdPrice(0); bf.setAdTax(0); bf.setChCost(0); bf.setChPrice(0); bf.setChTax(0); bf.setInCost(0); bf.setInPrice(0); bf.setInTax(0); bf.setOtCost(0); bf.setOtPrice(0); bf.setOtTax(0); bAir.getBookingFlights().add(bf); bf.setBookingAirline(bAir); // System.out.println("Build BookingFlight - " + bf.toString()); } return; }
From source file:vteaexploration.plottools.panels.XYChartPanel.java
private double getRangeofData(ArrayList alVolumes, int x) { ListIterator litr = alVolumes.listIterator(); ArrayList<Number> al = new ArrayList<Number>(); Number low = 0;/*from w w w. j av a 2 s . co m*/ Number high = 0; Number test; while (litr.hasNext()) { try { MicroObjectModel volume = (MicroObjectModel) litr.next(); Number Corrected = processPosition(x, volume); al.add(Corrected); if (Corrected.floatValue() < low.floatValue()) { low = Corrected; } if (Corrected.floatValue() > high.floatValue()) { high = Corrected; } } catch (NullPointerException e) { } } return high.longValue() - low.longValue(); }
From source file:com.projity.pm.assignment.HasAssignmentsImpl.java
public void updateAssignment(Assignment modified) { ListIterator i = assignments.listIterator(); Assignment current = null;/*from ww w . j a v a 2 s. c o m*/ while (i.hasNext()) { current = (Assignment) i.next(); if (current.getTask() == modified.getTask() && current.getResource() == modified.getResource()) { i.set(modified); // replace current with new one break; } } }
From source file:com.adobe.acs.commons.httpcache.engine.impl.HttpCacheEngineImpl.java
@Activate protected void activate(Map<String, Object> configs) { // PIDs of global cache handling rules. globalCacheHandlingRulesPid = new ArrayList<String>(Arrays.asList( PropertiesUtil.toStringArray(configs.get(PROP_GLOBAL_CACHE_HANDLING_RULES_PID), new String[] {}))); ListIterator<String> listIterator = globalCacheHandlingRulesPid.listIterator(); while (listIterator.hasNext()) { String value = listIterator.next(); if (StringUtils.isBlank(value)) { listIterator.remove();/* ww w .j a v a2 s.co m*/ } } log.info("HttpCacheEngineImpl activated."); }
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); }// ww w . j a va 2s .c o m } // 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); } }