當前位置: 首頁>>代碼示例>>Java>>正文


Java ConvertUtilsBean類代碼示例

本文整理匯總了Java中org.apache.commons.beanutils.ConvertUtilsBean的典型用法代碼示例。如果您正苦於以下問題:Java ConvertUtilsBean類的具體用法?Java ConvertUtilsBean怎麽用?Java ConvertUtilsBean使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ConvertUtilsBean類屬於org.apache.commons.beanutils包,在下文中一共展示了ConvertUtilsBean類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: afterPropertiesSet

import org.apache.commons.beanutils.ConvertUtilsBean; //導入依賴的package包/類
@Override
public void afterPropertiesSet() throws Exception {
    beanContext = new BackendBeanContext(beanFactory);
    BeanContextBean.getInstance().setBeanContext(beanContext);
    VenusBeanUtilsBean.setInstance(new BackendBeanUtilsBean(new ConvertUtilsBean(), new PropertyUtilsBean(), beanContext));
    AthenaExtensionResolver.getInstance().resolver();
    CodeMapScanner.getCodeMap();

    List<ServiceConfig> serviceConfigList = new ArrayList<ServiceConfig>();
    Map<String, InterceptorMapping> interceptors = new HashMap<String, InterceptorMapping>();
    Map<String, InterceptorStackConfig> interceptorStacks = new HashMap<String, InterceptorStackConfig>();
    loadVenusService(serviceConfigList, interceptors, interceptorStacks);
    loadMonitorService(interceptors, interceptorStacks);
    loadRegistryService(interceptors, interceptorStacks);
    initMonitor(serviceConfigList, interceptors, interceptorStacks);
}
 
開發者ID:blusechen,項目名稱:venus,代碼行數:17,代碼來源:XmlFileServiceManager.java

示例2: configureConvertUtilsBean

import org.apache.commons.beanutils.ConvertUtilsBean; //導入依賴的package包/類
public static void configureConvertUtilsBean(
		ConvertUtilsBean convertUtilsBean, ResourceBundle resourceBundle) {

	convertUtilsBean.register(new QualquerObjetoParaString(resourceBundle),
			String.class);
	convertUtilsBean.register(new StringParaDataConverter(resourceBundle),
			Date.class);
	convertUtilsBean.register(
			new StringParaNumberConverter(resourceBundle), Double.class);
	convertUtilsBean.register(
			new StringParaNumberConverter(resourceBundle), Float.class);
	convertUtilsBean.register(
			new StringParaNumberConverter(resourceBundle), Integer.class);
	convertUtilsBean.register(
			new StringParaNumberConverter(resourceBundle), Long.class);
	convertUtilsBean.register(
			new StringParaNumberConverter(resourceBundle), Short.class);
	convertUtilsBean.register(
			new CollectionParaSetConverter(resourceBundle), Set.class);
	convertUtilsBean.register(new CollectionParaListConverter(
			resourceBundle), List.class);

}
 
開發者ID:darciopacifico,項目名稱:omr,代碼行數:24,代碼來源:FrameworkAcheUtil.java

示例3: registerConverters

import org.apache.commons.beanutils.ConvertUtilsBean; //導入依賴的package包/類
public static void registerConverters(ConvertUtilsBean convertUtils,String[] datePatterns) {
	convertUtils.register(new StringConverter(), String.class);
	//date 
	convertUtils.register(ConvertRegisterHelper.setPatterns(new DateConverter(null),datePatterns),java.util.Date.class);
	convertUtils.register(ConvertRegisterHelper.setPatterns(new SqlDateConverter(null),datePatterns),java.sql.Date.class);
	convertUtils.register(ConvertRegisterHelper.setPatterns(new SqlTimeConverter(null),datePatterns),Time.class);
	convertUtils.register(ConvertRegisterHelper.setPatterns(new SqlTimestampConverter(null),datePatterns),Timestamp.class);
	//number
	convertUtils.register(new BooleanConverter(null), Boolean.class);
	convertUtils.register(new ShortConverter(null), Short.class);
	convertUtils.register(new IntegerConverter(null), Integer.class);
	convertUtils.register(new LongConverter(null), Long.class);
	convertUtils.register(new FloatConverter(null), Float.class);
	convertUtils.register(new DoubleConverter(null), Double.class);
	convertUtils.register(new BigDecimalConverter(null), BigDecimal.class); 
	convertUtils.register(new BigIntegerConverter(null), BigInteger.class);	
}
 
