01: // HtmlScript.java
02: // $Id: HtmlScript.java,v 1.3 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: /**
09: * a sample Script class for HTML documents
10: */
11:
12: public class HtmlScript {
13: String lang = null;
14: StringBuffer script = null;
15:
16: /**
17: * set the type of script used
18: * @param script the type
19: */
20:
21: public void setLanguage(String lang) {
22: this .lang = lang;
23: }
24:
25: /**
26: * append a string to the script buffer
27: * @param str1 A string to be append
28: */
29:
30: public void append(String str1) {
31: if (script == null)
32: script = new StringBuffer(str1);
33: else
34: script.append(str1);
35: }
36:
37: /**
38: * genereate a String representation that can be
39: * append in a HTML document
40: */
41:
42: public String toString() {
43: if (script == null)
44: return "";
45: return "<SCRIPT LANGUAGE=\"" + lang.toString() + "\">\n"
46: + script.toString() + "\n</SCRIPT>\n";
47: }
48:
49: public HtmlScript(String language, String script) {
50: setLanguage(language);
51: append(script);
52: }
53:
54: public HtmlScript(String script) {
55: append(script);
56: }
57: }
|