本文整理汇总了Java中org.kuali.rice.core.web.format.Formatter.convertFromPresentationFormat方法的典型用法代码示例。如果您正苦于以下问题:Java Formatter.convertFromPresentationFormat方法的具体用法?Java Formatter.convertFromPresentationFormat怎么用?Java Formatter.convertFromPresentationFormat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.kuali.rice.core.web.format.Formatter
的用法示例。
在下文中一共展示了Formatter.convertFromPresentationFormat方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: copyParametersToBO
import org.kuali.rice.core.web.format.Formatter; //导入方法依赖的package包/类
protected void copyParametersToBO(Map<String, String> parameters, PersistableBusinessObject newBO) throws Exception{
for (String parmName : parameters.keySet()) {
String propertyValue = parameters.get(parmName);
if (StringUtils.isNotBlank(propertyValue)) {
String propertyName = parmName;
// set value of property in bo
if (PropertyUtils.isWriteable(newBO, propertyName)) {
Class type = ObjectUtils.easyGetPropertyType(newBO, propertyName);
if (type != null && Formatter.getFormatter(type) != null) {
Formatter formatter = Formatter.getFormatter(type);
Object obj = formatter.convertFromPresentationFormat(propertyValue);
ObjectUtils.setObjectProperty(newBO, propertyName, obj.getClass(), obj);
}
else {
ObjectUtils.setObjectProperty(newBO, propertyName, String.class, propertyValue);
}
}
}
}
}
示例2: setObjectProperty
import org.kuali.rice.core.web.format.Formatter; //导入方法依赖的package包/类
/**
* Sets the property of an object with the given value. Converts using the formatter of the given type if one is
* found.
*
* @param bo
* @param propertyName
* @param propertyType
* @param propertyValue
* @throws NoSuchMethodException
* @throws InvocationTargetException
* @throws IllegalAccessException
*/
public static void setObjectProperty(Object bo, String propertyName, Class propertyType,
Object propertyValue) throws FormatException, IllegalAccessException, InvocationTargetException, NoSuchMethodException {
// reformat propertyValue, if necessary
boolean reformat = false;
if (propertyType != null) {
if (propertyValue != null && propertyType.isAssignableFrom(String.class)) {
// always reformat if the destination is a String
reformat = true;
} else if (propertyValue != null && !propertyType.isAssignableFrom(propertyValue.getClass())) {
// otherwise, only reformat if the propertyValue can't be assigned into the property
reformat = true;
}
// attempting to set boolean fields to null throws an exception, set to false instead
if (boolean.class.isAssignableFrom(propertyType) && propertyValue == null) {
propertyValue = false;
}
}
Formatter formatter = getFormatterWithDataDictionary(bo, propertyName);
if (reformat && formatter != null) {
LOG.debug("reformatting propertyValue using Formatter " + formatter.getClass().getName());
propertyValue = formatter.convertFromPresentationFormat(propertyValue);
}
// set property in the object
PropertyUtils.setNestedProperty(bo, propertyName, propertyValue);
}
示例3: getFormattedObject
import org.kuali.rice.core.web.format.Formatter; //导入方法依赖的package包/类
/**
* This method returns the formatted object for the given string. It uses the formatter class define for specification property
* if exists, otherwise look to the Data Dictionary of the parsedObject , otherwise use the default formatter class.
* @param subString the parsed subString
* @param the object to parse into
*/
protected Object getFormattedObject(String subString, Object parsedObject) {
Formatter formatter = getFormatter(parsedObject);
if (formatter instanceof BatchDateFormatter) {
((BatchDateFormatter) formatter).setDateFormat(dateFormat);
if (formatToTimestamp) {
((BatchDateFormatter) formatter).setFormatToTimestamp(true);
}
}
return formatter.convertFromPresentationFormat(subString);
}