開發者ID:545473750,項目名稱:zswxsqxt,代碼行數:18,代碼來源:ConvertRegisterHelper.java

示例4: getFileDataSource

import org.apache.commons.beanutils.ConvertUtilsBean; //導入依賴的package包/類
public CsvReaderDataSource getFileDataSource(int csvVersion, DaTable table, String content, char dataDelimiter, String nullToken, Function<String, String> convertDbObjectName) {
    CsvReaderDataSource fileSource = new CsvReaderDataSource(csvVersion, "fileSource", new StringReader(content),
            dataDelimiter, convertDbObjectName, nullToken);
    ConvertUtilsBean cub = new ConvertUtilsBean();
    for (DaColumn col : table.getColumns()) {
        Class targetClassName;

        // This is to handle cases in Sybase ASE where a column comes back in quotes, e.g. "Date"
        // This happens if the column name happens to be a keyword, e.g. for Date
        String columnName = col.getName();
        if (columnName.startsWith("\"") && columnName.endsWith("\"")) {
            columnName = columnName.substring(1, columnName.length() - 1);
        }
        try {
            // this is to handle "tinyint"
            if (col.getColumnDataType().getTypeClassName().equalsIgnoreCase("byte")) {
                targetClassName = Integer.class;
            } else {
                targetClassName = Class.forName(col.getColumnDataType().getTypeClassName());
            }
        } catch (ClassNotFoundException e) {
            throw new DeployerRuntimeException(e);
        }
        fileSource.addDerivedField(new MyDerivedField(csvVersion, convertDbObjectName.valueOf(columnName),
                targetClassName, cub, nullToken));
    }

    fileSource.init();  // initialize so that we can discover the fields in the file
    return fileSource;
}
 
開發者ID:goldmansachs,項目名稱:obevo,代碼行數:31,代碼來源:CsvStaticDataReader.java

示例5: MyDerivedField

import org.apache.commons.beanutils.ConvertUtilsBean; //導入依賴的package包/類
public MyDerivedField(int csvVersion, String field, Class targetClass, ConvertUtilsBean cub, String nullToken) {
    this.csvVersion = csvVersion;
    this.field = field;
    this.cub = cub;
    this.targetClass = targetClass;
    this.nullToken = nullToken;
}
 
開發者ID:goldmansachs,項目名稱:obevo,代碼行數:8,代碼來源:CsvStaticDataReader.java

示例6: convertWithDefault

import org.apache.commons.beanutils.ConvertUtilsBean; //導入依賴的package包/類
private static Function<FieldToColumnMapping, String> convertWithDefault(final ConvertUtilsBean cub) {
    return new Function<FieldToColumnMapping, String>() {
        @Override
        public String valueOf(FieldToColumnMapping field) {
            return field.getColumnName() + " DEFAULT '" + cub.convert(field.getDefaultValue()) + "'";
        }
    };
}
 
開發者ID:goldmansachs,項目名稱:obevo,代碼行數:9,代碼來源:IqLoadFileCreator.java

示例7: createBeanUtilsBean

import org.apache.commons.beanutils.ConvertUtilsBean; //導入依賴的package包/類
/**
 * Creates a BeanUtilsBean that is configured to use
 * type converters that throw a ConversionException
 * instead of using the default value when something
 * goes wrong.
 *
 * @return a configured BeanUtilsBean
 */
private static BeanUtilsBean createBeanUtilsBean() {
    final ConvertUtilsBean cub = new ConvertUtilsBean();

    registerIntegralTypes(cub);
    registerCustomTypes(cub);

    return new BeanUtilsBean(cub, new PropertyUtilsBean());
}
 
開發者ID:rnveach,項目名稱:checkstyle-backport-jre6,代碼行數:17,代碼來源:AutomaticBean.java

示例8: registerIntegralTypes

import org.apache.commons.beanutils.ConvertUtilsBean; //導入依賴的package包/類
/**
 * Register basic types of JDK like boolean, int, and String to use with BeanUtils. All these
 * types are found in the {@code java.lang} package.
 * @param cub
 *            Instance of {@link ConvertUtilsBean} to register types with.
 */
