Java源码示例:org.apache.commons.beanutils.converters.ByteConverter
示例1
/**
* Register standard default null.
*
* @see ConvertUtilsBean#registerPrimitives(boolean) registerPrimitives(boolean throwException)
* @see ConvertUtilsBean#registerStandard(boolean,boolean) registerStandard(boolean throwException, boolean defaultNull)
* @see ConvertUtilsBean#registerOther(boolean) registerOther(boolean throwException)
* @see ConvertUtilsBean#registerArrays(boolean,int) registerArrays(boolean throwException, int defaultArraySize)
* @see ConvertUtilsBean#deregister(Class) ConvertUtilsBean.deregister(Class)
* @since 1.11.2
*/
public static void registerStandardDefaultNull(){
ConvertUtils.register(new BigDecimalConverter(null), BigDecimal.class);
ConvertUtils.register(new BigIntegerConverter(null), BigInteger.class);
ConvertUtils.register(new BooleanConverter(null), Boolean.class);
ConvertUtils.register(new ByteConverter(null), Byte.class);
ConvertUtils.register(new CharacterConverter(null), Character.class);
ConvertUtils.register(new DoubleConverter(null), Double.class);
ConvertUtils.register(new FloatConverter(null), Float.class);
ConvertUtils.register(new IntegerConverter(null), Integer.class);
ConvertUtils.register(new LongConverter(null), Long.class);
ConvertUtils.register(new ShortConverter(null), Short.class);
ConvertUtils.register(new StringConverter(null), String.class);
}
示例2
/**
* <p>Initialize other global characteristics of the controller servlet.</p>
* Overridden to remove the ConvertUtils.deregister() command that caused problems
* with the concurrent data dictionary load. (KULRNE-4405)
*
* @exception ServletException if we cannot initialize these resources
*/
@Override
protected void initOther() throws ServletException {
String value = null;
value = getServletConfig().getInitParameter("config");
if (value != null) {
config = value;
}
// Backwards compatibility for form beans of Java wrapper classes
// Set to true for strict Struts 1.0 compatibility
value = getServletConfig().getInitParameter("convertNull");
if ("true".equalsIgnoreCase(value)
|| "yes".equalsIgnoreCase(value)
|| "on".equalsIgnoreCase(value)
|| "y".equalsIgnoreCase(value)
|| "1".equalsIgnoreCase(value)) {
convertNull = true;
}
if (convertNull) {
ConvertUtils.register(new BigDecimalConverter(null), BigDecimal.class);
ConvertUtils.register(new BigIntegerConverter(null), BigInteger.class);
ConvertUtils.register(new BooleanConverter(null), Boolean.class);
ConvertUtils.register(new ByteConverter(null), Byte.class);
ConvertUtils.register(new CharacterConverter(null), Character.class);
ConvertUtils.register(new DoubleConverter(null), Double.class);
ConvertUtils.register(new FloatConverter(null), Float.class);
ConvertUtils.register(new IntegerConverter(null), Integer.class);
ConvertUtils.register(new LongConverter(null), Long.class);
ConvertUtils.register(new ShortConverter(null), Short.class);
}
// KULRICE-8176: KFS Notes/Attachments Tab Functionality for Note Text Error - Visible/Special characters, spaces, or tabs
parameterEncoding = getServletConfig().getInitParameter("PARAMETER_ENCODING");
}
示例3
/**
* Returns an array representation of the field or a default value in case if the field cannot
* be converted to array.
* @param def the default value to be returned if an error occurs converting the field
* @return an array representation of the field
*/
public byte[] getBytes(byte[] def) {
return new ArrayConverter(byte[].class, new ByteConverter()).convert(byte[].class, value);
}