亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? stringformat.java

?? JSP設計第二版的源碼
?? JAVA
字號:
package com.ora.jsp.util;

import java.text.*;
import java.util.*;

/**
 * This class contains a number of static methods that can be used to
 * validate the format of Strings, typically received as input from
 * a user, and to format values as Strings that can be used in
 * HTML output without causing interpretation problems.
 *
 * @author Hans Bergsten, Gefion software <hans@gefionsoftware.com>
 * @version 2.0
 */
public class StringFormat {
    // Static format objects
    private static SimpleDateFormat dateFormat = new SimpleDateFormat();
    private static DecimalFormat numberFormat = new DecimalFormat();

    /**
     * Returns true if the specified date string represents a valid
     * date in the specified format, using the default Locale.
     *
     * @param dateString a String representing a date/time.
     * @param dateFormatPattern a String specifying the format to be used
     *   when parsing the dateString. The pattern is expressed with the
     *   pattern letters defined for the java.text.SimpleDateFormat class.
     * @return true if valid, false otherwise
     */
    public static boolean isValidDate(String dateString, 
        String dateFormatPattern) {
        Date validDate = null;
        synchronized (dateFormat) { 
            try {
                dateFormat.applyPattern(dateFormatPattern);
                dateFormat.setLenient(false);
                validDate = dateFormat.parse(dateString);
            }
            catch (ParseException e) {
                // Ignore and return null
            }
        }
        return validDate != null;
    }
    
    /**
     * Returns true if the specified number string represents a valid
     * integer in the specified range, using the default Locale.
     *
     * @param numberString a String representing an integer
     * @param min the minimal value in the valid range
     * @param min the maximal value in the valid range
     * @return true if valid, false otherwise
     */
    public static boolean isValidInteger(String numberString, int min, 
        int max) {
        Integer validInteger = null;
        try {
            Number aNumber = numberFormat.parse(numberString);
            int anInt = aNumber.intValue();
            if (anInt >= min && anInt <= max) {
                validInteger = new Integer(anInt);
            }
        }
        catch (ParseException e) {
            // Ignore and return null
        }
        return validInteger != null;
    }
    
    /**
     * Returns true if the string is in the format of a valid SMTP
     * mail address: only one at-sign, except as the first or last
     * character, no white-space and at least one dot after the
     * at-sign, except as the first or last character.
     * <p>
     * Note! This rule is not always correct (e.g. on an intranet it may 
     * be okay with just a name) and it does not guarantee a valid Internet 
     * email address but it takes care of the most obvious SMTP mail 
     * address format errors.
     *
     * @param mailAddr a String representing an email address
     * @return true if valid, false otherwise
     */
    public static boolean isValidEmailAddr(String mailAddr) {
	if (mailAddr == null) {
	    return false;
	}

        boolean isValid = true;
	mailAddr = mailAddr.trim();

	// Check at-sign and white-space usage
	int atSign = mailAddr.indexOf('@');
	if (atSign == -1 || 
	    atSign == 0 ||
	    atSign == mailAddr.length() -1 ||
	    mailAddr.indexOf('@', atSign + 1) != -1 ||
	    mailAddr.indexOf(' ') != -1 ||
	    mailAddr.indexOf('\t') != -1 ||
	    mailAddr.indexOf('\n') != -1 ||
	    mailAddr.indexOf('\r') != -1) {
	    isValid = false;
	}
	// Check dot usage
	if (isValid) {
	    mailAddr = mailAddr.substring(atSign + 1);
	    int dot = mailAddr.indexOf('.');
	    if (dot == -1 || 
		dot == 0 ||
		dot == mailAddr.length() -1) {
		isValid = false;
	    }
	}
        return isValid;
    }

    /**
     * Returns true if the specified string matches a string in the set
     * of provided valid strings, ignoring case if specified.
     *
     * @param value the String validate
     * @param validStrings an array of valid Strings
     * @param ignoreCase if true, case is ignored when comparing the value
     *  to the set of validStrings
     * @return true if valid, false otherwise
     */
    public static boolean isValidString(String value, String[] validStrings, 
            boolean ignoreCase) {
        boolean isValid = false;
        for (int i = 0; validStrings != null && i < validStrings.length; i++) {
            if (ignoreCase) {
                if (validStrings[i].equalsIgnoreCase(value)) {
                    isValid = true;
                    break;
                }
            }
            else {
                if (validStrings[i].equals(value)) {
                    isValid = true;
                    break;
                }
            }
        }
        return isValid;
    }

