List of usage examples for java.util List toString
public String toString()
From source file:com.sesnu.orion.config.AccessInterceptor.java
private static String insertId(String sql, List<Long> allowedOrderRefs, String tableName) { String key = "order_ref"; if (tableName.equals("orders") || tableName.equals("order_view")) { key = "id"; }//from ww w. j a va 2 s .c om String inClause = allowedOrderRefs.toString().replace("[", "(").replace("]", ")"); if (sql.indexOf("where") > 0) { String p1 = sql.substring(0, sql.indexOf("where") + 5); String p2 = sql.substring(sql.indexOf("where") + 5, sql.length()); return p1 + " " + key + " in " + inClause + (p2.trim().isEmpty() ? "" : " and " + p2); } else { String tnm = getTableName(sql); String p1 = sql.substring(0, sql.indexOf(tnm) + tnm.length()); String p2 = sql.substring(sql.indexOf(tnm) + tnm.length(), sql.length()); return p1 + " where " + key + " in " + inClause + (p2.trim().isEmpty() ? "" : " " + p2); } }
From source file:edu.cornell.mannlib.vitro.webapp.controller.json.JsonServlet.java
public static JSONObject getSearchIndividualsByVClasses(List<String> vclassURIs, HttpServletRequest req) throws Exception { VitroRequest vreq = new VitroRequest(req); log.debug("Retrieve search results for vclasses" + vclassURIs.toString()); IndividualListResults vcResults = getSearchVClassIntersectionResults(vclassURIs, vreq); log.debug("Results returned from search engine for " + vclassURIs.toString() + " are of size " + vcResults.getTotalCount()); return IndividualListResultsUtils.wrapIndividualListResultsInJson(vcResults, vreq, true); }
From source file:org.cloudfoundry.maven.common.CommonUtils.java
/** * Convert a List of CloudServices to a comma delimited String using their names. * * @param list/*from w ww .jav a2 s . com*/ * @return Returns the List as a comma delimited String. Returns an empty * String for a Null or empty list. */ public static String collectionServicesToCommaDelimitedString(Collection<? extends CloudService> list) { if (list == null || list.isEmpty()) { return ""; } List<String> sb = new ArrayList<String>(); for (CloudService service : list) { sb.add(service.getName()); } return sb.toString(); }
From source file:com.innoq.ldap.connector.Utils.java
private static void showConfigInfo() { StringBuilder sb = new StringBuilder("\n"); sb.append("------------------------------------------------------------------------\n"); sb.append("CONFIGURATION:\n"); sb.append("------------------------------------------------------------------------\n"); sb.append(" Version:\t").append(Configuration.getInstance().getVersion()).append("\n"); sb.append(" File:\t").append(Configuration.getInstance().getFilename()).append("\n"); sb.append(" Tmp-Dir:\t").append(Configuration.getInstance().getTmpDir()).append("\n"); sb.append(" Cache-Dir:\t").append(Configuration.getInstance().getCacheDir()).append("\n"); List<String> ocs; ocs = Arrays.asList(HELPER.getUserObjectClasses()); sb.append(" User oc List:\t").append(ocs.toString()).append("\n"); ocs = Arrays.asList(HELPER.getGroupObjectClasses()); sb.append(" Group oc List:\t").append(ocs.toString()).append("\n"); sb.append("------------------------------------------------------------------------\n"); LOG.log(Level.INFO, sb.toString()); }
From source file:it.incipict.tool.profiles.util.ProfilesToolUtils.java
public static Survey webAppProfilerManagerAssoc(final Survey survey) { if (!WEBASSOC_MODE) return survey; else {/*from w w w.ja va2 s .co m*/ // Make a copy of the survey Survey result = new Survey(survey); List<Double> answersRealVector = result.getAnswersRealVector(); System.out.println("\n[1] " + answersRealVector.toString()); int index = 0; for (Double d : answersRealVector) { if (d > 0.7) answersRealVector.set(index++, 1.0); else answersRealVector.set(index++, 0.0); } result.setAnswersRealVector(answersRealVector); System.out.println("[2] " + answersRealVector.toString()); return result; } }
From source file:tr.edu.gsu.nerwip.tools.corpus.ArticleCompletion.java
/** * Reads existing article, and apply the new * method to set their categories.//from ww w. j a v a 2 s . com * * @throws ParseException * Problem while accessing the files. * @throws SAXException * Problem while accessing the files. * @throws IOException * Problem while accessing the files. * @throws org.apache.http.ParseException * Problem while accessing the files. * @throws org.json.simple.parser.ParseException * Problem while accessing the files. */ private static void completeArticleCategories() throws ParseException, SAXException, IOException, org.apache.http.ParseException, org.json.simple.parser.ParseException { logger.log("Completing categories in articles"); logger.increaseOffset(); WikipediaReader reader = new WikipediaReader(); List<File> files = ArticleLists.getArticleList(); for (File file : files) { String name = file.getName(); logger.log("Processing article '" + name + "'"); logger.increaseOffset(); Article article = Article.read(name); List<ArticleCategory> categories = reader.getArticleCategories(article); article.setCategories(categories); logger.log("Detected categories: " + categories.toString()); article.write(); logger.log("Completed article written"); logger.decreaseOffset(); } logger.decreaseOffset(); logger.log("Categories completed"); }
From source file:com.threewks.analytics.filter.HttpRequestResponseTrackingFilter.java
/** * Create an {@link HttpResponse} from the given {@link HttpRequest} and {@link AnalyticsHttpServletResponseWrapper}. * /*from www . j ava 2 s . co m*/ * @param httpRequest the request object. * @param responseWrapper the response wrapper. * @return the response. */ private static HttpResponse createHttpResponse(HttpRequest httpRequest, AnalyticsHttpServletResponseWrapper responseWrapper) { HttpResponse httpResponse = new HttpResponse(); httpResponse.setCharacterEncoding(responseWrapper.getCharacterEncoding()); httpResponse.setContentType(responseWrapper.getContentType()); httpResponse.setRedirectUrl(responseWrapper.getRedirectUrl()); httpResponse.setStatusCode(responseWrapper.getStatusCode()); List<HttpCookie> cookies = httpResponse.getCookies(); for (Cookie cookie : responseWrapper.getCookies()) { cookies.add(new HttpCookie(cookie)); } List<HttpHeader> headers = httpResponse.getHeaders(); Map<String, List<String>> headers2 = responseWrapper.getHeaders(); for (Map.Entry<String, List<String>> header : headers2.entrySet()) { String name = header.getKey(); List<String> values = header.getValue(); headers.add(new HttpHeader(name, values.size() > 1 ? values.toString() : values.get(0))); } // link the id back to the request httpResponse.setId(httpRequest.getId()); return httpResponse; }
From source file:it.unibo.alchemist.language.protelis.util.ReflectionUtils.java
private static Method loadBestMethod(final Class<?> clazz, final String methodName, final Class<?>[] argClass) { Objects.requireNonNull(clazz, "The class on which the method will be invoked can not be null."); Objects.requireNonNull(methodName, "Method name can not be null."); Objects.requireNonNull(argClass, "Method arguments can not be null."); /*/*from www . j a v a 2s . c om*/ * If there is a matching method, return it */ try { return clazz.getMethod(methodName, argClass); } catch (NoSuchMethodException | SecurityException e) { /* * Look it up on the cache */ /* * Deal with Java method overloading scoring methods */ final Method[] candidates = clazz.getMethods(); final List<Pair<Integer, Method>> lm = new ArrayList<>(candidates.length); for (final Method m : candidates) { // TODO: Workaround for different Method API if (m.getParameterTypes().length == argClass.length && methodName.equals(m.getName())) { final Class<?>[] params = m.getParameterTypes(); int p = 0; boolean compatible = true; for (int i = 0; compatible && i < argClass.length; i++) { final Class<?> expected = params[i]; if (expected.isAssignableFrom(argClass[i])) { /* * No downcast required, there is compatibility */ p++; } else if (!PrimitiveUtils.classIsNumber(expected)) { compatible = false; } } if (compatible) { lm.add(new Pair<>(p, m)); } } } /* * Find best */ if (lm.size() > 0) { Pair<Integer, Method> max = lm.get(0); for (Pair<Integer, Method> cPair : lm) { if (cPair.getFirst().compareTo(max.getFirst()) > 0) { max = cPair; } } return max.getSecond(); } } List<Class<?>> list = new ArrayList<>(); for (Class<?> c : argClass) { list.add(c); } final String argType = list.toString(); throw new NoSuchMethodError( methodName + "/" + argClass.length + argType + " does not exist in " + clazz + "."); }
From source file:edu.cornell.mannlib.vitro.webapp.utils.pageDataGetter.DataGetterUtils.java
public static Map<String, Object> getDataForPage(String pageUri, VitroRequest vreq, ServletContext context) { //Based on page type get the appropriate data getter Map<String, Object> page = getMapForPage(vreq, pageUri); //Get data getters map Map<String, PageDataGetter> dataGetterMap = getPageDataGetterMap(context); //Get types associated with page Map<String, Object> data = new HashMap<String, Object>(); List<String> dataGetters = (List<String>) page.get("dataGetters"); log.debug("Retrieved data getters for Page " + pageUri + " = " + dataGetters.toString()); if (dataGetters != null) { for (String dataGetter : dataGetters) { Map<String, Object> moreData = null; PageDataGetter getter = dataGetterMap.get(dataGetter); log.debug("Retrieved data getter for " + dataGetter); try { moreData = getAdditionalData(pageUri, dataGetter, page, vreq, getter, context); if (moreData != null) data.putAll(moreData); } catch (Throwable th) { log.error(th, th);//from www. ja v a2s . c o m } } } return data; }
From source file:com.liferay.blade.samples.test.BladeCLIUtil.java
public static String execute(File workingDir, String... bladeArgs) throws Exception { String bladeCLIJarPath = getLatestBladeCLIJar(); List<String> command = new ArrayList<>(); command.add("java"); command.add("-jar"); command.add(bladeCLIJarPath);/*from w w w .jav a 2s .c o m*/ for (String arg : bladeArgs) { command.add(arg); } Process process = new ProcessBuilder(command.toArray(new String[0])).directory(workingDir).start(); process.waitFor(); InputStream stream = process.getInputStream(); String output = new String(IO.read(stream)); InputStream errorStream = process.getErrorStream(); List<String> errorList = new ArrayList<>(); if (errorStream != null) { errorList.add(new String(IO.read(errorStream))); } List<String> filteredErrorList = new ArrayList<>(); for (String string : errorList) { if (!string.isEmpty() && !string.contains("Picked up JAVA_TOOL_OPTIONS:")) { filteredErrorList.add(string); } } assertTrue(filteredErrorList.toString(), filteredErrorList.isEmpty()); output = StringUtil.toLowerCase(output); return output; }