KickJava   Java API By Example, From Geeks To Geeks.

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


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 an ObjectElement
64
65     @version $Id: ObjectElement.java,v 1.4 2003/04/27 09:22:12 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 ObjectElement extends MultiPartElement implements Printable, MouseEvents, KeyEvents
70 {
71     /**
72         Private initializer.
73     */

74     {
75         setElementType("object");
76     }
77
78     /**
79         Default constructor. Creates the &lt;object/&gt; Element.<br>
80         use set* methods.
81     */

82     public ObjectElement()
83     {
84     }
85
86     /**
87         Sets the declare attribute. (declare this object but don't instantiate it.
88         @param declare declare on or off
89     */

90     public ObjectElement setDeclare(boolean declare)
91     {
92         if(declare)
93             addAttribute("declare",NO_ATTRIBUTE_VALUE);
94         else
95             removeAttribute("declare");
96         return(this);
97     }
98
99     /**
100         Identifies an implementation.
101         @param url location of classid.
102     */

103     public ObjectElement setClassId(String JavaDoc url)
104     {
105         addAttribute("classid",url);
106         return(this);
107     }
108
109     /**
110         Sets the Internet content type for the code.
111         @param codetype Sets the Internet content type for the code.
112     */

113     public ObjectElement setCodeType(String JavaDoc codetype)
114     {
115         addAttribute("codetype",codetype);
116         return(this);
117     }
118
119     /**
120         Determines the base path to resolve relative urls specified by classid.
121         @param url base path to resolve relative urls specified by classid.
122     */

123     public ObjectElement setCodeBase(String JavaDoc url)
124     {
125         addAttribute("codebase",url);
126         return(this);
127     }
128
129     /**
130         This attribute specifies the location of the data to be rendered.
131         @param url this attribute specifies the location of the data to be rendered.
132     */

133     public ObjectElement setData(String JavaDoc url)
134     {
135         addAttribute("data",url);
136         return(this);
137     }
138
139     /**
140         This attribute specifies the Internet Media Type for the data specified by data.<br>
141         This should be a mime type.
142         @param type a mime type for the data specifed by the data attribute.
143     */

144     public ObjectElement setType(String JavaDoc type)
145     {
146         addAttribute("type",type);
147         return(this);
148     }
149
150     /**
151         Space seperated archive list.
152         @param url Space seperate archive list.
153     */

154     // Anyone know what the hell this is? the spec is rather vague in its definition.
155
public ObjectElement setArchive(String JavaDoc url)
156     {
157         addAttribute("archive",url);
158         return(this);
159     }
160
161     /**
162         Message to show while the object is loading.
163         @param cdata the message to show while the object is loading.
164     */

165     public ObjectElement setStandBy(String JavaDoc cdata)
166     {
167         addAttribute("standby",cdata);
168         return(this);
169     }
170
171     /**
172         Suggested link border width.
173         @param border suggested link border width.
174     */

175     public ObjectElement setBorder(String JavaDoc border)
176     {
177         addAttribute("border",border);
178         return(this);
179     }
180
181     /**
182         Suggested link border width.
183         @param border suggested link border width.
184     */

185     public ObjectElement setBorder(int border)
186     {
187         addAttribute("border",Integer.toString(border));
188         return(this);
189     }
190
191     /**
192         Suggested link border width.
193         @param border suggested link border width.
194     */

195     public ObjectElement setBorder(double border)
196     {
197         addAttribute("border",Double.toString(border));
198         return(this);
199     }
200
201     /**
202         Suggested height of object.
203         @param height suggested link height.
204     */

205     public ObjectElement setHeight(String JavaDoc height)
206     {
207         addAttribute("height",height);
208         return(this);
209     }
210
211     /**
212         Suggested height of object.
213         @param height suggested link height.
214     */

215     public ObjectElement setHeight(int height)
216     {
217         addAttribute("height",Integer.toString(height));
218         return(this);
219     }
220
221     /**
222         Suggested height of object.
223         @param height suggested link height.
224     */

225     public ObjectElement setHeight(double height)
226     {
227         addAttribute("height",Double.toString(height));
228         return(this);
229     }
230
231     /**
232         Suggested width of object.
233         @param height suggested link width.
234     */

235     public ObjectElement setWidth(String JavaDoc width)
236     {
237         addAttribute("width",width);
238         return(this);
239     }
240
241     /**
242         Suggested width of object.
243         @param height suggested link width.
244     */

245     public ObjectElement setWidth(int width)
246     {
247         addAttribute("width",Integer.toString(width));
248         return(this);
249     }
250
251     /**
252         Suggested width of object.
253         @param height suggested link width.
254     */

255     public ObjectElement setWidth(double width)
256     {
257         addAttribute("width",Double.toString(width));
258         return(this);
259     }
260
261     /**
262         Suggested horizontal gutter.
263         @param hspace suggested horizontal gutter.
264     */

265     public ObjectElement setHSpace(String JavaDoc hspace)
266     {
267         addAttribute("hspace",hspace);
268         return(this);
269     }
270
271     /**
272         Suggested horizontal gutter.
273         @param hspace suggested horizontal gutter.
274     */

275     public ObjectElement setHSpace(int hspace)
276     {
277         addAttribute("hspace",Integer.toString(hspace));
278         return(this);
279     }
280
281     /**
282         Suggested horizontal gutter.
283         @param hspace suggested horizontal gutter.
284     */

285     public ObjectElement setHSpace(double hspace)
286     {
287         addAttribute("hspace",Double.toString(hspace));
288         return(this);
289     }
290
291     /**
292         Suggested vertical gutter.
293         @param hspace suggested vertical gutter.
294     */

295     public ObjectElement setVSpace(String JavaDoc vspace)
296     {
297         addAttribute("vspace",vspace);
298         return(this);
299     }
300
301     /**
302         Suggested vertical gutter.
303         @param hspace suggested vertical gutter.
304     */

305     public ObjectElement setVSpace(int vspace)
306     {
307         addAttribute("vspace",Integer.toString(vspace));
308         return(this);
309     }
310
311     /**
312         Suggested vertical gutter.
313         @param hspace suggested vertical gutter.
314     */

315     public ObjectElement setVSpace(double vspace)
316     {
317         addAttribute("vspace",Double.toString(vspace));
318         return(this);
319     }
320
321     /**
322         Set the horizontal or vertical alignment of this object.<br>
323         Convience variables are in the AlignTypes interface.
324         @param alignment Set the horizontal or vertical alignment of this object.<br>
325         Convience variables are in the AlignTypes interface.
326     */

327     public ObjectElement setAlign(String JavaDoc alignment)
328     {
329         addAttribute("align",alignment);
330         return(this);
331     }
332
333     /**
334         Location of image map to use.
335         @param url location of image map to use.
336     */

337     public ObjectElement setUseMap(String JavaDoc url)
338     {
339         addAttribute("usemap",url);
340         return(this);
341     }
342
343     /**
344         Object has shaped hypertext links.
345         @param shape does the object have shaped hypertext links?
346     */

347     public ObjectElement setShapes(boolean shape)
348     {
349         if(shape)
350             addAttribute("shapes",NO_ATTRIBUTE_VALUE);
351         else
352             removeAttribute("shapes");
353         return(this);
354     }
355
356     /**
357         Set the name of this object.
358         @param name set the name of this object.
359     */

360     public ObjectElement setName(String JavaDoc name)
361     {
362         addAttribute("name",name);
363         return(this);
364     }
365
366     /**
367         Set the elements position in the tabbing order.
368         @param number set the elements position in the tabbing order.
369     */

370     public ObjectElement setTabIndex(int number)
371     {
372         addAttribute("tabindex",Integer.toString(number));
373         return(this);
374     }
375
376     /**
377         Set the elements position in the tabbing order.
378         @param number set the elements position in the tabbing order.
379     */

380     public ObjectElement setTabIndex(String JavaDoc number)
381     {
382         addAttribute("tabindex",number);
383         return(this);
384     }
385
386     /**
387         Adds an Element to the element.
388         @param hashcode name of element for hash table
389         @param element Adds an Element to the element.
390      */

391     public ObjectElement addElement(String JavaDoc hashcode,Element element)
392     {
393         addElementToRegistry(hashcode,element);
394         return(this);
395     }
396
397     /**
398         Adds an Element to the element.
399         @param hashcode name of element for hash table
400         @param element Adds an Element to the element.
401      */

402     public ObjectElement addElement(String JavaDoc hashcode,String JavaDoc element)
403     {
404         addElementToRegistry(hashcode,element);
405         return(this);
406     }
407
408     /**
409         Add an element to the element
410         @param element a string representation of the element
411     */

412     public ObjectElement addElement(String JavaDoc element)
413     {
414         addElementToRegistry(element);
415         return(this);
416     }
417
418     /**
419         Add an element to the element
420         @param element an element to add
421     */

422     public ObjectElement addElement(Element element)
423     {
424         addElementToRegistry(element);
425         return(this);
426     }
427     /**
428         Removes an Element from the element.
429         @param hashcode the name of the element to be removed.
430     */

431     public ObjectElement removeElement(String JavaDoc hashcode)
432     {
433         removeElementFromRegistry(hashcode);
434         return(this);
435     }
436
437     /**
438         The onclick event occurs when the pointing device button is clicked
439         over an element. This attribute may be used with most elements.
440         
441         @param The script
442     */

443     public void setOnClick(String JavaDoc script)
444     {
445         addAttribute ( "onClick", script );
446     }
447     /**
448         The ondblclick event occurs when the pointing device button is double
449         clicked over an element. This attribute may be used with most elements.
450
451         @param The script
452     */

453     public void setOnDblClick(String JavaDoc script)
454     {
455         addAttribute ( "onDblClick", script );
456     }
457     /**
458         The onmousedown event occurs when the pointing device button is pressed
459         over an element. This attribute may be used with most elements.
460
461         @param The script
462     */

463     public void setOnMouseDown(String JavaDoc script)
464     {
465         addAttribute ( "onMouseDown", script );
466     }
467     /**
468         The onmouseup event occurs when the pointing device button is released
469         over an element. This attribute may be used with most elements.
470
471         @param The script
472     */

473     public void setOnMouseUp(String JavaDoc script)
474     {
475         addAttribute ( "onMouseUp", script );
476     }
477     /**
478         The onmouseover event occurs when the pointing device is moved onto an
479         element. This attribute may be used with most elements.
480
481         @param The script
482     */

483     public void setOnMouseOver(String JavaDoc script)
484     {
485         addAttribute ( "onMouseOver", script );
486     }
487     /**
488         The onmousemove event occurs when the pointing device is moved while it
489         is over an element. This attribute may be used with most elements.
490
491         @param The script
492     */

493     public void setOnMouseMove(String JavaDoc script)
494     {
495         addAttribute ( "onMouseMove", script );
496     }
497     /**
498         The onmouseout event occurs when the pointing device is moved away from
499         an element. This attribute may be used with most elements.
500
501         @param The script
502     */

503     public void setOnMouseOut(String JavaDoc script)
504     {
505         addAttribute ( "onMouseOut", script );
506     }
507
508     /**
509         The onkeypress event occurs when a key is pressed and released over an
510         element. This attribute may be used with most elements.
511         
512         @param The script
513     */

514     public void setOnKeyPress(String JavaDoc script)
515     {
516         addAttribute ( "onKeyPress", script );
517     }
518
519     /**
520         The onkeydown event occurs when a key is pressed down over an element.
521         This attribute may be used with most elements.
522         
523         @param The script
524     */

525     public void setOnKeyDown(String JavaDoc script)
526     {
527         addAttribute ( "onKeyDown", script );
528     }
529
530     /**
531         The onkeyup event occurs when a key is released over an element. This
532         attribute may be used with most elements.
533         
534         @param The script
535     */

536     public void setOnKeyUp(String JavaDoc script)
537     {
538         addAttribute ( "onKeyUp", script );
539     }
540 }
541
Popular Tags