• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Formatter类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.kuali.rice.core.web.format.Formatter的典型用法代码示例。如果您正苦于以下问题:Java Formatter类的具体用法?Java Formatter怎么用?Java Formatter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Formatter类属于org.kuali.rice.core.web.format包,在下文中一共展示了Formatter类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getFormattersForPrimaryKeyFields

import org.kuali.rice.core.web.format.Formatter; //导入依赖的package包/类
@Deprecated
protected Map<String, Formatter> getFormattersForPrimaryKeyFields(Class<?> boClass) {
	List<String> keyNames = getLegacyDataAdapter().listPrimaryKeyFieldNames(boClass);
	Map<String, Formatter> formattersForPrimaryKeyFields = new HashMap<String, Formatter>();

	for (String pkFieldName : keyNames) {
		Formatter formatter = null;

		Class<? extends Formatter> formatterClass = dataDictionaryService.getAttributeFormatter(boClass, pkFieldName);
		if (formatterClass != null) {
			try {
				formatter = formatterClass.newInstance();
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
       }
	return formattersForPrimaryKeyFields;
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:20,代码来源:InactivationBlockingDisplayServiceImpl.java


示例2: formatValue

import org.kuali.rice.core.web.format.Formatter; //导入依赖的package包/类
/**
    * Tries to format the provided value by passing it to a suitable {@link Formatter}. Adds an ActionMessage to the ActionErrors
    * in the request if a FormatException is thrown.
    * <p>
    * Caution should be used when invoking this method. It should never be called prior to {@link #populate(HttpServletRequest)}
    * because the cached request reference could be stale.
    */
   @Override
public Object formatValue(Object value, String keypath, Class type) {

       Formatter formatter = getFormatter(keypath, type);
       if ( LOG.isDebugEnabled() ) {
           LOG.debug("formatValue (value,keypath,type) = (" + value + "," + keypath + "," + type.getName() + ")");
       }

       try {
           return Formatter.isSupportedType(type) ? formatter.formatForPresentation(value) : value;
       }
       catch (FormatException e) {
           GlobalVariables.getMessageMap().putError(keypath, e.getErrorKey(), e.getErrorArgs());
           return value.toString();
       }
   }
 
开发者ID:kuali,项目名称:kc-rice,代码行数:24,代码来源:PojoFormBase.java


示例3: getProperty

import org.kuali.rice.core.web.format.Formatter; //导入依赖的package包/类
public Object getProperty(Object bean, String key) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
    // begin Kuali Foundation modification
    if (!(bean instanceof PojoForm))
        return super.getProperty(bean, key);

    PojoForm form = (PojoForm) bean;
    Map unconvertedValues = form.getUnconvertedValues();

    if (unconvertedValues.containsKey(key))
        return unconvertedValues.get(key);

    Object val = getNestedProperty(bean, key);
    Class type = (val!=null)?val.getClass():null;
    if ( type == null ) {
        try {
            type = getPropertyType(bean, key);
        } catch ( Exception ex ) {
            type = String.class;
            LOG.warn( "Unable to get property type for Class: " + bean.getClass().getName() + "/Property: " + key );
        }
    }
    return (Formatter.isSupportedType(type) ? form.formatValue(val, key, type) : val);
    // end Kuali Foundation modification
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:25,代码来源:PojoPropertyUtilsBean.java


示例4: retrieveFormValueForLookupInquiryParameters

import org.kuali.rice.core.web.format.Formatter; //导入依赖的package包/类
/**
   * Retrieves a value from the form for the purposes of passing it as a parameter into the lookup or inquiry frameworks 
   * 
   * @param parameterName the name of the parameter, as expected by the lookup or inquiry frameworks
   * @param parameterValueLocation the name of the property containing the value of the parameter
   * @return the value of the parameter
   */
  public String retrieveFormValueForLookupInquiryParameters(String parameterName, String parameterValueLocation) {
  	// dereference literal values by simply trimming of the prefix
  	if (parameterValueLocation.startsWith(literalPrefixAndDelimiter)) {
  		return parameterValueLocation.substring(literalPrefixAndDelimiter.length());
  	}

  	Object value = ObjectUtils.getPropertyValue(this, parameterValueLocation);
if (value == null) {
	return null;
}
if (value instanceof String) {
	return (String) value;
}
Formatter formatter = Formatter.getFormatter(value.getClass());
return (String) formatter.format(value);	
  }
 
开发者ID:kuali,项目名称:kc-rice,代码行数:24,代码来源:KualiForm.java


示例5: 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);
				}
			}
		}
	}
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:22,代码来源:KualiMaintenanceDocumentAction.java


