Hier ein Codeschnipsel, das dies vorführt:
public final class Constants {
public static final Map ERRORMAP = new HashMap();
public static final String ERROR_500 = "f500";
public static final String ERROR_502 = "f502";
public static final String ERROR_503 = "f503";
public static final String ERROR_504 = "f504";
public static final String ERROR_505 = "f505";
public static final String ERROR_506 = "f506";
static {
errorMap.put(ERROR_500, "ConvertListDef: Invalid characters before newline. Only spaces and tabs allowed.");
errorMap.put(ERROR_502, "ConvertListDef: Missing '='");
errorMap.put(ERROR_503, "ConvertListDef: Value does not comply with naming convention");
errorMap.put(ERROR_504, "ConvertListDef: Syntactically invalid Attributename");
errorMap.put(ERROR_505, "ContextDef: Name of context invalid");
errorMap.put(ERROR_506, "ContextDef: Name of contextproperty invalid");
}
}
Der Zauberbereich ist der "statische" Konstruktor, der nur einmal bei Programmstart aufgerufen wird und mir meine HashMap befüllt.
Links:
Guido Krüger - JAVA 1.1 lernen - Kapitel 7
Siafoo Snippet
No comments:
Post a Comment