资源简介
代码片段和文件信息
package com.bbs.codeviewer;
import java.util.*;
/**
* A class that syntax highlights Java code into html.
*
* 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.
*
* Users of the class can set how the java code will be highlighted with
* setter methods.
*
* Only valid java lines should be passed in since the object maintains
* state and may not handle illegal code gracefully.
*
* The actual system is implemented as a series of filters that deal with
* specific portions of the java code. The filters are as follows:
*
*
* htmlFilter
* |__
* multiLineCommentFilter
* |___
* inlineCommentFilter
* |___
* stringFilter
* |__
* keywordFilter
*
*
*/
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 = ““;
private String commentEnd = ““;
private String stringStart = ““;
private String stringEnd = ““;
private String reservedWordStart = ““;
private String reservedWordEnd = ““;
/**
* 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;
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 414 2007-05-01 10:48 bbs\.classpath
文件 282 2007-05-01 10:45 bbs\.myme
文件 1343 2007-05-01 10:48 bbs\.project
文件 101 2007-05-01 11:04 bbs\.settings\org.eclipse.core.resources.prefs
文件 9254 2007-05-05 15:45 bbs\db\bbs\bbs1.frm
文件 7648 2009-01-06 15:28 bbs\db\bbs\bbs1.MYD
文件 3072 2009-01-06 15:28 bbs\db\bbs\bbs1.MYI
文件 8634 2007-05-05 15:45 bbs\db\bbs\bbsli
文件 460 2007-05-05 15:45 bbs\db\bbs\bbsli
文件 2048 2007-05-05 15:45 bbs\db\bbs\bbsli
文件 8698 2007-05-05 15:45 bbs\db\bbs\bbsnews.frm
文件 188 2007-05-05 15:45 bbs\db\bbs\bbsnews.MYD
文件 3072 2007-05-05 15:45 bbs\db\bbs\bbsnews.MYI
文件 9604 2007-05-05 15:45 bbs\db\bbs\board.frm
文件 1392 2009-01-06 15:28 bbs\db\bbs\board.MYD
文件 2048 2009-01-06 15:28 bbs\db\bbs\board.MYI
文件 8660 2007-05-05 15:45 bbs\db\bbs\bookmark.frm
文件 184 2007-05-05 15:45 bbs\db\bbs\bookmark.MYD
文件 3072 2007-05-05 15:45 bbs\db\bbs\bookmark.MYI
文件 8576 2007-05-05 15:45 bbs\db\bbs\class.frm
文件 220 2007-05-05 15:45 bbs\db\bbs\class.MYD
文件 1024 2007-05-05 15:45 bbs\db\bbs\class.MYI
文件 10856 2007-05-05 15:45 bbs\db\bbs\config.frm
文件 644 2009-01-06 15:28 bbs\db\bbs\config.MYD
文件 1024 2009-01-06 15:28 bbs\db\bbs\config.MYI
文件 8656 2007-05-05 15:45 bbs\db\bbs\friend.frm
文件 0 2007-05-05 15:45 bbs\db\bbs\friend.MYD
文件 1024 2007-05-05 15:45 bbs\db\bbs\friend.MYI
文件 8684 2007-05-05 15:45 bbs\db\bbs\log.frm
文件 448 2007-05-05 15:45 bbs\db\bbs\log.MYD
............此处省略615个文件信息
评论
共有 条评论