Example usage for org.springframework.util StringUtils arrayToDelimitedString

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

Introduction

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

Prototype

public static String arrayToDelimitedString(@Nullable Object[] arr, String delim) 

Source Link

Document

Convert a String array into a delimited String (e.g.

Usage

From source file:co.mafiagame.common.utils.ListToString.java

public static String toString(List<String> source) {
    return StringUtils.arrayToDelimitedString(source.toArray(new String[source.size()]), "  ");
}

From source file:org.web4thejob.orm.PathMetadataImpl.java

public PathMetadataImpl(Class<? extends Entity> entityType, String[] path) {
    this.path = StringUtils.arrayToDelimitedString(path, Path.DELIMITER);
    steps = new ArrayList<PropertyMetadata>();

    EntityMetadata entityMetadata = ContextUtil.getMRS().getEntityMetadata(entityType);

    if (entityMetadata == null) {
        throw new IllegalArgumentException("Entity type " + entityType.getName() + " is unknown");
    }/*from   ww  w .j av  a2  s  .  c o m*/

    for (final String step : path) {
        final PropertyMetadata propertyMetadata = entityMetadata.getPropertyMetadata(step);

        if (propertyMetadata == null) {
            throw new RuntimeException(
                    "invalid attribute " + step + " for entity type " + entityMetadata.getName());
        }

        steps.add(propertyMetadata);
        entityMetadata = propertyMetadata.getAssociatedEntityMetadata();
    }

}

From source file:io.pivotal.util.MarkdownEngine.java

public static String quote(String str) {
    String[] parts = str.split("\\{quote\\}");

    for (int i = 1; i < parts.length; i += 2) {
        parts[i] = "\n > " + parts[i].replaceAll("\n", "\n> ");
    }//from ww w . j av  a2s.co  m
    return StringUtils.arrayToDelimitedString(parts, "");
}

From source file:springobjectmapper.TableProperties.java

public TableProperties(final Class<T> typeClass) {
    this.typeClass = typeClass;
    idField = getAnnotatedField(typeClass, Id.class);
    updateFields = getUpdateFields();/*  w w w . ja  v  a  2s.c o  m*/
    allFields = getUpdateFields();
    allFields.add(idField); // idField is always the last one

    final List<String> fieldNames = getFieldNames(allFields);

    Map<String, String> tags = new HashMap<String, String>();
    tags.put("idField", fieldName(idField));
    tags.put("table", getTableName());
    tags.put("fields", StringUtils.arrayToDelimitedString(fieldNames.toArray(), ","));
    tags.put("values", placeHolders(fieldNames.size()));
    tags.put("updates", updates(updateFields));
    sqlTemplate = new SqlTemplate(tags);
    mapper = new FieldPropertyRowMapper<T>(typeClass, this);
}

From source file:org.web4thejob.orm.PropertyPathTest.java

@Test
public void getValue() {
    final String[] path = new String[] { Master1.FLD_REFERENCE1, Reference1.FLD_REFERENCE2 };

    final PathMetadata pathMetadata = metaReaderService.getPropertyPath(Master1.class, path);
    Assert.assertNotNull(pathMetadata);/*  w  ww . java 2 s. c  om*/
    Assert.assertEquals(pathMetadata.getSteps().size(), 2);
    Assert.assertEquals(pathMetadata.getPath(), StringUtils.arrayToDelimitedString(path, Path.DELIMITER));
    Assert.assertTrue(pathMetadata.getFirstStep().getAssociatedEntityMetadata()
            .equals(metaReaderService.getEntityMetadata(Reference1.class)));
    Assert.assertTrue(pathMetadata.getLastStep().getAssociatedEntityMetadata()
            .equals(metaReaderService.getEntityMetadata(Reference2.class)));

    final Master1 master1 = dataReaderService.getOne(Master1.class);

    final Query query = entityFactory.buildQuery(Reference2.class);
    query.addCriterion(
            new Path(Reference2.FLD_REFERENCES1).append(Reference1.FLD_MASTERS1).append(Master1.FLD_ID),
            Condition.EQ, master1.getId());

    final Reference2 reference2 = dataReaderService.findFirstByQuery(query);
    Assert.assertNotNull(reference2);
    Assert.assertEquals(pathMetadata.getValue(master1), reference2);

}

From source file:org.smigo.log.LogController.java

@RequestMapping(value = "/rest/log/error", method = RequestMethod.POST)
@ResponseBody/*  www.j av a 2  s .  c  om*/
public void logError(@RequestBody ReferenceError referenceError, HttpServletRequest request,
        HttpServletResponse response) {
    final Log logBean = Log.create(request, response);
    final String msg = "Angular error:\n" + referenceError + "\nPlants:\n"
            + StringUtils.arrayToDelimitedString(plantHolder.getPlants().toArray(), ",") + logBean;
    log.error(msg);
    mailHandler.sendAdminNotification("angular error", msg);
}

From source file:com.taobao.rpc.doclet.RPCAPIInfoHelper.java

public static RPCAPIInfo getAPIInfo(String realPath, Method method) {
    RPCAPIInfo apiInfo = new RPCAPIInfo();

    ClassInfo classInfo = RPCAPIDocletUtil.getClassInfo(method.getDeclaringClass().getName());
    MethodInfo methodInfo = null;/*from  w  w w  . j  a  v a2s.  c o  m*/

    if (classInfo != null) {
        methodInfo = classInfo.getMethodInfo(method.getName());
    }

    if (methodInfo != null) {

        apiInfo.setComment(methodInfo.getComment());
    }

    Annotation[][] parameterAnnotations = method.getParameterAnnotations();

    Security securityAnnotation = method.getAnnotation(Security.class);
    ResourceMapping resourceMapping = method.getAnnotation(ResourceMapping.class);

    Object returnType = null;

    returnType = buildTypeStructure(method.getReturnType(), method.getGenericReturnType(), null);

    boolean checkCSRF = false;
    if (securityAnnotation != null) {
        checkCSRF = securityAnnotation.checkCSRF();
    }

    apiInfo.setPattern(realPath.replaceAll("///", "/"));
    apiInfo.setCheckCSRF(checkCSRF);
    apiInfo.setResponseMimes(StringUtils.arrayToDelimitedString(resourceMapping.produces(), ","));
    apiInfo.setHttpMethod(StringUtils.arrayToDelimitedString(resourceMapping.method(), ","));

    List<RPCAPIInfo.Parameter> parameters = new ArrayList<RPCAPIInfo.Parameter>();

    RPCAPIInfo.Parameter parameter = null;
    LocalVariableTableParameterNameDiscoverer nameDiscoverer = new LocalVariableTableParameterNameDiscoverer();
    String[] paramNames = nameDiscoverer.getParameterNames(method);
    int i = 0;

    Class<?>[] parameterTypes = method.getParameterTypes();

    Type[] genericParameterTypes = method.getGenericParameterTypes();

    Class<?> paramType = null;

    Type genericType;

    for (int k = 0; k < parameterTypes.length; k++) {

        paramType = parameterTypes[k];
        genericType = genericParameterTypes[k];

        Annotation[] pAnnotations = parameterAnnotations[i];

        if (HttpServletRequest.class.isAssignableFrom(paramType)
                || HttpServletResponse.class.isAssignableFrom(paramType)
                || ErrorContext.class.isAssignableFrom(paramType)) {
            continue;
        } // end if

        String realParamName = paramNames[k];

        if (pAnnotations.length == 0) {

            parameter = apiInfo.new Parameter();
            parameter.setName(realParamName);
            parameter.setType(buildTypeStructure(paramType, genericType, null));
            parameters.add(parameter);

            setParameterComment(parameter, realParamName, methodInfo);

            continue;
        } // end if

        for (Annotation annotation : pAnnotations) {
            parameter = apiInfo.new Parameter();
            setParameterComment(parameter, realParamName, methodInfo);

            if (annotation instanceof RequestParam) {
                RequestParam requestParam = (RequestParam) annotation;
                parameter.setName(requestParam.name());
                parameter.setType(buildTypeStructure(paramType, genericType, null));
                if (!StringUtil.isBlank(requestParam.defaultValue())) {
                    parameter.setDefaultValue(requestParam.defaultValue().trim());
                }
                parameters.add(parameter);
            } else if (annotation instanceof PathParam) {
                PathParam pathParam = (PathParam) annotation;
                parameter.setName(pathParam.name());
                parameter.setType(buildTypeStructure(paramType, genericType, null));
                if (!StringUtil.isBlank(pathParam.defaultValue())) {
                    parameter.setDefaultValue(pathParam.defaultValue().trim());
                }
                parameters.add(parameter);
            } else if (annotation instanceof JsonParam) {
                JsonParam pathParam = (JsonParam) annotation;
                parameter.setName(pathParam.value());
                parameter.setType(buildTypeStructure(paramType, genericType, null));
                parameters.add(parameter);
            } else if (annotation instanceof RequestParams) {
                parameter.setName(realParamName);
                parameter.setType(buildTypeStructure(paramType, genericType, null));
                parameters.add(parameter);
            } else if (annotation instanceof File) {
                File file = (File) annotation;
                parameter.setName(file.value());
                parameter.setType("");
                parameters.add(parameter);
            } // end if
        } // end for
        i++;
    } // end for
    apiInfo.setParmeters(parameters);
    apiInfo.setReturnType(returnType);
    return apiInfo;
}

From source file:org.smigo.user.UserController.java

@RequestMapping(value = "/rest/user", method = RequestMethod.POST)
@ResponseBody//from   w  w  w .  j  av  a2  s. c  o m
public List<ObjectError> addUser(@RequestBody @Valid UserAdd user, BindingResult result,
        HttpServletResponse response, Locale locale) {
    log.info("Create user: " + user);
    if (result.hasErrors()) {
        log.warn("Create user failed. Username:" + user.getUsername() + " Errors:"
                + StringUtils.arrayToDelimitedString(result.getAllErrors().toArray(), ", "));
        response.setStatus(HttpStatus.UNPROCESSABLE_ENTITY.value());
        return result.getAllErrors();
    }
    userHandler.createUser(user, locale);
    return Collections.emptyList();
}

From source file:octopus.teamcity.agent.OctopusBuildProcess.java

private void startOcto(final OctopusCommandBuilder command) throws RunBuildException {
    String[] userVisibleCommand = command.buildMaskedCommand();
    String[] realCommand = command.buildCommand();

    logger = runningBuild.getBuildLogger();
    logger.activityStarted("Octopus Deploy", DefaultMessagesInfo.BLOCK_TYPE_INDENTATION);
    logger.message(/*from   w w  w .j  a  v a2 s .  com*/
            "Running command:   octo.exe " + StringUtils.arrayToDelimitedString(userVisibleCommand, " "));
    logger.progressMessage(getLogMessage());

    try {
        Runtime runtime = Runtime.getRuntime();

        String octopusVersion = getSelectedOctopusVersion();

        ArrayList<String> arguments = new ArrayList<String>();
        arguments.add(new File(extractedTo, octopusVersion + "\\octo.exe").getAbsolutePath());
        arguments.addAll(Arrays.asList(realCommand));

        process = runtime.exec(arguments.toArray(new String[arguments.size()]), null,
                context.getWorkingDirectory());

        final LoggingProcessListener listener = new LoggingProcessListener(logger);

        standardError = new OutputReaderThread(process.getErrorStream(), new OutputWriter() {
            public void write(String text) {
                listener.onErrorOutput(text);
            }
        });
        standardOutput = new OutputReaderThread(process.getInputStream(), new OutputWriter() {
            public void write(String text) {
                listener.onStandardOutput(text);
            }
        });

        standardError.start();
        standardOutput.start();
    } catch (IOException e) {
        final String message = "Error from Octo.exe: " + e.getMessage();
        Logger.getInstance(getClass().getName()).error(message, e);
        throw new RunBuildException(message);
    }
}

From source file:org.smigo.user.UserController.java

@PreAuthorize("isAuthenticated()")
@RequestMapping(value = "/rest/user", method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody//from www .j a  va  2s  .c o  m
public List<ObjectError> updateUser(@RequestBody @Valid User userBean, BindingResult result,
        @AuthenticationPrincipal AuthenticatedUser user, HttpServletResponse response) {
    if (result.hasErrors()) {
        log.warn("Update user failed. Username:" + user.getUsername() + " Errors:"
                + StringUtils.arrayToDelimitedString(result.getAllErrors().toArray(), ", "));
        response.setStatus(HttpStatus.UNPROCESSABLE_ENTITY.value());
        return result.getAllErrors();
    }
    log.info("Updating user: " + userBean.toString());
    userHandler.updateUser(user.getId(), userBean);
    return Collections.emptyList();
}