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

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

?? codeviewer.java

?? 隨著Internet 的迅速崛起
?? 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一区二区三区免费野_久草精品视频
日韩成人一区二区三区在线观看| 国产最新精品免费| 日本sm残虐另类| 8x8x8国产精品| 久久久久久黄色| 亚洲精品视频免费看| 麻豆一区二区三| 一本一道久久a久久精品| 91麻豆精品国产91久久久| 国产精品久久毛片av大全日韩| 日韩精品一区第一页| av中文字幕不卡| 欧美大度的电影原声| 亚洲欧美电影院| 国产精品系列在线观看| 欧美精品丝袜中出| 亚洲嫩草精品久久| 国产999精品久久| 欧美tickle裸体挠脚心vk| 亚洲一区二区在线免费看| 福利一区二区在线| 日韩一区二区三区在线视频| 亚洲综合男人的天堂| 国产高清不卡一区| 精品少妇一区二区三区视频免付费 | 91色九色蝌蚪| 国产欧美日韩在线看| 久草这里只有精品视频| 7878成人国产在线观看| 亚洲国产精品久久人人爱| 99re66热这里只有精品3直播| 久久一二三国产| 美女高潮久久久| 制服丝袜亚洲色图| 亚洲成av人在线观看| 欧美综合天天夜夜久久| 亚洲男人天堂av网| 色欧美片视频在线观看| 亚洲视频 欧洲视频| 99re这里都是精品| 亚洲丝袜自拍清纯另类| 91麻豆免费看片| 亚洲日本一区二区三区| 色天使久久综合网天天| 一区二区三区四区在线免费观看| 91蜜桃婷婷狠狠久久综合9色| 国产精品欧美一区喷水| 成人国产免费视频| 国产精品国产精品国产专区不片| 国产精品白丝av| 国产精品你懂的在线| av亚洲精华国产精华精华| 亚洲精品乱码久久久久久日本蜜臀| 99久久99精品久久久久久 | 久久福利视频一区二区| 欧美精品久久久久久久多人混战| 日韩高清中文字幕一区| 欧美大尺度电影在线| 国产老肥熟一区二区三区| 国产精品丝袜黑色高跟| 色综合一个色综合| 亚洲高清视频中文字幕| 欧美一二三区在线| 国产伦精一区二区三区| 中文字幕欧美一| 欧美丝袜丝交足nylons| 日本午夜一本久久久综合| 欧美成va人片在线观看| 国产成人免费视频| 亚洲影院理伦片| 欧美成人一区二区三区在线观看| 国产成人亚洲综合a∨婷婷| 国产精品乱码人人做人人爱| 欧美三级资源在线| 国产在线看一区| 亚洲精品日产精品乱码不卡| 91精品婷婷国产综合久久竹菊| 国产不卡在线一区| 香蕉久久夜色精品国产使用方法| 欧美va亚洲va在线观看蝴蝶网| 国产成人免费视| 日韩黄色在线观看| 欧美高清在线精品一区| 欧美日韩在线一区二区| 国产高清成人在线| 丝袜美腿高跟呻吟高潮一区| 国产三级精品在线| 91精品国产91热久久久做人人| 成人免费观看男女羞羞视频| 亚洲电影中文字幕在线观看| 国产精品美女久久久久久| 欧美精品日日鲁夜夜添| 91在线小视频| 国产精品一级二级三级| 日韩精品一区第一页| 亚洲男女毛片无遮挡| 久久久久久久久99精品| 欧美日韩一区二区三区四区五区| 成人精品一区二区三区四区| 毛片不卡一区二区| 成人丝袜高跟foot| 麻豆91精品91久久久的内涵| 亚洲午夜免费福利视频| 中文字幕在线不卡国产视频| 欧美mv和日韩mv国产网站| 欧美精品777| 欧美性猛交xxxx黑人交| 9久草视频在线视频精品| 国产剧情一区二区| 激情综合色播五月| 日本视频中文字幕一区二区三区| 亚洲精品欧美激情| 中文字幕在线不卡一区| 日本一区二区三区四区在线视频| 日韩女优av电影在线观看| 欧美日韩日日摸| 欧美三级乱人伦电影| 色94色欧美sute亚洲线路二| 91在线精品一区二区| 成人免费高清视频在线观看| 国产成人午夜电影网| 国产91丝袜在线播放| 国产大陆精品国产| 国产v综合v亚洲欧| 丁香六月综合激情| 粉嫩aⅴ一区二区三区四区五区| 久久国产婷婷国产香蕉| 久久激五月天综合精品| 久久99国产精品久久99果冻传媒| 蜜桃免费网站一区二区三区| 麻豆中文一区二区| 激情综合一区二区三区| 国产精品一区二区三区四区| 国产成人一区二区精品非洲| bt欧美亚洲午夜电影天堂| 99久久精品情趣| 色婷婷综合五月| 欧美电影在哪看比较好| 日韩美女视频在线| 337p日本欧洲亚洲大胆色噜噜| 久久久久97国产精华液好用吗| 久久久.com| ...xxx性欧美| 一区二区三区日韩欧美| 日韩激情av在线| 国产精品影视网| 91女人视频在线观看| 欧美在线播放高清精品| 欧美一区二区不卡视频| 国产香蕉久久精品综合网| 亚洲色图.com| jlzzjlzz亚洲女人18| 欧美影院一区二区三区| 日韩欧美亚洲一区二区| 国产精品情趣视频| 亚洲va欧美va人人爽| 国产一区二区三区综合| 一本一本大道香蕉久在线精品| 91精品国产综合久久香蕉的特点 | 国产·精品毛片| 欧美日韩一区中文字幕| 精品久久久久久无| 亚洲男人的天堂在线观看| 免费在线观看日韩欧美| caoporen国产精品视频| 欧美一级xxx| 亚洲色图制服丝袜| 久久99国产精品尤物| 91福利在线观看| 国产日韩欧美一区二区三区乱码| 一区二区三区在线不卡| 精品一区二区三区免费观看| 一本久久a久久免费精品不卡| 精品卡一卡二卡三卡四在线| 亚洲自拍偷拍网站| 国产成人免费高清| 欧美一级理论性理论a| 国产精品国产精品国产专区不蜜| 日本欧美一区二区三区乱码 | 精品一区二区影视| 欧美自拍偷拍午夜视频| 国产精品嫩草影院av蜜臀| 男女男精品视频网| 欧美日韩精品一区二区天天拍小说| 久久精品视频在线看| 日韩精品亚洲一区二区三区免费| 色综合天天狠狠| 日本一区二区三区高清不卡| 裸体歌舞表演一区二区| 欧美日韩精品一区二区三区蜜桃| 国产精品久久久久久久久久久免费看 | 久久成人av少妇免费| 国产日产欧美一区| 麻豆精品国产91久久久久久| 欧美日韩一区二区三区四区| 亚洲激情一二三区| 99精品视频一区二区| 国产欧美一区二区精品性| 国内欧美视频一区二区| 欧美mv日韩mv|