Example usage for org.springframework.util StringUtils arrayToCommaDelimitedString

List of usage examples for org.springframework.util StringUtils arrayToCommaDelimitedString

Introduction

In this page you can find the example usage for org.springframework.util StringUtils arrayToCommaDelimitedString.

Prototype

public static String arrayToCommaDelimitedString(@Nullable Object[] arr) 

Source Link

Document

Convert a String array into a comma delimited String (i.e., CSV).

Usage

From source file:org.spring.data.gemfire.app.main.InitializerPeerCacheApp.java

@Override
protected ConfigurableApplicationContext initApplicationContext(final String... args) {
    new SpringContextBootstrappingInitializer().init(PropertyUtils.createProperties(
            Collections.singletonMap(SpringContextBootstrappingInitializer.CONTEXT_CONFIG_LOCATIONS_PARAMETER,
                    StringUtils.arrayToCommaDelimitedString(getConfigurationFile(args)))));

    return SpringContextBootstrappingInitializer.getApplicationContext();
}

From source file:org.jdal.ui.bind.ControlBindingErrorProcessor.java

/** 
 * Add a ControlError instead FieldError to hold component that has failed.
 * @param control/*from w  ww . j av a  2 s  .c o  m*/
 * @param ex
 * @param bindingResult
 */
public void processPropertyAccessException(Object control, PropertyAccessException ex,
        BindingResult bindingResult) {
    // Create field error with the exceptions's code, e.g. "typeMismatch".
    String field = ex.getPropertyName();
    String[] codes = bindingResult.resolveMessageCodes(ex.getErrorCode(), field);
    Object[] arguments = getArgumentsForBindError(bindingResult.getObjectName(), field);
    Object rejectedValue = ex.getValue();
    if (rejectedValue != null && rejectedValue.getClass().isArray()) {
        rejectedValue = StringUtils.arrayToCommaDelimitedString(ObjectUtils.toObjectArray(rejectedValue));
    }
    bindingResult.addError(new ControlError(control, bindingResult.getObjectName(), field, rejectedValue, true,
            codes, arguments, ex.getLocalizedMessage()));
}

From source file:io.pivotal.strepsirrhini.chaoslemur.RandomFateEngine.java

@Autowired
RandomFateEngine(@Value("${blacklist:}") String[] blacklist,
        @Value("${default.probability:0.2}") Float defaultProbability, Environment environment, Random random,
        @Value("${whitelist:}") String[] whitelist) {

    this.blacklist = blacklist;
    this.defaultProbability = defaultProbability.toString();
    this.environment = environment;
    this.random = random;
    this.whitelist = whitelist;

    this.logger.info("Blacklist: {}", StringUtils.arrayToCommaDelimitedString(blacklist));
    this.logger.info("Whitelist: {}", StringUtils.arrayToCommaDelimitedString(whitelist));
    this.logger.info("Default probability: {}", defaultProbability);
}

From source file:com.eu.evaluation.server.service.impl.DataServiceImpl.java

public void copyData(EvaluateVersion ev, AccessSystem system) {
    List<ObjectDictionary> ods = objectDictionaryDAO.findAndOrder();

    String sqlTemp = "insert into {0} ( {1} ) select {2} , ''{3}'' from {4} o "
            + "where o.position = :position "
            + "and not exists (select 1 from {5} t where t.id = o.id and t.evaluateVersion_id = :evid and t.position = :position)";
    for (ObjectDictionary od : ods) {
        List<String> fds = fieldDictionaryDAO.findByObject(od.getId());
        String orgFieldStr = StringUtils.arrayToCommaDelimitedString(fds.toArray(new String[] {}));

        fds.add("evaluateVersion_id");
        String feildStr = StringUtils.arrayToCommaDelimitedString(fds.toArray(new String[] {}));

        String tableName = od.getTableName();
        String orgTableName = tableName + "_org";

        String sql = MessageFormat.format(sqlTemp,
                new Object[] { tableName, feildStr, orgFieldStr, ev.getId(), orgTableName, tableName });
        logger.debug("??sql" + sql);

        MapSqlParameterSource params = new MapSqlParameterSource("evid", ev.getId());
        params.addValue("position", system.getCode());
        defaultDAO.executeNativeInsert(sql, params);
    }//from  w  w w . j  av  a 2 s  . c o  m
}

