01: // ========================================================================
02: // $Id: Style.java,v 1.3 2004/05/09 20:31:28 gregwilkins Exp $
03: // Copyright 1999-2004 Mort Bay Consulting Pty. Ltd.
04: // ------------------------------------------------------------------------
05: // Licensed under the Apache License, Version 2.0 (the "License");
06: // you may not use this file except in compliance with the License.
07: // You may obtain a copy of the License at
08: // http://www.apache.org/licenses/LICENSE-2.0
09: // 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: /** HTML Style Block.
20: */
21: public class Style extends Block {
22: public static final String STYLE = "style", TYPE = "type",
23: MEDIA = "media";
24:
25: public final static String StyleSheet = "stylesheet",
26: AlternateStyleSheet = "alternate stylesheet",
27: text_css = "text/css", screen = "screen";
28:
29: /* ------------------------------------------------------------ */
30: /** Construct a Style element.
31: * @param type Format of Style */
32: public Style(String style, String type) {
33: super (STYLE);
34: if (type != null)
35: attribute(TYPE, type);
36: add(style);
37: }
38:
39: /* ------------------------------------------------------------ */
40: /** Construct a Style element */
41: public Style(String style) {
42: this (style, text_css);
43: }
44:
45: /* ------------------------------------------------------------ */
46: /** Construct a Style element */
47: public Style() {
48: super (STYLE);
49: attribute(TYPE, text_css);
50: }
51:
52: /* ------------------------------------------------------------ */
53: /** Set the media
54: */
55: public Style media(String m) {
56: attribute(MEDIA, m);
57: return this ;
58: }
59:
60: /* ------------------------------------------------------------ */
61: /** Nest style content in comment
62: */
63: public Style comment() {
64: nest(new Comment());
65: return this ;
66: }
67:
68: /* ------------------------------------------------------------ */
69: /** Import another style sheet.
70: * @param url The URL to import
71: * @return This style
72: */
73: public Style importStyle(String url) {
74: add("@import url(" + url + ");\n");
75: return this;
76: }
77: };
|