7 package org.libcsdbg.jtracer;
9 import java.util.Vector;
10 import java.util.Hashtable;
13 import java.io.FileReader;
14 import java.io.BufferedReader;
15 import java.io.IOException;
20 public class Highlighter extends Hashtable<String, Vector<String>>
55 File src = Registry.getCurrent().getResource(
"config/" + nm +
".dict");
56 String path = src.getCanonicalPath();
59 throw new IOException(
"Dictionary '" + path +
"' doesn't exist");
61 else if (!src.canRead())
62 throw new IOException(
"Can't read dictionary '" + path +
"'");
64 BufferedReader reader =
new BufferedReader(
new FileReader(src));
65 Vector<String> words =
new Vector<String>();
68 String line = reader.readLine();
73 if (line.length() > 0)
93 public boolean lookup(String token, String nm,
boolean regex)
95 Vector<String> words =
get(nm);
99 for (
int i = 0, cnt = words.size(); i < cnt; i++) {
100 String exp = words.get(i);
103 if (token.matches(exp))
107 else if (token.equals(exp))
boolean lookup(String token, String nm, boolean regex)
Check if a word belongs in a dictionary.
static Highlighter current
Current highlighter.
static final long serialVersionUID
Class version.
void loadDictionary(String nm)
Load a dictionary.
C++ stack trace syntax highlighter.
static Highlighter getCurrent()
Get the current highlighter.