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

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

?? codeviewer.java

?? 這是jsp網站開發死酷全書的代碼
?? JAVA
字號:
/**
 * $RCSfile: CodeViewer.java,v $
 * $Revision: 1.7 $
 * $Date: 2001/07/31 05:39:19 $
 *
 * Copyright (C) 1999-2001 CoolServlets, Inc. All rights reserved.
 *
 * This software is the proprietary information of CoolServlets, Inc.
 * Use is subject to license terms.
 */
 
package net.acai.codeviewer;

import java.util.*;

/**
 * A class that syntax highlights Java code into html.
 * <p>
 * A CodeViewer object is created and then keeps state as
 * lines are passed in. Each line passed in as java text, is returned as syntax
 * highlighted html text.
 * <p>
 * Users of the class can set how the java code will be highlighted with
 * setter methods.
 * <p>
 * Only valid java lines should be passed in since the object maintains
 * state and may not handle illegal code gracefully.
 * <p>
 * The actual system is implemented as a series of filters that deal with
 * specific portions of the java code. The filters are as follows:
 * <p>
 * <pre>
 *  htmlFilter
 *     |__
 *        multiLineCommentFilter
 *           |___
 *                inlineCommentFilter
 *                   |___
 *                        stringFilter
 *                           |__
 *                               keywordFilter
 * </pre>
 *
 */
public class CodeViewer {
    private static HashMap reservedWords = new HashMap(150); // >= Java2 only (also, not thread-safe)
    //private static Hashtable reservedWords = new Hashtable(150); // < Java2 (thread-safe)
    private boolean inMultiLineComment = false;
    private String backgroundColor = "#ffffff";
    private String commentStart = "<font color=\"#aa0000\"><i>";
    private String commentEnd = "</font></i>";
    private String stringStart = "<font color=\"#000099\">";
    private String stringEnd = "</font>";
    private String reservedWordStart = "<b>";
    private String reservedWordEnd = "</b>";
	
    /**
     * Load all keywords at class loading time.
     */
    static {
        loadKeywords();
    }
	
    /**
     * Gets the html for the start of a comment block.
     */
    public String getCommentStart() {
        return commentStart;
    }
	
    /**
     * Sets the html for the start of a comment block.
     */
    public void setCommentStart(String commentStart) {
        this.commentStart = commentStart;
    }
	
    /**
     * Gets the html for the end of a comment block.
     */
    public String getCommentEnd() {
        return commentEnd;
    }
	
    /**
     * Sets the html for the end of a comment block.
     */
    public void setCommentEnd(String commentEnd) {
        this.commentEnd = commentEnd;
    }
	
    /**
     * Gets the html for the start of a String.
     */
    public String getStringStart() {
        return stringStart;
    }
	
    /**
     * Sets the html for the start of a String.
     */
    public void setStringStart(String stringStart) {
        this.stringStart = stringStart;
    }
	
    /**
     * Gets the html for the end of a String.
     */
    public String getStringEnd() {
        return stringEnd;
    }
	
    /**
     * Sets the html for the end of a String.
     */
    public void setStringEnd(String stringEnd) {
        this.stringEnd = stringEnd;
    }
	
    /**
     * Gets the html for the start of a reserved word.
     */
    public String getReservedWordStart() {
        return reservedWordStart;
    }
	
    /**
     * Sets the html for the start of a reserved word.
     */
    public void setReservedWordStart(String reservedWordStart) {
        this.reservedWordStart = reservedWordStart;
    }
	
    /**
     * Gets the html for the end of a reserved word.
     */
    public String getReservedWordEnd() {
        return reservedWordEnd;
    }
	
    /**
     * Sets the html for the end of a reserved word.
     */
    public void setReservedWordEnd(String reservedWordEnd) {
        this.reservedWordEnd = reservedWordEnd;
    }
	
    /**
     * Passes off each line to the first filter.
     * @param   line    The line of Java code to be highlighted.
     */
    public String syntaxHighlight( String line ) {
       return htmlFilter(line);
    }
	
