KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > wings > header > Link


1 /*
2  * $Id: Link.java,v 1.3 2004/12/01 07:54:08 hengels Exp $
3  * Copyright 2000,2005 wingS development team.
4  *
5  * This file is part of wingS (http://www.j-wings.org).
6  *
7  * wingS is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU Lesser General Public License
9  * as published by the Free Software Foundation; either version 2.1
10  * of the License, or (at your option) any later version.
11  *
12  * Please see COPYING for the complete licence.
13  */

14 package org.wings.header;
15
16 import org.wings.Renderable;
17 import org.wings.SimpleURL;
18 import org.wings.URLResource;
19 import org.wings.io.Device;
20
21 import java.io.IOException JavaDoc;
22
23 /**
24  * @author <a HREF="mailto:hengels@mercatis.de">Holger Engels</a>
25  * @version $Revision: 1.3 $
26  */

27 public class Link implements Renderable {
28     protected String JavaDoc rel = null;
29     protected String JavaDoc rev = null;
30     protected String JavaDoc type = null;
31     protected String JavaDoc target = null;
32     protected URLResource urlSource = null;
33
34     public Link(String JavaDoc rel, String JavaDoc rev, String JavaDoc type,
35                 String JavaDoc target, URLResource urlSource) {
36         this.rel = rel;
37         this.rev = rev;
38         this.type = type;
39         this.target = target;
40         this.urlSource = urlSource;
41     }
42
43     public void setRel(String JavaDoc rel) {
44         this.rel = rel;
45     }
46
47     public String JavaDoc getRel() { return rel; }
48
49     public void setRev(String JavaDoc rev) {
50         this.rev = rev;
51     }
52
53     public String JavaDoc getRev() { return rev; }
54
55     public void setType(String JavaDoc type) {
56         this.type = type;
57     }
58
59     public String JavaDoc getType() { return type; }
60
61     public SimpleURL getURL() { return urlSource.getURL(); }
62
63     public void setTarget(String JavaDoc target) {
64         this.target = target;
65     }
66
67     public String JavaDoc getTarget() { return target; }
68
69     public void write(Device d)
70             throws IOException JavaDoc {
71         d.print("<link");
72         if (rel != null)
73             d.print(" rel=\"" + rel + "\"");
74         if (rev != null)
75             d.print(" rev=\"" + rev + "\"");
76         if (type != null)
77             d.print(" type=\"" + type + "\"");
78         if (target != null)
79             d.print(" target=\"" + target + "\"");
80
81         if (urlSource != null && urlSource.getURL() != null) {
82             d.print(" HREF=\"");
83             urlSource.getURL().write(d);
84             d.print("\"");
85         }
86         d.print("/>");
87     }
88 }
89
90
91
Popular Tags