private static void registerIntegralTypes(ConvertUtilsBean cub) {
    cub.register(new BooleanConverter(), Boolean.TYPE);
    cub.register(new BooleanConverter(), Boolean.class);
    cub.register(new ArrayConverter(
        boolean[].class, new BooleanConverter()), boolean[].class);
    cub.register(new ByteConverter(), Byte.TYPE);
    cub.register(new ByteConverter(), Byte.class);
    cub.register(new ArrayConverter(byte[].class, new ByteConverter()),
        byte[].class);
    cub.register(new CharacterConverter(), Character.TYPE);
    cub.register(new CharacterConverter(), Character.class);
    cub.register(new ArrayConverter(char[].class, new CharacterConverter()),
        char[].class);
    cub.register(new DoubleConverter(), Double.TYPE);
    cub.register(new DoubleConverter(), Double.class);
    cub.register(new ArrayConverter(double[].class, new DoubleConverter()),
        double[].class);
    cub.register(new FloatConverter(), Float.TYPE);
    cub.register(new FloatConverter(), Float.class);
    cub.register(new ArrayConverter(float[].class, new FloatConverter()),
        float[].class);
    cub.register(new IntegerConverter(), Integer.TYPE);
    cub.register(new IntegerConverter(), Integer.class);
    cub.register(new ArrayConverter(int[].class, new IntegerConverter()),
        int[].class);
    cub.register(new LongConverter(), Long.TYPE);
    cub.register(new LongConverter(), Long.class);
    cub.register(new ArrayConverter(long[].class, new LongConverter()),
        long[].class);
    cub.register(new ShortConverter(), Short.TYPE);
    cub.register(new ShortConverter(), Short.class);
    cub.register(new ArrayConverter(short[].class, new ShortConverter()),
        short[].class);
    cub.register(new RelaxedStringArrayConverter(), String[].class);

    // BigDecimal, BigInteger, Class, Date, String, Time, TimeStamp
    // do not use defaults in the default configuration of ConvertUtilsBean
}
 
開發者ID:rnveach,項目名稱:checkstyle-backport-jre6,代碼行數:45,代碼來源:AutomaticBean.java

示例9: registerCustomTypes

import org.apache.commons.beanutils.ConvertUtilsBean; //導入依賴的package包/類
/**
 * Register custom types of JDK like URI and Checkstyle specific classes to use with BeanUtils.
 * None of these types should be found in the {@code java.lang} package.
 * @param cub
 *            Instance of {@link ConvertUtilsBean} to register types with.
 */
private static void registerCustomTypes(ConvertUtilsBean cub) {
    cub.register(new PatternConverter(), Pattern.class);
    cub.register(new SeverityLevelConverter(), SeverityLevel.class);
    cub.register(new ScopeConverter(), Scope.class);
    cub.register(new UriConverter(), URI.class);
    cub.register(new RelaxedAccessModifierArrayConverter(), AccessModifier[].class);
}
 
開發者ID:rnveach,項目名稱:checkstyle-backport-jre6,代碼行數:14,代碼來源:AutomaticBean.java

示例10: prepare

import org.apache.commons.beanutils.ConvertUtilsBean; //導入依賴的package包/類
private static void prepare(){
	//使用自定義的替換
	PropertyUtilsBean propertyUtilsBean = new CustPropertyUtilsBean();
	ConvertUtilsBean convertUtilsBean = new CustConvertUtilsBean();
	
	BeanUtilsBean beanUtilsBean = new BeanUtilsBean(convertUtilsBean,propertyUtilsBean);
	BeanUtilsBean.setInstance(beanUtilsBean);
	
	//注冊轉換器,處理枚舉
	registEnumConvert();
}
 
開發者ID:yinshipeng,項目名稱:sosoapi-base,代碼行數:12,代碼來源:CustBeanPropUtils.java

示例11: initBeanUtils

import org.apache.commons.beanutils.ConvertUtilsBean; //導入依賴的package包/類
public static void initBeanUtils() {
    // begin Kuali Foundation modification
    ConvertUtilsBean convUtils = new ConvertUtilsBean();
    PropertyUtilsBean propUtils = new PojoPropertyUtilsBean();
    BeanUtilsBean pojoBeanUtils = new BeanUtilsBean(convUtils, propUtils);

    BeanUtilsBean.setInstance(pojoBeanUtils);
    logger.fine("Initialized BeanUtilsBean with " + pojoBeanUtils);
    // end Kuali Foundation modification
}
 
