Skip to content

Commit a5edf3f

Browse files
committed
javadoc fixes, source cleanup
1 parent 52c537a commit a5edf3f

File tree

12 files changed

+178
-131
lines changed

12 files changed

+178
-131
lines changed

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,23 @@ public CounterImpl(final boolean separatorSpecified, final LexicalUnit lu) throw
7373
}
7474
}
7575

76+
/**
77+
* @return the identifier
78+
*/
7679
public String getIdentifier() {
7780
return identifier_;
7881
}
7982

83+
/**
84+
* @return the list style
85+
*/
8086
public String getListStyle() {
8187
return listStyle_;
8288
}
8389

90+
/**
91+
* @return the separator
92+
*/
8493
public String getSeparator() {
8594
return separator_;
8695
}

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

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,25 +23,45 @@
2323
*/
2424
public class DOMExceptionImpl extends DOMException {
2525

26+
/** SYNTAX_ERROR = 0. */
2627
public static final int SYNTAX_ERROR = 0;
28+
/** INDEX_OUT_OF_BOUNDS = 1. */
2729
public static final int INDEX_OUT_OF_BOUNDS = 1;
30+
/** READ_ONLY_STYLE_SHEET = 2. */
2831
public static final int READ_ONLY_STYLE_SHEET = 2;
32+
/** EXPECTING_STYLE_RULE = 3. */
2933
public static final int EXPECTING_STYLE_RULE = 3;
34+
/** EXPECTING_CHARSET_RULE = 4. */
3035
public static final int EXPECTING_CHARSET_RULE = 4;
36+
/** EXPECTING_IMPORT_RULE = 5. */
3137
public static final int EXPECTING_IMPORT_RULE = 5;
38+
/** EXPECTING_MEDIA_RULE = 6. */
3239
public static final int EXPECTING_MEDIA_RULE = 6;
40+
/** EXPECTING_FONT_FACE_RULE = 7. */
3341
public static final int EXPECTING_FONT_FACE_RULE = 7;
42+
/** EXPECTING_PAGE_RULE = 8. */
3443
public static final int EXPECTING_PAGE_RULE = 8;
44+
/** FLOAT_ERROR = 9. */
3545
public static final int FLOAT_ERROR = 9;
46+
/** STRING_ERROR = 10. */
3647
public static final int STRING_ERROR = 10;
48+
/** COUNTER_ERROR = 11. */
3749
public static final int COUNTER_ERROR = 11;
50+
/** RECT_ERROR = 12. */
3851
public static final int RECT_ERROR = 12;
52+
/** RGBCOLOR_ERROR = 13. */
3953
public static final int RGBCOLOR_ERROR = 13;
54+
/** CHARSET_NOT_FIRST = 14. */
4055
public static final int CHARSET_NOT_FIRST = 14;
56+
/** CHARSET_NOT_UNIQUE = 15. */
4157
public static final int CHARSET_NOT_UNIQUE = 15;
58+
/** IMPORT_NOT_FIRST = 16. */
4259
public static final int IMPORT_NOT_FIRST = 16;
60+
/** NOT_FOUND = 17. */
4361
public static final int NOT_FOUND = 17;
62+
/** NOT_IMPLEMENTED = 18. */
4463
public static final int NOT_IMPLEMENTED = 18;
64+
/** INSERT_BEFORE_IMPORT = 19. */
4565
public static final int INSERT_BEFORE_IMPORT = 19;
4666

4767
static final String[] messages = {
@@ -67,14 +87,30 @@ public class DOMExceptionImpl extends DOMException {
6787
"Can't insert a rule before the last charset or import rule"
6888
};
6989

90+
/**
91+
* Ctor.
92+
* @param code the code
93+
* @param messageKey the message key
94+
*/
7095
public DOMExceptionImpl(final short code, final int messageKey) {
7196
this(code, messageKey, null);
7297
}
7398

99+
/**
100+
* Ctor.
101+
* @param code the code
102+
* @param messageKey the message key
103+
*/
74104
public DOMExceptionImpl(final int code, final int messageKey) {
75105
this(code, messageKey, null);
76106
}
77107

108+
/**
109+
* Ctor.
110+
* @param code the code
111+
* @param messageKey the message key
112+
* @param info additional info
113+
*/
78114
public DOMExceptionImpl(final int code, final int messageKey, final String info) {
79115
super((short) code, messages[messageKey] + " (" + info + ")");
80116
}

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

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ public MediaListImpl(final MediaQueryList mediaList) {
5353
}
5454
}
5555

56+
/**
57+
* @return the media text
58+
*/
5659
public String getMediaText() {
5760
final StringBuilder sb = new StringBuilder("");
5861
boolean isNotFirst = false;
@@ -68,6 +71,11 @@ public String getMediaText() {
6871
return sb.toString();
6972
}
7073

74+
/**
75+
* Parses the given media text.
76+
* @param mediaText text to be parsed
77+
* @throws DOMException in case of error
78+
*/
7179
public void setMediaText(final String mediaText) throws DOMException {
7280
final InputSource source = new InputSource(new StringReader(mediaText));
7381
try {
@@ -84,6 +92,9 @@ public void setMediaText(final String mediaText) throws DOMException {
8492
}
8593
}
8694

95+
/**
96+
* @return the media query count
97+
*/
8798
public int getLength() {
8899
return mediaQueries_.size();
89100
}
@@ -99,26 +110,15 @@ public MediaQuery mediaQuery(final int index) {
99110
return mediaQueries_.get(index);
100111
}
101112

102-
public void deleteMedium(final String oldMedium) throws DOMException {
103-
for (MediaQuery mediaQuery : mediaQueries_) {
104-
final String str = mediaQuery.getMedia();
105-
if (str.equalsIgnoreCase(oldMedium)) {
106-
mediaQueries_.remove(mediaQuery);
107-
return;
108-
}
109-
}
110-
throw new DOMExceptionImpl(DOMException.NOT_FOUND_ERR, DOMExceptionImpl.NOT_FOUND);
111-
}
112-
113-
public void appendMedium(final String newMedium) throws DOMException {
114-
mediaQueries_.add(new MediaQuery(newMedium));
115-
}
116-
117113
@Override
118114
public String toString() {
119115
return getMediaText();
120116
}
121117

118+
/**
119+
* Resets the list of media queries.
120+
* @param media the media queries string to be parsed
121+
*/
122122
public void setMedia(final List<String> media) {
123123
mediaQueries_.clear();
124124
for (String medium : media) {
@@ -128,9 +128,7 @@ public void setMedia(final List<String> media) {
128128

129129
private void setMediaList(final MediaQueryList mediaList) {
130130
if (mediaList != null) {
131-
for (int i = 0; i < mediaList.getLength(); i++) {
132-
mediaQueries_.add(mediaList.mediaQuery(i));
133-
}
131+
mediaQueries_.addAll(mediaList.getMediaQueries());
134132
}
135133
}
136134

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

Lines changed: 53 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@ public abstract class AbstractCSSParser implements CSSParser {
8989

9090
private static final String NUM_CHARS = "0123456789.";
9191

92+
/**
93+
* @return the document handler
94+
*/
9295
protected DocumentHandler getDocumentHandler() {
9396
if (documentHandler_ == null) {
9497
setDocumentHandler(new HandlerBase());
@@ -101,6 +104,9 @@ public void setDocumentHandler(final DocumentHandler handler) {
101104
documentHandler_ = handler;
102105
}
103106

107+
/**
108+
* @return the error handler
109+
*/
104110
protected CSSErrorHandler getErrorHandler() {
105111
if (errorHandler_ == null) {
106112
setErrorHandler(new HandlerBase());
@@ -113,6 +119,9 @@ public void setErrorHandler(final CSSErrorHandler eh) {
113119
errorHandler_ = eh;
114120
}
115121

122+
/**
123+
* @return the input source
124+
*/
116125
protected InputSource getInputSource() {
117126
return source_;
118127
}
@@ -127,6 +136,10 @@ public boolean isIeStarHackAccepted() {
127136
return ieStarHackAccepted_;
128137
}
129138

139+
/**
140+
* @param key the lookup key
141+
* @return the parser message
142+
*/
130143
protected String getParserMessage(final String key) {
131144
final String msg = parserMessages_.get(key);
132145
if (msg == null) {
@@ -135,14 +148,24 @@ protected String getParserMessage(final String key) {
135148
return msg;
136149
}
137150

151+
/**
152+
* Returns a new locator for the given token.
153+
* @param t the token to generate the locator for
154+
* @return a new locator
155+
*/
138156
protected Locator createLocator(final Token t) {
139157
return new Locator(getInputSource().getURI(),
140158
t == null ? 0 : t.beginLine,
141159
t == null ? 0 : t.beginColumn);
142160
}
143161

144-
protected String add_escapes(final String str) {
145-
final StringBuilder sb = new StringBuilder();
162+
/**
163+
* Escapes some chars in the given string.
164+
* @param str the input
165+
* @return a new string with the escaped values
166+
*/
167+
protected String addEscapes(final String str) {
168+
StringBuilder sb = new StringBuilder();
146169
char ch;
147170
for (int i = 0; i < str.length(); i++) {
148171
ch = str.charAt(i);
@@ -213,7 +236,7 @@ protected CSSParseException toCSSParseException(final String key, final ParseExc
213236
invalid.append(e.tokenImage[0]);
214237
break;
215238
}
216-
invalid.append(add_escapes(tok.image));
239+
invalid.append(addEscapes(tok.image));
217240
tok = tok.next;
218241
}
219242
final StringBuilder message = new StringBuilder(getParserMessage(key));
@@ -230,25 +253,44 @@ protected CSSParseException toCSSParseException(final String key, final ParseExc
230253
e.currentToken.next.beginColumn);
231254
}
232255

256+
/**
257+
* @param e the DOMException
258+
* @return a new CSSParseException
259+
*/
233260
protected CSSParseException toCSSParseException(final DOMException e) {
234261
final String messagePattern = getParserMessage("domException");
235262
return new CSSParseException(
236263
MessageFormat.format(messagePattern, e.getMessage()), getInputSource().getURI(), 1, 1);
237264
}
238265

266+
/**
267+
* @param e the TokenMgrError
268+
* @return a new CSSParseException
269+
*/
239270
protected CSSParseException toCSSParseException(final TokenMgrError e) {
240271
final String messagePattern = getParserMessage("tokenMgrError");
241272
return new CSSParseException(messagePattern, getInputSource().getURI(), 1, 1);
242273
}
243274

275+
/**
276+
* @param messageKey the message key
277+
* @param msgParams the params
278+
* @param locator the locator
279+
* @return a new CSSParseException
280+
*/
244281
protected CSSParseException toCSSParseException(final String messageKey,
245282
final Object[] msgParams, final Locator locator) {
246283
final String messagePattern = getParserMessage(messageKey);
247284
return new CSSParseException(MessageFormat.format(messagePattern, msgParams), locator);
248285
}
249286

250-
protected CSSParseException createSkipWarning(final String key, final CSSParseException e) {
251-
return new CSSParseException(getParserMessage(key), e.getURI(), e.getLineNumber(), e.getColumnNumber());
287+
/**
288+
* @param messageKey the message key
289+
* @param e a CSSParseException
290+
* @return a new CSSParseException
291+
*/
292+
protected CSSParseException createSkipWarning(final String messageKey, final CSSParseException e) {
293+
return new CSSParseException(getParserMessage(messageKey), e.getURI(), e.getLineNumber(), e.getColumnNumber());
252294
}
253295

254296
@Override
@@ -370,6 +412,12 @@ public boolean parsePriority(final InputSource source) throws IOException {
370412
return b;
371413
}
372414

415+
/**
416+
* Parse the given input source and return the media list.
417+
* @param source the input source
418+
* @return new media list
419+
* @throws IOException in case of errors
420+
*/
373421
public MediaQueryList parseMedia(final InputSource source) throws IOException {
374422
source_ = source;
375423
ReInit(getCharStream(source));

src/main/java/com/gargoylesoftware/css/parser/media/MediaQuery.java

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,37 +31,59 @@ public class MediaQuery extends AbstractLocatable implements Serializable {
3131
private boolean isOnly_;
3232
private boolean isNot_;
3333

34+
/**
35+
* Ctor.
36+
* @param media the media string
37+
*/
3438
public MediaQuery(final String media) {
3539
this(media, false, false);
3640
}
3741

42+
/**
43+
* Ctor.
44+
* @param media the media string
45+
* @param isOnly is only flag
46+
* @param isNot is not flag
47+
*/
3848
public MediaQuery(final String media, final boolean isOnly, final boolean isNot) {
39-
setMedia(media);
49+
media_ = media;
4050
properties_ = new ArrayList<Property>(10);
4151
isOnly_ = isOnly;
4252
isNot_ = isNot;
4353
}
4454

55+
/**
56+
* @return the media
57+
*/
4558
public String getMedia() {
4659
return media_;
4760
}
4861

49-
public void setMedia(final String media) {
50-
media_ = media;
51-
}
52-
62+
/**
63+
* @return the list of properties
64+
*/
5365
public List<Property> getProperties() {
5466
return properties_;
5567
}
5668

69+
/**
70+
* Adds a property to the list.
71+
* @param mp the property to add
72+
*/
5773
public void addMediaProperty(final Property mp) {
5874
properties_.add(mp);
5975
}
6076

77+
/**
78+
* @return the is only flag
79+
*/
6180
public boolean isOnly() {
6281
return isOnly_;
6382
}
6483

84+
/**
85+
* @return the is not flag
86+
*/
6587
public boolean isNot() {
6688
return isNot_;
6789
}

0 commit comments

Comments
 (0)