Java Code Examples for org.springframework.util.StringUtils#arrayToDelimitedString()

The following examples show how to use org.springframework.util.StringUtils#arrayToDelimitedString() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
/**
 * Validate the given type-level mapping metadata against the current request,
 * checking HTTP request method and parameter conditions.
 * @param mapping the mapping metadata to validate
 * @param request current HTTP request
 * @throws Exception if validation failed
 */
protected void validateMapping(RequestMapping mapping, HttpServletRequest request) throws Exception {
	RequestMethod[] mappedMethods = mapping.method();
	if (!ServletAnnotationMappingUtils.checkRequestMethod(mappedMethods, request)) {
		String[] supportedMethods = new String[mappedMethods.length];
		for (int i = 0; i < mappedMethods.length; i++) {
			supportedMethods[i] = mappedMethods[i].name();
		}
		throw new HttpRequestMethodNotSupportedException(request.getMethod(), supportedMethods);
	}

	String[] mappedParams = mapping.params();
	if (!ServletAnnotationMappingUtils.checkParameters(mappedParams, request)) {
		throw new UnsatisfiedServletRequestParameterException(mappedParams, request.getParameterMap());
	}

	String[] mappedHeaders = mapping.headers();
	if (!ServletAnnotationMappingUtils.checkHeaders(mappedHeaders, request)) {
		throw new ServletRequestBindingException("Header conditions \"" +
				StringUtils.arrayToDelimitedString(mappedHeaders, ", ") +
				"\" not met for actual request");
	}
}
 
Example 2
@Override
public void validate(PortletRequest request) throws PortletException {
	if (!PortletAnnotationMappingUtils.checkHeaders(this.headers, request)) {
		throw new PortletRequestBindingException("Header conditions \"" +
				StringUtils.arrayToDelimitedString(this.headers, ", ") +
				"\" not met for actual request");
	}
	if (!this.methods.isEmpty()) {
		if (!(request instanceof ClientDataRequest)) {
			throw new PortletRequestMethodNotSupportedException(StringUtils.toStringArray(this.methods));
		}
		String method = ((ClientDataRequest) request).getMethod();
		if (!this.methods.contains(method)) {
			throw new PortletRequestMethodNotSupportedException(method, StringUtils.toStringArray(this.methods));
		}
	}
}
 
Example 3
public void run() {
	logger.info("Listing images in image database, scheduled by Timer");
	List images = this.imageDatabase.getImages();
	String[] imageNames = new String[images.size()];
	for (int i = 0; i < images.size(); i++) {
		ImageDescriptor image = (ImageDescriptor) images.get(i);
		imageNames[i] = image.getName();
	}

	String text = "Images in image database: " + StringUtils.arrayToDelimitedString(imageNames, ", ");
	logger.info(text);

	if (!"".equals(this.mailTo)) {
		logger.info("Sending image list mail to: " + this.mailTo);
		SimpleMailMessage message = new SimpleMailMessage();
		message.setFrom(this.mailFrom);
		message.setTo(this.mailTo);
		message.setSubject("Image list");
		message.setText(text);
		this.mailSender.send(message);
	}
	else {
		logger.info("Not sending image list mail - specify mail settings in 'WEB-INF/mail.properties'");
	}

}
 
Example 4
/**
 * Method to CreateName value labels.
 *
 * @param label
 *            as string
 * @param values
 *            as string
 * @return HorizontalLayout
 */