From source file:com.reactivetechnologies.platform.analytics.dto.ArffJsonRequest.java

@Override
public String toString() {
    StringBuilder s = new StringBuilder("@RELATION ");
    s.append(StringUtils.hasText(getRelation()) ? getRelation() : "stream").append("\n\n");

    for (Attribute a : getAttributes()) {
        s.append("@ATTRIBUTE ").append(a.getName()).append(" ");
        if (StringUtils.hasText(a.getType())) {
            if (a.getType().equalsIgnoreCase("string") || a.getType().equalsIgnoreCase("numeric")) {
                s.append(a.getType()).append("\n");
            } else if (a.getType().equalsIgnoreCase("date")) {
                s.append(a.getType()).append("\"").append(a.getSelector()[0]).append("\"").append("\n");
            }//from   ww w.  j  a  v  a  2 s. c  o m
        } else {
            s.append("{").append(StringUtils.arrayToCommaDelimitedString(a.getSelector())).append("}")
                    .append("\n");
        }
    }

    s.append("\n@DATA\n");
    for (String d : getData()) {
        s.append(d).append("\n");
    }

    return s.toString();
}

From source file:com.autentia.wuija.spring.TestContextLoader.java

@Override
public final ConfigurableApplicationContext loadContext(String... locations) throws Exception {

    if (log.isDebugEnabled()) {
        log.debug("Loading ApplicationContext for locations ["
                + StringUtils.arrayToCommaDelimitedString(locations) + "].");
    }//from  ww w  .j  a v a 2s .c  o m

    final GenericWebApplicationContext context = new GenericWebApplicationContext();

    customizeBeanFactory(context.getDefaultListableBeanFactory());
    createBeanDefinitionReader(context).loadBeanDefinitions(locations);
    AnnotationConfigUtils.registerAnnotationConfigProcessors(context);
    customizeContext(context);

    context.refresh();
    context.registerShutdownHook();

    return context;
}

From source file:com.consol.citrus.validation.ValidationUtils.java

/**
 * Validates actual against expected value of element
 * @param actualValue/*from  ww w.  j a  va2  s  .  com*/
 * @param expectedValue
 * @param pathExpression
 * @param context
 * @throws com.consol.citrus.exceptions.ValidationException if validation fails
 */
public static void validateValues(Object actualValue, Object expectedValue, String pathExpression,
        TestContext context) throws ValidationException {
    try {
        if (actualValue != null) {
            Assert.isTrue(expectedValue != null, ValidationUtils.buildValueMismatchErrorMessage(
                    "Values not equal for element '" + pathExpression + "'", null, actualValue));

            if (expectedValue instanceof Matcher) {
                Assert.isTrue(((Matcher) expectedValue).matches(actualValue),
                        ValidationUtils.buildValueMismatchErrorMessage(
                                "Values not matching for element '" + pathExpression + "'", expectedValue,
                                actualValue));
                return;
            }

            if (!(expectedValue instanceof String)) {
                Object converted = TypeConversionUtils.convertIfNecessary(actualValue,
                        expectedValue.getClass());

                if (converted instanceof List) {
                    Assert.isTrue(converted.toString().equals(expectedValue.toString()),
                            ValidationUtils.buildValueMismatchErrorMessage(
                                    "Values not equal for element '" + pathExpression + "'",
                                    expectedValue.toString(), converted.toString()));
                } else if (converted instanceof String[]) {
                    String convertedDelimitedString = StringUtils
                            .arrayToCommaDelimitedString((String[]) converted);
                    String expectedDelimitedString = StringUtils
                            .arrayToCommaDelimitedString((String[]) expectedValue);

                    Assert.isTrue(convertedDelimitedString.equals(expectedDelimitedString),
                            ValidationUtils.buildValueMismatchErrorMessage(
                                    "Values not equal for element '" + pathExpression + "'",
                                    expectedDelimitedString, convertedDelimitedString));
                } else if (converted instanceof byte[]) {
                    String convertedBase64 = Base64.encodeBase64String((byte[]) converted);
                    String expectedBase64 = Base64.encodeBase64String((byte[]) expectedValue);

                    Assert.isTrue(convertedBase64.equals(expectedBase64),
                            ValidationUtils.buildValueMismatchErrorMessage(
                                    "Values not equal for element '" + pathExpression + "'", expectedBase64,
                                    convertedBase64));
                } else {
                    Assert.isTrue(converted.equals(expectedValue),
                            ValidationUtils.buildValueMismatchErrorMessage(
                                    "Values not equal for element '" + pathExpression + "'", expectedValue,
                                    converted));
                }
            } else {
                String expectedValueString = expectedValue.toString();
                String actualValueString;
                if (List.class.isAssignableFrom(actualValue.getClass())) {
                    actualValueString = StringUtils.arrayToCommaDelimitedString(
                            ((List) actualValue).toArray(new Object[((List) actualValue).size()]));
                    expectedValueString = expectedValueString.replaceAll("^\\[", "").replaceAll("\\]$", "")
                            .replaceAll(",\\s", ",");
                } else {
                    actualValueString = actualValue.toString();
                }

                if (ValidationMatcherUtils.isValidationMatcherExpression(String.valueOf(expectedValueString))) {
                    ValidationMatcherUtils.resolveValidationMatcher(pathExpression, actualValueString,
                            String.valueOf(expectedValueString), context);
                } else {
                    Assert.isTrue(actualValueString.equals(expectedValueString),
                            ValidationUtils.buildValueMismatchErrorMessage(
                                    "Values not equal for element '" + pathExpression + "'",
                                    expectedValueString, actualValueString));
                }
            }
        } else {
            Assert.isTrue(expectedValue == null || String.valueOf(expectedValue).length() == 0,
                    ValidationUtils.buildValueMismatchErrorMessage(
                            "Values not equal for element '" + pathExpression + "'", expectedValue, null));
        }
    } catch (IllegalArgumentException e) {
        throw new ValidationException("Validation failed:", e);
    }
}

