3434 */
3535public class CSSMediaRuleImpl extends AbstractCSSRuleImpl {
3636
37- private MediaListImpl media_ ;
37+ private MediaListImpl mediaList_ ;
3838 private CSSRuleListImpl cssRules_ ;
3939
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+ */
4846 public CSSMediaRuleImpl (
4947 final CSSStyleSheetImpl parentStyleSheet ,
5048 final AbstractCSSRuleImpl parentRule ,
5149 final MediaListImpl media ) {
5250 super (parentStyleSheet , parentRule );
53- media_ = media ;
51+ mediaList_ = media ;
5452 }
5553
5654 /**
@@ -59,7 +57,7 @@ public CSSMediaRuleImpl(
5957 public String getCssText () {
6058 final StringBuilder sb = new StringBuilder ("@media " );
6159
62- sb .append (getMedia ().getMediaText ());
60+ sb .append (getMediaList ().getMediaText ());
6361 sb .append (" {" );
6462 for (int i = 0 ; i < getCssRules ().getLength (); i ++) {
6563 final AbstractCSSRuleImpl rule = getCssRules ().getRules ().get (i );
@@ -89,7 +87,7 @@ public void setCssText(final String cssText) throws DOMException {
8987
9088 // The rule must be a media rule
9189 if (r instanceof CSSMediaRuleImpl ) {
92- media_ = ((CSSMediaRuleImpl ) r ).media_ ;
90+ mediaList_ = ((CSSMediaRuleImpl ) r ).mediaList_ ;
9391 cssRules_ = ((CSSMediaRuleImpl ) r ).cssRules_ ;
9492 }
9593 else {
@@ -112,18 +110,30 @@ public void setCssText(final String cssText) throws DOMException {
112110 }
113111 }
114112
115- public MediaListImpl getMedia () {
116- return media_ ;
113+ /**
114+ * @return the media list
115+ */
116+ public MediaListImpl getMediaList () {
117+ return mediaList_ ;
117118 }
118119
120+ /**
121+ * @return the css rules
122+ */
119123 public CSSRuleListImpl getCssRules () {
120124 if (cssRules_ == null ) {
121125 cssRules_ = new CSSRuleListImpl ();
122126 }
123127 return cssRules_ ;
124128 }
125129
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 {
127137 final CSSStyleSheetImpl parentStyleSheet = getParentStyleSheet ();
128138 if (parentStyleSheet != null && parentStyleSheet .isReadOnly ()) {
129139 throw new DOMExceptionImpl (
@@ -160,9 +170,13 @@ public int insertRule(final String rule, final int index) throws DOMException {
160170 DOMExceptionImpl .SYNTAX_ERROR ,
161171 e .getMessage ());
162172 }
163- return index ;
164173 }
165174
175+ /**
176+ * Removes a rule at the given index.
177+ * @param index the insert pos
178+ * @throws DOMException in case of error
179+ */
166180 public void deleteRule (final int index ) throws DOMException {
167181 final CSSStyleSheetImpl parentStyleSheet = getParentStyleSheet ();
168182 if (parentStyleSheet != null && parentStyleSheet .isReadOnly ()) {
@@ -181,6 +195,10 @@ public void deleteRule(final int index) throws DOMException {
181195 }
182196 }
183197
198+ /**
199+ * Replaces the rule list.
200+ * @param rules the new rule list
201+ */
184202 public void setRuleList (final CSSRuleListImpl rules ) {
185203 cssRules_ = rules ;
186204 }
@@ -200,21 +218,21 @@ public boolean equals(final Object obj) {
200218 }
201219 final CSSMediaRuleImpl cmr = (CSSMediaRuleImpl ) obj ;
202220 return super .equals (obj )
203- && LangUtils .equals (getMedia (), cmr .getMedia ())
221+ && LangUtils .equals (getMediaList (), cmr .getMediaList ())
204222 && LangUtils .equals (getCssRules (), cmr .getCssRules ());
205223 }
206224
207225 @ Override
208226 public int hashCode () {
209227 int hash = super .hashCode ();
210- hash = LangUtils .hashCode (hash , media_ );
228+ hash = LangUtils .hashCode (hash , mediaList_ );
211229 hash = LangUtils .hashCode (hash , cssRules_ );
212230 return hash ;
213231 }
214232
215233 private void writeObject (final ObjectOutputStream out ) throws IOException {
216234 out .writeObject (cssRules_ );
217- out .writeObject (media_ );
235+ out .writeObject (mediaList_ );
218236 }
219237
220238 private void readObject (final ObjectInputStream in )
@@ -228,6 +246,6 @@ private void readObject(final ObjectInputStream in)
228246 cssRule .setParentStyleSheet (getParentStyleSheet ());
229247 }
230248 }
231- media_ = (MediaListImpl ) in .readObject ();
249+ mediaList_ = (MediaListImpl ) in .readObject ();
232250 }
233251}
0 commit comments