当前位置: 首页>>代码示例>>Java>>正文


Java Joiner.on方法代码示例

本文整理汇总了Java中com.google.common.base.Joiner.on方法的典型用法代码示例。如果您正苦于以下问题:Java Joiner.on方法的具体用法?Java Joiner.on怎么用?Java Joiner.on使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.common.base.Joiner的用法示例。


在下文中一共展示了Joiner.on方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: validateColumnsAndAddCastsIfNecessary

import com.google.common.base.Joiner; //导入方法依赖的package包/类
/**
 * validate that result columns from subquery match explicit insert columns
 * or complete table schema
 */
private static void validateColumnsAndAddCastsIfNecessary(List<Reference> targetColumns,
                                                          QuerySpec querySpec) {
    if (targetColumns.size() != querySpec.outputs().size()) {
        Joiner commaJoiner = Joiner.on(", ");
        throw new IllegalArgumentException(String.format("Number of target columns (%s) of insert statement doesn't match number of source columns (%s)",
                commaJoiner.join(Iterables.transform(targetColumns, Reference.TO_COLUMN_NAME)),
                commaJoiner.join(Iterables.transform(querySpec.outputs(), SymbolPrinter.FUNCTION))));
    }

    int failedCastPosition = querySpec.castOutputs(Iterators.transform(targetColumns.iterator(), Symbols.TYPES_FUNCTION));
    if (failedCastPosition >= 0) {
        Symbol failedSource = querySpec.outputs().get(failedCastPosition);
        Reference failedTarget = targetColumns.get(failedCastPosition);
        throw new IllegalArgumentException(String.format(Locale.ENGLISH,
                "Type of subquery column %s (%s) does not match is not convertable to the type of table column %s (%s)",
                failedSource,
                failedSource.valueType(),
                failedTarget.info().ident().columnIdent().fqn(),
                failedTarget.valueType()
        ));
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:27,代码来源:InsertFromSubQueryAnalyzer.java

示例3: appendNode

import com.google.common.base.Joiner; //导入方法依赖的package包/类
@Override
public void appendNode(Node node) {
    Map<String, Object> attributes = Maps.newHashMap();
    Joiner joiner = Joiner.on("|");
    attributes.put("including", joiner.join(includes));
    attributes.put("excluding", joiner.join(excludes));
    attributes.put("output", output);
    addClasspathEntry(node, attributes);
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:10,代码来源:SourceFolder.java

示例4: buildResource

import com.google.common.base.Joiner; //导入方法依赖的package包/类
/**
 * 将path、queryParam、formParam合成一个字符串
 *
 */
private static String buildResource(String pathWithParams, Map<String, String> queryParams, Map<String, String> formParams) {
    StringBuilder result = new StringBuilder();
    result.append(pathWithParams);

    //使用TreeMap,默认按照字母排序
    TreeMap<String, String> parameter = new TreeMap<String, String>();
    if (MapUtils.isNotEmpty(queryParams)) {
        parameter.putAll(queryParams);
    }
    if (MapUtils.isNotEmpty(formParams)) {
        parameter.putAll(formParams);
    }

    if (parameter.size() > 0) {
        result.append("?");

        // bugfix by [email protected]: "kv separator should be ignored while value is empty, ex. k1=v1&k2&k3=v3&k4"
        List<String> comboMap = new ArrayList<String>();
        for(Entry<String, String> entry : parameter.entrySet()){
            String comboResult = entry.getKey() + (StringUtils.isNotEmpty(entry.getValue())? "="+entry.getValue() : StringUtils.EMPTY);
            comboMap.add(comboResult);
        }
        Joiner joiner = Joiner.on("&");
        result.append(joiner.join(comboMap));
    }
    return result.toString();
}
 
开发者ID:aliyun,项目名称:apigateway-sdk-core,代码行数:32,代码来源:SignUtil.java

示例5: formatLists

import com.google.common.base.Joiner; //导入方法依赖的package包/类
private static <T> String formatLists(List<T> actual, List<T> expected)
{
    Joiner joiner = Joiner.on("\n    ");
    return format("Actual [%s]:%n    %s%nExpected [%s]:%n    %s%n",
            actual.size(), joiner.join(actual),
            expected.size(), joiner.join(expected));
}
 
开发者ID:dbiir,项目名称:rainbow,代码行数:8,代码来源:TreeAssertions.java

示例6: 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

示例7: 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

示例8: 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

示例9: generateJoiner

import com.google.common.base.Joiner; //导入方法依赖的package包/类
@Generates private Joiner generateJoiner() {
  return Joiner.on(generateString());
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:4,代码来源:FreshValueGenerator.java

示例10: combineChapters

import com.google.common.base.Joiner; //导入方法依赖的package包/类
private boolean combineChapters(List<Chapter> chapters, String fileName)
{
    StringBuilder concat = new StringBuilder();
    concat.append("concat:");
    for(Chapter chapter: chapters)
        concat.append(chapterFilename(fileName, chapter.chapterNumber)).append("|");
    concat.setLength(concat.length() - 1);

    List<String> cmdArgs = new ArrayList<>();
    cmdArgs.add(this.ffmpeg);
    cmdArgs.add("-hide_banner");
    cmdArgs.addAll(ImmutableList.of("-loglevel", "error"));
    cmdArgs.add("-i");
    cmdArgs.add(concat.toString());
    cmdArgs.addAll(ImmutableList.of("-c", "copy"));
    cmdArgs.add("-copy_unknown");
    cmdArgs.add("-y");
    cmdArgs.add(finalFilename(fileName));

    try {
        logger.info("Combining Chapters...");
        Process process = new ProcessBuilder(cmdArgs).start();
        ProcessingLoggingHandler outputHandler = new ProcessingLoggingHandler("STDOUT", process.getInputStream(), logger, getFilterList());
        ProcessingLoggingHandler errorHandler = new ProcessingLoggingHandler("STDERR", process.getErrorStream(), logger, getFilterList());
        outputHandler.start();
        errorHandler.start();
        int rc = process.waitFor();
        if (rc != 0) {
            Joiner joiner = Joiner.on(" ");
            if (logger.isWarnEnabled()) {
                logger.warn("Command exited with code: {}", rc);
                logger.warn("{}", joiner.join(cmdArgs));
            }
        }
        return rc == 0;

    } catch (Exception ex) {
        logger.error(ex.getMessage(), ex);
    }
    return false;
}
 
开发者ID:KKDad,项目名称:MediaTool,代码行数:42,代码来源:RemoveCommercials.java

示例11: extractChapter

import com.google.common.base.Joiner; //导入方法依赖的package包/类
/**
 * Extract the chapter (Video and all Audio streams) from the Media file using ffmpeg
 * @param chapter - Chapter to extract. Chapter specified the start postion in seconds and the length of the clip
 * @param fileName - Media file to extract from
 * @return  Non-zero on failure, zero for success
 */
private int extractChapter(Chapter chapter, String fileName)
{
    List<String> filterList = getFilterList();

    List<String> cmdArgs = new ArrayList<>();
    cmdArgs.add(this.ffmpeg);
    cmdArgs.add("-hide_banner");
    cmdArgs.addAll(ImmutableList.of("-loglevel", "error"));
    cmdArgs.addAll(ImmutableList.of("-i", fileName));
    cmdArgs.addAll(ImmutableList.of("-ss", DECIMAL_FORMAT.format(chapter.start)));
    if (chapter.length > 0)
        cmdArgs.addAll(ImmutableList.of("-t", DECIMAL_FORMAT.format(chapter.length)));
    cmdArgs.addAll(generateMap(3));
    cmdArgs.addAll(ImmutableList.of("-c", "copy"));
    cmdArgs.add("-copy_unknown");
    cmdArgs.addAll(ImmutableList.of("-y", chapterFilename(fileName, chapter.chapterNumber)));

    try {
        logger.info("Extracting Chapter {}, Length: {}", chapter.chapterNumber, chapter.length);
        Process process = new ProcessBuilder(cmdArgs).start();
        ProcessingLoggingHandler outputHandler = new ProcessingLoggingHandler("STDOUT", process.getInputStream(), logger, filterList);
        ProcessingLoggingHandler errorHandler = new ProcessingLoggingHandler("STDERR", process.getErrorStream(), logger, filterList);
        outputHandler.start();
        errorHandler.start();

        int rc = process.waitFor();
        if (rc != 0) {
            Joiner joiner = Joiner.on(" ");
            if (logger.isWarnEnabled()) {
                logger.warn("Command exited with code: {}", rc);
                logger.warn("{}", joiner.join(cmdArgs));
            }
        }
        return rc;

    } catch (Exception ex) {
        logger.error(ex.getMessage(), ex);
    }
    return -1;
}
 
开发者ID:KKDad,项目名称:MediaTool,代码行数:47,代码来源:RemoveCommercials.java

示例12: 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


注:本文中的com.google.common.base.Joiner.on方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。