    /*
     * Filter html tags that appear in the java source into more benign text
     * that won't disrupt the output.
     */
    private String htmlFilter( String line ) {
        if( line == null || line.equals("") ) {
            return "";
        }
        // replace ampersands with HTML escape sequence for ampersand;
        line = replace(line, "&", "&#38;");
        // replace \" sequences with HTML escape sequences;
        line = replace(line, "\\\"", "&#92;&#34");
        // replace the \\ with HTML escape sequences. fixes a problem when
        // backslashes preceed quotes.
        line = replace(line, "\\\\", "&#92;&#92;" );
        // replace less-than signs which might be confused
        // by HTML as tag angle-brackets;
        line = replace(line, "<", "&#60;");
        // replace greater-than signs which might be confused
        // by HTML as tag angle-brackets;
        line = replace(line, ">", "&#62;");
        return multiLineCommentFilter(line);
    }
	
    /*
     * Filter out multiLine comments. State is kept with a private boolean
     * variable.
     */
    private String multiLineCommentFilter(String line) {
        if (line == null || line.equals("")) {
            return "";
        }
        StringBuffer buf = new StringBuffer();
        int index;
        //First, check for the end of a multi-line comment.
        if (inMultiLineComment && (index = line.indexOf("*/")) > -1 && !isInsideString(line,index)) {
            inMultiLineComment = false;
            buf.append(line.substring(0,index));
            buf.append("*/").append(commentEnd);
            if (line.length() > index+2) {
                buf.append(inlineCommentFilter(line.substring(index+2)));
            }
            return buf.toString();
        }
        //If there was no end detected and we're currently in a multi-line
        //comment, we don't want to do anymore work, so return line.
        else if (inMultiLineComment) {
            return line;
        }
        //We're not currently in a comment, so check to see if the start
        //of a multi-line comment is in this line.
        else if ((index = line.indexOf("/*")) > -1 && !isInsideString(line,index)) {
            inMultiLineComment = true;
            //Return result of other filters + everything after the start
            //of the multiline comment. We need to pass the through the
            //to the multiLineComment filter again in case the comment ends
            //on the same line.
            buf.append(inlineCommentFilter(line.substring(0,index)));
            buf.append(commentStart).append("/*");
            buf.append(multiLineCommentFilter(line.substring(index+2)));
            return buf.toString();
        }
        //Otherwise, no useful multi-line comment information was found so
        //pass the line down to the next filter for processesing.
        else {
            return inlineCommentFilter(line);
        }
    }
	
    /*
     * Filter inline comments from a line and formats them properly.
     */
    private String inlineCommentFilter(String line) {
        if (line == null || line.equals("")) {
            return "";
        }
        StringBuffer buf = new StringBuffer();
        int index;
        if ((index = line.indexOf("//")) > -1 && !isInsideString(line,index)) {
            buf.append(stringFilter(line.substring(0,index)));
            buf.append(commentStart);
            buf.append(line.substring(index));
            buf.append(commentEnd);
        }
        else {
            buf.append(stringFilter(line));
        }
        return buf.toString();
    }
	
    /*
     * Filters strings from a line of text and formats them properly.
     */
    private String stringFilter(String line) {
        if (line == null || line.equals("")) {
            return "";
        }
        StringBuffer buf = new StringBuffer();
        if (line.indexOf("\"") <= -1) {
            return keywordFilter(line);
        }
        int start = 0;
        int startStringIndex = -1;
        int endStringIndex = -1;
        int tempIndex;
        //Keep moving through String characters until we want to stop...
        while ((tempIndex = line.indexOf("\"")) > -1) {
            //We found the beginning of a string
            if (startStringIndex == -1) {
                startStringIndex = 0;
                buf.append( stringFilter(line.substring(start,tempIndex)) );
                buf.append(stringStart).append("\"");
                line = line.substring(tempIndex+1);
            }
            //Must be at the end
            else {
                startStringIndex = -1;
                endStringIndex = tempIndex;
                buf.append(line.substring(0,endStringIndex+1));
                buf.append(stringEnd);
                line = line.substring(endStringIndex+1);
            }
        }
        buf.append( keywordFilter(line) );
        return buf.toString();
    }
	