From source file:com.vmware.o11n.plugin.powershell.model.Pipeline.java

private Object getParamValue(Object value) {
    String res = null;//from www  . java  2 s .c om
    if (value != null && value.getClass().isArray()) {
        res = StringUtils.arrayToCommaDelimitedString((Object[]) value);
    } else if (value instanceof RemotePSObject) {
        RemotePSObject obj = (RemotePSObject) value;
        if (obj.getRefId() != null) {
            res = String.format("(getVarByRef( '%s'))", obj.getRefId());
        } else {
            res = String.format("(deserialize( '%s'))", obj.getXml());
        }
    } else {
        res = value.toString();
    }

    return res;
}

From source file:com.reactivetechnologies.analytics.dto.ArffJsonRequest.java

@Override
public String toString() {
    StringBuilder s = new StringBuilder("@RELATION ");
    s.append(StringUtils.hasText(getRelation()) ? getRelation() : "stream").append("\n\n");

    for (Attribute a : getAttributes()) {
        s.append("@ATTRIBUTE ").append(a.getName()).append(" ");
        if (StringUtils.hasText(a.getType())) {
            if (a.getType().equalsIgnoreCase("string") || a.getType().equalsIgnoreCase("numeric")) {
                s.append(a.getType()).append("\n");
            } else if (a.getType().equalsIgnoreCase("date")) {
                s.append(a.getType()).append("\"").append(a.getSelector()[0]).append("\"").append("\n");
            }/* www.  j  a v a 2  s  .c o m*/
        } else {
            s.append("{").append(StringUtils.arrayToCommaDelimitedString(a.getSelector())).append("}")
                    .append("\n");
        }
    }

    s.append("\n@DATA\n");
    for (Text d : getData()) {
        s.append(d.getText()).append("\n");
    }

    return s.toString();
}

From source file:lodsve.core.condition.OnJndiCondition.java

private ConditionOutcome getMatchOutcome(String[] locations) {
    if (!isJndiAvailable()) {
        return ConditionOutcome.noMatch("JNDI environment is not available");
    }/*from www.j  a v  a 2  s  .com*/
    if (locations.length == 0) {
        return ConditionOutcome.match("JNDI environment is available");
    }
    JndiLocator locator = getJndiLocator(locations);
    String location = locator.lookupFirstLocation();
    if (location != null) {
        return ConditionOutcome.match("JNDI location '" + location + "' found from candidates "
                + StringUtils.arrayToCommaDelimitedString(locations));
    }
    return ConditionOutcome.noMatch(
            "No JNDI location found from candidates " + StringUtils.arrayToCommaDelimitedString(locations));
}