public static HorizontalLayout createNameValueLayout(final String label, final String... values) {
    final String valueStr = StringUtils.arrayToDelimitedString(values, " ");

    final Label nameValueLabel = new Label( label );
    nameValueLabel.setContentMode(ContentMode.TEXT);
    nameValueLabel.addStyleName(SPUIDefinitions.TEXT_STYLE);
    nameValueLabel.addStyleName("text-bold");
    nameValueLabel.setSizeUndefined();

    final Label valueStrLabel = new Label(valueStr);
    valueStrLabel.setWidth("100%");
    valueStrLabel.addStyleName("text-cut");
    valueStrLabel.addStyleName(SPUIDefinitions.TEXT_STYLE);
    valueStrLabel.addStyleName(LABEL_STYLE);

    final HorizontalLayout nameValueLayout = new HorizontalLayout();
    nameValueLayout.setMargin(false);
    nameValueLayout.setSpacing(true);
    nameValueLayout.setSizeFull();

    nameValueLayout.addComponent(nameValueLabel);
    nameValueLayout.setComponentAlignment(nameValueLabel, Alignment.TOP_LEFT);
    nameValueLayout.setExpandRatio(nameValueLabel, 0.0F);

    nameValueLayout.addComponent(valueStrLabel);
    nameValueLayout.setComponentAlignment(valueStrLabel, Alignment.TOP_LEFT);
    nameValueLayout.setExpandRatio(valueStrLabel, 1.0F);

    return nameValueLayout;
}
 
Example 5
/**
 * @return a colon separated representation of the stub configuration (e.g.
 * groupid:artifactid:version:classifier)
 */
public String toColonSeparatedDependencyNotation() {
	if (!isDefined()) {
		return "";
	}
	return StringUtils.arrayToDelimitedString(
			new String[] { nullCheck(this.groupId), nullCheck(this.artifactId),
					nullCheck(this.version), nullCheck(this.classifier) },
			STUB_COLON_DELIMITER);
}
 
Example 6
private String valueToString(Object value) {
	if (value == this) {
		return "(this Map)";
	}
	if (value instanceof Object[]) {
		return "[" + StringUtils.arrayToDelimitedString((Object[]) value, ", ") + "]";
	}
	return String.valueOf(value);
}
 
Example 7
Source Project: onboard   File: DueTodosScheduler.java    License: Apache License 2.0 5 votes vote down vote up
@Scheduled(cron = "0 1 0 * * ?")
    public void notifyDueTodo() throws MessageSendingException {
        List<Todo> todos = this.getDueTodosOfToday();

        logger.info("todos of day {} counts : {}", new DateTime(), todos.size());
        for (Todo todo : todos) {
            if (todo.getAssigneeId() == null) {
                continue;
            }
            Project project = projectService.getById(todo.getProjectId());
            User user = userService.getById(todo.getAssigneeId());

            Map<String, Object> model = new HashMap<String, Object>();
            model.put("content", todo.getContent());
            model.put("host", protocol + this.host);
            model.put("date", new SimpleDateFormat("yyyy年MM月dd日").format(todo.getDueDate()));
            //TODO: get url
//            String url = identifiableManager.getIdentifiableURL(todo);
            String url = String.format("https://onboard.cn/teams/%s/projects/%s/todolists/open?id=%s1&type=todo", 
                    todo.getCompanyId(), todo.getProjectId(), todo.getId());
            model.put("url", url);

            String content = templateEngineService.process(getClass(), VM_PATH, model);
            String replyTo = StringUtils.arrayToDelimitedString(
                    new String[] { todo.getType(), String.valueOf(todo.getId()), DataCipher.encode(user.getEmail()) },
                    "-");
            emailService.sendEmail("OnBoard", user.getEmail(), null, null,
                    String.format("[%s]%s 快要到期了!", project.getName(), todo.getContent()), content, replyTo);
        }
    }
 
Example 8
Source Project: score   File: DependencyServiceImpl.java    License: Apache License 2.0 5 votes vote down vote up
private void invokeMavenLauncher(String[] args) throws Exception {
    ClassLoader origCL = Thread.currentThread().getContextClassLoader();
    Thread.currentThread().setContextClassLoader(mavenClassLoader);
    try {
        int exitCode = (Integer) MAVEN_EXECUTE_METHOD.invoke(null, new Object[]{args});
        if (exitCode != 0) {
            throw new RuntimeException("mvn " + StringUtils.arrayToDelimitedString(args, " ") + " returned " +
                    exitCode + ", see log for details");
        }
    } finally {
        Thread.currentThread().setContextClassLoader(origCL);
    }
}
 
