Java 类org.apache.commons.beanutils.converters.LongConverter 实例源码

项目:zswxsqxt    文件:ConvertRegisterHelper.java   
public static void registerConverters() {
    ConvertUtils.register(new StringConverter(), String.class);
    //date 
    ConvertUtils.register(new DateConverter(null),java.util.Date.class);
       ConvertUtils.register(new SqlDateConverter(null),java.sql.Date.class);
    ConvertUtils.register(new SqlTimeConverter(null),Time.class);
    ConvertUtils.register(new SqlTimestampConverter(null),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); 
}
项目:zswxsqxt    文件:ConvertRegisterHelper.java   
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); 
}
项目:NotifyTools    文件:ConvertUtilsBean.java   
/**
 * Sets the default value for Long conversions.
 * @param newDefaultLong The default Long value
 * @deprecated Register replacement converters for Long.TYPE and
 *  Long.class instead
 */
@Deprecated
public void setDefaultLong(final long newDefaultLong) {
    defaultLong = new Long(newDefaultLong);
    register(new LongConverter(defaultLong), Long.TYPE);
    register(new LongConverter(defaultLong), Long.class);
}
项目:NotifyTools    文件:ConvertUtilsBean.java   
/**
 * Register array converters.
 *
 * @param throwException <code>true</code> if the converters should
 * throw an exception when a conversion error occurs, otherwise <code>
 * <code>false</code> if a default value should be used.
 * @param defaultArraySize The size of the default array value for array converters
 * (N.B. This values is ignored if <code>throwException</code> is <code>true</code>).
 * Specifying a value less than zero causes a <code>null<code> value to be used for
 * the default.
 */
private void registerArrays(final boolean throwException, final int defaultArraySize) {

    // Primitives
    registerArrayConverter(Boolean.TYPE,   new BooleanConverter(),   throwException, defaultArraySize);
    registerArrayConverter(Byte.TYPE,      new ByteConverter(),      throwException, defaultArraySize);
    registerArrayConverter(Character.TYPE, new CharacterConverter(), throwException, defaultArraySize);
    registerArrayConverter(Double.TYPE,    new DoubleConverter(),    throwException, defaultArraySize);
    registerArrayConverter(Float.TYPE,     new FloatConverter(),     throwException, defaultArraySize);
    registerArrayConverter(Integer.TYPE,   new IntegerConverter(),   throwException, defaultArraySize);
    registerArrayConverter(Long.TYPE,      new LongConverter(),      throwException, defaultArraySize);
    registerArrayConverter(Short.TYPE,     new ShortConverter(),     throwException, defaultArraySize);

    // Standard
    registerArrayConverter(BigDecimal.class, new BigDecimalConverter(), throwException, defaultArraySize);
    registerArrayConverter(BigInteger.class, new BigIntegerConverter(), throwException, defaultArraySize);
    registerArrayConverter(Boolean.class,    new BooleanConverter(),    throwException, defaultArraySize);
    registerArrayConverter(Byte.class,       new ByteConverter(),       throwException, defaultArraySize);
    registerArrayConverter(Character.class,  new CharacterConverter(),  throwException, defaultArraySize);
    registerArrayConverter(Double.class,     new DoubleConverter(),     throwException, defaultArraySize);
    registerArrayConverter(Float.class,      new FloatConverter(),      throwException, defaultArraySize);
    registerArrayConverter(Integer.class,    new IntegerConverter(),    throwException, defaultArraySize);
    registerArrayConverter(Long.class,       new LongConverter(),       throwException, defaultArraySize);
    registerArrayConverter(Short.class,      new ShortConverter(),      throwException, defaultArraySize);
    registerArrayConverter(String.class,     new StringConverter(),     throwException, defaultArraySize);

    // Other
    registerArrayConverter(Class.class,          new ClassConverter(),        throwException, defaultArraySize);
    registerArrayConverter(java.util.Date.class, new DateConverter(),         throwException, defaultArraySize);
    registerArrayConverter(Calendar.class,       new DateConverter(),         throwException, defaultArraySize);
    registerArrayConverter(File.class,           new FileConverter(),         throwException, defaultArraySize);
    registerArrayConverter(java.sql.Date.class,  new SqlDateConverter(),      throwException, defaultArraySize);
    registerArrayConverter(java.sql.Time.class,  new SqlTimeConverter(),      throwException, defaultArraySize);
    registerArrayConverter(Timestamp.class,      new SqlTimestampConverter(), throwException, defaultArraySize);
    registerArrayConverter(URL.class,            new URLConverter(),          throwException, defaultArraySize);

}
项目:lams    文件:ActionServlet.java   
/**
 * <p>Initialize other global characteristics of the controller servlet.</p>
 *
 * @exception ServletException if we cannot initialize these resources
 */
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.deregister();
        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);
    }

}
项目:bluetooth-gatt-parser    文件:FieldHolder.java   
/**
 * Returns a Long representation of the field or a default value in case if the field cannot
 * be converted to a Long.
 * @param def the default value to be returned if an error occurs converting the field
 * @return a Long representation of the field
 */
