List of usage examples for org.springframework.util StringUtils collectionToDelimitedString
public static String collectionToDelimitedString(@Nullable Collection<?> coll, String delim)
From source file:org.springframework.data.keyvalue.riak.core.AbstractRiakTemplate.java
/** * Get a string that represents the QOS parameters, taken either from the specified object or * from the template defaults./*ww w .j av a2 s . c om*/ * * @param qosParams * @return */ protected String extractQosParameters(QosParameters qosParams) { List<String> params = new LinkedList<String>(); if (null != qosParams.getReadThreshold()) { params.add(String.format("r=%s", qosParams.<Object>getReadThreshold())); } else if (null != defaultQosParameters && null != defaultQosParameters.getReadThreshold()) { params.add(String.format("r=%s", defaultQosParameters.getReadThreshold())); } if (null != qosParams.getWriteThreshold()) { params.add(String.format("w=%s", qosParams.<Object>getWriteThreshold())); } else if (null != defaultQosParameters && null != defaultQosParameters.getWriteThreshold()) { params.add(String.format("w=%s", defaultQosParameters.getWriteThreshold())); } if (null != qosParams.getDurableWriteThreshold()) { params.add(String.format("dw=%s", qosParams.<Object>getDurableWriteThreshold())); } else if (null != defaultQosParameters && null != defaultQosParameters.getDurableWriteThreshold()) { params.add(String.format("dw=%s", defaultQosParameters.getDurableWriteThreshold())); } return (params.size() > 0 ? "?" + StringUtils.collectionToDelimitedString(params, "&") : ""); }
From source file:org.springframework.data.rest.webmvc.alps.RootResourceInformationToAlpsDescriptorConverter.java
private Doc getDocFor(ResourceDescription description, PersistentProperty<?> property) { if (description == null) { return null; }// w w w . j ava2 s . co m String message = resolveMessage(description); // Manually post process the default message for enumerations if needed if (configuration.isEnableEnumTranslation() && property != null && property.getType().isEnum()) { if (description.isDefault()) { return new Doc( StringUtils.collectionToDelimitedString( translator.getValues((Class<? extends Enum<?>>) property.getType()), ", "), Format.TEXT); } } return message == null ? null : new Doc(message, Format.TEXT); }
From source file:org.springframework.data.rest.webmvc.jpa.JpaWebTests.java
private static String toUriList(Link... links) { List<String> uris = new ArrayList<String>(links.length); for (Link link : links) { uris.add(link.expand().getHref()); }/*from w w w. ja va 2s. c o m*/ return StringUtils.collectionToDelimitedString(uris, "\n"); }
From source file:org.springframework.jndi.support.SimpleNamingContext.java
/** * Look up the object with the given name. * Note: Not intended for direct use by applications. * Will be used by any standard InitialContext JNDI lookups. * @throws NameNotFoundException if the object could not be found *//*from ww w .j av a 2 s . c o m*/ public Object lookup(String pname) throws NameNotFoundException { String name = root + pname; logger.info("Static JNDI lookup: [" + name + "]"); if ("".equals(name)) { return new SimpleNamingContext(root, boundObjects, environment); } Object found = boundObjects.get(name); if (found == null) { if (!name.endsWith("/")) { name = name + "/"; } for (Iterator it = boundObjects.keySet().iterator(); it.hasNext();) { String boundName = (String) it.next(); if (boundName.startsWith(name)) { return new SimpleNamingContext(name, boundObjects, environment); } } throw new NameNotFoundException("Name [" + root + pname + "] not bound: " + boundObjects.size() + " bindings -- [" + StringUtils.collectionToDelimitedString(boundObjects.keySet(), ",") + "]"); } return found; }
From source file:org.tinygroup.weblayer.webcontext.parser.util.BeanWrapperImpl.java
/** * Parse the given property name into the corresponding property name tokens. * @param propertyName the property name to parse * @return representation of the parsed property tokens *///from w ww.j a va 2 s .c om private PropertyTokenHolder getPropertyNameTokens(String propertyName) { PropertyTokenHolder tokens = new PropertyTokenHolder(); String actualName = null; List keys = new ArrayList(2); int searchIndex = 0; while (searchIndex != -1) { int keyStart = propertyName.indexOf(PROPERTY_KEY_PREFIX, searchIndex); searchIndex = -1; if (keyStart != -1) { int keyEnd = propertyName.indexOf(PROPERTY_KEY_SUFFIX, keyStart + PROPERTY_KEY_PREFIX.length()); if (keyEnd != -1) { if (actualName == null) { actualName = propertyName.substring(0, keyStart); } String key = propertyName.substring(keyStart + PROPERTY_KEY_PREFIX.length(), keyEnd); if ((key.startsWith("'") && key.endsWith("'")) || (key.startsWith("\"") && key.endsWith("\""))) { key = key.substring(1, key.length() - 1); } keys.add(key); searchIndex = keyEnd + PROPERTY_KEY_SUFFIX.length(); } } } tokens.actualName = (actualName != null ? actualName : propertyName); tokens.canonicalName = tokens.actualName; if (!keys.isEmpty()) { tokens.canonicalName += PROPERTY_KEY_PREFIX + StringUtils.collectionToDelimitedString(keys, PROPERTY_KEY_SUFFIX + PROPERTY_KEY_PREFIX) + PROPERTY_KEY_SUFFIX; tokens.keys = StringUtils.toStringArray(keys); } return tokens; }