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


Java Joiner.join方法代碼示例

本文整理匯總了Java中com.google.common.base.Joiner.join方法的典型用法代碼示例。如果您正苦於以下問題:Java Joiner.join方法的具體用法?Java Joiner.join怎麽用?Java Joiner.join使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.google.common.base.Joiner的用法示例。


在下文中一共展示了Joiner.join方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: assertIssues

import com.google.common.base.Joiner; //導入方法依賴的package包/類
/**
 * Asserts that the given resource (usually an N4JS file) contains issues with the given messages and no other
 * issues. Each message given should be prefixed with the line numer where the issues occurs, e.g.:
 *
 * <pre>
 * line 5: Couldn't resolve reference to identifiable element 'unknown'.
 * </pre>
 *
 * Column information is not provided, so this method is not intended for several issues within a single line.
 */
public static void assertIssues(final IResource resource, String... expectedMessages) throws CoreException {
	final IMarker[] markers = resource.findMarkers(MarkerTypes.ANY_VALIDATION, true, IResource.DEPTH_INFINITE);
	final String[] actualMessages = new String[markers.length];
	for (int i = 0; i < markers.length; i++) {
		final IMarker m = markers[i];
		actualMessages[i] = "line " + MarkerUtilities.getLineNumber(m) + ": " + m.getAttribute(IMarker.MESSAGE);
	}
	if (!Objects.equals(
			new HashSet<>(Arrays.asList(actualMessages)),
			new HashSet<>(Arrays.asList(expectedMessages)))) {
		final Joiner joiner = Joiner.on("\n    ");
		final String msg = "expected these issues:\n"
				+ "    " + joiner.join(expectedMessages) + "\n"
				+ "but got these:\n"
				+ "    " + joiner.join(actualMessages);
		System.out.println("*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*");
		System.out.println(msg);
		System.out.println("*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*");
		Assert.fail(msg);
	}
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:32,代碼來源:ProjectUtils.java

示例2: toResponse

import com.google.common.base.Joiner; //導入方法依賴的package包/類
@Override
public Response toResponse(final ConstraintViolationException exception) {
    List<String> violations = new ArrayList<>();
    exception.getConstraintViolations()
        .stream()
        .forEach(input -> violations.add(format(input)));
    Joiner joiner = Joiner.on("; ").skipNulls();
    String detail = joiner.join(violations);
    return Response.status(BAD_REQUEST)
        .entity(new Failure(detail))
        .build();
}
 
開發者ID:drakeet,項目名稱:rebase-server,代碼行數:13,代碼來源:ConstraintViolationExceptionMapper.java

示例3: combineNames

import com.google.common.base.Joiner; //導入方法依賴的package包/類
private static String combineNames(CommonTree node) {
    List<Tree> children = node.getChildren();
    List<String> names = new ArrayList<String>();
    for (Tree child : children) {
        names.add(child.getText());
    }
    Joiner joiner = Joiner.on(".").skipNulls();

    return joiner.join(names);
}
 
開發者ID:ajoabraham,項目名稱:hue,代碼行數:11,代碼來源:TreePatcher.java

示例4: configureForKeyStore

import com.google.common.base.Joiner; //導入方法依賴的package包/類
public static Map<String, String> configureForKeyStore(File keyStoreFile,
                                                       File keyStorePasswordFile,
                                                       Map<String, File> keyAliasPassword)
    throws Exception {
  Map<String, String> context = Maps.newHashMap();
  List<String> keys = Lists.newArrayList();
  Joiner joiner = Joiner.on(".");
  for (String alias : keyAliasPassword.keySet()) {
    File passwordFile = keyAliasPassword.get(alias);
    if (passwordFile == null) {
      keys.add(alias);
    } else {
      String propertyName = joiner.join(EncryptionConfiguration.KEY_PROVIDER,
                                        EncryptionConfiguration.JCE_FILE_KEYS,
                                        alias,
                                        EncryptionConfiguration.JCE_FILE_KEY_PASSWORD_FILE);
      keys.add(alias);
      context.put(propertyName, passwordFile.getAbsolutePath());
    }
  }
  context.put(joiner.join(EncryptionConfiguration.KEY_PROVIDER,
                          EncryptionConfiguration.JCE_FILE_KEY_STORE_FILE),
              keyStoreFile.getAbsolutePath());
  if (keyStorePasswordFile != null) {
    context.put(joiner.join(EncryptionConfiguration.KEY_PROVIDER,
                            EncryptionConfiguration.JCE_FILE_KEY_STORE_PASSWORD_FILE),
                keyStorePasswordFile.getAbsolutePath());
  }
  context.put(joiner.join(EncryptionConfiguration.KEY_PROVIDER,
                          EncryptionConfiguration.JCE_FILE_KEYS),
              Joiner.on(" ").join(keys));
  return context;
}
 
開發者ID:moueimei,項目名稱:flume-release-1.7.0,代碼行數:34,代碼來源:EncryptionTestUtils.java

示例5: toJavaTypeName

import com.google.common.base.Joiner; //導入方法依賴的package包/類
/**
 * Returns the full Java type name based on the given protobuf type parameters.
 *
 * @param className the protobuf type name
 * @param enclosingClassName the optional enclosing class for the given type
 * @param javaPackage the proto file's configured java package name
 */
public static String toJavaTypeName(
        @Nonnull String className,
        @Nullable String enclosingClassName,
        @Nullable String javaPackage) {

    Preconditions.checkNotNull(className, "className");

    Joiner dotJoiner = Joiner.on('.').skipNulls();
    return dotJoiner.join(javaPackage, enclosingClassName, className);
}
 
開發者ID:salesforce,項目名稱:grpc-java-contrib,代碼行數:18,代碼來源:ProtoTypeMap.java

示例6: prefixAndJoin

import com.google.common.base.Joiner; //導入方法依賴的package包/類
/**
 * @param list   of strings to be joined by ','
 * @param prefix e.g. 'extends' or 'implements'
 */
public static String prefixAndJoin(final List<FullyQualifiedName> list, final String prefix) {
    if (list.isEmpty()) {
        return "";
    }
    Joiner joiner = Joiner.on(",");
    return " " + prefix + " " + joiner.join(list);
}
 
開發者ID:hashsdn,項目名稱:hashsdn-controller,代碼行數:12,代碼來源:StringUtil.java

示例7: format

import com.google.common.base.Joiner; //導入方法依賴的package包/類
private String format(String pattern, String value) {
    Splitter splitter = Splitter.on("%1$s");
    Joiner joiner = Joiner.on(value);
    return joiner.join(splitter.split(pattern));
}
 
開發者ID:YoungDigitalPlanet,項目名稱:empiria.player,代碼行數:6,代碼來源:ContentFieldInfo.java

示例8: combineCoalesceSets

import com.google.common.base.Joiner; //導入方法依賴的package包/類
private static String combineCoalesceSets(Set<String> coalesceSets) {
    Joiner joiner = Joiner.on(", ").skipNulls();

    return joiner.join(coalesceSets);
}
 
開發者ID:ajoabraham,項目名稱:hue,代碼行數:6,代碼來源:TreePatcher.java

示例9: ActiveAppBeacon

import com.google.common.base.Joiner; //導入方法依賴的package包/類
public ActiveAppBeacon(Collection<Integer> ports, final String pingMessage) {
    this.pingMessage = pingMessage;
    for (Integer p : ports) {
        // Check that port is unused and use first available port
        if (available(p)) {
            try {
                serverSocket = new ServerSocket(p);
                break;
            }
            catch (IOException e) {
                log.info("Unable to open port {}", p);
            }
        }
    }

    if (serverSocket == null) {
        ok = false;
        Joiner joiner = Joiner.on(", ").skipNulls();
        String portMsg = joiner.join(ports);
        beaconThread = null;
        log.warn("Failed to activate a ServerSocket for ActiveAppBeacon on any of the following ports: " + portMsg);
    }
    else {
        final ServerSocket s = serverSocket;
        beaconThread = new Thread(() -> {
            while (ok) {
                try {
                    Socket socket = s.accept();
                    Writer writer = new OutputStreamWriter(socket.getOutputStream());
                    writer.write(pingMessage + "\n");
                    writer.flush();
                    socket.close();
                }
                catch (IOException e) {
                    // do nothing
                }

            }
        });
        beaconThread.setDaemon(true);
        beaconThread.start();
    }
}
 
開發者ID:mbari-media-management,項目名稱:vars-annotation,代碼行數:44,代碼來源:ActiveAppBeacon.java

示例10: scanSchema

import com.google.common.base.Joiner; //導入方法依賴的package包/類
/**
 * Scan the schame tree, invoking the visitor as appropriate.
 * @param  rootSchema  the given schema
 */
public void scanSchema(SchemaPlus rootSchema) {
  if (!shouldVisitCatalog() || !visitCatalog()) {
    return;
  }

  // Visit this schema and if requested ...
  for (String subSchemaName: rootSchema.getSubSchemaNames()) {
    final SchemaPlus firstLevelSchema = rootSchema.getSubSchema(subSchemaName);

    if (shouldVisitSchema(subSchemaName, firstLevelSchema) && visitSchema(subSchemaName, firstLevelSchema)) {

      final AbstractSchema schemaInstance;
      try{
        schemaInstance = (AbstractSchema) firstLevelSchema.unwrap(AbstractSchema.class).getDefaultSchema();
      }catch(Exception ex){
        logger.warn("Failure reading schema {}. Skipping inclusion in INFORMATION_SCHEMA.", subSchemaName, ex);
        continue;
      }

      // ... do for each of the schema's tables.
      for (String tableName : firstLevelSchema.getTableNames()) {
        try {
          final TableInfo tableInfo = schemaInstance.getTableInfo(tableName);

          if (tableInfo == null) {
            // Schema may return NULL for table if the query user doesn't have permissions to load the table. Ignore such
            // tables as INFO SCHEMA is about showing tables which the user has access to query.
            continue;
          }
          final Table table;
          if (tableInfo.getTable() == null) {
            table = schemaInstance.getTable(tableName);
          } else {
            table = tableInfo.getTable();
          }
          final TableType tableType = table.getJdbcTableType();
          // Visit the table, and if requested ...
          if (shouldVisitTable(subSchemaName, tableName, tableType) && visitTable(subSchemaName, tableName, tableInfo)) {
            // ... do for each of the table's fields.
            RelDataType tableRow = table.getRowType(new JavaTypeFactoryImpl());
            for (RelDataTypeField field : tableRow.getFieldList()) {
              if (shouldVisitColumn(subSchemaName, tableName, field.getName())) {
                visitField(subSchemaName, tableName, field);
              }
            }
          }
        } catch (Exception e) {
          Joiner joiner = Joiner.on('.');
          String path = joiner.join(joiner.join(firstLevelSchema.getTableNames()), tableName);
          logger.warn("Failure while trying to read schema for table {}. Skipping inclusion in INFORMATION_SCHEMA.", path, e);;
          continue;
        }

      }
    }
  }
}
 
開發者ID:dremio,項目名稱:dremio-oss,代碼行數:62,代碼來源:InfoSchemaRecordGenerator.java

示例11: join

import com.google.common.base.Joiner; //導入方法依賴的package包/類
/**
 * Returns a {@link String} containing all of the elements of this fluent iterable joined with
 * {@code joiner}.
 *
 * <p><b>{@code Stream} equivalent:</b> {@code joiner.join(stream.iterator())}, or, if you are not
 * using any optional {@code Joiner} features,
 * {@code stream.collect(Collectors.joining(delimiter)}.
 *
 * @since 18.0
 */
@Beta
public final String join(Joiner joiner) {
  return joiner.join(this);
}
 
開發者ID:zugzug90,項目名稱:guava-mock,代碼行數:15,代碼來源:FluentIterable.java


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