34
34
*/
35
35
public class CSSMediaRuleImpl extends AbstractCSSRuleImpl {
36
36
37
- private MediaListImpl media_ ;
37
+ private MediaListImpl mediaList_ ;
38
38
private CSSRuleListImpl cssRules_ ;
39
39
40
- public void setMedia (final MediaListImpl media ) {
41
- media_ = media ;
42
- }
43
-
44
- public void setCssRules (final CSSRuleListImpl cssRules ) {
45
- cssRules_ = cssRules ;
46
- }
47
-
40
+ /**
41
+ * Ctor.
42
+ * @param parentStyleSheet the parent style sheet
43
+ * @param parentRule the parent rule
44
+ * @param media the media
45
+ */
48
46
public CSSMediaRuleImpl (
49
47
final CSSStyleSheetImpl parentStyleSheet ,
50
48
final AbstractCSSRuleImpl parentRule ,
51
49
final MediaListImpl media ) {
52
50
super (parentStyleSheet , parentRule );
53
- media_ = media ;
51
+ mediaList_ = media ;
54
52
}
55
53
56
54
/**
@@ -59,7 +57,7 @@ public CSSMediaRuleImpl(
59
57
public String getCssText () {
60
58
final StringBuilder sb = new StringBuilder ("@media " );
61
59
62
- sb .append (getMedia ().getMediaText ());
60
+ sb .append (getMediaList ().getMediaText ());
63
61
sb .append (" {" );
64
62
for (int i = 0 ; i < getCssRules ().getLength (); i ++) {
65
63
final AbstractCSSRuleImpl rule = getCssRules ().getRules ().get (i );
@@ -89,7 +87,7 @@ public void setCssText(final String cssText) throws DOMException {
89
87
90
88
// The rule must be a media rule
91
89
if (r instanceof CSSMediaRuleImpl ) {
92
- media_ = ((CSSMediaRuleImpl ) r ).media_ ;
90
+ mediaList_ = ((CSSMediaRuleImpl ) r ).mediaList_ ;
93
91
cssRules_ = ((CSSMediaRuleImpl ) r ).cssRules_ ;
94
92
}
95
93
else {
@@ -112,18 +110,30 @@ public void setCssText(final String cssText) throws DOMException {
112
110
}
113
111
}
114
112
115
- public MediaListImpl getMedia () {
116
- return media_ ;
113
+ /**
114
+ * @return the media list
115
+ */
116
+ public MediaListImpl getMediaList () {
117
+ return mediaList_ ;
117
118
}
118
119
120
+ /**
121
+ * @return the css rules
122
+ */
119
123
public CSSRuleListImpl getCssRules () {
120
124
if (cssRules_ == null ) {
121
125
cssRules_ = new CSSRuleListImpl ();
122
126
}
123
127
return cssRules_ ;
124
128
}
125
129
126
- public int insertRule (final String rule , final int index ) throws DOMException {
130
+ /**
131
+ * Insert a new rule at the given index.
132
+ * @param rule the rule to be inserted
133
+ * @param index the insert pos
134
+ * @throws DOMException in case of error
135
+ */
136
+ public void insertRule (final String rule , final int index ) throws DOMException {
127
137
final CSSStyleSheetImpl parentStyleSheet = getParentStyleSheet ();
128
138
if (parentStyleSheet != null && parentStyleSheet .isReadOnly ()) {
129
139
throw new DOMExceptionImpl (
@@ -160,9 +170,13 @@ public int insertRule(final String rule, final int index) throws DOMException {
160
170
DOMExceptionImpl .SYNTAX_ERROR ,
161
171
e .getMessage ());
162
172
}
163
- return index ;
164
173
}
165
174
175
+ /**
176
+ * Removes a rule at the given index.
177
+ * @param index the insert pos
178
+ * @throws DOMException in case of error
179
+ */
166
180
public void deleteRule (final int index ) throws DOMException {
167
181
final CSSStyleSheetImpl parentStyleSheet = getParentStyleSheet ();
168
182
if (parentStyleSheet != null && parentStyleSheet .isReadOnly ()) {
@@ -181,6 +195,10 @@ public void deleteRule(final int index) throws DOMException {
181
195
}
182
196
}
183
197
198
+ /**
199
+ * Replaces the rule list.
200
+ * @param rules the new rule list
201
+ */
184
202
public void setRuleList (final CSSRuleListImpl rules ) {
185
203
cssRules_ = rules ;
186
204
}
@@ -200,21 +218,21 @@ public boolean equals(final Object obj) {
200
218
}
201
219
final CSSMediaRuleImpl cmr = (CSSMediaRuleImpl ) obj ;
202
220
return super .equals (obj )
203
- && LangUtils .equals (getMedia (), cmr .getMedia ())
221
+ && LangUtils .equals (getMediaList (), cmr .getMediaList ())
204
222
&& LangUtils .equals (getCssRules (), cmr .getCssRules ());
205
223
}
206
224
207
225
@ Override
208
226
public int hashCode () {
209
227
int hash = super .hashCode ();
210
- hash = LangUtils .hashCode (hash , media_ );
228
+ hash = LangUtils .hashCode (hash , mediaList_ );
211
229
hash = LangUtils .hashCode (hash , cssRules_ );
212
230
return hash ;
213
231
}
214
232
215
233
private void writeObject (final ObjectOutputStream out ) throws IOException {
216
234
out .writeObject (cssRules_ );
217
- out .writeObject (media_ );
235
+ out .writeObject (mediaList_ );
218
236
}
219
237
220
238
private void readObject (final ObjectInputStream in )
@@ -228,6 +246,6 @@ private void readObject(final ObjectInputStream in)
228
246
cssRule .setParentStyleSheet (getParentStyleSheet ());
229
247
}
230
248
}
231
- media_ = (MediaListImpl ) in .readObject ();
249
+ mediaList_ = (MediaListImpl ) in .readObject ();
232
250
}
233
251
}
0 commit comments