List of usage examples for java.util ArrayList addAll
public boolean addAll(Collection<? extends E> c)
From source file:org.opendatakit.aggregate.odktables.impl.api.wink.AppEngineHandlersFactory.java
@Override public List<? extends ResponseHandler> getResponseHandlers() { ArrayList<ResponseHandler> myHandlers = new ArrayList<ResponseHandler>(); myHandlers.add(new NotModifiedHandler()); myHandlers.addAll(super.getResponseHandlers()); return myHandlers; }
From source file:eu.stratosphere.api.common.operators.util.FieldList.java
@Override public FieldList addFields(FieldSet set) { if (set == null) { throw new IllegalArgumentException("FieldSet to add must not be null."); }/*from w w w. jav a 2 s .co m*/ if (set.size() == 0) { return this; } else if (size() == 0 && set instanceof FieldList) { return (FieldList) set; } else { ArrayList<Integer> list = new ArrayList<Integer>(size() + set.size()); list.addAll(this.collection); list.addAll(set.collection); return new FieldList(Collections.unmodifiableList(list)); } }
From source file:com.star.printer.StarPrinter.java
/** * This function shows how to read the MSR data(credit card) of a portable * printer. The function first puts the printer into MSR read mode, then * asks the user to swipe a credit card The function waits for a response * from the user. The user can cancel MSR mode or have the printer read the * card./*w w w . ja v a2 s . com*/ * * @param context * Activity for displaying messages to the user * @param portName * Port name to use for communication. This should be * (TCP:<IPAddress> or BT:<Device pair name>) * @param portSettings * Should be mini, the port settings mini is used for portable * printers * @param strPrintArea * Printable area size, This should be ("2inch (58mm)" or * "3inch (80mm)") */ public static boolean PrintSignature(Context context, String portName, String portSettings, String strPrintArea, String sigArgs) { ArrayList<byte[]> list = new ArrayList<byte[]>(); ArrayList<byte[]> al = new ArrayList<byte[]>(); if (strPrintArea.equals("3inch (80mm)")) { byte[] outputByteBuffer = null; list = StarPrinter.PrintBitmap(context, portName, portSettings, sigArgs, 576, true, false); al.addAll(list); return sendCommand(context, portName, portSettings, al); // return true; } return false; }
From source file:hrpod.tools.nlp.NLPTools.java
public ArrayList<String> stemmer(ArrayList<String> wordList) { PorterStemmer stemmer = new PorterStemmer(); for (int wl = 0; wl < wordList.size(); wl++) { //logger.info("OLD WORD: " + wordList.get(wl)); ArrayList<String> subWordList = new ArrayList(); subWordList.addAll(Arrays.asList(wordList.get(wl).split(" "))); for (int swl = 0; swl < subWordList.size(); swl++) { String word = subWordList.get(swl); stemmer.setCurrent(word); //set string you need to stem stemmer.stem();/*from w ww.j a v a2s . c o m*/ String stemmedWord = stemmer.getCurrent(); subWordList.set(swl, stemmedWord); } wordList.set(wl, StringUtils.join(subWordList, " ")); //logger.info("NEW WORD: " + wordList.get(wl)); } return wordList; }
From source file:com.thoughtworks.studios.journey.models.ActionsGraph.java
@JsonProperty("links") public Collection<Link> links() { ArrayList<Link> result = new ArrayList<>(links.size()); result.addAll(links.values()); Collections.sort(result);// w w w .j a v a 2s. co m return result; }
From source file:org.openmrs.web.controller.report.ReportDataListController.java
/** * This is called prior to displaying a form for the first time. It tells Spring the * form/command object to load into the request * /*from w w w. ja v a 2s. c o m*/ * @see org.springframework.web.servlet.mvc.AbstractFormController#formBackingObject(javax.servlet.http.HttpServletRequest) */ protected Object formBackingObject(HttpServletRequest request) throws ServletException { String key = ServletRequestUtils.getStringParameter(request, "indicator", "empty"); // If there is no parameter named 'indicator' then return an empty Person stub. if (null == key || "empty".equals(key)) { Person p = new Person(); p.setPersonId(-1); return p; } // Get the ReportData that is in the current Session. ReportData report = (ReportData) request.getSession() .getAttribute(ReportingCompatibilityConstants.OPENMRS_REPORT_DATA); // Extract the Collection<DataSet> from the ReportData and put it into an ArrayList so it is usable. ArrayList<DataSet> cohortDataSets = new ArrayList<DataSet>(); Map<String, DataSet> dataSetMap = report.getDataSets(); cohortDataSets.addAll(dataSetMap.values()); // For each CohortDataSet.cohortData in the DataSet row... Iterator<Map<String, Cohort>> iterator = cohortDataSets.get(0).iterator(); Cohort cohort = null; while (iterator.hasNext()) { Map<String, Cohort> cohortData = iterator.next(); // ... if the cohortData contains the indicator key... if (cohortData.containsKey(key)) { // ... then use that Cohort. cohort = cohortData.get(key); } } // Set the 'patientIds' attribute of the request to the Cohort.personIds Set<Integer> ids = cohort.getMemberIds(); String personIds = ids.toString(); personIds = personIds.replaceAll("\\[", ""); personIds = personIds.replaceAll("\\]", ""); personIds = personIds.replaceAll(", ", ","); personIds = personIds.trim(); request.setAttribute("patientIds", personIds); // return the ReportData return report; }
From source file:eu.stratosphere.api.common.operators.util.FieldList.java
@Override public FieldList addFields(int... fieldIDs) { if (fieldIDs == null || fieldIDs.length == 0) { return this; }/*from w w w. j av a2 s . co m*/ if (size() == 0) { return new FieldList(fieldIDs); } else { ArrayList<Integer> list = new ArrayList<Integer>(size() + fieldIDs.length); list.addAll(this.collection); for (int i = 0; i < fieldIDs.length; i++) { list.add(fieldIDs[i]); } return new FieldList(Collections.unmodifiableList(list)); } }
From source file:com.thoughtworks.studios.journey.models.ActionsGraph.java
@JsonProperty("nodes") public List<GraphNode> nodes() { ArrayList<GraphNode> result = new ArrayList<>(nodes.size()); result.addAll(nodes.values()); Collections.sort(result);// ww w. ja v a2s . c o m return result; }
From source file:com.erudika.scoold.controllers.SearchController.java
@GetMapping({ "/search/{type}/{query}", "/search" }) public String get(@PathVariable(required = false) String type, @PathVariable(required = false) String query, @RequestParam(required = false) String q, HttpServletRequest req, Model model) { List<Profile> userlist = new ArrayList<Profile>(); List<Post> questionlist = new ArrayList<Post>(); List<Post> answerlist = new ArrayList<Post>(); List<Post> feedbacklist = new ArrayList<Post>(); Pager itemcount = utils.getPager("page", req); String queryString = StringUtils.isBlank(q) ? query : q; // [space query filter] + original query string String qs = utils.sanitizeQueryString(queryString, req); String qsUsers = qs.replaceAll("properties\\.space:", "properties.spaces:"); if ("questions".equals(type)) { questionlist = pc.findQuery(Utils.type(Question.class), qs, itemcount); } else if ("answers".equals(type)) { answerlist = pc.findQuery(Utils.type(Reply.class), qs, itemcount); } else if ("feedback".equals(type)) { feedbacklist = pc.findQuery(Utils.type(Feedback.class), queryString, itemcount); } else if ("people".equals(type)) { userlist = pc.findQuery(Utils.type(Profile.class), qsUsers, itemcount); } else {// ww w .j a va 2 s. c o m questionlist = pc.findQuery(Utils.type(Question.class), qs); answerlist = pc.findQuery(Utils.type(Reply.class), qs); feedbacklist = pc.findQuery(Utils.type(Feedback.class), queryString); userlist = pc.findQuery(Utils.type(Profile.class), qsUsers); } ArrayList<Post> list = new ArrayList<Post>(); list.addAll(questionlist); list.addAll(answerlist); list.addAll(feedbacklist); utils.fetchProfiles(list); model.addAttribute("path", "search.vm"); model.addAttribute("title", utils.getLang(req).get("search.title")); model.addAttribute("searchSelected", "navbtn-hover"); model.addAttribute("showParam", type); model.addAttribute("searchQuery", queryString); model.addAttribute("itemcount", itemcount); model.addAttribute("userlist", userlist); model.addAttribute("questionlist", questionlist); model.addAttribute("answerlist", answerlist); model.addAttribute("feedbacklist", feedbacklist); return "base"; }
From source file:com.playhaven.android.req.OpenRequest.java
protected void handleResponse(Context context, String json) { PlayHaven.DID_CALL_OPEN = true;// ww w .java 2 s .c om SharedPreferences pref = PlayHaven.getPreferences(context); SharedPreferences.Editor edit = pref.edit(); // reset SCOUNT edit.putInt(SCOUNT, 1); // reset SSUM edit.putLong(SSUM, 0); // Commit changes edit.commit(); try { String newApiEndpoint = JsonUtil.asString(json, "$.response.prefix"); if (newApiEndpoint != null) { if (!newApiEndpoint.endsWith("/")) newApiEndpoint = newApiEndpoint + "/"; String key = PlayHaven.Config.APIServer.toString(); edit.putString(key, newApiEndpoint); edit.commit(); PlayHaven.d("%s: %s", key, pref.getString(key, "unset")); } } catch (InvalidPathException e) { // no-op } try { if (cache == null) cache = new Cache(context); ArrayList<String> urls = new ArrayList<String>(); urls.addAll(JsonUrlExtractor.getContentTemplates(json)); cache.bulkRequest(new CacheResponseHandler() { @Override public void cacheSuccess(CachedInfo... cachedInfos) { /* no-op, just don't precache */ } @Override public void cacheFail(URL url, PlayHavenException exception) { /* no-op, just don't precache */ } }, urls); } catch (Exception e) { /* no-op, just don't precache */ } try { Boolean locationPermission = JsonUtil.asBoolean(json, "$.response.location_allow_access"); if (locationPermission) { PlayHaven.USE_LOCATION = locationPermission; } } catch (InvalidPathException e) { /* no-op, just catch if location_allow_access is missing */ } try { Integer loadContextLimit = JsonUtil.asInteger(json, "$.response.load_context_limit"); if (loadContextLimit != null) { PlayHaven.LOAD_CONTEXT_LIMIT = loadContextLimit; } } catch (InvalidPathException e) { /* no-op, just catch if location_allow_access is load_context_limit */ } super.handleResponse(context, json); }