KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > ecs > html > PRE


1 /*
2  * ====================================================================
3  *
4  * The Apache Software License, Version 1.1
5  *
6  * Copyright (c) 1999-2003 The Apache Software Foundation. All rights
7  * reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  *
13  * 1. Redistributions of source code must retain the above copyright
14  * notice, this list of conditions and the following disclaimer.
15  *
16  * 2. Redistributions in binary form must reproduce the above copyright
17  * notice, this list of conditions and the following disclaimer in
18  * the documentation and/or other materials provided with the
19  * distribution.
20  *
21  * 3. The end-user documentation included with the redistribution, if
22  * any, must include the following acknowlegement:
23  * "This product includes software developed by the
24  * Apache Software Foundation (http://www.apache.org/)."
25  * Alternately, this acknowlegement may appear in the software itself,
26  * if and wherever such third-party acknowlegements normally appear.
27  *
28  * 4. The names "The Jakarta Project", "Jakarta Element Construction Set",
29  * "Jakarta ECS" , and "Apache Software Foundation" must not be used
30  * to endorse or promote products derived
31  * from this software without prior written permission. For written
32  * permission, please contact apache@apache.org.
33  *
34  * 5. Products derived from this software may not be called "Apache",
35  * "Jakarta Element Construction Set" nor "Jakarta ECS" nor may "Apache"
36  * appear in their names without prior written permission of the Apache Group.
37  *
38  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
39  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
40  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
41  * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
42  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
44  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
45  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
46  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
47  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
48  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
49  * SUCH DAMAGE.
50  * ====================================================================
51  *
52  * This software consists of voluntary contributions made by many
53  * individuals on behalf of the Apache Software Foundation. For more
54  * information on the Apache Software Foundation, please see
55  * <http://www.apache.org/>.
56  *
57  */

58 package org.apache.ecs.html;
59
60 import org.apache.ecs.*;
61
62 /**
63     This class creates a &lt;PRE&gt; tag.
64
65     @version $Id: PRE.java,v 1.3 2003/04/27 09:22:49 rdonkin Exp $
66     @author <a HREF="mailto:snagy@servletapi.com">Stephan Nagy</a>
67     @author <a HREF="mailto:jon@clearink.com">Jon S. Stevens</a>
68 */

