List of usage examples for org.springframework.util StringUtils collectionToDelimitedString
public static String collectionToDelimitedString(@Nullable Collection<?> coll, String delim)
From source file:edu.txstate.dmlab.clusteringwiki.preprocess.CollectionContext.java
/** * Analyzes query and created queryTerms array, then * returns analyzed query string//from ww w . ja va 2s.c o m * @param query * @return */ public int[] analyzeQuery(String query) { StringTokenizer st = new StringTokenizer(query, ApplicationSettings.TOKEN_CHARS, true); List<Integer> qTerms = new ArrayList<Integer>(); List<String> qTermStrings = new ArrayList<String>(); while (st.hasMoreTokens()) { String tok = st.nextToken(); if (!tok.equals(" ") && tok.length() > 0) { while (CharUtils.startsWithPhraseSeparator(tok)) tok = tok.substring(1); while (CharUtils.endsWithPhraseSeparator(tok)) tok = tok.substring(0, tok.length() - 1); final short tt = TokenUtils.getFullTokenType(tok); final boolean isStopWord = TokenUtils.isStopWord(tt); final boolean isPunctuation = TokenUtils.isPunctuation(tt); if (!isStopWord && !isPunctuation) { final String tm = edu.txstate.dmlab.clusteringwiki.util.StringUtils.stemWord(tok); if (tm.length() >= ApplicationSettings.MINIMUM_TERM_LENGTH) { final int tid = this.getTermId(tm); // add token this.getWordId(tok); //add word to allWordsIndex qTerms.add(tid); qTermStrings.add(tm); } else { this.getWordId(tok); } } } } this.analyzedQuery = StringUtils.collectionToDelimitedString(qTermStrings, " "); int[] terms = ArrayUtils.intColToArray(qTerms); return terms; }
From source file:com.github.hateoas.forms.affordance.Affordance.java
/** * Affordance represented as http link header value. * * @return link header value//from w w w . java 2 s .com */ public String asHeader() { StringBuilder result = new StringBuilder(); for (Map.Entry<String, List<String>> linkParamEntry : linkParams.entrySet()) { if (result.length() != 0) { result.append("; "); } String linkParamEntryKey = linkParamEntry.getKey(); if ("rel".equals(linkParamEntryKey) || "rev".equals(linkParamEntryKey)) { result.append(linkParamEntryKey).append("="); result.append("\"").append(StringUtils.collectionToDelimitedString(linkParamEntry.getValue(), " ")) .append("\""); } else { StringBuilder linkParams = new StringBuilder(); for (String value : linkParamEntry.getValue()) { if (linkParams.length() != 0) { linkParams.append("; "); } linkParams.append(linkParamEntryKey).append("="); linkParams.append("\"").append(value).append("\""); } result.append(linkParams); } } String linkHeader = "<" + partialUriTemplate.asComponents().toString() + ">; "; return result.insert(0, linkHeader).toString(); }
From source file:fr.mby.utils.spring.beans.factory.BasicProxywiredManager.java
/** * Update the wiring configuration./*from w w w . j a va2 s .c o m*/ * * @param dependencies * @param dependencyToModify */ protected void updateWiringConfiguration(final LinkedHashMap<String, Object> dependencies, final IManageableProxywired dependencyToModify) { if (this.configuration != null) { final IProxywiredIdentifier identifier = dependencyToModify.getIdentifier(); // Internal method => Identifier cannot be null here ! Assert.notNull(identifier, "Cannot found valid identifier for this dependency !"); final String beanNames = StringUtils.collectionToDelimitedString(dependencies.keySet(), IProxywiredManager.WIRING_PREFS_SEPARATOR); final Configuration elementConfig = identifier.getConfigurationSubset(this.configuration); elementConfig.addProperty(IProxywiredManager.WIRED_BEANS_CONFIG_KEY, beanNames); } }
From source file:com.idtmatter.insta4j.client.FullInstaClient.java
/** * Lists the user's unread bookmarks, and can also synchronize reading positions. * * @param limit Optional. A number between 1 and 500, default 25. * @param folderId Optional. Possible values are unread (default), starred, archive, * or a folder_id value from /api/1/folders/list. * @param bookmarkId Optional. A concatenation of bookmark_id values that the client already has from the specified folder. See below. * <p>/* w w w. j av a2 s . c o m*/ * The have? parameter: This is a comma-separated list of bookmark_id values that the client * already has in its local bookmark data, and shouldnt be re-sent. Any IDs sent in the have parameter * that would not have appeared in the list within the given limit are returned in a delete_ids parameter on the meta object. * </p> * <p> * The have parameter can just be a list of the bookmark_id values, e.g.: * 12345,12346,12347 * in which case Instapaper wont include those bookmarks in the output. * </p> * <p> * But it can also do more. Each bookmark returned by the API has a hash value, which is computed from its URL, title, description, and reading progress. If you join the hash value you have for an article with its article ID using a colon, e.g.: * 12345:OjMuzFp6,12346:0n4ONgYs,12347:YXo82wTR * then Instapaper will omit those bookmarks from the output, but only if the hashes havent changed. So you can use this method to selectively be informed of updates to article metadata without otherwise re-downloading the entire list on each update. * </p> * <p> * Finally, you can optionally append two more fields to each ID with colons to indicate how far the user has read each article, as a floating-point value between 0.0 and 1.0 to indicate progress and the Unix timestamp value of the time that the progress was recorded, e.g.: * 12345:OjMuzFp6:0.5:1288584076 * This would indicate that the bookmark with bookmark_id=12345 and hash=OjMuzFp6 was read to 0.5 progress, or 50% of its length, at timestamp 1288584076 (2010-11-01 12:01:16am EST). If the servers information is less recent than this, it will update the bookmark and return it in the output with a new hash value. * </p> * @return One meta object, the current user, and between 0 and limit bookmarks. */ public List<InstaRecordBean> listBookmarks(final String limit, final String folderId, final String... bookmarkId) { final WebResource resource = client.resource(INSTAPAPER_BASE_API_URL).path("/api/1/bookmarks/list"); final MultivaluedMap<String, String> postData = new MultivaluedMapImpl(); if (limit != null) { postData.add("limit", limit); } if (folderId != null) { postData.add("folder_id", folderId); } if (bookmarkId != null) { postData.add("have", StringUtils.collectionToDelimitedString(asList(bookmarkId), ",")); } final List<InstaRecordBean> instaRecordBeans = processJsonResponse( resource.type(MediaType.APPLICATION_FORM_URLENCODED).accept(MediaType.APPLICATION_JSON) .post(ClientResponse.class, postData)); return instaRecordBeans; }
From source file:ch.sdi.core.impl.ftp.FTPClientExample.java
private SdiException createFtpException(String aMessage, Throwable aThrowable) { StringBuilder sb = new StringBuilder(aMessage); if (myFtp != null) { sb.append("ReplyCode: ").append(myFtp.getReplyCode()); sb.append("\n Reply-Message:"); sb.append("\n ").append( StringUtils.collectionToDelimitedString(Arrays.asList(myFtp.getReplyStrings()), "\n ")); } // if myFtp != null return new SdiException(sb.toString(), aThrowable, SdiException.EXIT_CODE_FTP_ERROR); }
From source file:es.logongas.ix3.dao.impl.GenericDAOImplHibernate.java
private JoinProperty getJoinProperty(Filter filter) { JoinProperty joinProperty = new JoinProperty(); String[] propertiesName = filter.getPropertyName().split("\\."); MetaData currentMetaData = getEntityMetaData(); int splitIndex = -1; for (int i = 0; i < propertiesName.length; i++) { currentMetaData = currentMetaData.getPropertyMetaData(propertiesName[i]); if (currentMetaData.isCollection() == true) { if (splitIndex != -1) { throw new RuntimeException("No se permite mas de una coleccin en un filtro where: " + filter.getPropertyName() + " la primera es:" + propertiesName[splitIndex] + " y la segunda es:" + propertiesName[i]); }/*from ww w .j a v a2s. c om*/ splitIndex = i; } } if (splitIndex == -1) { joinProperty.join = null; joinProperty.property = filter.getPropertyName(); } else { joinProperty.join = StringUtils.collectionToDelimitedString( Arrays.asList(Arrays.copyOfRange(propertiesName, 0, splitIndex + 1)), "."); joinProperty.property = StringUtils.collectionToDelimitedString( Arrays.asList(Arrays.copyOfRange(propertiesName, splitIndex + 1, propertiesName.length)), "."); } return joinProperty; }
From source file:org.opennms.ng.dao.support.PropertiesGraphDao.java
/** {@inheritDoc} */ @Override/* ww w . j a va 2 s. c o m*/ public PrefabGraph[] getPrefabGraphsForResource(OnmsResource resource) { if (resource == null) { LOG.warn("returning empty graph list for resource because it is null"); return new PrefabGraph[0]; } Set<OnmsAttribute> attributes = resource.getAttributes(); // Check if there are no attributes if (attributes.size() == 0) { LOG.debug("returning empty graph list for resource {} because its attribute list is empty", resource); return new PrefabGraph[0]; } Set<String> availableRrdAttributes = resource.getRrdGraphAttributes().keySet(); Set<String> availableStringAttributes = resource.getStringPropertyAttributes().keySet(); Set<String> availableExternalAttributes = resource.getExternalValueAttributes().keySet(); // Check if there are no RRD attributes if (availableRrdAttributes.size() == 0) { LOG.debug("returning empty graph list for resource {} because it has no RRD attributes", resource); return new PrefabGraph[0]; } String resourceType = resource.getResourceType().getName(); Map<String, PrefabGraph> returnList = new LinkedHashMap<String, PrefabGraph>(); for (PrefabGraph query : getAllPrefabGraphs()) { if (resourceType != null && !query.hasMatchingType(resourceType)) { LOG.debug("skipping {} because its types \"{}\" does not match resourceType \"{}\"", query.getName(), StringUtils.arrayToDelimitedString(query.getTypes(), ", "), resourceType); continue; } if (!verifyAttributesExist(query, "RRD", Arrays.asList(query.getColumns()), availableRrdAttributes)) { continue; } if (!verifyAttributesExist(query, "string property", Arrays.asList(query.getPropertiesValues()), availableStringAttributes)) { continue; } if (!verifyAttributesExist(query, "external value", Arrays.asList(query.getExternalValues()), availableExternalAttributes)) { continue; } LOG.debug("adding {} to query list", query.getName()); returnList.put(query.getName(), query); } if (LOG.isDebugEnabled()) { ArrayList<String> nameList = new ArrayList<String>(returnList.size()); for (PrefabGraph graph : returnList.values()) { nameList.add(graph.getName()); } LOG.debug("found {} prefabricated graphs for resource {}: {}", nameList.size(), resource, StringUtils.collectionToDelimitedString(nameList, ", ")); } Set<String> suppressReports = new HashSet<String>(); for (Entry<String, PrefabGraph> entry : returnList.entrySet()) { suppressReports.addAll(Arrays.asList(entry.getValue().getSuppress())); } suppressReports.retainAll(returnList.keySet()); if (suppressReports.size() > 0) { LOG.debug("suppressing {} prefabricated graphs for resource {}: {}", suppressReports.size(), resource, StringUtils.collectionToDelimitedString(suppressReports, ", ")); } for (String suppressReport : suppressReports) { returnList.remove(suppressReport); } return returnList.values().toArray(new PrefabGraph[returnList.size()]); }