KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > batik > css > engine > MediaRule


1 /*
2
3    Copyright 2002-2003 The Apache Software Foundation
4
5    Licensed under the Apache License, Version 2.0 (the "License");
6    you may not use this file except in compliance with the License.
7    You may obtain a copy of the License at
8
9        http://www.apache.org/licenses/LICENSE-2.0
10
11    Unless required by applicable law or agreed to in writing, software
12    distributed under the License is distributed on an "AS IS" BASIS,
13    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14    See the License for the specific language governing permissions and
15    limitations under the License.
16
17  */

18 package org.apache.batik.css.engine;
19
20 import org.w3c.css.sac.SACMediaList;
21
22 /**
23  * This class represents a @media CSS rule.
24  *
25  * @author <a HREF="mailto:stephane@hillion.org">Stephane Hillion</a>
26  * @version $Id: MediaRule.java,v 1.4 2004/08/18 07:12:48 vhardy Exp $
27  */

28 public class MediaRule extends StyleSheet implements Rule {
29     
30     /**
31      * The type constant.
32      */

33     public final static short TYPE = (short)1;
34
35     /**
36      * The media list.
37      */

38     protected SACMediaList mediaList;
39
40     /**
41      * Returns a constant identifying the rule type.
42      */

43     public short getType() {
44         return TYPE;
45     }
46
47     /**
48      * Sets the media list.
49      */

50     public void setMediaList(SACMediaList ml) {
51         mediaList = ml;
52     }
53
54     /**
55      * Returns the media list.
56      */

57     public SACMediaList getMediaList() {
58         return mediaList;
59     }
60
61     /**
62      * Returns a printable representation of this media rule.
63      */

64     public String JavaDoc toString(CSSEngine eng) {
65         StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
66         sb.append("@media");
67         if (mediaList != null) {
68             for (int i = 0; i < mediaList.getLength(); i++) {
69                 sb.append(' ');
70                 sb.append(mediaList.item(i));
71             }
72         }
73         sb.append(" {\n");
74         for (int i = 0; i < size; i++) {
75             sb.append(rules[i].toString(eng));
76         }
77         sb.append("}\n");
78         return sb.toString();
79     }
80 }
81
Popular Tags