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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? codeviewer.java

?? JSP四酷全書是一本很好的學(xué)習(xí)JSP建網(wǎng)站的書籍
?? JAVA
字號(hào):
/**
 * $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");
    }
}

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
精品中文字幕一区二区| 精品卡一卡二卡三卡四在线| 丁香激情综合国产| 国产精品1区二区.| 国产美女精品在线| 国产精品一区二区三区四区| 国产一区亚洲一区| 国产成人在线视频网站| 成人av先锋影音| aaa欧美色吧激情视频| 99久久精品费精品国产一区二区| 波多野结衣在线aⅴ中文字幕不卡| 国产成人综合在线| 不卡电影一区二区三区| 99久久国产综合色|国产精品| 99精品久久只有精品| 日本高清免费不卡视频| 欧美在线色视频| 91精品国产全国免费观看| 欧美一区日本一区韩国一区| 日韩免费视频线观看| 精品国产乱码久久久久久老虎| 精品国产制服丝袜高跟| 欧美一区二区三区成人| 亚洲精品一区二区三区在线观看| 久久久蜜桃精品| 自拍偷拍亚洲激情| 午夜欧美一区二区三区在线播放 | 国产在线视频精品一区| 国产suv精品一区二区883| av成人老司机| 欧美精品18+| 精品国内片67194| 中文字幕亚洲综合久久菠萝蜜| 亚洲一区二区高清| 看电视剧不卡顿的网站| 99久久777色| 欧美精品高清视频| 久久久久久电影| 一区二区三区产品免费精品久久75| 三级在线观看一区二区| 国产ts人妖一区二区| 在线视频欧美精品| 26uuu精品一区二区在线观看| 国产精品久久久久一区二区三区| 亚洲国产va精品久久久不卡综合| 激情亚洲综合在线| 欧美综合久久久| 久久久精品免费网站| 午夜视频在线观看一区二区| 国产传媒日韩欧美成人| 欧美丰满嫩嫩电影| 国产精品久线在线观看| 日本不卡视频在线观看| 99re视频这里只有精品| 精品美女在线播放| 亚洲一区自拍偷拍| 成人激情午夜影院| 精品美女在线观看| 亚洲成人av在线电影| av电影一区二区| 精品国内二区三区| 五月天久久比比资源色| 91在线精品一区二区三区| 精品精品欲导航| 亚洲国产成人va在线观看天堂| 春色校园综合激情亚洲| 日韩视频在线你懂得| 亚洲综合男人的天堂| a4yy欧美一区二区三区| 久久九九国产精品| 美女国产一区二区| 欧美精品v国产精品v日韩精品| 亚洲欧洲精品一区二区三区不卡| 国产揄拍国内精品对白| 欧美一二三区精品| 丝袜美腿亚洲一区| 91久久人澡人人添人人爽欧美 | 爽好多水快深点欧美视频| 99vv1com这只有精品| 国产农村妇女毛片精品久久麻豆| 美女网站视频久久| 91精品视频网| 亚洲国产精品一区二区尤物区| 91在线精品一区二区三区| 国产欧美在线观看一区| 国产麻豆9l精品三级站| 欧美电视剧在线观看完整版| 婷婷成人激情在线网| 欧美在线不卡一区| 亚洲综合免费观看高清完整版在线| aaa欧美日韩| 日韩毛片高清在线播放| 成人黄色片在线观看| 国产日韩av一区| 国产成人精品在线看| 久久蜜桃av一区二区天堂| 韩国女主播成人在线观看| 精品黑人一区二区三区久久 | 欧美一级爆毛片| 日本午夜精品一区二区三区电影| 欧美日韩精品二区第二页| 亚洲国产精品久久人人爱蜜臀| 欧美视频一区二区在线观看| 洋洋av久久久久久久一区| 在线观看网站黄不卡| 亚洲mv在线观看| 欧美乱妇23p| 麻豆传媒一区二区三区| 欧美电影免费观看完整版| 国产精品一品视频| 成人免费在线观看入口| 91视频在线观看免费| 一区二区三区在线视频免费| 欧美在线免费观看亚洲| 日韩不卡手机在线v区| 欧美第一区第二区| 国产成人自拍网| 最新日韩在线视频| 欧美日韩一区 二区 三区 久久精品| 亚洲不卡一区二区三区| 日韩精品中文字幕一区二区三区 | 精品一区二区成人精品| 久久久777精品电影网影网| gogo大胆日本视频一区| 亚洲精品视频在线观看网站| 欧美日韩综合色| 麻豆精品国产91久久久久久| 久久久久国产精品麻豆| 99久久精品一区二区| 五月婷婷久久综合| 精品日韩av一区二区| 99re8在线精品视频免费播放| 一级中文字幕一区二区| 日韩三区在线观看| 高清视频一区二区| 一区二区三区产品免费精品久久75| 8x8x8国产精品| 国产成人精品三级| 亚洲国产日产av| 欧美精品一区视频| 91黄色小视频| 免费不卡在线观看| 中文字幕中文字幕在线一区| 欧美日韩国产片| 懂色av一区二区在线播放| 亚洲愉拍自拍另类高清精品| 26uuu亚洲综合色欧美| 色乱码一区二区三区88 | 欧美一区二区视频在线观看| 国产超碰在线一区| 亚洲午夜在线电影| 久久亚洲一区二区三区四区| 日本韩国欧美在线| 国产精品一线二线三线精华| 亚洲一区二区3| 亚洲国产岛国毛片在线| 8v天堂国产在线一区二区| 成人福利电影精品一区二区在线观看| 亚洲国产人成综合网站| 中文字幕不卡三区| 日韩欧美一级片| 日本道色综合久久| 成人网男人的天堂| 久久99精品网久久| 亚洲二区在线视频| 中文字幕乱码亚洲精品一区| 日韩一区二区三区在线观看| 一本色道久久综合狠狠躁的推荐| 激情综合网激情| 视频一区二区三区在线| 国产精品久久久久久久久免费桃花| 欧美一区二区三区精品| 在线影视一区二区三区| 成人黄色小视频在线观看| 国产中文字幕一区| 免费成人你懂的| 日日摸夜夜添夜夜添亚洲女人| 亚洲视频你懂的| 国产视频一区在线观看 | 免费av成人在线| 亚洲国产aⅴ成人精品无吗| 国产精品久久久久久久久果冻传媒 | 在线看国产一区二区| 成人动漫中文字幕| 国产99久久久国产精品免费看| 日本不卡一区二区三区高清视频| 一区二区三区四区蜜桃| 国产精品视频在线看| 久久久精品免费观看| 欧美成人精品3d动漫h| 7777精品伊人久久久大香线蕉经典版下载 | 色综合激情久久| 91在线播放网址| av在线不卡免费看| www.亚洲激情.com| 国产成人av一区| 国产91精品久久久久久久网曝门| 国产专区欧美精品| 国产盗摄精品一区二区三区在线 |