public Long getLong(Long def) {
    Long result = new LongConverter(null).convert(Long.class, value);
    if (result != null) {
        return Math.round(result * getMultiplier());
    } else {
        return def;
    }
}
项目:checkstyle-backport-jre6    文件:AutomaticBean.java   
/**
 * 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
}
项目:sonar-scanner-maven    文件:ActionServlet.java   
/**
 * <p>Initialize other global characteristics of the controller
 * servlet.</p>
 *
 * @throws ServletException if we cannot initialize these resources
 */
protected void initOther()
    throws ServletException {
    String value;

    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.deregister();
        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);
    }
}
项目:payment    文件:ContextInitializer.java   
public void initialize(ConfigurableApplicationContext applicationContext) {
    logger.debug("Context is initialized");
    BeanUtilsBean.getInstance().
            getConvertUtils().register(new LongConverter(null),
            Long.class);
    BeanUtilsBean.getInstance()
            .getConvertUtils().register(new BigDecimalConverter(null),
            BigDecimal.class);
}
项目:kc-rice    文件:KualiActionServlet.java   
/**
    * <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");
   }
项目:rice    文件:KualiActionServlet.java   
/**
    * <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");
   }
项目:checkstyle    文件:AutomaticBean.java   
/**
 * 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
}
项目:kuali_rice    文件:KualiActionServlet.java   
/**
    * <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");
   }
项目:NotifyTools    文件:ConvertUtilsBean.java   
/**
 * Register the converters for standard types.
 * </p>
 * This method registers the following converters:
 * <ul>
 *     <li><code>BigDecimal.class</code> - {@link BigDecimalConverter}</li>
 *     <li><code>BigInteger.class</code> - {@link BigIntegerConverter}</li>
 *     <li><code>Boolean.class</code> - {@link BooleanConverter}</li>
 *     <li><code>Byte.class</code> - {@link ByteConverter}</li>
 *     <li><code>Character.class</code> - {@link CharacterConverter}</li>
 *     <li><code>Double.class</code> - {@link DoubleConverter}</li>
 *     <li><code>Float.class</code> - {@link FloatConverter}</li>
 *     <li><code>Integer.class</code> - {@link IntegerConverter}</li>
 *     <li><code>Long.class</code> - {@link LongConverter}</li>
 *     <li><code>Short.class</code> - {@link ShortConverter}</li>
 *     <li><code>String.class</code> - {@link StringConverter}</li>
 * </ul>
 * @param throwException <code>true</code> if the converters should
 * throw an exception when a conversion error occurs, otherwise <code>
 * <code>false</code> if a default value should be used.
 * @param defaultNull <code>true</code>if the <i>standard</i> converters
 * (see {@link ConvertUtilsBean#registerStandard(boolean, boolean)})
 * should use a default value of <code>null</code>, otherwise <code>false</code>.
 * N.B. This values is ignored if <code>throwException</code> is <code>true</code>
 */