開發者ID:kuali,項目名稱:kc-rice,代碼行數:11,代碼來源:PojoPlugin.java

示例12: register

import org.apache.commons.beanutils.ConvertUtilsBean; //導入依賴的package包/類
/**
 * Register the conversion types.
 *
 * @param convertUtilsBean registrar.
 */
@Override
public void register(ConvertUtilsBean convertUtilsBean) {
    convertUtilsBean.deregister(String.class);
    convertUtilsBean.deregister(Calendar.class);
    convertUtilsBean.deregister(Date.class);
    convertUtilsBean.register(this, String.class);
    convertUtilsBean.register(this, Calendar.class);
    convertUtilsBean.register(this, Date.class);
}
 
開發者ID:ZenHarbinger,項目名稱:torgo,代碼行數:15,代碼來源:DateConverter.java

示例13: register

import org.apache.commons.beanutils.ConvertUtilsBean; //導入依賴的package包/類
/**
 * Register the conversion types.
 *
 * @param convertUtilsBean registrar.
 */
@Override
public void register(ConvertUtilsBean convertUtilsBean) {
    convertUtilsBean.deregister(String.class);
    convertUtilsBean.deregister(Color.class);
    convertUtilsBean.register(this, String.class);
    convertUtilsBean.register(this, Color.class);
}
 
開發者ID:ZenHarbinger,項目名稱:torgo,代碼行數:13,代碼來源:ColorConverter.java

示例14: setup

import org.apache.commons.beanutils.ConvertUtilsBean; //導入依賴的package包/類
/**
 * Perform CoerceUtil setup.
 */
private static void setup() {
    BeanUtilsBean.setInstance(new BeanUtilsBean(new ConvertUtilsBean() {
        {
            // https://github.com/yahoo/elide/issues/260
            // enable throwing exceptions when conversion fails
            register(true, false, 0);
        }

        @Override
        /*
         * Overriding lookup to execute enum converter if target is enum
         * or map convert if source is map
         */
        public Converter lookup(Class<?> sourceType, Class<?> targetType) {
            if (targetType.isEnum()) {
                return TO_ENUM_CONVERTER;
            } else if (targetType == UUID.class) {
                return TO_UUID_CONVERTER;
            }
            else if (Map.class.isAssignableFrom(sourceType)) {
                return FROM_MAP_CONVERTER;
            } else if ((String.class.isAssignableFrom(sourceType) || Number.class.isAssignableFrom(sourceType))
                    && ClassUtils.isAssignable(targetType, Date.class)) {
                return EPOCH_TO_DATE_CONVERTER;
            } else {
                return super.lookup(sourceType, targetType);
            }
        }
    }));
}
 
開發者ID:yahoo,項目名稱:elide,代碼行數:34,代碼來源:CoerceUtil.java

示例15: getArgumentValues

import org.apache.commons.beanutils.ConvertUtilsBean; //導入依賴的package包/類
/**
 * @return Returns the argumentValues.
 * @throws PopUpControllerException
 */
protected Object[] getArgumentValues() throws PopUpControllerException {
	Object[] argumentValues = new Object[arguments.size()];

	Iterator iterator = arguments.iterator();
	int i = 0;
	while (iterator.hasNext()) {
		PopUpArgument popUpArgument = (PopUpArgument) iterator.next();

		/* valor em formato String */
		String value = popUpArgument.getValue();
		/* tipo do valor */
		Class type = popUpArgument.getArgumentType();

		/* CRIANDO UM OBJETO ConvertUtilsBean */
		ConvertUtilsBean convertUtilsBean = new ConvertUtilsBean();

		/* Configura um ConvertUtilsBean j� criado */
		FrameworkAcheUtil.configureConvertUtilsBean(convertUtilsBean,
				getResourceBundle());

		/* INVOCANDO CONVERS�O */
		Object objectValue = convertUtilsBean.convert(value, type);

		/* ATRIBUINDO AA LISTA DE ARGUMENTOS */
		argumentValues[i++] = objectValue;
	}

	return argumentValues;
}
 
開發者ID:darciopacifico,項目名稱:omr,代碼行數:34,代碼來源:PopUpController.java


注:本文中的org.apache.commons.beanutils.ConvertUtilsBean類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。