69 public class PRE extends MultiPartElement implements MouseEvents, KeyEvents
70 {
71     /**
72         Private initialization routine.
73     */

74     {
75         setElementType("pre");
76         setPrettyPrint(false);
77     }
78
79     /**
80         Basic constructor. You need to set the attributes using the
81         set* methods.
82     */

83     public PRE()
84     {
85     }
86
87     /**
88         Use the set* methods to set the values
89         of the attributes.
90
91         @param element set the value of &lt;PRE&gt;value&lt;/PRE&gt;
92     */

93     public PRE(Element element)
94     {
95         addElement(element);
96     }
97
98     /**
99         Use the set* methods to set the values
100         of the attributes.
101
102         @param value set the value of &lt;PRE&gt;value&lt;/PRE&gt;
103         @param width set the value of WIDTH=""
104     */

105     public PRE(String JavaDoc value, int width)
106     {
107         setWidth(width);
108         addElement(value);
109     }
110
111     /**
112         Use the set* methods to set the values
113         of the attributes.
114
115         @param element set the value of &lt;PRE&gt;value&lt;/PRE&gt;
116         @param width set the value of WIDTH=""
117     */

118     public PRE(Element element, int width)
119     {
120         setWidth(width);
121         addElement(element);
122     }
123
124     /**
125         Use the set* methods to set the values
126         of the attributes.
127
128         @param element set the value of &lt;PRE&gt;value&lt;/PRE&gt;
129         @param width set the value of WIDTH=""
130     */

131     public PRE(Element element, String JavaDoc width)
132     {
133         setWidth(width);
134         addElement(element);
135     }
136
137     /**
138         Use the set* methods to set the values
139         of the attributes.
140
141         @param value set the value of &lt;PRE&gt;value&lt;/PRE&gt;
142     */

143     public PRE(String JavaDoc value)
144     {
145         addElement(value);
146     }
147
148     /**
149         Sets the WIDTH="" attribute
150         @param width the WIDTH="" attribute
151     */

152     public PRE setWidth(int width)
153     {
154         addAttribute("width",Integer.toString(width));
155         return this;
156     }
157
158     /**
159         Sets the WIDTH="" attribute
160         @param width the WIDTH="" attribute
161     */

162     public PRE setWidth(String JavaDoc width)
163     {
164         addAttribute("width",width);
165         return this;
166     }
167
168     /**
169         Adds an Element to the element.
170         @param hashcode name of element for hash table
171         @param element Adds an Element to the element.
172      */

173     public PRE addElement(String JavaDoc hashcode,Element element)
174     {
175         addElementToRegistry(hashcode,element);
176         return(this);
177     }
178
179     /**
180         Adds an Element to the element.
181         @param hashcode name of element for hash table
182         @param element Adds an Element to the element.
183      */

184     public PRE addElement(String JavaDoc hashcode,String JavaDoc element)
185     {
186         addElementToRegistry(hashcode,element);
187         return(this);
188     }
189
190     /**
191         Adds an Element to the element.
192         @param element Adds an Element to the element.
193      */

194     public PRE addElement(Element element)
195     {
196         addElementToRegistry(element);
197         return(this);
198     }
199
200     /**
201         Adds an Element to the element.
202         @param element Adds an Element to the element.
203      */

204     public PRE addElement(String JavaDoc element)
205     {
206         addElementToRegistry(element);
207         return(this);
208     }
209     /**
210         Removes an Element from the element.
211         @param hashcode the name of the element to be removed.
212     */

213     public PRE removeElement(String JavaDoc hashcode)
214     {
215         removeElementFromRegistry(hashcode);
216         return(this);
217     }
218
219     /**
220         The onclick event occurs when the pointing device button is clicked
221         over an element. This attribute may be used with most elements.
222         
223         @param The script
224     */

225     public void setOnClick(String JavaDoc script)
226     {
227         addAttribute ( "onClick", script );
228     }
229     /**
230         The ondblclick event occurs when the pointing device button is double
231         clicked over an element. This attribute may be used with most elements.
232
233         @param The script
234     */

235     public void setOnDblClick(String JavaDoc script)
236     {
237         addAttribute ( "onDblClick", script );
238     }
239     /**
240         The onmousedown event occurs when the pointing device button is pressed
241         over an element. This attribute may be used with most elements.
242
243         @param The script
244     */

245     public void setOnMouseDown(String JavaDoc script)
246     {
247         addAttribute ( "onMouseDown", script );
248     }
249     /**
250         The onmouseup event occurs when the pointing device button is released
251         over an element. This attribute may be used with most elements.
252
253         @param The script
254     */

255     public void setOnMouseUp(String JavaDoc script)
256     {
257         addAttribute ( "onMouseUp", script );
258     }
259     /**
260         The onmouseover event occurs when the pointing device is moved onto an
261         element. This attribute may be used with most elements.
262
263         @param The script
264     */

265     public void setOnMouseOver(String JavaDoc script)
266     {
267         addAttribute ( "onMouseOver", script );
268     }
269     /**
270         The onmousemove event occurs when the pointing device is moved while it
271         is over an element. This attribute may be used with most elements.
272
273         @param The script
274     */

275     public void setOnMouseMove(String JavaDoc script)
276     {
277         addAttribute ( "onMouseMove", script );
278     }
279     /**
280         The onmouseout event occurs when the pointing device is moved away from
281         an element. This attribute may be used with most elements.
282
283         @param The script
284     */

285     public void setOnMouseOut(String JavaDoc script)
286     {
287         addAttribute ( "onMouseOut", script );
288     }
289
290     /**
291         The onkeypress event occurs when a key is pressed and released over an
292         element. This attribute may be used with most elements.
293         
294         @param The script
295     */

296     public void setOnKeyPress(String JavaDoc script)
297     {
298         addAttribute ( "onKeyPress", script );
299     }
300
301     /**
302         The onkeydown event occurs when a key is pressed down over an element.
303         This attribute may be used with most elements.
304         
305         @param The script
306     */

307     public void setOnKeyDown(String JavaDoc script)
308     {
309         addAttribute ( "onKeyDown", script );
310     }
311
312     /**
313         The onkeyup event occurs when a key is released over an element. This
314         attribute may be used with most elements.
315         
316         @param The script
317     */

318     public void setOnKeyUp(String JavaDoc script)
319     {
320         addAttribute ( "onKeyUp", script );
321     }
322 }
323
Popular Tags