private void registerStandard(final boolean throwException, final boolean defaultNull) {

    final Number     defaultNumber     = defaultNull ? null : ZERO;
    final BigDecimal bigDecDeflt       = defaultNull ? null : new BigDecimal("0.0");
    final BigInteger bigIntDeflt       = defaultNull ? null : new BigInteger("0");
    final Boolean    booleanDefault    = defaultNull ? null : Boolean.FALSE;
    final Character  charDefault       = defaultNull ? null : SPACE;
    final String     stringDefault     = defaultNull ? null : "";

    register(BigDecimal.class, throwException ? new BigDecimalConverter() : new BigDecimalConverter(bigDecDeflt));
    register(BigInteger.class, throwException ? new BigIntegerConverter() : new BigIntegerConverter(bigIntDeflt));
    register(Boolean.class,    throwException ? new BooleanConverter()    : new BooleanConverter(booleanDefault));
    register(Byte.class,       throwException ? new ByteConverter()       : new ByteConverter(defaultNumber));
    register(Character.class,  throwException ? new CharacterConverter()  : new CharacterConverter(charDefault));
    register(Double.class,     throwException ? new DoubleConverter()     : new DoubleConverter(defaultNumber));
    register(Float.class,      throwException ? new FloatConverter()      : new FloatConverter(defaultNumber));
    register(Integer.class,    throwException ? new IntegerConverter()    : new IntegerConverter(defaultNumber));
    register(Long.class,       throwException ? new LongConverter()       : new LongConverter(defaultNumber));
    register(Short.class,      throwException ? new ShortConverter()      : new ShortConverter(defaultNumber));
    register(String.class,     throwException ? new StringConverter()     : new StringConverter(stringDefault));

}
项目:cattle    文件:CommonsConverterStartup.java   
public static void init() {
    ConvertUtilsBean service = BeanUtilsBean.getInstance().getConvertUtils();
    service.register(new LongConverter(null), Long.class);
    service.register(new IntegerConverter(null), Integer.class);
}
项目:cloud-cattle    文件:CommonsConverterStartup.java   
@PostConstruct
public void init() {
    ConvertUtilsBean service = BeanUtilsBean.getInstance().getConvertUtils();
    service.register(new LongConverter(null), Long.class);
    service.register(new IntegerConverter(null), Integer.class);
}
项目:dstack    文件:CommonsConverterStartup.java   
@PostConstruct
public void init() {
    ConvertUtilsBean service = BeanUtilsBean.getInstance().getConvertUtils();
    service.register(new LongConverter(null), Long.class);
    service.register(new IntegerConverter(null), Long.class);
}
项目:qb-core    文件:RmActionServlet.java   
/**
 * <p>Initialize other global characteristics of the controller
 * servlet.</p>
 *
 * @throws ServletException if we cannot initialize these resources
 */
protected void initOther()
    throws ServletException {
    String value;

    value = getServletConfig().getInitParameter("config");

    if (value != null) {
        //QB-RM add *.xml
        if(value.trim().length() > 0 && value.indexOf("*.xml") > -1){ //
            String finalValue = "";
            String[] aValue = value.trim().split(",");
            for (int j = 0; j < aValue.length; j++) {
                String path = aValue[j];
                if(path.trim().length() == 0) {
                    continue;
                }
                //判断当前这行是否*.xml
                if(path.trim().endsWith("*.xml")) {
                    File fWarDirStr = RmPathHelper.getWarDir();
                    File fPath = new File(fWarDirStr + File.separator + (path.substring(0, path.length()-"*.xml".length())));
                    for (int i = 0; i < fPath.listFiles().length; i++) {
                        File fPathXml = fPath.listFiles()[i];
                        if(fPathXml.isFile() && fPathXml.toString().toLowerCase().endsWith(".xml")) {
                            String newPath = fPathXml.getAbsolutePath().substring((int)fWarDirStr.getAbsoluteFile().toString().length()).replaceAll("\\\\", "/");
                            finalValue += newPath + ",";
                        }
                    } 
                } else {
                    finalValue += path + ",";
                }
            }
            if(finalValue.endsWith(",")) {
                finalValue = finalValue.substring(0, finalValue.length() - ",".length());
            }
            config = finalValue;
        } else {
            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.deregister();
        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);
    }
}
项目:javasec    文件:RmActionServlet.java   
/**
 * <p>Initialize other global characteristics of the controller
 * servlet.</p>
 *
 * @throws ServletException if we cannot initialize these resources
 */
