Skip to content

Commit 94f7caa

Browse files
committed
% cleanup
1 parent 7a4d2ee commit 94f7caa

File tree

2 files changed

+40
-88
lines changed

2 files changed

+40
-88
lines changed

src/main/java/com/gargoylesoftware/css/dom/DOMExceptionImpl.java

Lines changed: 40 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@
1414
*/
1515
package com.gargoylesoftware.css.dom;
1616

17-
import java.util.Locale;
18-
import java.util.ResourceBundle;
19-
2017
import org.w3c.dom.DOMException;
2118

2219
/**
@@ -29,29 +26,46 @@ public class DOMExceptionImpl extends DOMException {
2926
public static final int SYNTAX_ERROR = 0;
3027
public static final int INDEX_OUT_OF_BOUNDS = 1;
3128
public static final int READ_ONLY_STYLE_SHEET = 2;
32-
public static final int EXPECTING_UNKNOWN_RULE = 3;
33-
public static final int EXPECTING_STYLE_RULE = 4;
34-
public static final int EXPECTING_CHARSET_RULE = 5;
35-
public static final int EXPECTING_IMPORT_RULE = 6;
36-
public static final int EXPECTING_MEDIA_RULE = 7;
37-
public static final int EXPECTING_FONT_FACE_RULE = 8;
38-
public static final int EXPECTING_PAGE_RULE = 9;
39-
public static final int FLOAT_ERROR = 10;
40-
public static final int STRING_ERROR = 11;
41-
public static final int COUNTER_ERROR = 12;
42-
public static final int RECT_ERROR = 13;
43-
public static final int RGBCOLOR_ERROR = 14;
44-
public static final int CHARSET_NOT_FIRST = 15;
45-
public static final int CHARSET_NOT_UNIQUE = 16;
46-
public static final int IMPORT_NOT_FIRST = 17;
47-
public static final int NOT_FOUND = 18;
48-
public static final int NOT_IMPLEMENTED = 19;
49-
public static final int INSERT_BEFORE_IMPORT = 20;
29+
public static final int EXPECTING_STYLE_RULE = 3;
30+
public static final int EXPECTING_CHARSET_RULE = 4;
31+
public static final int EXPECTING_IMPORT_RULE = 5;
32+
public static final int EXPECTING_MEDIA_RULE = 6;
33+
public static final int EXPECTING_FONT_FACE_RULE = 7;
34+
public static final int EXPECTING_PAGE_RULE = 8;
35+
public static final int FLOAT_ERROR = 9;
36+
public static final int STRING_ERROR = 10;
37+
public static final int COUNTER_ERROR = 11;
38+
public static final int RECT_ERROR = 12;
39+
public static final int RGBCOLOR_ERROR = 13;
40+
public static final int CHARSET_NOT_FIRST = 14;
41+
public static final int CHARSET_NOT_UNIQUE = 15;
42+
public static final int IMPORT_NOT_FIRST = 16;
43+
public static final int NOT_FOUND = 17;
44+
public static final int NOT_IMPLEMENTED = 18;
45+
public static final int INSERT_BEFORE_IMPORT = 19;
5046

51-
private static ResourceBundle ExceptionResource_ =
52-
ResourceBundle.getBundle(
53-
"com.gargoylesoftware.css.parser.ExceptionResource",
54-
Locale.ENGLISH);
47+
static final String[] messages = {
48+
"Syntax error",
49+
"Index out of bounds error",
50+
"This style sheet is read only",
51+
"The text does not represent a style rule",
52+
"The text does not represent a charset rule",
53+
"The text does not represent an import rule",
54+
"The text does not represent a media rule",
55+
"The text does not represent a font face rule",
56+
"The text does not represent a page rule",
57+
"This isn't a Float type",
58+
"This isn't a String type",
59+
"This isn't a Counter type",
60+
"This isn't a Rect type",
61+
"This isn't an RGBColor type",
62+
"A charset rule must be the first rule",
63+
"A charset rule already exists",
64+
"An import rule must preceed all other rules",
65+
"The specified type was not found",
66+
"The functionality is not implemented",
67+
"Can't insert a rule before the last charset or import rule"
68+
};
5569

5670
public DOMExceptionImpl(final short code, final int messageKey) {
5771
this(code, messageKey, null);
@@ -62,15 +76,6 @@ public DOMExceptionImpl(final int code, final int messageKey) {
6276
}
6377

6478
public DOMExceptionImpl(final int code, final int messageKey, final String info) {
65-
super((short) code, constructMessage(messageKey, info));
66-
}
67-
68-
private static String constructMessage(final int key, final String info) {
69-
final String messageKey = "s" + String.valueOf(key);
70-
String message = ExceptionResource_.getString(messageKey);
71-
if (null != info && info.length() > 0) {
72-
message = message + " (" + info + ")";
73-
}
74-
return message;
79+
super((short) code, messages[messageKey] + " (" + info + ")");
7580
}
7681
}

src/main/java/com/gargoylesoftware/css/parser/ExceptionResource.java

Lines changed: 0 additions & 53 deletions
This file was deleted.

0 commit comments

Comments
 (0)