⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 strings.java

📁 这个是网络上下载的一个struct框架的程序
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
// Decompiled by DJ v3.5.5.77 Copyright 2003 Atanas Neshkov  Date: 2003-6-23 11:15:48
// Home Page : http://members.fortunecity.com/neshkov/dj.html  - Check often for new version!
// Decompiler options: packimports(3) 
// Source File Name:   Strings.java

package com.struts2.framework.util;

import java.math.BigDecimal;
import java.math.BigInteger;
import java.text.*;
import java.util.Date;

public class Strings
{

    public static BigDecimal asBigDecimal(String str)
    {
        return asBigDecimal(str, new BigDecimal(BigInteger.ZERO));
    }

    public static BigDecimal asBigDecimal(String str, BigDecimal defaultValue)
    {
        try
        {
            return new BigDecimal(str.trim());
        }
        catch(NullPointerException nullpointerexception)
        {
            return defaultValue;
        }
        catch(NumberFormatException numberformatexception)
        {
            return defaultValue;
        }
        catch(RuntimeException runtimeexception)
        {
            return defaultValue;
        }
    }

    public static BigInteger asBigInteger(String str)
    {
        return asBigInteger(str, BigInteger.ZERO);
    }

    public static BigInteger asBigInteger(String str, BigInteger defaultValue)
    {
        try
        {
            return new BigInteger(str.trim());
        }
        catch(NullPointerException nullpointerexception)
        {
            return defaultValue;
        }
        catch(NumberFormatException numberformatexception)
        {
            return defaultValue;
        }
    }

    public static boolean asBoolean(String str)
    {
        return asBoolean(str, false);
    }

    public static Boolean asBoolean(String str, Boolean defaultValue)
    {
        try
        {
            str = str.trim();
            return Integer.decode(str).intValue() == 0 ? Boolean.FALSE : Boolean.TRUE;
        }
        catch(NullPointerException nullpointerexception)
        {
            return defaultValue;
        }
        catch(NumberFormatException numberformatexception) { }
        if(str.equals(""))
            return defaultValue;
        for(int i = 0; i < FALSE_STRINGS.length; i++)
            if(str.equalsIgnoreCase(FALSE_STRINGS[i]))
                return Boolean.FALSE;

        return Boolean.TRUE;
    }

    public static boolean asBoolean(String str, boolean defaultValue)
    {
        try
        {
            str = str.trim();
            return Integer.decode(str).intValue() != 0;
        }
        catch(NullPointerException nullpointerexception)
        {
            return defaultValue;
        }
        catch(NumberFormatException numberformatexception) { }
        if(str.equals(""))
            return defaultValue;
        for(int i = 0; i < FALSE_STRINGS.length; i++)
            if(str.equalsIgnoreCase(FALSE_STRINGS[i]))
                return false;

        return true;
    }

    public static byte asByte(String str)
    {
        return asByte(str, (byte)0);
    }

    public static Byte asByte(String str, Byte defaultValue)
    {
        try
        {
            return Byte.decode(str.trim());
        }
        catch(NullPointerException nullpointerexception)
        {
            return defaultValue;
        }
        catch(NumberFormatException numberformatexception)
        {
            return defaultValue;
        }
    }

    public static byte asByte(String str, byte defaultValue)
    {
        try
        {
            return Byte.decode(str.trim()).byteValue();
        }
        catch(NullPointerException nullpointerexception)
        {
            return defaultValue;
        }
        catch(NumberFormatException numberformatexception)
        {
            return defaultValue;
        }
    }

    public static char asCharacter(String str)
    {
        return asCharacter(str, '\0');
    }

    public static Character asCharacter(String str, Character defaultValue)
    {
        try
        {
            return new Character(str.trim().charAt(0));
        }
        catch(NullPointerException nullpointerexception)
        {
            return defaultValue;
        }
        catch(IndexOutOfBoundsException indexoutofboundsexception)
        {
            return defaultValue;
        }
    }

    public static char asCharacter(String str, char defaultValue)
    {
        try
        {
            return str.trim().charAt(0);
        }
        catch(NullPointerException nullpointerexception)
        {
            return defaultValue;
        }
        catch(IndexOutOfBoundsException indexoutofboundsexception)
        {
            return defaultValue;
        }
    }

    public static double asDouble(String str)
    {
        return asDouble(str, 0.0D);
    }

    public static Double asDouble(String str, Double defaultValue)
    {
        try
        {
            return new Double(str.trim());
        }
        catch(NullPointerException nullpointerexception)
        {
            return defaultValue;
        }
        catch(NumberFormatException numberformatexception)
        {
            return defaultValue;
        }
    }

    public static double asDouble(String str, double defaultValue)
    {
        try
        {
            return (new Double(str.trim())).doubleValue();
        }
        catch(NullPointerException nullpointerexception)
        {
            return defaultValue;
        }
        catch(NumberFormatException numberformatexception)
        {
            return defaultValue;
        }
    }

    public static float asFloat(String str)
    {
        return asFloat(str, 0.0F);
    }

    public static Float asFloat(String str, Float defaultValue)
    {
        try
        {
            return new Float(str.trim());
        }
        catch(NullPointerException nullpointerexception)
        {
            return defaultValue;
        }
        catch(NumberFormatException numberformatexception)
        {
            return defaultValue;
        }
    }

    public static float asFloat(String str, float defaultValue)
    {
        try
        {
            return (new Float(str.trim())).floatValue();
        }
        catch(NullPointerException nullpointerexception)
        {
            return defaultValue;
        }
        catch(NumberFormatException numberformatexception)
        {
            return defaultValue;
        }
    }

    public static int asInteger(String str)
    {
        return asInteger(str, 0);
    }

    public static Integer asInteger(String str, Integer defaultValue)
    {
        try
        {
            return Integer.decode(str.trim());
        }
        catch(NullPointerException nullpointerexception)
        {
            return defaultValue;
        }
        catch(NumberFormatException numberformatexception)
        {
            return defaultValue;
        }
    }

    public static int asInteger(String str, int defaultValue)
    {
        try
        {
            return Integer.decode(str.trim()).intValue();
        }
        catch(NullPointerException nullpointerexception)
        {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -