当前位置: 首页>>代码示例>>Java>>正文


Java StringUtils.arrayToCommaDelimitedString方法代码示例

本文整理汇总了Java中org.springframework.util.StringUtils.arrayToCommaDelimitedString方法的典型用法代码示例。如果您正苦于以下问题:Java StringUtils.arrayToCommaDelimitedString方法的具体用法?Java StringUtils.arrayToCommaDelimitedString怎么用?Java StringUtils.arrayToCommaDelimitedString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.util.StringUtils的用法示例。


在下文中一共展示了StringUtils.arrayToCommaDelimitedString方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: processPropertyAccessException

import org.springframework.util.StringUtils; //导入方法依赖的package包/类
@Override
public void processPropertyAccessException(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 FieldError(
			bindingResult.getObjectName(), field, rejectedValue, true,
			codes, arguments, ex.getLocalizedMessage()));
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:15,代码来源:DefaultBindingErrorProcessor.java

示例2: convertListToDelimitedString

import org.springframework.util.StringUtils; //导入方法依赖的package包/类
private String convertListToDelimitedString(List<String> list) {

		String result = "";
		if (list != null) {
			result = StringUtils.arrayToCommaDelimitedString(list.toArray());
		}
		return result;

	}
 
开发者ID:filipebraida,项目名称:siga,代码行数:10,代码来源:UserDaoImpl.java

示例3: processAddNewProductForm

import org.springframework.util.StringUtils; //导入方法依赖的package包/类
@RequestMapping(value = "/add", method = RequestMethod.POST)
public String processAddNewProductForm(@ModelAttribute("newProduct") @Valid Product newProduct, BindingResult result, @ModelAttribute("productImage") ProductImage image, HttpServletRequest request) throws IOException {
    if(result.hasErrors()) {
        return "addProduct";
    }
    String[] suppressedFields = result.getSuppressedFields();
    if (suppressedFields.length > 0) {
        throw new RuntimeException("Próba wiązania niedozwolonych pól: " + StringUtils.arrayToCommaDelimitedString(suppressedFields));
    }
    ProductThumbnail productThumbnail = new ProductThumbnail(newProduct);
    ProductPicture productPicture = new ProductPicture(newProduct);
    MultipartFile productImage = image.getProductImage();
    if (productImage!=null && !productImage.isEmpty()) {
        try {
            InputStream is = image.getProductImage().getInputStream();
            BufferedImage img = Thumbnails.of(is)
                    .crop(Positions.CENTER)
                    .size(400, 300)
                    .asBufferedImage();
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            ImageIO.write(img, "jpg", baos);
            byte[] imageBytess = Base64.getEncoder().encode(baos.toByteArray());
            productThumbnail.setBase64Image(new String(imageBytess));

            byte[] encoded = Base64.getEncoder().encode(image.getProductImage().getBytes());
            productPicture.setBase64Image(new String(encoded));

        } catch(Exception e) {
            throw new RuntimeException("Niepowodzenie podczas próby zapisu obrazka produktu", e);
        }
    }
    productService.create(newProduct);
    productThumbnailService.create(productThumbnail);
    productPictureService.create(productPicture);
    return "redirect:/products";
}
 
开发者ID:TomirKlos,项目名称:Webstore,代码行数:37,代码来源:ProductController.java

示例4: toString

import org.springframework.util.StringUtils; //导入方法依赖的package包/类
@Override
public String toString() {
	return getClass().getName() + ": basenames=[" + StringUtils.arrayToCommaDelimitedString(this.basenames) + "]";
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:5,代码来源:ReloadableResourceBundleMessageSource.java

示例5: toString

import org.springframework.util.StringUtils; //导入方法依赖的package包/类
/**
 * Show the configuration of this MessageSource.
 */
@Override
public String toString() {
	return getClass().getName() + ": basenames=[" +
			StringUtils.arrayToCommaDelimitedString(this.basenames) + "]";
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:9,代码来源:ResourceBundleMessageSource.java

示例6: doConvertValue

import org.springframework.util.StringUtils; //导入方法依赖的package包/类
/**
 * Convert the value to the required type (if necessary from a String),
 * using the given property editor.
 * @param oldValue the previous value, if available (may be {@code null})
 * @param newValue the proposed new value
 * @param requiredType the type we must convert to
 * (or {@code null} if not known, for example in case of a collection element)
 * @param editor the PropertyEditor to use
 * @return the new value, possibly the result of type conversion
 * @throws IllegalArgumentException if type conversion failed
 */
private Object doConvertValue(Object oldValue, Object newValue, Class<?> requiredType, PropertyEditor editor) {
	Object convertedValue = newValue;

	if (editor != null && !(convertedValue instanceof String)) {
		// Not a String -> use PropertyEditor's setValue.
		// With standard PropertyEditors, this will return the very same object;
		// we just want to allow special PropertyEditors to override setValue
		// for type conversion from non-String values to the required type.
		try {
			editor.setValue(convertedValue);
			Object newConvertedValue = editor.getValue();
			if (newConvertedValue != convertedValue) {
				convertedValue = newConvertedValue;
				// Reset PropertyEditor: It already did a proper conversion.
				// Don't use it again for a setAsText call.
				editor = null;
			}
		}
		catch (Exception ex) {
			if (logger.isDebugEnabled()) {
				logger.debug("PropertyEditor [" + editor.getClass().getName() + "] does not support setValue call", ex);
			}
			// Swallow and proceed.
		}
	}

	Object returnValue = convertedValue;

	if (requiredType != null && !requiredType.isArray() && convertedValue instanceof String[]) {
		// Convert String array to a comma-separated String.
		// Only applies if no PropertyEditor converted the String array before.
		// The CSV String will be passed into a PropertyEditor's setAsText method, if any.
		if (logger.isTraceEnabled()) {
			logger.trace("Converting String array to comma-delimited String [" + convertedValue + "]");
		}
		convertedValue = StringUtils.arrayToCommaDelimitedString((String[]) convertedValue);
	}

	if (convertedValue instanceof String) {
		if (editor != null) {
			// Use PropertyEditor's setAsText in case of a String value.
			if (logger.isTraceEnabled()) {
				logger.trace("Converting String to [" + requiredType + "] using property editor [" + editor + "]");
			}
			String newTextValue = (String) convertedValue;
			return doConvertTextValue(oldValue, newTextValue, editor);
		}
		else if (String.class.equals(requiredType)) {
			returnValue = convertedValue;
		}
	}

	return returnValue;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:66,代码来源:TypeConverterDelegate.java

示例7: toString

import org.springframework.util.StringUtils; //导入方法依赖的package包/类
@Override
public String toString() {
	return "SimpleKey [" + StringUtils.arrayToCommaDelimitedString(this.params) + "]";
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:5,代码来源:SimpleKey.java


注:本文中的org.springframework.util.StringUtils.arrayToCommaDelimitedString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。