01 package de.java2html.javasource;
02 
03 import java.util.ArrayList;
04 import java.util.List;
05 
06 /**
07  * Different types of source code for classifying characters in the raw text.
08  @author Markus Gebhard
09  */
10 public class SourceType {
11   private static final List ALL = new ArrayList();
12 
13   private static int idCounter = 0;
14 
15   public final static SourceType BACKGROUND = new SourceType("Background"false);
16 
17   //Not really a Javasource type, but useful for conversion output options
18   public final static SourceType LINE_NUMBERS = new SourceType("Line numbers"true);
19 
20   public final static SourceType COMMENT_BLOCK = new SourceType("Multi-line comments"true)//green 
21 
22   public final static SourceType COMMENT_LINE = new SourceType("Single-line comments"true)//green 
23 
24   public final static SourceType KEYWORD = new SourceType("Keywords"true);
25 
26   public final static SourceType STRING = new SourceType("Strings"true)//darker red
27 
28   public final static SourceType CHAR_CONSTANT = new SourceType("Character constants"true)//dark red
29 
30   public final static SourceType NUM_CONSTANT = new SourceType("Numeric constants"true)//dark red 
31 
32   public final static SourceType PARENTHESIS = new SourceType("Parenthesis"true);
33 
34   public final static SourceType CODE_TYPE = new SourceType("Primitive Types"true);
35 
36   public final static SourceType CODE = new SourceType("Others"true);
37 
38   public final static SourceType JAVADOC_KEYWORD = new SourceType("Javadoc keywords"true)//dark green
39 
40   public final static SourceType JAVADOC_HTML_TAG = new SourceType("Javadoc HTML tags"true);
41 
42   public final static SourceType JAVADOC_LINKS = new SourceType("Javadoc links"true);
43 
44   public final static SourceType JAVADOC = new SourceType("Javadoc others"true)//green 
45 
46   public final static SourceType UNDEFINED = new SourceType("Undefined"false);
47 
48   public static final SourceType ANNOTATION = new SourceType("Annotation"true);
49 
50   public static SourceType[] getAll() {
51     return (SourceType[]) ALL.toArray(new SourceType[ALL.size()]);
52   }
53 
54   private String name;
55   private int id;
56   private boolean displayRelevant;
57 
58   /**
59    @param name The name of the type
60    @param displayRelevant false if this type does not really matter for
61    * display (e.g. because type means empty or illegal code).
62    */
63   private SourceType(String name, boolean displayRelevant) {
64     this.id = idCounter++;
65     this.name = name;
66     this.displayRelevant = displayRelevant;
67     ALL.add(this);
68   }
69 
70   public String getName() {
71     return toString();
72   }
73 
74   public int getID() {
75     return id;
76   }
77 
78   @Override
79   public String toString() {
80     return name;
81   }
82 
83   public boolean isDisplayRelevant() {
84     return displayRelevant;
85   }
86 }