<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    9910

    單飛

       :: 首頁(yè) :: 聯(lián)系 :: 聚合  :: 管理

    import java.util.ArrayList;

    public final class StringUtils {

        
    private StringUtils() {
        }

        
    public static boolean isFloatNoExponent(String str) {
            
    int len = str.length();
            
    if (len == 0)
                
    return false;
            
    char c = str.charAt(0);
            
    int i = c != '-' && c != '+' ? 0 : 1;
            
    if (i >= len)
                
    return false;
            
    boolean decimalPointFound = false;
            
    do {
                c 
    = str.charAt(i);
                
    if (c == '.') {
                    
    if (decimalPointFound)
                        
    return false;
                    decimalPointFound 
    = true;
                } 
    else if (!Character.isDigit(c))
                    
    return false;
            } 
    while (++< len);
            
    return true;
        }

        
    public static boolean isFloatWithOptionalExponent(String str) {
            
    int len = str.length();
            
    if (len == 0)
                
    return false;
            
    char c = str.charAt(0);
            
    int i = c != '-' && c != '+' ? 0 : 1;
            
    if (i >= len)
                
    return false;
            
    boolean exponentFound = false;
            
    boolean decimalPointFound = false;
            
    do {
                c 
    = str.charAt(i);
                
    switch (c) {
                
    case 46// '.'
                    if (decimalPointFound || exponentFound)
                        
    return false;
                    decimalPointFound 
    = true;
                    
    break;

                
    case 69// 'E'
                case 101// 'e'
                    if (exponentFound)
                        
    return false;
                    exponentFound 
    = true;
                    c 
    = str.charAt(i + 1);
                    
    if (c == '-' || c == '+')
                        i
    ++;
                    
    break;

                
    default:
                    
    if (!Character.isDigit(c))
                        
    return false;
                    
    break;
                }
            } 
    while (++< len);
            
    return true;
        }

        
    public static boolean isInteger(String str) {
            
    int len = str.length();
            
    if (len == 0)
                
    return false;
            
    char c = str.charAt(0);
            
    int i = c != '-' && c != '+' ? 0 : 1;
            
    if (i >= len)
                
    return false;
            
    do
                
    if (!Character.isDigit(str.charAt(i)))
                    
    return false;
            
    while (++< len);
            
    return true;
        }

        
    public static boolean isUnsignedInteger(String str) {
            
    int len = str.length();
            
    if (len == 0)
                
    return false;
            
    for (int i = 0; i < len; i++)
                
    if (!Character.isDigit(str.charAt(i)))
                    
    return false;

            
    return true;
        }

        
    public static String dequote(String str, char quote) {
            
    if (str == null)
                
    return null;
            
    else
                
    return dequote(str, 0, str.length(), quote);
        }

        
    public static String dequote(String str, int begin, int end, char quote) {
            
    if (begin == end)
                
    return "";
            
    int end_ = str.indexOf(quote, begin);
            
    if (end_ < 0)
                
    return str.substring(begin, end);
            StringBuffer sb 
    = new StringBuffer(end - begin);
            
    int begin_ = begin;
            
    for (; end_ >= 0 && end_ < end; end_ = str.indexOf(quote,
                    begin_ 
    = end_ + 2)) {
                
    if (end_ + 1 >= end || str.charAt(end_ + 1!= quote)
                    
    throw new IllegalArgumentException(
                            
    "Internal quote not doubled in string '"
                                    
    + str.substring(begin, end) + "'");
                sb.append(substring(str, begin_, end_)).append(quote);
            }

            
    return sb.append(substring(str, begin_, end)).toString();
        }

        
    public static String dequoteFull(String str, char quote) {
            
    if (str == null)
                
    return null;
            
    else
                
    return dequoteFull(str, 0, str.length(), quote);
        }

        
    public static String dequoteFull(String str, int begin, int end, char quote) {
            
    if (begin == end)
                
    return "";
            
    if (str.charAt(begin) != quote)
                
    return str.substring(begin, end);
            
    int _end = end - 1;
            
    if (str.length() < 2 || str.charAt(_end) != quote)
                
    throw new IllegalArgumentException(
                        
    "Closing quote missing in string '"
                                
    + substring(str, begin, end) + "'");
            
    else
                
    return dequote(str, begin + 1, _end, quote);
        }

        
    public static String replace(String str, String repl, String with) {
            
    int lastindex = 0;
            
    int pos = str.indexOf(repl);
            
    if (pos < 0)
                
    return str;
            
    int len = repl.length();
            
    int lendiff = with.length() - repl.length();
            StringBuffer out 
    = new StringBuffer(lendiff > 0 ? str.length() + 10
                    
    * lendiff : str.length());
            
    for (; pos >= 0; pos = str.indexOf(repl, lastindex = pos + len))
                out.append(substring(str, lastindex, pos)).append(with);

            
    return out.append(substring(str, lastindex, str.length())).toString();
        }

        
    public static String replace(String str, char repl, String with) {
            
    int pos = str.indexOf(repl);
            
    if (pos < 0)
                
    return str;
            
    int len = str.length();
            
    int lendiff = with.length() - 1;
            StringBuffer out 
    = new StringBuffer(lendiff > 0 ? str.length() + 10
                    
    * lendiff : str.length());
            
    int lastindex = 0;
            
    for (; pos >= 0; pos = str.indexOf(repl, lastindex = pos + 1))
                out.append(substring(str, lastindex, pos)).append(with);

            
    return out.append(substring(str, lastindex, len)).toString();
        }

        
    public static StringBuffer replace(StringBuffer out, String s, String repl,
                String with) {
            
    int lastindex = 0;
            
    int len = repl.length();
            
    for (int index = s.indexOf(repl); index >= 0; index = s.indexOf(repl,
                    lastindex 
    = index + len))
                out.append(substring(s, lastindex, index)).append(with);

            
    return out.append(substring(s, lastindex, len));
        }

        
    public static String[] splitLongString(String str, char separator) {
            
    int len;
            
    if (str == null || (len = str.length()) == 0)
                
    return EMPTY_STRING_ARRAY;
            
    int oldPos = 0;
            ArrayList list 
    = new ArrayList();
            
    for (int pos = str.indexOf(separator); pos >= 0; pos = str.indexOf(
                    separator, oldPos 
    = pos + 1))
                list.add(substring(str, oldPos, pos));

            list.add(substring(str, oldPos, len));
            
    return (String[]) list.toArray(EMPTY_STRING_ARRAY);
        }

        
    public static String[] splitLongString(String str, char separator,
                
    char quote) {
            
    int len;
            
    if (str == null || (len = str.length()) == 0)
                
    return EMPTY_STRING_ARRAY;
            
    int oldPos = 0;
            ArrayList list 
    = new ArrayList();
            
    for (int pos = 0; pos < len;) {
                
    while (pos < len && str.charAt(pos) == quote) {
                    pos 
    = str.indexOf(quote, pos + 1+ 1;
                    
    if (pos == 0)
                        
    throw new IllegalArgumentException(
                                
    "Closing quote missing in string '" + str + "'");
                }
                
    boolean quoted;
                
    if (pos != oldPos) {
                    quoted 
    = true;
                    
    if (pos < len && str.charAt(pos) != separator)
                        
    throw new IllegalArgumentException(
                                
    "Separator must follow closing quote in string '"
                                        
    + str + "'");
                } 
    else {
                    quoted 
    = false;
                    pos 
    = str.indexOf(separator, pos);
                    
    if (pos < 0)
                        pos 
    = len;
                }
                list.add(quoted 
    ? ((Object) (dequote(str, oldPos + 1, pos - 1,
                        quote))) : ((Object) (substring(str, oldPos, pos))));
                oldPos 
    = ++pos;
            }

            
    return (String[]) list.toArray(EMPTY_STRING_ARRAY);
        }

        
    public static String[] splitShortString(String str, char separator) {
            
    int len;
            
    if (str == null || (len = str.length()) == 0)
                
    return EMPTY_STRING_ARRAY;
            
    int lastTokenIndex = 0;
            
    for (int pos = str.indexOf(separator); pos >= 0; pos = str.indexOf(
                    separator, pos 
    + 1))
                lastTokenIndex
    ++;

            String list[] 
    = new String[lastTokenIndex + 1];
            
    int oldPos = 0;
            
    int pos = str.indexOf(separator);
            
    int i = 0;
            
    for (; pos >= 0; pos = str.indexOf(separator, oldPos = pos + 1))
                list[i
    ++= substring(str, oldPos, pos);

            list[lastTokenIndex] 
    = substring(str, oldPos, len);
            
    return list;
        }

        
    public static String[] splitShortString(String str, char separator,
                
    char quote) {
            
    int len;
            
    if (str == null || (len = str.length()) == 0)
                
    return EMPTY_STRING_ARRAY;
            
    int tokenCount = 0;
            
    int oldPos;
            
    for (int pos = 0; pos < len; pos++) {
                tokenCount
    ++;
                oldPos 
    = pos;
                
    while (pos < len && str.charAt(pos) == quote) {
                    pos 
    = str.indexOf(quote, pos + 1+ 1;
                    
    if (pos == 0)
                        
    throw new IllegalArgumentException(
                                
    "Closing quote missing in string '" + str + "'");
                }
                
    if (pos != oldPos) {
                    
    if (pos < len && str.charAt(pos) != separator)
                        
    throw new IllegalArgumentException(
                                
    "Separator must follow closing quote in strng '"
                                        
    + str + "'");
                    
    continue;
                }
                pos 
    = str.indexOf(separator, pos);
                
    if (pos < 0)
                    
    break;
            }

            
    if (str.charAt(len - 1== separator)
                tokenCount
    ++;
            String list[] 
    = new String[tokenCount];
            tokenCount
    --;
            oldPos 
    = 0;
            
    int pos = 0;
            
    for (int i = 0; i < tokenCount;) {
                
    while (str.charAt(pos) == quote)
                    pos 
    = str.indexOf(quote, pos + 1+ 1;
                
    boolean quoted;
                
    if (pos != oldPos) {
                    quoted 
    = true;
                    
    if (str.charAt(pos) != separator)
                        
    throw new IllegalArgumentException(
                                
    "Separator must follow closing quote in strng '"
                                        
    + str + "'");
                } 
    else {
                    quoted 
    = false;
                    pos 
    = str.indexOf(separator, pos);
                }
                list[i] 
    = quoted ? dequote(str, oldPos + 1, pos - 1, quote)
                        : substring(str, oldPos, pos);
                i
    ++;
                oldPos 
    = ++pos;
            }

            list[tokenCount] 
    = dequoteFull(str, oldPos, len, quote);
            
    return list;
        }

        
    public static String substring(String str, int begin, int end) {
            
    if (begin == end)
                
    return "";
            
    else
                
    return str.substring(begin, end);
        }

        
    public static String[] trim(String strings[]) {
            
    if (strings == null)
                
    return null;
            
    int i = 0;
            
    for (int len = strings.length; i < len; i++)
                strings[i] 
    = strings[i].trim();

            
    return strings;
        }

        
    public static int minIndex(int a, int b) {
            
    return a >= 0 ? b >= 0 ? a >= b ? b : a : a : b;
        }

        
    public static final String EMPTY_STRING_ARRAY[] = new String[0];

    }
    posted on 2009-03-18 15:12 單飛 閱讀(232) 評(píng)論(0)  編輯  收藏

    只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


    網(wǎng)站導(dǎo)航:
     
    主站蜘蛛池模板: 亚洲专区中文字幕| 亚洲爆乳无码精品AAA片蜜桃| 亚洲综合在线一区二区三区| 美景之屋4在线未删减免费| 无码少妇精品一区二区免费动态| 久久电影网午夜鲁丝片免费| 精品亚洲视频在线观看| 亚洲无砖砖区免费| 一级毛片高清免费播放| h视频在线观看免费完整版| 亚洲AV无码成人精品区大在线| 麻豆亚洲AV永久无码精品久久 | 国产精品福利在线观看免费不卡| 亚洲黄色免费在线观看| 亚洲精品国产精品乱码不卞| 亚洲免费在线视频播放| 中文字幕在线免费看| 成人免费视频试看120秒| 亚洲国产精品国自产拍AV| 亚洲av永久中文无码精品| 巨波霸乳在线永久免费视频 | 永久中文字幕免费视频网站| 久久久久亚洲av无码尤物| 亚洲av无码日韩av无码网站冲| 先锋影音资源片午夜在线观看视频免费播放 | a毛片免费全部在线播放**| 黄a大片av永久免费| 水蜜桃亚洲一二三四在线 | 深夜A级毛片视频免费| 69式国产真人免费视频| 国产精品亚洲精品日韩已满| 久久久久久久久无码精品亚洲日韩| 91大神在线免费观看| 91麻豆精品国产自产在线观看亚洲| 亚洲乱码国产乱码精华| xxxx日本免费| 亚洲av片劲爆在线观看| 国产99精品一区二区三区免费 | 亚洲一区二区在线免费观看| 亚洲天堂免费在线视频| 国产精品亚洲av色欲三区|