Example 9
Source Project: spring-boot-demo   File: RedisConfig.java    License: MIT License 5 votes vote down vote up
/**
 * 自定义生成key的策略
 *
 * @return
 */
@Bean
@Override
public KeyGenerator keyGenerator() {
    return new KeyGenerator() {
        @Override
        public Object generate(Object target, Method method, Object... params) {
            return target.getClass().getSimpleName() + "_"
                    + method.getName() + "_"
                    + StringUtils.arrayToDelimitedString(params, "_");
        }
    };
}
 
Example 10
@Override
public String resolvePlaceholder(String placeholderName) {
    Object replacement = this.constraint.getConfiguration().get(placeholderName);
    if (replacement == null) {
        return null;
    }
    if (replacement.getClass().isArray()) {
        return StringUtils.arrayToDelimitedString((Object[]) replacement, ", ");
    }
    return replacement.toString();
}
 
Example 11
Source Project: score   File: DependencyServiceImpl.java    License: Apache License 2.0 5 votes vote down vote up
private String getResourceString(String[] gav, boolean transitive) {
    //if not transitive, use type "pom"
    String[] newGav = new String[Math.max(4, gav.length)];
    System.arraycopy(gav, 0, newGav, 0, gav.length);
    if (!transitive) {
        newGav[3] = "pom";
    } else {
        if (newGav[3] == null) {
            newGav[3] = "jar";
        }
    }
    return StringUtils.arrayToDelimitedString(newGav, GAV_DELIMITER);
}
 
Example 12
@Override
public String getAsText() {
	return StringUtils.arrayToDelimitedString(ObjectUtils.toObjectArray(getValue()), this.separator);
}
 
Example 13
Source Project: tutorials   File: CustomKeyGenerator.java    License: MIT License 4 votes vote down vote up
public Object generate(Object target, Method method, Object... params) {
    return target.getClass().getSimpleName() + "_" + method.getName() + "_"
            + StringUtils.arrayToDelimitedString(params, "_");
}
 
Example 14
public String getCommandString() {
	return StringUtils.arrayToDelimitedString(getCommand().toArray(), " ");
}
 
Example 15
private String sse(String... values) {
	return "data:" + StringUtils.arrayToDelimitedString(values, "\n\ndata:") + "\n\n";
}
 
Example 16
private String sse(String... values) {
	return "data:" + StringUtils.arrayToDelimitedString(values, "\n\ndata:") + "\n\n";
}
 
Example 17
/**
 * Set multiple JAXB context paths. The given array of context paths gets
 * converted to a colon-delimited string, as supported by JAXB.
 */
public void setContextPaths(String... contextPaths) {
	Assert.notEmpty(contextPaths, "'contextPaths' must not be empty");
	this.contextPath = StringUtils.arrayToDelimitedString(contextPaths, ":");
}
 
Example 18
private String sse(String... values) {
	return "data:" + StringUtils.arrayToDelimitedString(values, "\n\ndata:") + "\n\n";
}
 
Example 19
Source Project: java-technology-stack   File: BindStatus.java    License: MIT License 2 votes vote down vote up
/**
 * Return an error message string, concatenating all messages
 * separated by the given delimiter.
 * @param delimiter separator string, e.g. ", " or "<br>"
 * @return the error message string
 */
public String getErrorMessagesAsString(String delimiter) {
	return StringUtils.arrayToDelimitedString(initErrorMessages(), delimiter);
}
 
Example 20
Source Project: lams   File: BindStatus.java    License: GNU General Public License v2.0 2 votes vote down vote up
/**
 * Return an error message string, concatenating all messages
 * separated by the given delimiter.
 * @param delimiter separator string, e.g. ", " or "<br>"
 * @return the error message string
 */
public String getErrorMessagesAsString(String delimiter) {
	initErrorMessages();
	return StringUtils.arrayToDelimitedString(this.errorMessages, delimiter);
}