001: package de.java2html.javasource;
002:
003: import java.util.ArrayList;
004: import java.util.List;
005:
006: /**
007: * Different types of source code for classifying characters in the raw text.
008: * @author Markus Gebhard
009: */
010: public class JavaSourceType {
011: private static final List ALL = new ArrayList();
012:
013: private static int idCounter = 0;
014:
015: public final static JavaSourceType BACKGROUND = new JavaSourceType(
016: "Background", false);
017:
018: //Not really a Javasource type, but useful for conversion output options
019: public final static JavaSourceType LINE_NUMBERS = new JavaSourceType(
020: "Line numbers", true);
021:
022: public final static JavaSourceType COMMENT_BLOCK = new JavaSourceType(
023: "Multi-line comments", true); //green
024:
025: public final static JavaSourceType COMMENT_LINE = new JavaSourceType(
026: "Single-line comments", true); //green
027:
028: public final static JavaSourceType KEYWORD = new JavaSourceType(
029: "Keywords", true);
030:
031: public final static JavaSourceType STRING = new JavaSourceType(
032: "Strings", true); //darker red
033:
034: public final static JavaSourceType CHAR_CONSTANT = new JavaSourceType(
035: "Character constants", true); //dark red
036:
037: public final static JavaSourceType NUM_CONSTANT = new JavaSourceType(
038: "Numeric constants", true); //dark red
039:
040: public final static JavaSourceType PARENTHESIS = new JavaSourceType(
041: "Parenthesis", true);
042:
043: public final static JavaSourceType CODE_TYPE = new JavaSourceType(
044: "Primitive Types", true);
045:
046: public final static JavaSourceType CODE = new JavaSourceType(
047: "Others", true);
048:
049: public final static JavaSourceType JAVADOC_KEYWORD = new JavaSourceType(
050: "Javadoc keywords", true); //dark green
051:
052: public final static JavaSourceType JAVADOC_HTML_TAG = new JavaSourceType(
053: "Javadoc HTML tags", true);
054:
055: public final static JavaSourceType JAVADOC_LINKS = new JavaSourceType(
056: "Javadoc links", true);
057:
058: public final static JavaSourceType JAVADOC = new JavaSourceType(
059: "Javadoc others", true); //green
060:
061: public final static JavaSourceType UNDEFINED = new JavaSourceType(
062: "Undefined", false);
063:
064: public static final JavaSourceType ANNOTATION = new JavaSourceType(
065: "Annotation", true);
066:
067: public static JavaSourceType[] getAll() {
068: return (JavaSourceType[]) ALL.toArray(new JavaSourceType[ALL
069: .size()]);
070: }
071:
072: private String name;
073: private int id;
074: private boolean displayRelevant;
075:
076: /**
077: * @param name The name of the type
078: * @param displayRelevant false if this type does not really matter for
079: * display (e.g. because type means empty or illegal code).
080: */
081: private JavaSourceType(String name, boolean displayRelevant) {
082: this .id = idCounter++;
083: this .name = name;
084: this .displayRelevant = displayRelevant;
085: ALL.add(this );
086: }
087:
088: public String getName() {
089: return toString();
090: }
091:
092: public int getID() {
093: return id;
094: }
095:
096: public String toString() {
097: return name;
098: }
099:
100: public boolean isDisplayRelevant() {
101: return displayRelevant;
102: }
103: }
|