?? strings.java
字號:
// 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 + -