Example usage for org.apache.commons.lang StringUtils join

List of usage examples for org.apache.commons.lang StringUtils join

Introduction

In this page you can find the example usage for org.apache.commons.lang StringUtils join.

Prototype

public static String join(Collection<?> collection, String separator) 

Source Link

Document

Joins the elements of the provided Collection into a single String containing the provided elements.

Usage

From source file:com.kstenschke.copypastestack.Preferences.java

/**
 * Store items//from ww w .  jav a2  s  . c  o m
 *
 * @param items
 */
public static void saveCopyItems(String[] items) {
    PropertiesComponent.getInstance().setValue(PROPERTY_ITEMS,
            StringUtils.join(items, StaticTexts.SEPARATOR_ITEMS_SPLIT));
}

From source file:ch.ethz.polyql.jql.domain.shared.TextUtil.java

/**
 * Join./*from  w  w  w. j a va2s  .co m*/
 *
 * @param text the text
 * @return the string
 */
public static String join(final String[] text) {

    return StringUtils.join(text, "\n");

}

From source file:com.hs.mail.imap.processor.CapabilityProcessor.java

@Override
protected void doProcess(ImapSession session, ImapRequest message, Responder responder) {
    CapabilityRequest request = (CapabilityRequest) message;
    responder.untagged(request.getCommand() + " " + StringUtils.join(capabilities, ' ') + "\r\n");
    responder.okCompleted(request);// w  ww. j  a v a 2  s. com
}

From source file:beans.HmacImpl.java

@Override
public String sign(Object... objs) {
    try {//from   w  w  w  . j a v  a  2s .c o m
        List objects = CollectionUtils.addTo(new LinkedList(), objs);
        objects.add(conf.application.secret); // add the secret so no-one can reproduce this string.
        String joined = StringUtils.join(objs, SEPARATOR);
        byte[] base64Result = Base64.encodeBase64(joined.getBytes());
        byte[] md5s = MessageDigest.getInstance("MD5").digest(base64Result);

        StringBuffer sb = new StringBuffer();
        for (byte md5 : md5s) {
            sb.append(Integer.toString((md5 & 0xff) + 0x100, 16).substring(1));
        }

        return sb.toString();
    } catch (Exception e) {
        throw new RuntimeException("unable to sign Hmac for " + ArrayUtils.toString(objs), e);
    }
}

From source file:ar.edu.fesf.security.OpenIDAttributes2UserDetailsImpl.java

/**
 * {@inheritDoc}// ww  w  . ja  v  a2s  .  c  om
 */
@Override
public UserDetails extract(final OpenIDAuthenticationToken token) {
    String email = "";
    String firstName = "";
    String lastName = "";
    String language = "";
    List<OpenIDAttribute> attributes = token.getAttributes();
    for (OpenIDAttribute openIDAttribute : attributes) {
        if (openIDAttribute.getName().equals("firstName")) {
            firstName = StringUtils.join(openIDAttribute.getValues(), "");
        }

        if (openIDAttribute.getName().equals("email")) {
            email = StringUtils.join(openIDAttribute.getValues(), "");
        }

        if (openIDAttribute.getName().equals("lastName")) {
            lastName = StringUtils.join(openIDAttribute.getValues(), "");
        }

        if (openIDAttribute.getName().equals("language")) {
            language = StringUtils.join(openIDAttribute.getValues(), "");
        }
    }
    return new UserDetailsImpl(token.getIdentityUrl(), firstName, lastName, email, language);
}

From source file:cd.go.contrib.elasticagents.dockerswarm.elasticagent.executors.MemoryMetadata.java

@Override
protected String doValidate(String input) {
    List<String> errors = new ArrayList<>(Arrays.asList(super.doValidate(input)));

    try {/*from   w ww  . j ava  2s  . co m*/
        Size.parse(input);
    } catch (Exception e) {
        errors.add(e.getMessage());
    }

    errors.removeAll(Collections.singleton(null));

    if (errors.isEmpty()) {
        return null;
    }
    return StringUtils.join(errors, ". ");
}

From source file:com.dilipkumarg.qb.InsertQueryBuilder.java

private String buildArgsKeyList(Set<TableColumn> columns) {
    List<String> keys = Lists.newArrayList();
    for (TableColumn column : columns) {
        keys.add(column.getFieldName());
    }/*from   w  ww.  j a v  a2s . c  o m*/
    return StringUtils.join(keys, SEPARATOR);
}

From source file:io.kodokojo.bdd.stage.ExpectedProjectState.java

@Override
public String toString() {
    return StringUtils.join(brickTypePresents, ",");
}

From source file:net.mikaboshi.intra_mart.tools.log_stats.parser.ExceptionLogParserV7Test.java

    () throws ParseException {

   String logText = StringUtils.join(new String[] {
            "log.generating.time=Sun Nov 13 15:55:39 KST 2011",
            "log.level=ERROR",
            "log.logger.name=jp.co.intra_mart.system.javascript.imapi.ResinDataSourceConfiguraterObject",
            "log.id=5i0slu795nope",
            "log.thread.id=http-APP:localhost:8088-8088-0$312771783",
            "log.thread.group=main",
            "log.message=JNDI??(jdbc/oracle)???????",
            "",//from   ww w .j  av  a2 s. c om
            "jp.co.intra_mart.foundation.database.exception.DataSourceConfigurationException: JNDI??(jdbc/oracle)???????",
            "\tat jp.co.intra_mart.foundation.database.ResinDataSourceConfigurater.bind(ResinDataSourceConfigurater.java:111)",
            "\tat jp.co.intra_mart.system.javascript.imapi.ResinDataSourceConfiguraterObject.jsFunction_bind(ResinDataSourceConfiguraterObject.java:152)"
         }, IOUtils.LINE_SEPARATOR);

   ExceptionLogParser exceptionLogParser = new ExceptionLogParserV7(new ParserParameter());

   ExceptionLog log = exceptionLogParser.parse(logText);

   assertEquals(
         new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy", Locale.ENGLISH).parse("Sun Nov 13 15:55:39 KST 2011"),
         log.date);

   assertEquals(Level.ERROR, log.level);
   assertEquals("jp.co.intra_mart.system.javascript.imapi.ResinDataSourceConfiguraterObject", log.logger);
   assertEquals("5i0slu795nope", log.logId);
   assertEquals("http-APP:localhost:8088-8088-0$312771783", log.thread);
   assertEquals("main", log.logThreadGroup);
   assertEquals("JNDI??(jdbc/oracle)???????", log.message);
   assertEquals("jp.co.intra_mart.foundation.database.exception.DataSourceConfigurationException: JNDI??(jdbc/oracle)???????", log.getFirstLineOfStackTrace());
}

From source file:com.microsoft.azure.shortcuts.services.samples.StorageAccountsSample.java

public static void test(Azure azure) throws Exception {
    final String accountName = "store" + String.valueOf(System.currentTimeMillis());
    System.out.println(String.format("Creating account named '%s'...", accountName));

    // Create a new storage account
    azure.storageAccounts().define(accountName).withRegion("West US").create();

    // List storage accounts
    Map<String, StorageAccount> storageAccounts = azure.storageAccounts().asMap();
    System.out.println("Available storage accounts:\n\t" + StringUtils.join(storageAccounts.keySet(), ",\n\t"));

    // Get storage account information
    StorageAccount storageAccount = azure.storageAccounts(accountName);
    System.out.println(String.format(
            "Found storage account: %s\n" + "\tAffinity group: %s\n" + "\tLabel: %s\n" + "\tDescription: %s\n"
                    + "\tGeo primary region: %s\n" + "\tGeo primary region status: %s\n"
                    + "\tGeo secondary region: %s\n" + "\tGeo secondary region status: %s\n"
                    + "\tLast geo failover time: %s\n" + "\tRegion: %s\n" + "\tStatus: %s\n"
                    + "\tEndpoints: %s\n" + "\tType: %s\n",

            storageAccount.id(), storageAccount.affinityGroup(), storageAccount.label(),
            storageAccount.description(), storageAccount.geoPrimaryRegion(),
            storageAccount.geoPrimaryRegionStatus(), storageAccount.geoSecondaryRegion(),
            storageAccount.geoSecondaryRegionStatus(),
            (storageAccount.lastGeoFailoverTime() != null) ? storageAccount.lastGeoFailoverTime().getTime()
                    : null,//from  w  w w  .j  a  v  a  2s  . c  om
            storageAccount.region(), storageAccount.status(),
            StringUtils.join(storageAccount.endpoints(), ", "), storageAccount.type()));

    // Update storage info
    System.out.println(String.format("Updating storage account named '%s'...", accountName));

    azure.storageAccounts().update(accountName).withDescription("Updated").withLabel("Updated").apply();

    storageAccount = azure.storageAccounts(accountName);
    System.out.println(String.format("Updated storage account: %s\n" + "\tLabel: %s\n" + "\tDescription: %s\n",
            storageAccount.id(), storageAccount.label(), storageAccount.description()));

    // Delete the newly created storage account
    System.out.println(String.format("Deleting storage account named '%s'...", accountName));
    azure.storageAccounts().delete(accountName);
}