01: // HtmlStyle.java
02: // $Id: HtmlStyle.java,v 1.6 2000/08/16 21:37:40 ylafon Exp $
03: // (c) COPYRIGHT MIT and INRIA, 1996.
04: // Please first read the full copyright statement in file COPYRIGHT.html
05:
06: package org.w3c.jigsaw.html;
07:
08: import org.w3c.www.mime.MimeType;
09:
10: /**
11: * a sample Style class for HTML documents
12: */
13:
14: public class HtmlStyle {
15: MimeType type = MimeType.TEXT_CSS;
16: StringBuffer style = null;
17:
18: /**
19: * set the type of style sheet used
20: * @param style the sheet's MimeType.
21: */
22:
23: public void setType(MimeType type) {
24: this .type = type;
25: }
26:
27: /**
28: * append a string to the style buffer
29: * @param str1 A string to be append
30: */
31:
32: public void append(String str1) {
33: if (style == null)
34: style = new StringBuffer(str1);
35: else
36: style.append(str1);
37: }
38:
39: /**
40: * genereate a String representation that can be
41: * append in a HTML document
42: */
43:
44: public String toString() {
45: if (style == null)
46: return "";
47: return "<STYLE TYPE=\"" + type.toString() + "\">\n"
48: + style.toString() + "\n</STYLE>\n";
49: }
50:
51: public HtmlStyle(MimeType type, String style) {
52: setType(type);
53: append(style);
54: }
55:
56: public HtmlStyle(String style) {
57: append(style);
58: }
59: }
|