List of usage examples for java.util List clear
void clear();
From source file:com.bb.extensions.plugin.unittests.internal.utilities.FileUtils.java
/** * Finds all the files in the given folder. * /*from w w w .j av a 2s. c o m*/ * @param folder * The folder to search * @return The list of files found. */ public static List<IFile> findFiles(IFolder folder) { final List<IFile> files = new ArrayList<IFile>(); try { folder.accept(new IResourceVisitor() { /* * (non-Javadoc) * * @see org.eclipse.core.resources.IResourceVisitor#visit(org * .eclipse .core.resources.IResource) */ @Override public boolean visit(IResource res) throws CoreException { if (res.getType() == IResource.FILE) { files.add((IFile) res); return false; } return true; } }); } catch (CoreException e1) { // on exception, return nothing files.clear(); } return files; }
From source file:org.cbio.portal.pipelines.foundation.FusionDataWriter.java
@Override public void write(List<? extends CompositeResultBean> items) throws Exception { writeList.clear(); List<String> writeList = new ArrayList<String>(); for (CompositeResultBean resultList : items) { for (String result : resultList.getFusionDataResult().split("\n")) { if (!Strings.isNullOrEmpty(result)) { writeList.add(result);//from w w w. java 2 s .co m } } } flatFileItemWriter.write(writeList); }
From source file:com.espertech.esper.regression.pattern.TestFollowedByMaxEnginePool.java
private static void assertContextEnginePool(EPServiceProvider epService, EPStatement stmt, List<ConditionHandlerContext> contexts, int max, Map<String, Long> counts) { assertEquals(1, contexts.size());//from w ww . ja v a2s. c o m ConditionHandlerContext context = contexts.get(0); assertEquals(epService.getURI(), context.getEngineURI()); assertEquals(stmt.getText(), context.getEpl()); assertEquals(stmt.getName(), context.getStatementName()); ConditionPatternEngineSubexpressionMax condition = (ConditionPatternEngineSubexpressionMax) context .getEngineCondition(); assertEquals(max, condition.getMax()); assertEquals(counts.size(), condition.getCounts().size()); for (Map.Entry<String, Long> expected : counts.entrySet()) { assertEquals("failed for key " + expected.getKey(), expected.getValue(), condition.getCounts().get(expected.getKey())); } contexts.clear(); }
From source file:com.baasbox.controllers.Push.java
public static Result sendUsers() throws Exception { boolean verbose = false; try {// w ww. ja v a 2s . com if (BaasBoxLogger.isTraceEnabled()) BaasBoxLogger.trace("Method Start"); PushLogger pushLogger = PushLogger.getInstance().init(); if (UserService.isAnAdmin(DbHelper.currentUsername())) { pushLogger.enable(); } else { pushLogger.disable(); } if (request().getQueryString("verbose") != null && request().getQueryString("verbose").equalsIgnoreCase("true")) verbose = true; Http.RequestBody body = request().body(); JsonNode bodyJson = body.asJson(); //{"message":"Text"} if (BaasBoxLogger.isTraceEnabled()) BaasBoxLogger.trace("send bodyJson: " + bodyJson); if (bodyJson == null) return status(CustomHttpCode.JSON_PAYLOAD_NULL.getBbCode(), CustomHttpCode.JSON_PAYLOAD_NULL.getDescription()); pushLogger.addMessage("Payload received: %s", bodyJson.toString()); JsonNode messageNode = bodyJson.findValue("message"); pushLogger.addMessage("Payload message received: %s", messageNode == null ? "null" : messageNode.asText()); if (messageNode == null) return status(CustomHttpCode.PUSH_MESSAGE_INVALID.getBbCode(), CustomHttpCode.PUSH_MESSAGE_INVALID.getDescription()); if (!messageNode.isTextual()) return status(CustomHttpCode.PUSH_MESSAGE_INVALID.getBbCode(), CustomHttpCode.PUSH_MESSAGE_INVALID.getDescription()); String message = messageNode.asText(); JsonNode usernamesNodes = bodyJson.get("users"); pushLogger.addMessage("users: %s", usernamesNodes == null ? "null" : usernamesNodes.toString()); List<String> usernames = new ArrayList<String>(); if (!(usernamesNodes == null)) { if (!(usernamesNodes.isArray())) return status(CustomHttpCode.PUSH_USERS_FORMAT_INVALID.getBbCode(), CustomHttpCode.PUSH_USERS_FORMAT_INVALID.getDescription()); for (JsonNode usernamesNode : usernamesNodes) { usernames.add(usernamesNode.asText()); } HashSet<String> hs = new HashSet<String>(); hs.addAll(usernames); usernames.clear(); usernames.addAll(hs); pushLogger.addMessage("Users extracted: %s", Joiner.on(",").join(usernames)); } else { return status(CustomHttpCode.PUSH_NOTFOUND_KEY_USERS.getBbCode(), CustomHttpCode.PUSH_NOTFOUND_KEY_USERS.getDescription()); } JsonNode pushProfilesNodes = bodyJson.get("profiles"); pushLogger.addMessage("profiles: %s", pushProfilesNodes == null ? "null" : pushProfilesNodes.toString()); List<Integer> pushProfiles = new ArrayList<Integer>(); if (!(pushProfilesNodes == null)) { if (!(pushProfilesNodes.isArray())) return status(CustomHttpCode.PUSH_PROFILE_FORMAT_INVALID.getBbCode(), CustomHttpCode.PUSH_PROFILE_FORMAT_INVALID.getDescription()); for (JsonNode pushProfileNode : pushProfilesNodes) { if (pushProfileNode.isTextual()) return status(CustomHttpCode.PUSH_PROFILE_FORMAT_INVALID.getBbCode(), CustomHttpCode.PUSH_PROFILE_FORMAT_INVALID.getDescription()); pushProfiles.add(pushProfileNode.asInt()); } HashSet<Integer> hs = new HashSet<Integer>(); hs.addAll(pushProfiles); pushProfiles.clear(); pushProfiles.addAll(hs); } else { pushProfiles.add(1); } pushLogger.addMessage("Profiles computed: %s", Joiner.on(",").join(pushProfiles)); boolean[] withError = new boolean[6]; PushService ps = new PushService(); Result toRet = null; try { boolean isValid = (ps.validate(pushProfiles)); pushLogger.addMessage("Profiles validation: %s", isValid); if (isValid) withError = ps.send(message, usernames, pushProfiles, bodyJson, withError); pushLogger.addMessage("Service result: %s", Booleans.join(", ", withError)); } catch (UserNotFoundException e) { return notFound("Username not found"); } catch (SqlInjectionException e) { return badRequest("The supplied name appears invalid (Sql Injection Attack detected)"); } catch (PushNotInitializedException e) { BaasBoxLogger.error(ExceptionUtils.getMessage(e)); return status(CustomHttpCode.PUSH_CONFIG_INVALID.getBbCode(), CustomHttpCode.PUSH_CONFIG_INVALID.getDescription()); } catch (PushProfileDisabledException e) { BaasBoxLogger.error(ExceptionUtils.getMessage(e)); return status(CustomHttpCode.PUSH_PROFILE_DISABLED.getBbCode(), CustomHttpCode.PUSH_PROFILE_DISABLED.getDescription()); } catch (PushProfileInvalidException e) { BaasBoxLogger.error(ExceptionUtils.getMessage(e)); return status(CustomHttpCode.PUSH_PROFILE_FORMAT_INVALID.getBbCode(), CustomHttpCode.PUSH_PROFILE_FORMAT_INVALID.getDescription()); } catch (PushInvalidApiKeyException e) { BaasBoxLogger.error(ExceptionUtils.getMessage(e)); return status(CustomHttpCode.PUSH_INVALID_APIKEY.getBbCode(), CustomHttpCode.PUSH_INVALID_APIKEY.getDescription()); } catch (UnknownHostException e) { BaasBoxLogger.error(ExceptionUtils.getMessage(e)); return status(CustomHttpCode.PUSH_HOST_UNREACHABLE.getBbCode(), CustomHttpCode.PUSH_HOST_UNREACHABLE.getDescription()); } catch (InvalidRequestException e) { BaasBoxLogger.error(ExceptionUtils.getMessage(e)); return status(CustomHttpCode.PUSH_INVALID_REQUEST.getBbCode(), CustomHttpCode.PUSH_INVALID_REQUEST.getDescription()); } catch (IOException e) { BaasBoxLogger.error(ExceptionUtils.getMessage(e)); return badRequest(ExceptionUtils.getMessage(e)); } catch (PushSoundKeyFormatException e) { BaasBoxLogger.error(ExceptionUtils.getMessage(e)); return status(CustomHttpCode.PUSH_SOUND_FORMAT_INVALID.getBbCode(), CustomHttpCode.PUSH_SOUND_FORMAT_INVALID.getDescription()); } catch (PushBadgeFormatException e) { BaasBoxLogger.error(ExceptionUtils.getMessage(e)); return status(CustomHttpCode.PUSH_BADGE_FORMAT_INVALID.getBbCode(), CustomHttpCode.PUSH_BADGE_FORMAT_INVALID.getDescription()); } catch (PushActionLocalizedKeyFormatException e) { BaasBoxLogger.error(ExceptionUtils.getMessage(e)); return status(CustomHttpCode.PUSH_ACTION_LOCALIZED_KEY_FORMAT_INVALID.getBbCode(), CustomHttpCode.PUSH_ACTION_LOCALIZED_KEY_FORMAT_INVALID.getDescription()); } catch (PushLocalizedKeyFormatException e) { BaasBoxLogger.error(ExceptionUtils.getMessage(e)); return status(CustomHttpCode.PUSH_LOCALIZED_KEY_FORMAT_INVALID.getBbCode(), CustomHttpCode.PUSH_LOCALIZED_ARGUMENTS_FORMAT_INVALID.getDescription()); } catch (PushLocalizedArgumentsFormatException e) { BaasBoxLogger.error(ExceptionUtils.getMessage(e)); return status(CustomHttpCode.PUSH_LOCALIZED_ARGUMENTS_FORMAT_INVALID.getBbCode(), CustomHttpCode.PUSH_LOCALIZED_ARGUMENTS_FORMAT_INVALID.getDescription()); } catch (PushCollapseKeyFormatException e) { BaasBoxLogger.error(ExceptionUtils.getMessage(e)); return status(CustomHttpCode.PUSH_COLLAPSE_KEY_FORMAT_INVALID.getBbCode(), CustomHttpCode.PUSH_COLLAPSE_KEY_FORMAT_INVALID.getDescription()); } catch (PushTimeToLiveFormatException e) { BaasBoxLogger.error(ExceptionUtils.getMessage(e)); return status(CustomHttpCode.PUSH_TIME_TO_LIVE_FORMAT_INVALID.getBbCode(), CustomHttpCode.PUSH_TIME_TO_LIVE_FORMAT_INVALID.getDescription()); } catch (PushContentAvailableFormatException e) { BaasBoxLogger.error(ExceptionUtils.getMessage(e)); return status(CustomHttpCode.PUSH_CONTENT_AVAILABLE_FORMAT_INVALID.getBbCode(), CustomHttpCode.PUSH_CONTENT_AVAILABLE_FORMAT_INVALID.getDescription()); } catch (PushCategoryFormatException e) { BaasBoxLogger.error(ExceptionUtils.getMessage(e)); return status(CustomHttpCode.PUSH_CATEGORY_FORMAT_INVALID.getBbCode(), CustomHttpCode.PUSH_CATEGORY_FORMAT_INVALID.getDescription()); } if (BaasBoxLogger.isTraceEnabled()) BaasBoxLogger.trace("Method End"); for (int i = 0; i < withError.length; i++) { if (withError[i] == true) return status(CustomHttpCode.PUSH_SENT_WITH_ERROR.getBbCode(), CustomHttpCode.PUSH_SENT_WITH_ERROR.getDescription()); } PushLogger.getInstance().messages(); if (UserService.isAnAdmin(DbHelper.currentUsername()) && verbose) { return ok(toJson(PushLogger.getInstance().messages())); } else { return ok("Push Notification(s) has been sent"); } } finally { if (UserService.isAnAdmin(DbHelper.currentUsername()) && verbose) { return ok(toJson(PushLogger.getInstance().messages())); } BaasBoxLogger.debug("Push execution flow:\n{}", PushLogger.getInstance().toString()); } }
From source file:dbconverter.dao.util.Utils.java
/** * Method will take a File that contains SQL data and extract the data into * a String object that can be passed to a ResultSet object * * @param queryFileName// w w w . j av a2 s . c o m * @return String object from a SQL file */ public String readQueryFile(String queryFileName) { assert queryFileName != null : "queryFileName cannont be null"; StringBuilder queryBuilder = new StringBuilder(); String query = null; InputStream input = null; try { input = new FileInputStream(queryFileName); List<String> queryLines = new ArrayList<>(); queryLines.clear(); queryLines.addAll(IOUtils.readLines(input)); if (!queryLines.isEmpty()) { for (String queryLine : queryLines) { queryBuilder.append(queryLine).append("\n"); } } } catch (FileNotFoundException ex) { //Logger.getLogger(OracleDAO.class.getName()).log(Level.SEVERE, null, ex); logger.error(queryFileName + " could not be found", ex); } catch (IOException ioe) { logger.error("There was a problem with the file " + queryFileName, ioe); } finally { if (input != null) { try { input.close(); } catch (IOException ex) { logger.error("There was a problem with the file " + queryFileName, ex); } } } //InputStream input = new URL(queryFileName).openStream(); query = queryBuilder.toString(); return query; }
From source file:org.cbio.portal.pipelines.foundation.MutationDataWriter.java
@Override public void write(List<? extends CompositeResultBean> items) throws Exception { writeList.clear(); List<String> writeList = new ArrayList<>(); for (CompositeResultBean resultList : items) { for (String result : resultList.getMutationDataResult().split("\n")) { if (!Strings.isNullOrEmpty(result)) { writeList.add(result);/*from w w w . java2s.com*/ } } } flatFileItemWriter.write(writeList); }
From source file:blue.lapis.pore.impl.event.server.PoreTabCompleteEvent.java
@Override public void setCompletions(List<String> completions) { Validate.notNull(completions);// w ww .j a va2 s . c om List<String> eventCompletions = getHandle().getTabCompletions(); eventCompletions.clear(); eventCompletions.addAll(completions); }
From source file:com.meltmedia.cadmium.servlets.BasicFileServlet.java
public static List<String> parseETagList(String value) { List<String> etags = new ArrayList<String>(); value = value.trim();/*from w w w .j ava 2 s . c om*/ if ("*".equals(value)) { etags.add(value); } else { Matcher etagMatcher = etagPattern.matcher(value); while (etagMatcher.lookingAt()) { etags.add(unescapePattern.matcher(etagMatcher.group(2)).replaceAll("$1")); etagMatcher.region(etagMatcher.start() + etagMatcher.group().length(), value.length()); } if (!etagMatcher.hitEnd()) { etags.clear(); } } return etags; }
From source file:com.redhat.persistence.oql.MultiMap.java
void clear() { m_keys.clear();//from www .j av a 2 s .c om for (Iterator it = m_values.entrySet().iterator(); it.hasNext();) { Map.Entry me = (Map.Entry) it.next(); List values = (List) me.getValue(); values.clear(); m_free.add(values); it.remove(); } m_size = 0; }
From source file:edu.uci.ics.hyracks.algebricks.rewriter.rules.ConsolidateAssignsRule.java
@Override public boolean rewritePost(Mutable<ILogicalOperator> opRef, IOptimizationContext context) throws AlgebricksException { AbstractLogicalOperator op = (AbstractLogicalOperator) opRef.getValue(); if (op.getOperatorTag() != LogicalOperatorTag.ASSIGN) { return false; }/*from w w w. ja va 2 s. c om*/ AssignOperator assign1 = (AssignOperator) op; AbstractLogicalOperator op2 = (AbstractLogicalOperator) assign1.getInputs().get(0).getValue(); if (op2.getOperatorTag() != LogicalOperatorTag.ASSIGN) { return false; } AssignOperator assign2 = (AssignOperator) op2; HashSet<LogicalVariable> used1 = new HashSet<LogicalVariable>(); VariableUtilities.getUsedVariables(assign1, used1); for (LogicalVariable v2 : assign2.getVariables()) { if (used1.contains(v2)) { return false; } } assign1.getVariables().addAll(assign2.getVariables()); assign1.getExpressions().addAll(assign2.getExpressions()); Mutable<ILogicalOperator> botOpRef = assign2.getInputs().get(0); List<Mutable<ILogicalOperator>> asgnInpList = assign1.getInputs(); asgnInpList.clear(); asgnInpList.add(botOpRef); context.computeAndSetTypeEnvironmentForOperator(assign1); return true; }