protected void initOther()
    throws ServletException {
    String value;

    value = getServletConfig().getInitParameter("config");

    if (value != null) {
        //QB-RM add *.xml
        if(value.trim().length() > 0 && value.indexOf("*.xml") > -1){ //
            String finalValue = "";
            String[] aValue = value.trim().split(",");
            for (int j = 0; j < aValue.length; j++) {
                String path = aValue[j];
                if(path.trim().length() == 0) {
                    continue;
                }
                //判断当前这行是否*.xml
                if(path.trim().endsWith("*.xml")) {
                    File fWarDirStr = RmPathHelper.getWarDir();
                    File fPath = new File(fWarDirStr + File.separator + (path.substring(0, path.length()-"*.xml".length())));
                    for (int i = 0; i < fPath.listFiles().length; i++) {
                        File fPathXml = fPath.listFiles()[i];
                        if(fPathXml.isFile() && fPathXml.toString().toLowerCase().endsWith(".xml")) {
                            String newPath = fPathXml.getAbsolutePath().substring((int)fWarDirStr.getAbsoluteFile().toString().length()).replaceAll("\\\\", "/");
                            finalValue += newPath + ",";
                        }
                    } 
                } else {
                    finalValue += path + ",";
                }
            }
            if(finalValue.endsWith(",")) {
                finalValue = finalValue.substring(0, finalValue.length() - ",".length());
            }
            config = finalValue;
        } else {
            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.deregister();
        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);
    }
}
项目:java-lib    文件:RmActionServlet.java   
/**
 * <p>Initialize other global characteristics of the controller
 * servlet.</p>
 *
 * @throws ServletException if we cannot initialize these resources
 */
protected void initOther()
    throws ServletException {
    String value;

    value = getServletConfig().getInitParameter("config");

    if (value != null) {
        //QB-RM add *.xml
        if(value.trim().length() > 0 && value.indexOf("*.xml") > -1){ //
            String finalValue = "";
            String[] aValue = value.trim().split(",");
            for (int j = 0; j < aValue.length; j++) {
                String path = aValue[j];
                if(path.trim().length() == 0) {
                    continue;
                }
                //判断当前这行是否*.xml
                if(path.trim().endsWith("*.xml")) {
                    File fWarDirStr = RmPathHelper.getWarDir();
                    File fPath = new File(fWarDirStr + File.separator + (path.substring(0, path.length()-"*.xml".length())));
                    for (int i = 0; i < fPath.listFiles().length; i++) {
                        File fPathXml = fPath.listFiles()[i];
                        if(fPathXml.isFile() && fPathXml.toString().toLowerCase().endsWith(".xml")) {
                            String newPath = fPathXml.getAbsolutePath().substring((int)fWarDirStr.getAbsoluteFile().toString().length()).replaceAll("\\\\", "/");
                            finalValue += newPath + ",";
                        }
                    } 
                } else {
                    finalValue += path + ",";
                }
            }
            if(finalValue.endsWith(",")) {
                finalValue = finalValue.substring(0, finalValue.length() - ",".length());
            }
            config = finalValue;
        } else {
            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.deregister();
        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);
    }
}
项目:NotifyTools    文件:ConvertUtilsBean.java   
/**
 * Register the converters for primitive types.
 * </p>
 * This method registers the following converters:
 * <ul>
 *     <li><code>Boolean.TYPE</code> - {@link BooleanConverter}</li>
 *     <li><code>Byte.TYPE</code> - {@link ByteConverter}</li>
 *     <li><code>Character.TYPE</code> - {@link CharacterConverter}</li>
 *     <li><code>Double.TYPE</code> - {@link DoubleConverter}</li>
 *     <li><code>Float.TYPE</code> - {@link FloatConverter}</li>
 *     <li><code>Integer.TYPE</code> - {@link IntegerConverter}</li>
 *     <li><code>Long.TYPE</code> - {@link LongConverter}</li>
 *     <li><code>Short.TYPE</code> - {@link ShortConverter}</li>
 * </ul>
 * @param throwException <code>true</code> if the converters should
 * throw an exception when a conversion error occurs, otherwise <code>
 * <code>false</code> if a default value should be used.
 */