    /*
     * Filters keywords from a line of text and formats them properly.
     */
    private String keywordFilter( String line ) {
        if( line == null || line.equals("") ) {
            return "";
        }
        StringBuffer buf = new StringBuffer();
        //HashMap usedReservedWords = new HashMap(); // >= Java2 only (not thread-safe)
        Hashtable usedReservedWords = new Hashtable(); // < Java2 (thread-safe)
        int i=0, startAt=0;
        char ch;
        StringBuffer temp = new StringBuffer();
        while( i < line.length() ) {
            temp.setLength(0);
            ch = line.charAt(i);
            startAt = i;
            // 65-90, uppercase letters
            // 97-122, lowercase letters
            while( i<line.length() && ( ( ch >= 65 && ch <= 90 )
                    || ( ch >= 97 && ch <= 122 ) ) ) {
                temp.append(ch);
                i++;
                if( i < line.length() ) {
                    ch = line.charAt(i);
                }
            }
            String tempString = temp.toString();
            if( reservedWords.containsKey(tempString) && !usedReservedWords.containsKey(tempString)) {
                usedReservedWords.put(tempString,tempString);
                line = replace( line, tempString, (reservedWordStart+tempString+reservedWordEnd) );
                i += (reservedWordStart.length() + reservedWordEnd.length());
            }
            else {
                i++;
            }
        }
        buf.append(line);
        return buf.toString();
    }
	
    /**
     * Replaces all instances of oldString with newString in line.
     */
    private static final String replace( String line, String oldString, String newString )
    {
        int i=0;
        if ((i=line.indexOf(oldString, i)) >= 0 ) {
            char [] line2 = line.toCharArray();
            char [] newString2 = newString.toCharArray();
            int oLength = oldString.length();
            StringBuffer buf = new StringBuffer(line2.length);
            buf.append(line2, 0, i).append(newString2);
            i += oLength;
            int j = i;
            while((i=line.indexOf(oldString, i)) > 0 ) {
                buf.append(line2, j, i-j).append(newString2);
                i += oLength;
                j = i;
            }
            buf.append(line2, j, line2.length - j);
            return buf.toString();
        }
        return line;
    }
	
    /*
     * Checks to see if some position in a line is between String start and
     * ending characters. Not yet used in code or fully working :)
     */
    private boolean isInsideString(String line, int position) {
        if (line.indexOf("\"") < 0) {
            return false;
        }
        int index;
        String left = line.substring(0,position);
        String right = line.substring(position);
        int leftCount = 0;
        int rightCount = 0;
        while ((index = left.indexOf("\"")) > -1) {
            leftCount ++;
            left = left.substring(index+1);
        }
        while ((index = right.indexOf("\"")) > -1) {
            rightCount ++;
            right = right.substring(index+1);
        }
        if (rightCount % 2 != 0 && leftCount % 2 != 0) {
            return true;
        }
        else {
            return false;
        }
    }
	