示例6: getFormattedPropertyValue

import org.kuali.rice.core.web.format.Formatter; //导入依赖的package包/类
/**
 * Gets the property value from the business object, then based on the value
 * type select a formatter and format the value
 *
 * @param businessObject BusinessObject instance that contains the property
 * @param propertyName Name of property in BusinessObject to get value for
 * @param formatter Default formatter to use (or null)
 * @return Formatted property value as String, or empty string if value is null
 */
@Deprecated
public static String getFormattedPropertyValue(BusinessObject businessObject, String propertyName,
        Formatter formatter) {
    String propValue = KRADConstants.EMPTY_STRING;

    Object prop = ObjectUtils.getPropertyValue(businessObject, propertyName);
    if (formatter == null) {
        propValue = formatPropertyValue(prop);
    } else {
        final Object formattedValue = formatter.format(prop);
        if (formattedValue != null) {
            propValue = String.valueOf(formattedValue);
        }
    }

    return propValue;
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:27,代码来源:ObjectUtils.java


示例7: convertPKFieldMapToLookupId

import org.kuali.rice.core.web.format.Formatter; //导入依赖的package包/类
/**
 * Converts a Map of PKFields into a String lookup ID
 * @param pkFieldNames the name of the PK fields, which should be converted to the given lookupId
 * @param businessObjectClass the class of the business object getting the primary key
 * @return the String lookup id
 */
protected String convertPKFieldMapToLookupId(List<String> pkFieldNames, BusinessObject businessObject) {
	StringBuilder lookupId = new StringBuilder();
	for (String pkFieldName : pkFieldNames) {
		try {
			final Object value = PropertyUtils.getProperty(businessObject, pkFieldName);

			if (value != null) {
				lookupId.append(pkFieldName);
				lookupId.append("-");
				final Formatter formatter = retrieveBestFormatter(pkFieldName, businessObject.getClass());
				final String formattedValue = (formatter != null) ? formatter.format(value).toString() : value.toString();

				lookupId.append(formattedValue);
			}
			lookupId.append(SearchOperator.OR.op());
		} catch (IllegalAccessException iae) {
			throw new RuntimeException("Could not retrieve pk field value "+pkFieldName+" from business object "+businessObject.getClass().getName(), iae);
		} catch (InvocationTargetException ite) {
			throw new RuntimeException("Could not retrieve pk field value "+pkFieldName+" from business object "+businessObject.getClass().getName(), ite);
		} catch (NoSuchMethodException nsme) {
			throw new RuntimeException("Could not retrieve pk field value "+pkFieldName+" from business object "+businessObject.getClass().getName(), nsme);
		}
	}
	return lookupId.substring(0, lookupId.length() - 1); // kill the last "|"
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:32,代码来源:DataDictionaryLookupResultsSupportStrategy.java


示例8: getTableCellAlignment

import org.kuali.rice.core.web.format.Formatter; //导入依赖的package包/类
/**
 * get the alignment definitions of all table cells in one row according to the property's formatter class
 * 
 * @return the alignment definitions of all table cells in one row according to the property's formatter class
 */
public List<String> getTableCellAlignment() {
    List<String> cellWidthList = new ArrayList<String>();
    List<Class<? extends Formatter>> numberFormatters = this.getNumberFormatters();
    
    for (Map.Entry<String, String> entry : orderedPropertyNameToHeaderLabelMap.entrySet()) {
        String attributeName = entry.getKey();
        
        boolean isNumber = false;
        if (!attributeName.startsWith(OLEConstants.ReportConstants.EMPTY_CELL_ENTRY_KEY_PREFIX)) {
            try {
                Class<? extends Formatter> formatterClass = this.retrievePropertyFormatterClass(dataDictionaryBusinessObjectClass, attributeName);
                
                isNumber = numberFormatters.contains(formatterClass);
            }
            catch (Exception e) {
                throw new RuntimeException("Failed getting propertyName=" + attributeName + " from businessObjecName=" + dataDictionaryBusinessObjectClass.getName(), e);
            }
        }

        cellWidthList.add(isNumber ? RIGHT_ALIGNMENT : LEFT_ALIGNMENT);
    }
    
    return cellWidthList;
}
 
开发者ID:VU-libtech,项目名称:OLE-INST,代码行数:30,代码来源:BusinessObjectReportHelper.java


示例9: validateSearchParameters

import org.kuali.rice.core.web.format.Formatter; //导入依赖的package包/类
/**
 * Overridden to validate the invoie amount and payment date fields to make sure they are parsable
 * @see org.kuali.rice.kns.lookup.AbstractLookupableHelperServiceImpl#validateSearchParameters(java.util.Map)
 */
@Override
public void validateSearchParameters(Map<String, String> fieldValues) {
    if (!StringUtils.isBlank(fieldValues.get(ArPropertyConstants.PAYMENT_DATE))) {
        validateDateField(fieldValues.get(ArPropertyConstants.PAYMENT_DATE), ArPropertyConstants.PAYMENT_DATE, getDateTimeService());
    }
    if (!StringUtils.isBlank(fieldValues.get(ArPropertyConstants.RANGE_LOWER_BOUND_KEY_PREFIX+ArPropertyConstants.PAYMENT_DATE))) {
        validateDateField(fieldValues.get(ArPropertyConstants.RANGE_LOWER_BOUND_KEY_PREFIX+ArPropertyConstants.PAYMENT_DATE), ArPropertyConstants.RANGE_LOWER_BOUND_KEY_PREFIX+ArPropertyConstants.PAYMENT_DATE, getDateTimeService());
    }
    if (!StringUtils.isBlank(fieldValues.get(ArPropertyConstants.INVOICE_AMOUNT))) {
        try {
            Formatter f = new CurrencyFormatter();
            f.format(fieldValues.get(ArPropertyConstants.INVOICE_AMOUNT));
        } catch (FormatException fe) {
            // we'll assume this was a parse exception
            final String label = getDataDictionaryService().getAttributeLabel(getBusinessObjectClass(), ArPropertyConstants.INVOICE_AMOUNT);
            GlobalVariables.getMessageMap().putError(ArPropertyConstants.INVOICE_AMOUNT, KFSKeyConstants.ERROR_NUMERIC, label);
        }
    }
    super.validateSearchParameters(fieldValues);
}
 
开发者ID:kuali,项目名称:kfs,代码行数:25,代码来源:ContractsGrantsPaymentHistoryReportLookupableHelperServiceImpl.java


示例10: getTableCellAlignment

import org.kuali.rice.core.web.format.Formatter; //导入依赖的package包/类
/**
 * get the alignment definitions of all table cells in one row according to the property's formatter class
 * 
 * @return the alignment definitions of all table cells in one row according to the property's formatter class
 */
public List<String> getTableCellAlignment() {
    List<String> cellWidthList = new ArrayList<String>();
    List<Class<? extends Formatter>> numberFormatters = this.getNumberFormatters();
    
    for (Map.Entry<String, String> entry : orderedPropertyNameToHeaderLabelMap.entrySet()) {
        String attributeName = entry.getKey();
        
        boolean isNumber = false;
        if (!attributeName.startsWith(KFSConstants.ReportConstants.EMPTY_CELL_ENTRY_KEY_PREFIX)) {
            try {
                Class<? extends Formatter> formatterClass = this.retrievePropertyFormatterClass(dataDictionaryBusinessObjectClass, attributeName);
                
                isNumber = numberFormatters.contains(formatterClass);
            }
            catch (Exception e) {
                throw new RuntimeException("Failed getting propertyName=" + attributeName + " from businessObjecName=" + dataDictionaryBusinessObjectClass.getName(), e);
            }
        }

        cellWidthList.add(isNumber ? RIGHT_ALIGNMENT : LEFT_ALIGNMENT);
    }
    
    return cellWidthList;
}
 
开发者ID:kuali,项目名称:kfs,代码行数:30,代码来源:BusinessObjectReportHelper.java


示例11: buildBatchReportSummary

import org.kuali.rice.core.web.format.Formatter; //导入依赖的package包/类
/**
 * Build Procurement Card report object.
 *
 * @param docMapByPstDt
 * @param transctionMapByPstDt
 * @param totalAmountMapByPstDt
 * @return
 */
protected List<ProcurementCardReportType> buildBatchReportSummary(Map<Date, HashMap<String, String>> docMapByPstDt, Map<Date, Integer> transctionMapByPstDt, Map<Date, KualiDecimal> totalAmountMapByPstDt) {
    List<ProcurementCardReportType> summaryList = new ArrayList<ProcurementCardReportType>();
    ProcurementCardReportType reportEntry;

    Formatter currencyFormatter = new CurrencyFormatter();
    DateFormat dateFormatter = getDateFormat(KFSConstants.CoreModuleNamespaces.FINANCIAL, KFSConstants.ProcurementCardParameters.PCARD_BATCH_CREATE_DOC_STEP, KFSConstants.ProcurementCardParameters.BATCH_SUMMARY_POSTING_DATE_FORMAT,KFSConstants.ProcurementCardTransactionTimeFormat);

    for (Date keyDate : docMapByPstDt.keySet()) {
        reportEntry = new ProcurementCardReportType();
        reportEntry.setTransactionPostingDate(keyDate);

        reportEntry.setFormattedPostingDate(dateFormatter.format(keyDate));
        reportEntry.setTotalDocNumber(docMapByPstDt.get(keyDate).keySet().isEmpty() ? 0 : docMapByPstDt.get(keyDate).keySet().size());
        reportEntry.setTotalTranNumber(transctionMapByPstDt.get(keyDate));
        reportEntry.setTotalAmount(currencyFormatter.formatForPresentation(totalAmountMapByPstDt.get(keyDate)).toString());
        summaryList.add(reportEntry);
    }
    return summaryList;
}
 
开发者ID:kuali,项目名称:kfs,代码行数:28,代码来源:ProcurementCardCreateDocumentServiceImpl.java


示例12: getFormattedPropertyValue

import org.kuali.rice.core.web.format.Formatter; //导入依赖的package包/类
/**
 * Gets the property value from the business object, then based on the value
 * type select a formatter and format the value
 *
 * @param businessObject BusinessObject instance that contains the property
 * @param propertyName Name of property in BusinessObject to get value for
 * @param formatter Default formatter to use (or null)
 * @return Formatted property value as String, or empty string if value is null
 */
public static String getFormattedPropertyValue(BusinessObject businessObject, String propertyName,
        Formatter formatter) {
    String propValue = KRADConstants.EMPTY_STRING;

    Object prop = ObjectUtils.getPropertyValue(businessObject, propertyName);
    if (formatter == null) {
        propValue = formatPropertyValue(prop);
    } else {
        final Object formattedValue = formatter.format(prop);
        if (formattedValue != null) {
            propValue = String.valueOf(formattedValue);
        }
    }

    return propValue;
}
 
开发者ID:aapotts,项目名称:kuali_rice,代码行数:26,代码来源:ObjectUtils.java


示例13: getFormattersForPrimaryKeyFields

import org.kuali.rice.core.web.format.Formatter; //导入依赖的package包/类
protected Map<String, Formatter> getFormattersForPrimaryKeyFields(Class boClass) {
	List<String> keyNames = persistenceStructureService.listPrimaryKeyFieldNames(boClass);
	Map<String, Formatter> formattersForPrimaryKeyFields = new HashMap<String, Formatter>();

	for (String pkFieldName : keyNames) {
		Formatter formatter = null;

		Class<? extends Formatter> formatterClass = dataDictionaryService.getAttributeFormatter(boClass, pkFieldName);
		if (formatterClass != null) {
			try {
				formatter = formatterClass.newInstance();
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
       }
	return formattersForPrimaryKeyFields;
}
 
开发者ID:aapotts,项目名称:kuali_rice,代码行数:19,代码来源:InactivationBlockingDisplayServiceImpl.java


示例14: convertPKFieldMapToLookupId

import org.kuali.rice.core.web.format.Formatter; //导入依赖的package包/类
/**
 * Converts a Map of PKFields into a String lookup ID
 * @param pkFieldNames the name of the PK fields, which should be converted to the given lookupId
 * @param businessObjectClass the class of the business object getting the primary key
 * @return the String lookup id
 */
protected String convertPKFieldMapToLookupId(List<String> pkFieldNames, BusinessObject businessObject) {
	StringBuilder lookupId = new StringBuilder();
	for (String pkFieldName : pkFieldNames) {
		try {
			final Object value = PropertyUtils.getProperty(businessObject, pkFieldName);
			
			if (value != null) {
				lookupId.append(pkFieldName);
				lookupId.append("-");
				final Formatter formatter = retrieveBestFormatter(pkFieldName, businessObject.getClass());
				final String formattedValue = (formatter != null) ? formatter.format(value).toString() : value.toString();
				
				lookupId.append(formattedValue);
			}
			lookupId.append(SearchOperator.OR.op());
		} catch (IllegalAccessException iae) {
			throw new RuntimeException("Could not retrieve pk field value "+pkFieldName+" from business object "+businessObject.getClass().getName(), iae);
		} catch (InvocationTargetException ite) {
			throw new RuntimeException("Could not retrieve pk field value "+pkFieldName+" from business object "+businessObject.getClass().getName(), ite);
		} catch (NoSuchMethodException nsme) {
			throw new RuntimeException("Could not retrieve pk field value "+pkFieldName+" from business object "+businessObject.getClass().getName(), nsme);
		}
	}
	return lookupId.substring(0, lookupId.length() - 1); // kill the last "|"
}
 
开发者ID:aapotts,项目名称:kuali_rice,代码行数:32,代码来源:DataDictionaryLookupResultsSupportStrategy.java


示例15: getAttributeFormatter

import org.kuali.rice.core.web.format.Formatter; //导入依赖的package包/类
/**
 * @see org.kuali.rice.krad.service.DataDictionaryService#getAttributeFormatter(java.lang.String)
 */
@Override
public Class<? extends Formatter> getAttributeFormatter(String entryName, String attributeName) {
    Class formatterClass = null;

    AttributeDefinition attributeDefinition = getAttributeDefinition(entryName, attributeName);
    if (attributeDefinition != null) {
        if (attributeDefinition.hasFormatterClass()) {
            formatterClass = ClassLoaderUtils.getClass(attributeDefinition.getFormatterClass());
        }
    }

    return formatterClass;
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:17,代码来源:TestDataDictionaryService.java


示例16: getAttributeFormatter

import org.kuali.rice.core.web.format.Formatter; //导入依赖的package包/类
@Override
public Class<? extends Formatter> getAttributeFormatter(String entryName, String attributeName) {
       Class formatterClass = null;

       AttributeDefinition attributeDefinition = getAttributeDefinition(entryName, attributeName);
       if (attributeDefinition != null) {
           if (attributeDefinition.hasFormatterClass()) {
               formatterClass = ClassLoaderUtils.getClass(attributeDefinition.getFormatterClass());
           }
       }

       return formatterClass;
   }
 
开发者ID:kuali,项目名称:kc-rice,代码行数:14,代码来源:DataDictionaryServiceImpl.java


示例17: buildFormatter

import org.kuali.rice.core.web.format.Formatter; //导入依赖的package包/类
private Formatter buildFormatter(String keypath, Class propertyType, Map requestParams) {
    Formatter formatter = buildFormatterForKeypath(keypath, propertyType, requestParams);
    if (formatter == null) {
        formatter = buildFormatterForType(propertyType);
    }
    return formatter;
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:8,代码来源:PojoFormBase.java


示例18: buildFormatterForType

import org.kuali.rice.core.web.format.Formatter; //导入依赖的package包/类
private Formatter buildFormatterForType(Class propertyType) {
    Formatter formatter = null;

    if (Formatter.findFormatter(propertyType) != null) {
        formatter = Formatter.getFormatter(propertyType);
    }
    return formatter;
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:9,代码来源:PojoFormBase.java


示例19: cacheUnconvertedValue

import org.kuali.rice.core.web.format.Formatter; //导入依赖的package包/类
protected void cacheUnconvertedValue(String key, Object value) {
    Class type = value.getClass();
    if (type.isArray()) {
        value = Formatter.isEmptyValue(value) ? null : ((Object[]) value)[0];
    }

    unconvertedValues.put(key, value);
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:9,代码来源:PojoFormBase.java


示例20: getAttributeFormatter

import org.kuali.rice.core.web.format.Formatter; //导入依赖的package包/类
protected Formatter getAttributeFormatter(KimAttributeField definition) {
    if (definition.getAttributeField().getDataType() == null) {
        return null;
    }

    return Formatter.getFormatter(definition.getAttributeField().getDataType().getType());
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:8,代码来源:DataDictionaryTypeServiceBase.java



注:本文中的org.kuali.rice.core.web.format.Formatter类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java RedirectAttributesModelMap类代码示例发布时间:2022-05-22
下一篇:
Java KafkaBolt类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap