1 // ========================================================================
2 // $Id: Style.java,v 1.3 2004/05/09 20:31:28 gregwilkins Exp $
3 // Copyright 1999-2004 Mort Bay Consulting Pty. Ltd.
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 // http://www.apache.org/licenses/LICENSE-2.0
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 // ========================================================================
15
16 package org.mortbay.html;
17
18
19 /* -------------------------------------------------------------------- */
20 /** HTML Style Block.
21 */
22 public class Style extends Block
23 {
24 public static final String
25 STYLE = "style",
26 TYPE = "type",
27 MEDIA = "media";
28
29 public final static String
30 StyleSheet="stylesheet",
31 AlternateStyleSheet="alternate stylesheet",
32 text_css="text/css",
33 screen = "screen";
34
35
36 /* ------------------------------------------------------------ */
37 /** Construct a Style element.
38 * @param type Format of Style */
39 public Style(String style, String type)
40 {
41 super(STYLE);
42 if (type!=null)
43 attribute(TYPE,type);
44 add(style);
45 }
46
47 /* ------------------------------------------------------------ */
48 /** Construct a Style element */
49 public Style(String style)
50 {
51 this(style, text_css);
52 }
53
54 /* ------------------------------------------------------------ */
55 /** Construct a Style element */
56 public Style()
57 {
58 super(STYLE);
59 attribute(TYPE,text_css);
60 }
61
62 /* ------------------------------------------------------------ */
63 /** Set the media
64 */
65 public Style media(String m)
66 {
67 attribute(MEDIA,m);
68 return this;
69 }
70
71 /* ------------------------------------------------------------ */
72 /** Nest style content in comment
73 */
74 public Style comment()
75 {
76 nest(new Comment());
77 return this;
78 }
79
80
81 /* ------------------------------------------------------------ */
82 /** Import another style sheet.
83 * @param url The URL to import
84 * @return This style
85 */
86 public Style importStyle(String url)
87 {
88 add("@import url("+url+");\n");
89 return this;
90 }
91 };
92
93
94
95