private void registerPrimitives(final boolean throwException) {
    register(Boolean.TYPE,   throwException ? new BooleanConverter()    : new BooleanConverter(Boolean.FALSE));
    register(Byte.TYPE,      throwException ? new ByteConverter()       : new ByteConverter(ZERO));
    register(Character.TYPE, throwException ? new CharacterConverter()  : new CharacterConverter(SPACE));
    register(Double.TYPE,    throwException ? new DoubleConverter()     : new DoubleConverter(ZERO));
    register(Float.TYPE,     throwException ? new FloatConverter()      : new FloatConverter(ZERO));
    register(Integer.TYPE,   throwException ? new IntegerConverter()    : new IntegerConverter(ZERO));
    register(Long.TYPE,      throwException ? new LongConverter()       : new LongConverter(ZERO));
    register(Short.TYPE,     throwException ? new ShortConverter()      : new ShortConverter(ZERO));
}
项目:feilong-core    文件:ConvertUtil.java   
/**
 * 将 <code>toBeConvertedValue</code> 转换成 {@link Long}类型.
 * 
 * <h3>示例:</h3>
 * 
 * <blockquote>
 * 
 * <pre class="code">
 * ConvertUtil.toLong(null)                     = null
 * ConvertUtil.toLong("aaaa")                   = null
 * ConvertUtil.toLong(8)                        = 8L
 * ConvertUtil.toLong("8")                      = 8L
 * ConvertUtil.toLong(new BigDecimal("8"))      = 8L
 * </pre>
 * 
 * <p>
 * 如果传入的参数 <code>toBeConvertedValue</code> 是 <b>数组</b>,那么<b>取第一个元素</b>进行转换,参见 {@link AbstractConverter#convertArray(Object)} L227:
 * </p>
 * 
 * <pre class="code">
 * ConvertUtil.toLong(new String[] { "1", "2", "3" }) = 1L
 * </pre>
 * 
 * <p>
 * 如果传入的参数 <code>toBeConvertedValue</code> 是 <b>集合</b>,那么<b>取第一个元素</b>进行转换,参见 {@link AbstractConverter#convertArray(Object)} Line234:
 * </p>
 * 
 * <pre class="code">
 * ConvertUtil.toLong(toList("1", "2")) = 1L
 * </pre>
 * 
 * </blockquote>
 * 
 * @param toBeConvertedValue
 *            包含数字的对象.
 * @return 如果 <code>toBeConvertedValue</code> 是null,返回 null<br>
 *         如果传入的参数 <code>toBeConvertedValue</code> 是 <b>数组</b>,那么<b>取第一个元素</b>进行转换<br>
 *         如果传入的参数 <code>toBeConvertedValue</code> 是 <b>集合</b>,那么<b>取第一个元素</b>进行转换<br>
 *         如果找不到转换器或者转换的时候出现了异常,返回 null
 * @see #convert(Object, Class)
 * @see org.apache.commons.beanutils.converters.LongConverter
 * @see org.apache.commons.lang3.math.NumberUtils#toLong(String)
 */
public static Long toLong(Object toBeConvertedValue){
    return new LongConverter(null).convert(Long.class, toBeConvertedValue);
}