List of usage examples for java.util ArrayDeque ArrayDeque
public ArrayDeque()
From source file:org.codice.ddf.catalog.ui.forms.builder.XmlModelBuilder.java
public XmlModelBuilder(AttributeRegistry registry) { this.logicOpCache = new ArrayDeque<>(); this.depth = new ArrayDeque<>(); this.normalizer = new AttributeValueNormalizer(registry); }
From source file:spout.mddb.MddbFeatureExtractorSpout.java
/** * Called when a task for this component is initialized within a worker on the cluster. * It provides the spout with the environment in which the spout executes. * <p/>/*from w ww . ja v a 2 s . com*/ * <p>This includes the:</p> * * @param conf The Storm configuration for this spout. This is the configuration provided to the topology merged in with cluster configuration on this machine. * @param context This object can be used to pythonDictToJava information about this task's place within the topology, including the task id and component id of this task, input and output information, etc. * @param collector The collector is used to emit tuples from this spout. Tuples can be emitted at any time, including the open and close methods. The collector is thread-safe and should be saved as an instance variable of this spout object. */ @Override public void open(final Map conf, final TopologyContext context, final SpoutOutputCollector collector) { Logger.getAnonymousLogger().log(Level.INFO, MessageFormat.format("Opening {0}", getClass().getCanonicalName())); this.collector = collector; this.taskId = context.getThisTaskId(); this.featureFiles = new ArrayDeque<String>(); SpoutUtils.listFilesForFolder(new File(folder), featureFiles); try { this.peekableScanner = moveSpoutForward(); updateMlStormFieldTemplate(fieldTemplate, peekableScanner.peek().split(FIELD_SEPARATOR).length); } catch (FileNotFoundException e) { throw new IllegalStateException(e); } }
From source file:com.rammelkast.anticheatreloaded.config.yaml.CommentedConfiguration.java
@Override public String saveToString() { yamlOptions.setIndent(options().indent()); yamlOptions.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK); yamlRepresenter.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK); // String header = buildHeader(); - CommentedConfiguration String dump = yaml.dump(getValues(false)); if (dump.equals(BLANK_CONFIG)) { dump = ""; }//from www .j a v a 2s .c om // Begin CommentedConfiguration StringBuilder builder = new StringBuilder(); String[] lines = dump.split("\n"); ArrayDeque<String> queue = new ArrayDeque<String>(); for (String string : lines) { queue.add(string); } int i = 0; while (queue.size() > 0) { if (comments.containsKey(i)) { builder.append(comments.get(i)); // Handle subsequent comments int b = i; while (true) { b++; if (comments.containsKey(b)) { builder.append('\n'); builder.append(comments.get(b)); } else { break; } } builder.append('\n'); i = b; } builder.append(queue.getFirst()); builder.append('\n'); queue.pop(); i++; } // End CommentedConfiguration return builder.toString(); }
From source file:com.espertech.esper.filter.FilterServiceBase.java
protected long evaluateInternal(EventBean theEvent, Collection<FilterHandle> matches, String statementId) { long version = filtersVersion; numEventsEvaluated.incrementAndGet(); ArrayDeque<FilterHandle> allMatches = new ArrayDeque<FilterHandle>(); // Finds all matching filters retryableMatchEvent(theEvent, allMatches); // Add statement matches to collection passed for (FilterHandle match : allMatches) { if (match.getStatementId().equals(statementId)) { matches.add(match);/* w ww . ja v a 2 s . co m*/ } } if ((AuditPath.isAuditEnabled) && (!filterServiceListeners.isEmpty())) { for (FilterServiceListener listener : filterServiceListeners) { listener.filtering(theEvent, matches, statementId); } } return version; }
From source file:com.obomprogramador.tools.jqana.parsers.CycloListener.java
/** * Default constructor.//from w ww . jav a 2s .com * * @param metric * The metric being used for analysis. * @param measurement * The expected measurement to return to the Parser. * @param parser * Instance of JavaParser (ANTLR4) used to get the AST. */ public CycloListener(Metric metric, Measurement measurement, JavaParser parser) { this.metric = metric; this.measurement = measurement; this.parser = parser; this.logger = LoggerFactory.getLogger(this.getClass()); this.measurementsStack = new ArrayDeque<Measurement>(); this.currentMetricValue = this.getMetricValue(this.measurement); if (this.currentMetricValue == null) { throw new IllegalArgumentException("Measurement should have a MetricValue"); } }
From source file:bachelorthesis.captchabuilder.builder.CaptchaBuildSequenceParser.java
/** * Creates new elementCreators from the list CaptchaElementCreatorBuilders * in the CaptchaBuilder./* ww w . j a v a 2 s . co m*/ * * @param builder * <p/> * @throws ParseException */ public static void shortParse(CaptchaBuilder builder) throws ParseException { ArrayDeque<CaptchaElementCreatorBuilder> elementBuilders = builder.getBuilders().clone(); ArrayDeque<BuildSequenceOptions> sequence = new ArrayDeque<>(); for (String lvl1Arg : builder.getBuildSequence().split(CaptchaConstants.buildSequencelvl1Delim)) { if (!lvl1Arg.isEmpty()) { try { String[] optionArgs = lvl1Arg.split(CaptchaConstants.buildSequencelvl2Delim); sequence.offer(BuildSequenceOptions.valueOf(optionArgs[0])); } catch (IllegalArgumentException e) { throw new ParseException(e.getMessage()); } } } for (BuildSequenceOptions buildSequence : sequence) { switch (buildSequence) { case BACKGROUND: { CaptchaElementCreatorBuilder elementBuilder = elementBuilders.poll(); if (elementBuilder instanceof BackgroundProducerBuilder) { builder.addBackground((BackgroundProducer) elementBuilder.create()); } else { throw new ParseException("ShortParse Failed ... How is that possible?\n" + "Class Mismatch: Got " + elementBuilder.getClass().getSimpleName() + " and expected " + BackgroundProducerBuilder.class.getSimpleName()); } } break; case BORDER: { CaptchaElementCreatorBuilder elementBuilder = elementBuilders.poll(); if (elementBuilder instanceof BorderProducerBuilder) { builder.addBorder((BorderProducer) elementBuilder.create()); } else { throw new ParseException("ShortParse Failed ... How is that possible?\n" + "Class Mismatch: Got " + elementBuilder.getClass().getSimpleName() + " and expected " + BorderProducerBuilder.class.getSimpleName()); } } break; case GIMP: { CaptchaElementCreatorBuilder elementBuilder = elementBuilders.poll(); if (elementBuilder instanceof GimpyRendererBuilder) { builder.gimp((GimpyRenderer) elementBuilder.create()); } else { throw new ParseException("ShortParse Failed ... How is that possible?\n" + "Class Mismatch: Got " + elementBuilder.getClass().getSimpleName() + " and expected " + GimpyRendererBuilder.class.getSimpleName()); } } break; case NOISE: { CaptchaElementCreatorBuilder elementBuilder = elementBuilders.poll(); if (elementBuilder instanceof NoiseProducerBuilder) { builder.addNoise((NoiseProducer) elementBuilder.create()); } else { throw new ParseException("ShortParse Failed ... How is that possible?\n" + "Class Mismatch: Got " + elementBuilder.getClass().getSimpleName() + " and expected " + NoiseProducerBuilder.class.getSimpleName()); } } break; case TEXT: { CaptchaElementCreatorBuilder elementBuilder1 = elementBuilders.poll(); CaptchaElementCreatorBuilder elementBuilder2 = elementBuilders.poll(); if (elementBuilder1 instanceof TextProducerBuilder && elementBuilder2 instanceof WordRendererBuilder) { builder.addText((TextProducer) elementBuilder1.create(), (WordRenderer) elementBuilder2.create()); } else { throw new ParseException("ShortParse Failed ... How is that possible?\n" + "Class Mismatch: Got " + elementBuilder1.getClass().getSimpleName() + " and expected " + TextProducerBuilder.class.getSimpleName() + "\n" + "Class Mismatch: Got " + elementBuilder2.getClass().getSimpleName() + " and expected " + WordRendererBuilder.class.getSimpleName()); } } } } }
From source file:com.blackbear.flatworm.config.impl.DefaultAnnotationConfigurationReaderImpl.java
public DefaultAnnotationConfigurationReaderImpl() { fileFormat = new FileFormat(); recordCache = new HashMap<>(); lineCache = new HashMap<>(); lineElementDeque = new ArrayDeque<>(); performValidation = true;//from www . j a va 2 s . c o m onFirstPassFlag = false; }
From source file:io.divolte.server.recordmapping.DslRecordMapping.java
public DslRecordMapping(final Schema schema, final UserAgentParserAndCache uaParser, final Optional<LookupService> geoIpService) { this.schema = Objects.requireNonNull(schema); this.uaParser = Objects.requireNonNull(uaParser); this.geoIpService = Objects.requireNonNull(geoIpService); stack = new ArrayDeque<>(); stack.add(ImmutableList.<MappingAction>builder()); }
From source file:org.commonjava.maven.ext.manip.rest.DefaultVersionTranslator.java
/** * Translate the versions./* www.j a va2 s.c o m*/ * There may be a lot of them, possibly causing timeouts or other issues. * This is mitigated by splitting them into smaller chunks when an error occurs and retrying. */ public Map<ProjectVersionRef, String> translateVersions(List<ProjectVersionRef> projects) { final Map<ProjectVersionRef, String> result = new HashMap<>(); final Queue<Task> queue = new ArrayDeque<>(); queue.add(new Task(pvrm, projects, endpointUrl)); while (!queue.isEmpty()) { Task task = queue.remove(); task.executeTranslate(); if (task.isSuccess()) { result.putAll(task.getResult()); } else { if (task.canSplit()) { if (task.getStatus() < 0) { logger.debug("Caught exception calling server with message {}", task.getErrorMessage()); } else { logger.debug("Did not get status {} but received {}", SC_OK, task.getStatus()); } List<Task> tasks = task.split(); logger.warn( "Failed to translate versions for task @{}, splitting and retrying. Chunk size was: {} and new chunk size {} in {} segments.", task.hashCode(), task.getChunkSize(), tasks.get(0).getChunkSize(), tasks.size()); queue.addAll(tasks); } else { logger.debug("Cannot split and retry anymore."); if (task.getStatus() > 0) { throw new RestException("Received response status " + task.getStatus() + " with message: " + task.getErrorMessage()); } else { throw new RestException("Received response status " + task.getStatus() + " with message " + task.getErrorMessage()); } } } } return result; }