List of usage examples for java.util List clear
void clear();
From source file:io.pivotal.kr.load_gen.LineReader.java
public boolean readLines(List<Line> lines) throws IOException { lines.clear(); int idx = 0;//from w ww . jav a2 s .c o m if (rbufIdx > 0) { for (; idx < rbufIdx; idx++) { cbuf[idx] = rbuf[idx]; } } if ((readBytes = reader.read(cbuf, idx, bufSize - idx)) == -1) { if (rbufIdx > 0) { lines.add(new Line(new String(ArrayUtils.subarray(rbuf, 0, rbufIdx)), offset)); } return false; } if (recognizeLineDelimiter(cbuf) == false) { throw new IOException("line delimiter cannot be found !!"); } offsets.clear(); lineElems.clear(); rbufIdx = 0; long len = offset; for (int i = 0; i < idx + readBytes; i++) { rbuf[rbufIdx] = cbuf[i]; if (lineDelimiter.equals("\r\n")) { if (cbuf[i] == '\r') { lineElems.add(new String(ArrayUtils.subarray(rbuf, 0, rbufIdx))); offsets.add(len - rbufIdx); } else if (cbuf[i] == '\n') { rbufIdx = -1; } } else { if (cbuf[i] == '\n') { lineElems.add(new String(ArrayUtils.subarray(rbuf, 0, rbufIdx))); offsets.add(len - rbufIdx); rbufIdx = -1; } } rbufIdx++; len++; } if (lineElems.size() == 0) { return false; } for (int i = 0; i < lineElems.size(); i++) { lines.add(new Line(lineElems.get(i), offsets.get(i))); } offset = len - rbufIdx; return true; }
From source file:com.cse3310.phms.ui.fragments.AppointmentScreenFragment.java
@Override public void onDateSelected(Date date) { if (isAddMode) { // start an activity to add new appointment isAddMode = false;/*www.j av a 2 s.c om*/ Intent intent = new Intent(getActivity(), AddAppointmentActivity_.class); intent.putExtra("date", date); startActivity(intent); } else { // use has not click the add icon i.e. not in add mode final List<Card> cardList = new ArrayList<Card>(); cardList.clear(); // get appointment with the same date as the selected date for (Appointment appointment : mUser.getAppointments()) { if (DateUtils.isSameDay(date, new Date(appointment.getTime()))) { cardList.add(new AppointmentCard(getActivity(), appointment)); } } // open up a dialog with a list of appointments for dates that have appointment if (!cardList.isEmpty()) { Collections.sort(cardList, AppointmentCardComparator.TIME_SORT); CardListDialogFragment_.newInstance(cardList, "Appointments").show(getFragmentManager(), "tag"); } } }
From source file:com.yahoo.glimmer.indexing.VerticalDocument.java
protected void ensureParsed_(Iterator<Relation> relations) throws IOException { // clear fields for (List<String> field : fields) { field.clear(); }//from ww w .ja v a 2 s . c o m while (relations.hasNext()) { Relation relation = relations.next(); String predicate = relation.getPredicate().toString(); // Check if prefix is on blacklist if (RDFDocumentFactory.isOnPredicateBlacklist(predicate)) { factory.incrementCounter(RdfCounters.BLACKLISTED_TRIPLES, 1); continue; } // Determine whether we need to index, and the field int fieldIndex = factory.getFieldIndex(predicate); if (fieldIndex == -1) { factory.incrementCounter(RdfCounters.UNINDEXED_PREDICATE_TRIPLES, 1); continue; } List<String> fieldForPredicate = fields.get(fieldIndex); if (relation.getObject() instanceof Resource || relation.getObject() instanceof BNode) { // Encode the resource URI or bnode ID using the resources hash String objectId; try { objectId = factory.lookupResource(relation.getObject().toString(), true); } catch (ResourceHashLookupException rhle) { factory.incrementCounter(RdfCounters.OBJECT_NOT_IN_HASH, 1); LOG.info("Object not in hash:" + relation.getContext().toString()); continue; } fieldForPredicate.add(objectId); if (predicate.equals(RDF.TYPE.toString())) { // If the predicate is RDF type and the object is a Resource // we use the ontology(if set) // to also index all super types. factory.incrementCounter(RdfCounters.RDF_TYPE_TRIPLES, 1); for (String ancestor : factory.getAncestors(relation.getObject().toString())) { String ancestorId; try { ancestorId = factory.lookupResource(ancestor, true); } catch (ResourceHashLookupException rhle) { factory.incrementCounter(RdfCounters.ANCESTOR_OBJECT_NOT_IN_HASH, 1); LOG.info("Ancestor(" + ancestor + ") of " + relation.getObject().toString() + " not in resources hash function!. Was the same ontology used with the PrepTool?"); continue; } if (ancestorId == null) { throw new IllegalStateException(); } fieldForPredicate.add(ancestorId); } } } else { String object = relation.getObject().toString(); // Iterate over the words of the value FastBufferedReader fbr = new FastBufferedReader(object.toCharArray()); MutableString word = new MutableString(); MutableString nonWord = new MutableString(); while (fbr.next(word, nonWord)) { if (word != null && !word.equals("")) { if (CombinedTermProcessor.getInstance().processTerm(word)) { fieldForPredicate.add(word.toString()); } } } fbr.close(); } factory.incrementCounter(RdfCounters.INDEXED_TRIPLES, 1); } }
From source file:eu.europa.esig.dss.tsl.service.TSLValidator.java
@Override public TSLValidationResult call() throws Exception { CertificateVerifier certificateVerifier = new CommonCertificateVerifier(true); certificateVerifier.setTrustedCertSource(buildTrustedCertificateSource(dssKeyStore, potentialSigners)); DSSDocument dssDocument = new FileDocument(file); XMLDocumentValidator xmlDocumentValidator = new XMLDocumentValidator(dssDocument); xmlDocumentValidator.setCertificateVerifier(certificateVerifier); // To increase the security: the default {@code XPathQueryHolder} is used. List<XPathQueryHolder> xPathQueryHolders = xmlDocumentValidator.getXPathQueryHolder(); xPathQueryHolders.clear(); xPathQueryHolders.add(new XPathQueryHolder()); Reports reports = xmlDocumentValidator.validateDocument(); SimpleReport simpleReport = reports.getSimpleReport(); String indication = simpleReport.getIndication(simpleReport.getFirstSignatureId()); boolean isValid = Indication.VALID.equals(indication); TSLValidationResult result = new TSLValidationResult(); result.setCountryCode(countryCode);//w w w . j a v a 2 s . c o m result.setIndication(indication); result.setSubIndication(simpleReport.getSubIndication(simpleReport.getFirstSignatureId())); if (!isValid) { logger.info("The TSL signature is not valid : \n" + simpleReport.toString()); } return result; }
From source file:edu.uci.ics.asterix.optimizer.rules.RemoveUnusedOneToOneEquiJoinRule.java
private void fillPKVars(DataSourceScanOperator dataScan, List<LogicalVariable> pkVars) { pkVars.clear(); DatasetDataSource datasetDataSource = (DatasetDataSource) dataScan.getDataSource(); pkVars.clear();//from w w w . j a v a 2s . co m if (datasetDataSource.getDataset().getDatasetDetails() instanceof InternalDatasetDetails) { int numPKs = DatasetUtils.getPartitioningKeys(datasetDataSource.getDataset()).size(); for (int i = 0; i < numPKs; i++) { pkVars.add(dataScan.getVariables().get(i)); } } }
From source file:com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.distributed.google.GoogleProviderUtils.java
static private Proxy openSshTunnel(String ip, int port, String keyFile) throws InterruptedException { JobExecutor jobExecutor = DaemonTaskHandler.getJobExecutor(); List<String> command = new ArrayList<>(); // Make sure we don't have an entry for this host already (GCP recycles IPs). command.add("ssh-keygen"); command.add("-R"); command.add(ip);/*w w w. j a v a2s .co m*/ JobRequest request = new JobRequest().setTokenizedCommand(command); JobStatus status = jobExecutor.backoffWait(jobExecutor.startJob(request)); if (status.getResult() != JobStatus.Result.SUCCESS) { if (status.getStdErr().contains("No such file")) { log.info("No ssh known_hosts file exists yet"); } else { throw new HalException(FATAL, "Unable to remove old host entry " + status.getStdErr()); } } int localPort = SocketUtils.findAvailableTcpPort(); command.clear(); command.add("ssh"); command.add("ubuntu@" + ip); command.add("-o"); command.add("StrictHostKeyChecking=no"); command.add("-i"); command.add(keyFile); command.add("-N"); command.add("-L"); command.add(String.format("%d:localhost:%d", localPort, port)); request = new JobRequest().setTokenizedCommand(command); String jobId = jobExecutor.startJob(request); status = jobExecutor.updateJob(jobId); while (status == null) { DaemonTaskHandler.safeSleep(TimeUnit.SECONDS.toMillis(1)); status = jobExecutor.updateJob(jobId); } return new Proxy().setJobId(jobId).setPort(localPort); }
From source file:graph.inference.module.TransitiveWorker.java
/** * Runs the transitive interval module to efficiently compute the solution * to a query./*from w w w . j a v a 2 s . c o m*/ * * @param queryObj * The query to run and store results in. */ private void runIntervalModule(QueryObject queryObj) { // TODO Ensure node is a collection. if (queryObj.isProof()) { // Find the proof and justify it. Collection<DAGNode> result = transIntModule_.execute(true, queryObj.getNode(1), queryObj.getNode(2)); if (result != null) { queryObj.addResult(new Substitution(), queryObj.getNodes()); List<Node[]> justification = queryObj.getJustification(); justification.clear(); justification.addAll(transIntModule_.justifyTransitive((DAGNode) queryObj.getNode(1), (DAGNode) queryObj.getNode(2))); } } else { // Find the results and add them to the query object. boolean upwards = queryObj.getAtomicIndex() == 1; DAGNode baseNode = queryObj.getAtomic(); Collection<DAGNode> transitiveNodes = transIntModule_.execute(upwards, baseNode); if (transitiveNodes == null) return; for (DAGNode n : transitiveNodes) { queryObj.addCompleted(n); Node[] nodes = Arrays.copyOf(queryObj.getNodes(), 3); nodes[queryObj.getVariableIndex()] = n; queryObj.addResult(nodes); } } }
From source file:benedict.zhang.addon.roleplaying.model.RolePlayingConfiguration.java
public void setSpells(List<SpellConfiguration> spells) { List<SpellConfiguration> temp = new ArrayList<>(); temp.clear(); temp.addAll(spells);//from www . j ava 2 s.c o m this.spellList.clear(); this.spellList.addAll(temp); }
From source file:edu.uci.ics.hyracks.algebricks.rewriter.rules.CopyLimitDownRule.java
@Override public boolean rewritePre(Mutable<ILogicalOperator> opRef, IOptimizationContext context) throws AlgebricksException { AbstractLogicalOperator op = (AbstractLogicalOperator) opRef.getValue(); if (op.getOperatorTag() != LogicalOperatorTag.LIMIT) { return false; }//w w w. j a va 2 s.c o m LimitOperator limitOp = (LimitOperator) op; if (!limitOp.isTopmostLimitOp()) { return false; } List<LogicalVariable> limitUsedVars = new ArrayList<>(); VariableUtilities.getUsedVariables(limitOp, limitUsedVars); Mutable<ILogicalOperator> safeOpRef = null; Mutable<ILogicalOperator> candidateOpRef = limitOp.getInputs().get(0); List<LogicalVariable> candidateProducedVars = new ArrayList<>(); while (true) { candidateProducedVars.clear(); ILogicalOperator candidateOp = candidateOpRef.getValue(); LogicalOperatorTag candidateOpTag = candidateOp.getOperatorTag(); if (candidateOp.getInputs().size() > 1 || !candidateOp.isMap() || candidateOpTag == LogicalOperatorTag.SELECT || candidateOpTag == LogicalOperatorTag.LIMIT || !OperatorPropertiesUtil.disjoint(limitUsedVars, candidateProducedVars)) { break; } safeOpRef = candidateOpRef; candidateOpRef = safeOpRef.getValue().getInputs().get(0); } if (safeOpRef != null) { ILogicalOperator safeOp = safeOpRef.getValue(); Mutable<ILogicalOperator> unsafeOpRef = safeOp.getInputs().get(0); ILogicalOperator unsafeOp = unsafeOpRef.getValue(); LimitOperator limitCloneOp = null; if (limitOp.getOffset().getValue() == null) { limitCloneOp = new LimitOperator(limitOp.getMaxObjects().getValue(), false); } else { IFunctionInfo finfoAdd = context.getMetadataProvider() .lookupFunction(AlgebricksBuiltinFunctions.NUMERIC_ADD); List<Mutable<ILogicalExpression>> addArgs = new ArrayList<>(); addArgs.add(new MutableObject<ILogicalExpression>( limitOp.getMaxObjects().getValue().cloneExpression())); addArgs.add( new MutableObject<ILogicalExpression>(limitOp.getOffset().getValue().cloneExpression())); ScalarFunctionCallExpression maxPlusOffset = new ScalarFunctionCallExpression(finfoAdd, addArgs); limitCloneOp = new LimitOperator(maxPlusOffset, false); } limitCloneOp.setPhysicalOperator(new StreamLimitPOperator()); limitCloneOp.getInputs().add(new MutableObject<ILogicalOperator>(unsafeOp)); limitCloneOp.setExecutionMode(unsafeOp.getExecutionMode()); limitCloneOp.recomputeSchema(); unsafeOpRef.setValue(limitCloneOp); context.computeAndSetTypeEnvironmentForOperator(limitCloneOp); context.addToDontApplySet(this, limitOp); } return safeOpRef != null; }
From source file:com.epam.ta.reportportal.core.configs.MvcConfig.java
@Override public void configureMessageConverters(List<HttpMessageConverter<?>> converters) { converters.clear(); converters.add(jsonConverter());//from www. jav a 2 s . c o m }