    /**
     * Returns true if the strings in the specified array all match a string 
     * in the set of provided valid strings, ignoring case if specified.
     *
     * @param values the String[] validate
     * @param validStrings an array of valid Strings
     * @param ignoreCase if true, case is ignored when comparing the value
     *  to the set of validStrings
     * @return true if valid, false otherwise
     */
    public static boolean isValidString(String[] values, 
	    String[] validStrings, boolean ignoreCase) {

	if (values == null) {
	    return false;
	}
        boolean isValid = true;
        for (int i = 0; values != null && i < values.length; i++) {
	    if (!isValidString(values[i], validStrings, ignoreCase)) {
		isValid = false;
		break;
	    }
	}
	return isValid;
    }

    /**
     * Returns the specified string converted to a format suitable for
     * HTML. All signle-quote, double-quote, greater-than, less-than and
     * ampersand characters are replaces with their corresponding HTML
     * Character Entity code.
     *
     * @param in the String to convert
     * @return the converted String
     */
    public static String toHTMLString(String in) {
        StringBuffer out = new StringBuffer();
        for (int i = 0; in != null && i < in.length(); i++) {
            char c = in.charAt(i);
            if (c == '\'') {
                out.append("&#039;");
            }
            else if (c == '\"') {
                out.append("&#034;");
            }
            else if (c == '<') {
                out.append("&lt;");
            }
            else if (c == '>') {
                out.append("&gt;");
            }
            else if (c == '&') {
                out.append("&amp;");
            }
            else {
                out.append(c);
            }
        }
        return out.toString();
    }

    /**
     * Converts a String to a Date, using the specified pattern.
     * (see java.text.SimpleDateFormat for pattern description) and
     * the default Locale.
     *
     * @param dateString the String to convert
     * @param dateFormatPattern the pattern
     * @return the corresponding Date
     * @exception ParseException, if the String doesn't match the pattern
     */
    public static Date toDate(String dateString, String dateFormatPattern) 
        throws ParseException {
        Date date = null;
        if (dateFormatPattern == null) {
            dateFormatPattern = "yyyy-MM-dd";
        }
        synchronized (dateFormat) { 
            dateFormat.applyPattern(dateFormatPattern);
            dateFormat.setLenient(false);
            date = dateFormat.parse(dateString);
        }
        return date;
    }

    /**
     * Converts a String to a Number, using the specified pattern.
     * (see java.text.NumberFormat for pattern description) and the
     * default Locale.
     *
     * @param numString the String to convert
     * @param numFormatPattern the pattern
     * @return the corresponding Number
     * @exception ParseException, if the String doesn't match the pattern
     */
    public static Number toNumber(String numString, String numFormatPattern) 
        throws ParseException {
        Number number = null;
        if (numFormatPattern == null) {
            numFormatPattern = "######.##";
        }
        synchronized (numberFormat) { 
            numberFormat.applyPattern(numFormatPattern);
            number = numberFormat.parse(numString);
        }
        return number;
    }

    /**
     * Replaces one string with another throughout a source string.
     *
     * @param in the source String
     * @param from the sub String to replace
     * @param to the sub String to replace with
     * @return a new String with all occurences of from replaced by to
     */
    public static String replaceInString(String in, String from, String to) {
        if (in == null || from == null || to == null) {
            return in;
        }

        StringBuffer newValue = new StringBuffer();
        char[] inChars = in.toCharArray();
        int inLen = inChars.length;
        char[] fromChars = from.toCharArray();
        int fromLen = fromChars.length;

        for (int i = 0; i < inLen; i++) {
            if (inChars[i] == fromChars[0] && (i + fromLen) <= inLen) {
                boolean isEqual = true;
                for (int j = 1; j < fromLen; j++) {
                    if (inChars[i + j] != fromChars[j]) {
                        isEqual = false;
                        break;
                    }
                }
                if (isEqual) {
                    newValue.append(to);
                    i += fromLen - 1;
                }
                else {
                    newValue.append(inChars[i]);
                }
            }
            else {
                newValue.append(inChars[i]);
            }
        }
        return newValue.toString();
    }

