Example usage for java.lang String join

List of usage examples for java.lang String join

Introduction

In this page you can find the example usage for java.lang String join.

Prototype

public static String join(CharSequence delimiter, Iterable<? extends CharSequence> elements) 

Source Link

Document

Returns a new String composed of copies of the CharSequence elements joined together with a copy of the specified delimiter .

Usage

From source file:com.baifendian.swordfish.execserver.engine.hive.HiveUtil.java

/**
 * /*from   w ww  . j av  a  2  s.c o m*/
 */
public static String getTmpTableDDL(String dbName, String tableName, List<HqlColumn> hqlColumnList,
        String localtion, String fieldDelimiter, String fileCode) throws SQLException {

    List<String> fieldList = new ArrayList<>();

    for (HqlColumn hqlColumn : hqlColumnList) {
        fieldList.add(MessageFormat.format("{0} {1}", hqlColumn.getName(), hqlColumn.getType()));
    }

    String sql = "CREATE TEMPORARY EXTERNAL TABLE {0}.{1}({2}) ROW FORMAT SERDE \"org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe\" WITH SERDEPROPERTIES(\"field.delim\"=\"{3}\",\"serialization.encoding\"=\"{4}\") STORED AS textfile LOCATION \"{5}\"";

    sql = MessageFormat.format(sql, dbName, tableName, String.join(",", fieldList), fieldDelimiter, fileCode,
            localtion);

    return sql;
}

From source file:com.ottogroup.bi.streaming.testing.JSONFieldContentMatcher.java

/**
 * Initializes the json content matcher using the provided input
 * @param contentReference/*from   w w w  . j  a  v  a 2s  .  c o m*/
 * @param contentMatcher
 */
public JSONFieldContentMatcher(final JsonContentReference contentReference, final Matcher<?> contentMatcher) {

    ///////////////////////////////////////////////////////////
    // validate provided input
    if (contentReference == null)
        throw new IllegalArgumentException("Missing required content reference");
    if (contentReference.getPath() == null || contentReference.getPath().length < 1)
        throw new IllegalArgumentException("Missing required content path");
    if (contentReference.getContentType() == JsonContentType.TIMESTAMP
            && StringUtils.isBlank(contentReference.getConversionPattern()))
        throw new IllegalArgumentException("Missing required conversion pattern for timestamp values");
    if (contentMatcher == null)
        throw new IllegalArgumentException("Missing required content matcher");
    ///////////////////////////////////////////////////////////

    this.contentReference = contentReference;
    this.contentMatcher = contentMatcher;

    ///////////////////////////////////////////////////////////
    // create flattened 
    this.flattenedContentPath = String.join(".", contentReference.getPath());
    ///////////////////////////////////////////////////////////
}

From source file:com.caricah.iotracah.datastore.ignitecache.internal.impl.SubscriptionFilterHandler.java

public IotSubscriptionFilterKey keyFromList(String partitionId, List<String> topicList) {

    IotSubscriptionFilterKey filterKey = new IotSubscriptionFilterKey();
    filterKey.setName(String.join(Constant.PATH_SEPARATOR, topicList));
    filterKey.setPartitionId(partitionId);
    return filterKey;
}

From source file:io.galeb.router.sync.HttpClient.java

private static String localIpsEncoded() {
    final List<String> ipList = new ArrayList<>();
    try {//  w  w w  .j  a v  a 2  s.  co  m
        Enumeration<NetworkInterface> ifs = NetworkInterface.getNetworkInterfaces();
        while (ifs.hasMoreElements()) {
            NetworkInterface localInterface = ifs.nextElement();
            if (!localInterface.isLoopback() && localInterface.isUp()) {
                Enumeration<InetAddress> ips = localInterface.getInetAddresses();
                while (ips.hasMoreElements()) {
                    InetAddress ipaddress = ips.nextElement();
                    if (ipaddress instanceof Inet4Address) {
                        ipList.add(ipaddress.getHostAddress());
                        break;
                    }
                }
            }
        }
    } catch (Exception e) {
        LOGGER.error(ExceptionUtils.getStackTrace(e));
    }
    String ip = String.join("-", ipList);
    if (ip == null || "".equals(ip)) {
        ip = "undef-" + System.currentTimeMillis();
    }
    return ip.replaceAll("[:%]", "");
}

From source file:com.github.blindpirate.gogradle.util.StringUtils.java

public static String formatEnv(Map<String, String> env) {
    return String.join("\n", env.entrySet().stream().map(entry -> " " + entry.getKey() + "=" + entry.getValue())
            .collect(toList()));//from  w w w  .  j a  va  2 s  . co  m
}

From source file:com.cdd.bao.template.ClipboardSchema.java

public static String composeAssignmentTSV(Schema.Assignment assn) {
    List<String> lines = new ArrayList<>();
    lines.add("name\t" + assn.name);
    lines.add("description\t" + assn.descr.replace("\n", " "));
    lines.add("property URI\t" + assn.propURI);
    lines.add("group nest\t" + String.join("\t", assn.groupNest()));
    lines.add("");
    lines.add("value hierarchy");
    lines.add("");

    SchemaTree tree = new SchemaTree(assn, Vocabulary.globalInstance());
    if (tree != null)
        for (SchemaTree.Node node : tree.getFlat()) {
            List<String> cols = new ArrayList<>();
            cols.add(node.label);//from  w  w w . ja  va 2s. co m
            cols.add(Util.safeString(node.descr).replace("\n", " "));
            for (SchemaTree.Node look = node.parent; look != null; look = look.parent)
                cols.add("");
            cols.add(node.uri);
            lines.add(String.join("\t", cols));
        }

    return String.join("\n", lines);
}