    /*
     * Load Hashtable (or HashMap) with Java reserved words. Improved list
     * in version 1.1 taken directly from Java language spec.
     */
    private static void loadKeywords() {
        reservedWords.put("abstract", "abstract");
        reservedWords.put("boolean", "boolean");
        reservedWords.put("break", "break");
        reservedWords.put("byte", "byte");
        reservedWords.put("case", "case");
        reservedWords.put("catch", "catch");
        reservedWords.put("char", "char");
        reservedWords.put("class", "class");
        reservedWords.put("const", "const");
        reservedWords.put("continue", "continue");
        reservedWords.put("default", "default");
        reservedWords.put("do", "do");
        reservedWords.put("double", "double");
        reservedWords.put("else", "else");
        reservedWords.put("extends", "extends");
        reservedWords.put("false", "false");
        reservedWords.put("final", "final");
        reservedWords.put("finally", "finally");
        reservedWords.put("float", "float");
        reservedWords.put("for", "for");
        reservedWords.put("goto", "goto");
        reservedWords.put("if", "if");
        reservedWords.put("implements", "implements");
        reservedWords.put("import", "import");
        reservedWords.put("instanceof", "instanceof");
        reservedWords.put("int", "int");
        reservedWords.put("interface", "interface");
        reservedWords.put("long", "long");
        reservedWords.put("native", "native");
        reservedWords.put("new", "new");
        reservedWords.put("package", "package");
        reservedWords.put("private", "private");
        reservedWords.put("protected", "protected");
        reservedWords.put("public", "public");
        reservedWords.put("return", "return");
        reservedWords.put("short", "short");
        reservedWords.put("static", "static");
        reservedWords.put("strictfp", "strictfp");
        reservedWords.put("super", "super");
        reservedWords.put("switch", "switch");
        reservedWords.put("synchronized", "synchronized");
        reservedWords.put("this", "this");
        reservedWords.put("throw", "throw");
        reservedWords.put("throws", "throws");
        reservedWords.put("transient", "transient");
        reservedWords.put("true", "true");
        reservedWords.put("try", "try");
        reservedWords.put("void", "void");
        reservedWords.put("volatile", "volatile");
        reservedWords.put("while", "while");
    }
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
91精品午夜视频| 亚洲电影你懂得| 粉嫩久久99精品久久久久久夜| 在线一区二区视频| 亚洲黄色小说网站| 欧美丰满少妇xxxxx高潮对白 | 久久黄色级2电影| 91精品国产高清一区二区三区蜜臀| 日本亚洲电影天堂| 久久久久久一二三区| 国产福利精品导航| 亚洲自拍偷拍av| 精品粉嫩aⅴ一区二区三区四区| 韩国v欧美v日本v亚洲v| 亚洲久草在线视频| 亚洲综合一区二区精品导航| 亚洲精品免费播放| 天天综合色天天综合色h| 国产精品美女久久久久久久久| 欧美性猛交xxxx黑人交| 国产91精品一区二区| 成人网男人的天堂| 韩国在线一区二区| 国产aⅴ精品一区二区三区色成熟| 国产成人午夜99999| 国产精品中文有码| 日本不卡高清视频| 亚洲成va人在线观看| 喷白浆一区二区| 粗大黑人巨茎大战欧美成人| 99久久精品免费观看| 国产一区二区三区四区在线观看| 一区二区三区在线免费视频| 欧美经典一区二区三区| 99久久综合狠狠综合久久| 久久精品av麻豆的观看方式| 国产91在线|亚洲| 欧美色男人天堂| 日本久久一区二区三区| 日韩女优av电影| 日韩精品影音先锋| **欧美大码日韩| 欧美国产精品中文字幕| 午夜电影网一区| www.亚洲色图| 精品人在线二区三区| 精品久久久久久久人人人人传媒 | 天堂一区二区在线| 亚洲男人的天堂av| 亚洲一区在线观看免费观看电影高清| 久久精品国产澳门| 色婷婷综合久久久久中文 | 91精品福利视频| 久久综合国产精品| 国产亚洲综合性久久久影院| 欧美一区二区三区播放老司机| 中文字幕 久热精品 视频在线 | 色欲综合视频天天天| 精品免费视频一区二区| 亚洲成人av资源| 在线亚洲高清视频| 欧美区在线观看| 欧美成人高清电影在线| 亚洲一区二区在线免费观看视频| 国产高清一区日本| 久久噜噜亚洲综合| 久久精品99国产精品| 欧美日韩国产综合视频在线观看| 18涩涩午夜精品.www| 国产成人超碰人人澡人人澡| 337p粉嫩大胆噜噜噜噜噜91av| 亚洲国产wwwccc36天堂| 精品在线播放免费| 99久久精品国产麻豆演员表| 欧美激情资源网| av在线这里只有精品| 国产亚洲精品aa| 国产一区999| 国产女同性恋一区二区| 懂色av中文一区二区三区| 国产视频一区在线播放| 丁香啪啪综合成人亚洲小说 | 国产99久久久精品| 国产精品久线观看视频| 日日骚欧美日韩| 欧美酷刑日本凌虐凌虐| 日韩电影在线看| 日韩欧美激情一区| 国产成人啪免费观看软件| 中文字幕精品综合| 色综合久久88色综合天天| 亚洲国产日产av| 日韩欧美一区二区在线视频| 国产精品国模大尺度视频| 成人av电影在线播放| 欧美一区二区二区| 国产一区二区三区av电影| 国产午夜亚洲精品午夜鲁丝片| 国产精品一品二品| 亚洲女人的天堂| 欧美老女人在线| 福利91精品一区二区三区| 亚洲欧美国产三级| 日韩一区二区三区电影在线观看| 麻豆国产精品官网| 4hu四虎永久在线影院成人| 免费日本视频一区| 国产女人aaa级久久久级| 日本精品裸体写真集在线观看| 琪琪一区二区三区| 国产精品成人免费精品自在线观看 | 亚洲动漫第一页| 国产午夜精品一区二区三区嫩草 | 亚洲精品一区二区在线观看| 福利91精品一区二区三区| 亚洲va欧美va人人爽| 国产色爱av资源综合区| 欧美日韩在线电影| 国产不卡视频在线播放| 亚洲妇女屁股眼交7| 国产午夜精品久久| 欧美一级精品在线| 色吊一区二区三区| 粉嫩在线一区二区三区视频| 日韩中文字幕1| 亚洲欧美激情在线| 国产欧美日产一区| 欧美一卡二卡三卡| 欧美色图在线观看| 成人aa视频在线观看| 精品一区二区三区日韩| 亚洲第一成人在线| 亚洲色图都市小说| 色天天综合久久久久综合片| 狠狠色丁香婷综合久久| 偷拍亚洲欧洲综合| 一区二区三区欧美| 亚洲国产成人一区二区三区| 精品欧美乱码久久久久久| 欧美视频精品在线| 91久久奴性调教| 99视频有精品| 91香蕉国产在线观看软件| 亚洲成av人在线观看| 亚洲色欲色欲www在线观看| 国产女人aaa级久久久级| 精品国产91洋老外米糕| 日韩一区二区三免费高清| 91精品国产aⅴ一区二区| 欧美日韩国产高清一区| 成人免费黄色大片| 国产成人综合网| 国产精品综合在线视频| 国产在线不卡一区| 国产精品18久久久久久久久 | 波多野结衣一区二区三区| 国产不卡在线播放| 成人动漫av在线| 99re这里只有精品首页| 91在线观看免费视频| 91日韩精品一区| 欧美综合亚洲图片综合区| 91论坛在线播放| 欧美性猛交xxxxxxxx| 日韩视频中午一区| 2023国产精品视频| 国产精品麻豆99久久久久久| 国产精品美女久久久久久久久 | 精品国产一区二区亚洲人成毛片| 日韩视频免费观看高清完整版| 欧美一区二区三区在| 亚洲精品一区二区精华| 中国色在线观看另类| 亚洲男女毛片无遮挡| 五月天激情综合| 狠狠狠色丁香婷婷综合激情| 大尺度一区二区| 欧美伊人精品成人久久综合97| 欧美一区二区福利在线| 欧美国产在线观看| 三级成人在线视频| 国产美女在线精品| 色拍拍在线精品视频8848| 欧美一区二视频| 国产精品久久久久四虎| 亚洲aⅴ怡春院| 高清beeg欧美| 欧美一区二区三区视频免费| 欧美国产日本视频| 午夜欧美在线一二页| 国产精选一区二区三区| 欧美三级午夜理伦三级中视频| 精品免费视频一区二区| 亚洲激情网站免费观看| 韩国一区二区三区| 91成人网在线| 国产日韩亚洲欧美综合| 午夜电影一区二区三区| 99久久精品免费看国产| 精品福利一区二区三区|