    /**
     * Returns a page-relative or context-relative path URI as
     * a context-relative URI.
     *
     * @param relURI the page or context-relative URI
     * @param currURI the context-relative URI for the current request
     * @exception IllegalArgumentException if the relURI is invalid
     */
    public static String toContextRelativeURI(String relURI, String currURI) 
        throws IllegalArgumentException {

        if (relURI.startsWith("/")) {
            // Must already be context-relative
            return relURI;
        }
        
        String origRelURI = relURI;
        if (relURI.startsWith("./")) {
            // Remove current dir characters
            relURI = relURI.substring(2);
        }
        
        String currDir = currURI.substring(0, currURI.lastIndexOf("/") + 1);
        StringTokenizer currLevels = new StringTokenizer(currDir, "/");
        
        // Remove and count all parent dir characters
        int removeLevels = 0;
        while (relURI.startsWith("../")) {
            if (relURI.length() < 4) {
                throw new IllegalArgumentException("Invalid relative URI: " + 
		    origRelURI);
            }
            relURI = relURI.substring(3);
            removeLevels++;
        }
        
        if (removeLevels > currLevels.countTokens()) {
            throw new IllegalArgumentException("Invalid relative URI: " + 
		origRelURI + " points outside the context");
        }
        int keepLevels = currLevels.countTokens() - removeLevels;
        StringBuffer newURI = new StringBuffer("/");
        for (int j = 0; j < keepLevels; j++) {
            newURI.append(currLevels.nextToken()).append("/");
        }
        return newURI.append(relURI).toString();
    }
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美日精品一区视频| 成人综合在线视频| 亚洲免费av高清| 中文字幕一区在线| 1000部国产精品成人观看| 国产精品美女久久久久aⅴ国产馆 国产精品美女久久久久av爽李琼 国产精品美女久久久久高潮 | 日本乱码高清不卡字幕| av中文字幕不卡| 91亚洲男人天堂| 欧美亚洲另类激情小说| 欧美一区二区人人喊爽| 欧美变态凌虐bdsm| 国产日韩欧美激情| 国产精品精品国产色婷婷| 亚洲精品免费看| 亚洲综合免费观看高清在线观看| 亚洲一区在线观看视频| 亚洲成人高清在线| 精油按摩中文字幕久久| 韩国v欧美v日本v亚洲v| 丁香婷婷综合激情五月色| 99精品在线观看视频| 欧美日韩一本到| 欧美大片免费久久精品三p| 久久九九国产精品| 亚洲三级在线免费观看| 日韩影院在线观看| 丁香另类激情小说| 色婷婷久久99综合精品jk白丝| 欧美美女一区二区在线观看| 精品人在线二区三区| 1区2区3区欧美| 麻豆一区二区99久久久久| 成人18精品视频| 91精品国产综合久久久蜜臀粉嫩| 久久亚洲一区二区三区四区| 国产精品欧美久久久久无广告| 亚洲一区二区成人在线观看| 美女网站视频久久| 91麻豆精品一区二区三区| 日韩午夜在线观看| 亚洲男同1069视频| 国产精品正在播放| 69堂国产成人免费视频| 中文字幕日韩一区二区| 日本特黄久久久高潮| 一本一本久久a久久精品综合麻豆| 欧美一区二区三区视频免费播放 | 国产精品美女久久久久久久| 日韩精品久久久久久| 91在线看国产| 久久综合99re88久久爱| 日本三级亚洲精品| 在线免费观看视频一区| 日本一区二区久久| 久久99久久99精品免视看婷婷| 91香蕉视频污| 国产精品久久久久婷婷二区次| 久久成人综合网| 欧美亚洲动漫精品| 亚洲黄色小视频| 91看片淫黄大片一级在线观看| 国产丝袜欧美中文另类| 黄页网站大全一区二区| 欧美电视剧免费全集观看| 日韩二区在线观看| 欧美丰满美乳xxx高潮www| 亚洲综合一区二区精品导航| 91小视频免费观看| 日韩理论片在线| 99久久精品情趣| 中文一区在线播放| 福利电影一区二区三区| 国产亚洲精品中文字幕| 国产精品一区二区在线观看不卡| 欧美tickling网站挠脚心| 亚洲精品一二三四区| 91精品1区2区| 亚洲午夜激情av| 欧美高清一级片在线| 天天色综合天天| 欧美一区二区高清| 国内精品国产成人国产三级粉色| 日韩欧美电影一区| 国产美女在线观看一区| 久久久久亚洲蜜桃| 国产成人综合精品三级| 国产精品无圣光一区二区| 国产精品国产精品国产专区不片| 日韩免费看网站| 成人综合在线视频| 亚洲影视资源网| 欧美成人性战久久| av欧美精品.com| 亚洲一级不卡视频| 欧美电视剧在线观看完整版| 国产黄色精品网站| 一区二区三区免费看视频| 欧美精品丝袜久久久中文字幕| 捆绑变态av一区二区三区| 国产亚洲欧美日韩俺去了| 91国模大尺度私拍在线视频| 五月天激情综合网| 国产网站一区二区三区| 欧洲日韩一区二区三区| 麻豆成人综合网| ...中文天堂在线一区| 欧美疯狂性受xxxxx喷水图片| 国产高清精品网站| 亚洲一区二区高清| 国产人久久人人人人爽| 在线观看av一区| 国产综合久久久久久久久久久久| 亚洲女与黑人做爰| 精品成人a区在线观看| 99久久久精品| 国产精品白丝jk白祙喷水网站| 亚洲欧美一区二区久久| 欧美va亚洲va香蕉在线| 色噜噜久久综合| 国产精品一区在线观看乱码| 午夜一区二区三区视频| 国产精品国产三级国产aⅴ中文| 欧美喷潮久久久xxxxx| 成人久久久精品乱码一区二区三区| 亚洲成年人影院| 亚洲欧美国产三级| 久久久99精品久久| 日韩一级精品视频在线观看| 99re热这里只有精品视频| 国产一区二三区好的| 日韩和欧美的一区| 亚洲精选视频免费看| 国产精品欧美综合在线| 国产亚洲一本大道中文在线| 欧美日韩高清影院| 91小视频免费看| 成人av中文字幕| 狠狠色丁香婷婷综合| 日韩国产欧美三级| 亚洲一区二区五区| 亚洲欧美日韩一区二区| 国产精品无码永久免费888| 欧美va在线播放| 日韩欧美国产成人一区二区| 91麻豆精品国产91久久久更新时间| 在线区一区二视频| 日韩三级视频在线看| 欧美日韩不卡在线| 欧美日本国产视频| 精品视频在线视频| 91黄色激情网站| 欧美日韩国产一级二级| 欧美色倩网站大全免费| 欧美日韩视频在线第一区| 在线免费观看视频一区| 精品视频免费看| 欧美一区二区三区免费观看视频| 91精品国产综合久久久蜜臀图片| 欧美一区二区啪啪| 欧美精品一区二区三区四区| 精品国产污污免费网站入口| 久久综合久色欧美综合狠狠| 久久综合久久综合亚洲| 国产午夜精品理论片a级大结局| 亚洲国产精品高清| 亚洲日韩欧美一区二区在线| 亚洲精品免费在线观看| 蜜臀av一区二区| 国产精品一卡二卡| 97久久人人超碰| 精品视频一区 二区 三区| 精品国产自在久精品国产| 久久亚洲精品小早川怜子| 久久久不卡影院| 亚洲视频在线一区观看| 亚洲午夜在线观看视频在线| 青青草国产成人99久久| 国产精品 日产精品 欧美精品| 成人av在线播放网站| 欧美调教femdomvk| 精品毛片乱码1区2区3区| 国产人妖乱国产精品人妖| 亚洲va欧美va人人爽午夜| 美女尤物国产一区| 91小视频免费看| 精品福利二区三区| 亚洲午夜国产一区99re久久| 狠狠色狠狠色综合系列| 麻豆成人在线观看| 欧美日韩国产大片| 日韩欧美www| 国产精品久久久久aaaa| 亚洲午夜在线视频| 成人污视频在线观看| 欧美久久婷婷综合色| 国产日韩欧美一区二区三区综合| 一区二区三区视频在线看| 国产一区视频网站| 欧美老女人第四色|