KickJava   Java API By Example, From Geeks To Geeks.

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


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;Link&gt; tag.
64
65     @version $Id: Link.java,v 1.5 2003/04/27 09:22:43 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 Link extends SinglePartElement implements Printable, MouseEvents, KeyEvents
70 {
71
72     /**
73           Private initialization routine.
74      */

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

84     public Link()
85     {
86     }
87
88     public Link setHref(String JavaDoc href)
89     {
90         addAttribute("href",href);
91         return this;
92     }
93
94     /**
95         Sets the TARGET="" attribute
96         @param target the TARGET="" attribute
97     */

98     public Link setTarget(String JavaDoc target)
99     {
100         addAttribute("target",target);
101         return this;
102     }
103
104     /**
105         Sets the REL="" attribute
106         @param rel the REL="" attribute
107     */

108     public Link setRel(String JavaDoc rel)
109     {
110         addAttribute("rel",rel);
111         return this;
112     }
113
114     /**
115         Sets the REV="" attribute
116         @param rev the REV="" attribute
117     */

118     public Link setRev(String JavaDoc rev)
119     {
120         addAttribute("rev",rev);
121         return this;
122     }
123
124     /**
125         Sets the charset="" attribute
126         @param charset the charset="" attribute
127     */

128     public Link setCharset(String JavaDoc charset)
129     {
130         addAttribute("charset",charset);
131         return this;
132     }
133
134     /**
135         Sets the TYPE="" attribute
136         @param type set the mime type of this link
137     */

138     public Link setType(String JavaDoc type)
139     {
140         addAttribute("type",type);
141         return this;
142     }
143
144     /**
145         Sets the media="" attribute
146         @param media the media="" attribute
147     */

148
149     public Link setMedia(String JavaDoc media)
150     {
151         addAttribute("media",media);
152         return this;
153     }
154
155     /**
156         Adds an Element to the element.
157         @param hashcode name of element for hash table
158         @param element Adds an Element to the element.
159      */

160     public Link addElement(String JavaDoc hashcode,Element element)
161     {
162         addElementToRegistry(hashcode,element);
163         return(this);
164     }
165
166     /**
167         Adds an Element to the element.
168         @param hashcode name of element for hash table
169         @param element Adds an Element to the element.
170      */

171     public Link addElement(String JavaDoc hashcode,String JavaDoc element)
172     {
173         addElementToRegistry(hashcode,element);
174         return(this);
175     }
176     /**
177         Adds an Element to the element.
178         @param element Adds an Element to the element.
179      */

180     public Link addElement(Element element)
181     {
182         addElementToRegistry(element);
183         return(this);
184     }
185
186     /**
187         Adds an Element to the element.
188         @param element Adds an Element to the element.
189      */

190     public Link addElement(String JavaDoc element)
191     {
192         addElementToRegistry(element);
193         return(this);
194     }
195     /**
196         Removes an Element from the element.
197         @param hashcode the name of the element to be removed.
198     */

199     public Link removeElement(String JavaDoc hashcode)
200     {
201         removeElementFromRegistry(hashcode);
202         return(this);
203     }
204
205     /**
206         The onclick event occurs when the pointing device button is clicked
207         over an element. This attribute may be used with most elements.
208         
209         @param The script
210     */

211     public void setOnClick(String JavaDoc script)
212     {
213         addAttribute ( "onClick", script );
214     }
215     /**
216         The ondblclick event occurs when the pointing device button is double
217         clicked over an element. This attribute may be used with most elements.
218
219         @param The script
220     */

221     public void setOnDblClick(String JavaDoc script)
222     {
223         addAttribute ( "onDblClick", script );
224     }
225     /**
226         The onmousedown event occurs when the pointing device button is pressed
227         over an element. This attribute may be used with most elements.
228
229         @param The script
230     */

231     public void setOnMouseDown(String JavaDoc script)
232     {
233         addAttribute ( "onMouseDown", script );
234     }
235     /**
236         The onmouseup event occurs when the pointing device button is released
237         over an element. This attribute may be used with most elements.
238
239         @param The script
240     */

241     public void setOnMouseUp(String JavaDoc script)
242     {
243         addAttribute ( "onMouseUp", script );
244     }
245     /**
246         The onmouseover event occurs when the pointing device is moved onto an
247         element. This attribute may be used with most elements.
248
249         @param The script
250     */

251     public void setOnMouseOver(String JavaDoc script)
252     {
253         addAttribute ( "onMouseOver", script );
254     }
255     /**
256         The onmousemove event occurs when the pointing device is moved while it
257         is over an element. This attribute may be used with most elements.
258
259         @param The script
260     */

261     public void setOnMouseMove(String JavaDoc script)
262     {
263         addAttribute ( "onMouseMove", script );
264     }
265     /**
266         The onmouseout event occurs when the pointing device is moved away from
267         an element. This attribute may be used with most elements.
268
269         @param The script
270     */

271     public void setOnMouseOut(String JavaDoc script)
272     {
273         addAttribute ( "onMouseOut", script );
274     }
275
276     /**
277         The onkeypress event occurs when a key is pressed and released over an
278         element. This attribute may be used with most elements.
279         
280         @param The script
281     */

282     public void setOnKeyPress(String JavaDoc script)
283     {
284         addAttribute ( "onKeyPress", script );
285     }
286
287     /**
288         The onkeydown event occurs when a key is pressed down over an element.
289         This attribute may be used with most elements.
290         
291         @param The script
292     */

293     public void setOnKeyDown(String JavaDoc script)
294     {
295         addAttribute ( "onKeyDown", script );
296     }
297
298     /**
299         The onkeyup event occurs when a key is released over an element. This
300         attribute may be used with most elements.
301         
302         @param The script
303     */

304     public void setOnKeyUp(String JavaDoc script)
305     {
306         addAttribute ( "onKeyUp", script );
307     }
308 }
309
Popular Tags