From source file:com.pawandubey.griffin.model.Page.java

/**
 * @return the slug/*from w w  w .j  a v a2s.  c  o  m*/
 */
@Override
public String getSlug() {
    if (slug == null || slug.equals(" ")) {
        return String.join("-", title.trim().toLowerCase().split(" "));
    } else {
        return String.join("-", slug.trim().toLowerCase().split(" "));
    }
}

From source file:cop.raml.utils.ProblemResolver.java

public static void ambiguousImportClassDefinition(String className, String importClassName,
        List<String> candidates, String candidate) {
    if (StringUtils.isBlank(className) || StringUtils.isBlank(importClassName))
        return;/*from w w  w.  j  a  va2 s  .  c  o  m*/

    if (Config.get().ramlStopOnError())
        throw new RamlProcessingException(String.format(
                "Cannot choose correct import for class name '%s' in class '%s'. Existed candidates: [%s]",
                importClassName, className, String.join(",", candidates)));

    ThreadLocalContext.getMessager().printMessage(WARNING,
            String.format("Multiple candidates for class name '%s' in class '%s' found. Will use: '%s'",
                    importClassName, className, candidate));
}

From source file:edu.usu.sdl.openstorefront.web.action.APIAction.java

@DefaultHandler
public Resolution mainPage() {
    ResolverUtil resolverUtil = new ResolverUtil();
    resolverUtil.find(new ResolverUtil.IsA(BaseResource.class), "edu.usu.sdl.openstorefront.web.rest.resource");

    List<Class> classList = new ArrayList<>();
    classList.addAll(resolverUtil.getClasses());
    for (Class apiResourceClass : classList) {
        if (BaseResource.class.getName().equals(apiResourceClass.getName()) == false) {
            LookupModel lookupModel = new LookupModel();
            lookupModel.setCode(apiResourceClass.getSimpleName());
            lookupModel.setDescription(String
                    .join(" ", StringUtils.splitByCharacterTypeCamelCase(apiResourceClass.getSimpleName()))
                    .replace("Resource", "").replace("REST", ""));
            resourceClasses.add(lookupModel);
        }//  w w w . jav a2s .co m
    }

    resolverUtil = new ResolverUtil();
    resolverUtil.find(new ResolverUtil.IsA(BaseResource.class), "edu.usu.sdl.openstorefront.web.rest.service");

    classList = new ArrayList<>();
    classList.addAll(resolverUtil.getClasses());
    for (Class apiResourceClass : classList) {
        LookupModel lookupModel = new LookupModel();
        lookupModel.setCode(apiResourceClass.getSimpleName());
        lookupModel.setDescription(
                String.join(" ", StringUtils.splitByCharacterTypeCamelCase(apiResourceClass.getSimpleName()))
                        .replace("Service", ""));
        serviceClasses.add(lookupModel);
    }
    resourceClasses
            .sort(new BeanComparator<>(OpenStorefrontConstant.SORT_DESCENDING, LookupModel.DESCRIPTION_FIELD));
    serviceClasses
            .sort(new BeanComparator<>(OpenStorefrontConstant.SORT_DESCENDING, LookupModel.DESCRIPTION_FIELD));

    return new ForwardResolution("/WEB-INF/securepages/api/main.jsp");
}

From source file:esiptestbed.mudrod.recommendation.structure.OHCodeExtractor.java

/**
 * load code value of giving variables//w  ww.j ava 2  s . c  om
 *
 * @param es
 *          the Elasticsearch client
 * @param fields
 *          variables list
 * @return code ist
 */
public List<String> loadFieldsOHEncode(ESDriver es, List<String> fields) {

    List<String> metedataCode = new ArrayList<>();
    SearchResponse scrollResp = es.getClient().prepareSearch(indexName).setTypes(metadataType)
            .setScroll(new TimeValue(60000)).setQuery(QueryBuilders.matchAllQuery()).setSize(100).execute()
            .actionGet();

    int fieldnum = fields.size();
    while (true) {
        for (SearchHit hit : scrollResp.getHits().getHits()) {
            Map<String, Object> metadata = hit.getSource();

            String shortname = (String) metadata.get("Dataset-ShortName");

            String[] codeArr = new String[fieldnum];
            for (int i = 0; i < fieldnum; i++) {
                String field = fields.get(i);
                String code = (String) metadata.get(field + "_code");
                codeArr[i] = code;
            }
            String codeStr = String.join(" & ", codeArr);

            metedataCode.add(shortname + ":" + codeStr);
        }

        scrollResp = es.getClient().prepareSearchScroll(scrollResp.getScrollId())
                .setScroll(new TimeValue(600000)).execute().actionGet();
        if (scrollResp.getHits().getHits().length == 0) {
            break;
        }
    }

    return metedataCode;
}