當前位置: 首頁>>代碼示例>>Java>>正文


Java Collection.toString方法代碼示例

本文整理匯總了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====================");
}
 
開發者ID:Team-Sprout,項目名稱:Clipcon-Server,代碼行數:24,代碼來源:Logging.java

示例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;
}
 
開發者ID:JetBrains,項目名稱:teamcity-hashicorp-vault-plugin,代碼行數:34,代碼來源:VaultResponses.java

示例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();
}
 
開發者ID:kickstarter,項目名稱:dropwizard-influxdb-reporter,代碼行數:21,代碼來源:InfluxDbMeasurement.java

示例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 + "]");
}
 
開發者ID:convertigo,項目名稱:convertigo-engine,代碼行數:9,代碼來源:ScreenClass.java

示例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 + "]");
}
 
開發者ID:convertigo,項目名稱:convertigo-engine,代碼行數:9,代碼來源:ScreenClass.java

示例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();
}
 
開發者ID:funkemunky,項目名稱:HCFCore,代碼行數:9,代碼來源:AbstractMultiValuedMap.java

示例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);
    }
}
 
開發者ID:cadox8,項目名稱:PA,代碼行數:15,代碼來源:ParticleEffect.java

示例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());
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:13,代碼來源:CopyOnWriteArraySetTest.java

示例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;
}
 
開發者ID:ligoj,項目名稱:bootstrap,代碼行數:11,代碼來源:RestRepositoryImpl.java

示例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);
}
 
開發者ID:kszatan,項目名稱:gocd-phabricator-staging-material,代碼行數:10,代碼來源:LatestRevisionsSinceRequest.java

示例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);
}
 
開發者ID:kszatan,項目名稱:gocd-phabricator-staging-material,代碼行數:9,代碼來源:CheckoutRequest.java

示例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);
}
 
開發者ID:kszatan,項目名稱:gocd-phabricator-staging-material,代碼行數:9,代碼來源:LatestRevisionRequest.java

示例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);
}
 
開發者ID:kszatan,項目名稱:gocd-phabricator-staging-material,代碼行數:9,代碼來源:ScmConfigurationRequest.java

示例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!");
  }
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:52,代碼來源:FSNamesystem.java

示例15: formatThreadName

import java.util.Collection; //導入方法依賴的package包/類
private String formatThreadName() {
  Collection<StorageLocation> dataDirs =
      DataNode.getStorageLocations(dn.getConf());
  return "DataNode: [" + dataDirs.toString() + "] " +
    " heartbeating to " + nnAddr;
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:7,代碼來源:BPServiceActor.java


注:本文中的java.util.Collection.toString方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。