本文整理汇总了Java中java.util.Collection.toString方法的典型用法代码示例。如果您正苦于以下问题:Java Collection.toString方法的具体用法?Java Collection.toString怎么用?Java Collection.toString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.Collection
的用法示例。
在下文中一共展示了Collection.toString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: responseMsgLog
import java.util.Collection; //导入方法依赖的package包/类
/** send response message to client */
public static void responseMsgLog(HttpServletResponse response) {
response.setContentType("text/html");
response.setCharacterEncoding("UTF-8");
System.out.println("Http Post Response: " + response.toString());
/* response status info */
System.out.println("==================STARTLINE==================");
System.out.println("Response Status: " + response.getStatus());
System.out.println("Response ContentType: " + response.getContentType());
/* response header info */
System.out.println("==================HEADER=====================");
Collection<String> headerNames = response.getHeaderNames();
while (!headerNames.isEmpty()) {
String headerName = (String) headerNames.toString();
System.out.println(headerName + ": " + response.getHeader(headerName));
}
System.out.println("===================ENTITY====================");
}
示例2: getError
import java.util.Collection; //导入方法依赖的package包/类
/**
* Obtain the error message from a JSON response.
*
* @param json must not be {@literal null}.
* @return
*/
public static String getError(String json) {
Assert.notNull(json, "Error JSON must not be null!");
if (json.contains("\"errors\":")) {
try {
Map<String, Object> map = OBJECT_MAPPER.readValue(json.getBytes(),
new TypeReference<Map<String, Object>>() {
});
if (map.containsKey("errors")) {
//noinspection unchecked
Collection<String> errors = (Collection<String>) map.get("errors");
if (errors.size() == 1) {
return errors.iterator().next();
}
return errors.toString();
}
}
catch (IOException o_O) {
// ignore
}
}
return json;
}
示例3: validatedPrimitiveCollection
import java.util.Collection; //导入方法依赖的package包/类
/**
* Validates that the collection only contains null values, Strings, and primitives.
*
* @return the collection as a string, if valid.
* @throws IllegalArgumentException if any collection value is not a null value, string or primitive.
*/
private static String validatedPrimitiveCollection(final String key, final Collection collection) {
for (final Object value : collection) {
if (!isValidField(value)) {
throw new IllegalArgumentException(
String.format(
"InfluxDbMeasurement collection field '%s' must contain only Strings and primitives: invalid field '%s'",
key, value
)
);
}
}
return collection.toString();
}
示例4: debugCriterias
import java.util.Collection; //导入方法依赖的package包/类
private void debugCriterias() {
String criterias = "";
if (orderedCriterias.size() > 0) {
Collection<Long> ordered = orderedCriterias.get(0);
criterias = ordered.toString();
}
Engine.logBeans.trace("["+ getName() +"] Ordered Criterias ["+ criterias + "]");
}
示例5: debugExtractionRules
import java.util.Collection; //导入方法依赖的package包/类
private void debugExtractionRules() {
String extractionrules = "";
if (orderedExtractionRules.size() > 0) {
Collection<Long> ordered = orderedExtractionRules.get(0);
extractionrules = ordered.toString();
}
Engine.logBeans.trace("["+ getName() +"] Ordered ExtractionRules ["+ extractionrules + "]");
}
示例6: toString
import java.util.Collection; //导入方法依赖的package包/类
@Override
public String toString() {
final Collection<V> coll = getMapping();
if (coll == null) {
return CollectionUtils.EMPTY_COLLECTION.toString();
}
return coll.toString();
}
示例7: send
import java.util.Collection; //导入方法依赖的package包/类
void send(Collection<? extends Player> receivers, double x, double y, double z, double offsetX, double offsetY, double offsetZ, double speed, int count, int... extra) {
if (!this.effect.isCompatible()) {
throw new ParticleException("Particle " + this.effect + " is not compatible with the server version (" + Minecraft.VERSION + " < " + this.effect.getMinVersion() + ")");
}
try {
if (Minecraft.VERSION.newerThan(v1_8_R1)) {
send_1_8(receivers, x, y, z, offsetX, offsetY, offsetZ, speed, count, extra);
} else {//1.7
send_1_7(effect.name, receivers, x, y, z, offsetX, offsetY, offsetZ, speed, count);
}
} catch (Exception e) {
throw new ParticleException("Failed to send particle " + this.effect + " to " + receivers.toString(), e);
}
}
示例8: testToString
import java.util.Collection; //导入方法依赖的package包/类
/**
* toString holds toString of elements
*/
public void testToString() {
assertEquals("[]", new CopyOnWriteArraySet().toString());
Collection full = populatedSet(3);
String s = full.toString();
for (int i = 0; i < 3; ++i)
assertTrue(s.contains(String.valueOf(i)));
assertEquals(new ArrayList(full).toString(),
full.toString());
}
示例9: deleteAllExpected
import java.util.Collection; //导入方法依赖的package包/类
@Override
@Transactional
public int deleteAllExpected(final Collection<K> identifiers) {
final int deleted = deleteAll(identifiers);
if (deleted != org.apache.commons.collections4.CollectionUtils.size(identifiers)) {
// At least one row has not been deleted
throw new EntityNotFoundException(identifiers.toString());
}
return deleted;
}
示例10: LatestRevisionsSinceRequest
import java.util.Collection; //导入方法依赖的package包/类
public LatestRevisionsSinceRequest(String json) throws InvalidJson, IncompleteJson {
final List<String> requiredFields =
Arrays.asList("scm-configuration", "flyweight-folder", "previous-revision");
Collection<String> missing = GsonService.validate(json, requiredFields);
if (!missing.isEmpty()) {
throw new IncompleteJson("Missing fields: " + missing.toString());
}
latestRevisionsSince = GsonService.fromJson(json, LatestRevisionsSince.class);
}
示例11: CheckoutRequest
import java.util.Collection; //导入方法依赖的package包/类
public CheckoutRequest(String json) throws IncompleteJson, InvalidJson {
final List<String> requiredFields = Arrays.asList("scm-configuration", "destination-folder", "revision");
Collection<String> missing = GsonService.validate(json, requiredFields);
if (!missing.isEmpty()) {
throw new IncompleteJson("Missing fields: " + missing.toString());
}
checkout = GsonService.fromJson(json, Checkout.class);
}
示例12: LatestRevisionRequest
import java.util.Collection; //导入方法依赖的package包/类
public LatestRevisionRequest(String json) throws InvalidJson, IncompleteJson {
final List<String> requiredFields = Arrays.asList("scm-configuration", "flyweight-folder");
Collection<String> missing = GsonService.validate(json, requiredFields);
if (!missing.isEmpty()) {
throw new IncompleteJson("Missing fields: " + missing.toString());
}
latestRevision = GsonService.fromJson(json, LatestRevision.class);
}
示例13: ScmConfigurationRequest
import java.util.Collection; //导入方法依赖的package包/类
public ScmConfigurationRequest(String json) throws InvalidJson, IncompleteJson {
Collection<String> missing = GsonService.validate(json, Arrays.asList("scm-configuration"));
if (!missing.isEmpty()) {
throw new IncompleteJson("Missing fields: " + missing.toString());
}
String configurationJson = GsonService.getField(json, "scm-configuration");
configuration = GsonService.fromJson(configurationJson, ScmConfiguration.class);
}
示例14: checkConfiguration
import java.util.Collection; //导入方法依赖的package包/类
/**
* Check the supplied configuration for correctness.
* @param conf Supplies the configuration to validate.
* @throws IOException if the configuration could not be queried.
* @throws IllegalArgumentException if the configuration is invalid.
*/
private static void checkConfiguration(Configuration conf)
throws IOException {
final Collection<URI> namespaceDirs =
FSNamesystem.getNamespaceDirs(conf);
final Collection<URI> editsDirs =
FSNamesystem.getNamespaceEditsDirs(conf);
final Collection<URI> requiredEditsDirs =
FSNamesystem.getRequiredNamespaceEditsDirs(conf);
final Collection<URI> sharedEditsDirs =
FSNamesystem.getSharedEditsDirs(conf);
for (URI u : requiredEditsDirs) {
if (u.toString().compareTo(
DFSConfigKeys.DFS_NAMENODE_EDITS_DIR_DEFAULT) == 0) {
continue;
}
// Each required directory must also be in editsDirs or in
// sharedEditsDirs.
if (!editsDirs.contains(u) &&
!sharedEditsDirs.contains(u)) {
throw new IllegalArgumentException(
"Required edits directory " + u.toString() + " not present in " +
DFSConfigKeys.DFS_NAMENODE_EDITS_DIR_KEY + ". " +
DFSConfigKeys.DFS_NAMENODE_EDITS_DIR_KEY + "=" +
editsDirs.toString() + "; " +
DFSConfigKeys.DFS_NAMENODE_EDITS_DIR_REQUIRED_KEY + "=" +
requiredEditsDirs.toString() + ". " +
DFSConfigKeys.DFS_NAMENODE_SHARED_EDITS_DIR_KEY + "=" +
sharedEditsDirs.toString() + ".");
}
}
if (namespaceDirs.size() == 1) {
LOG.warn("Only one image storage directory ("
+ DFS_NAMENODE_NAME_DIR_KEY + ") configured. Beware of data loss"
+ " due to lack of redundant storage directories!");
}
if (editsDirs.size() == 1) {
LOG.warn("Only one namespace edits storage directory ("
+ DFS_NAMENODE_EDITS_DIR_KEY + ") configured. Beware of data loss"
+ " due to lack of redundant storage directories!");
}
}
示例15: formatThreadName
import java.util.Collection; //导入方法依赖的package包/类
private String formatThreadName() {
Collection<StorageLocation> dataDirs =
DataNode.getStorageLocations(dn.getConf());
return "DataNode: [" + dataDirs.toString() + "] " +
" heartbeating to " + nnAddr;
}