1 /*
2 * Copyright 2004 Sun Microsystems, Inc.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 */
17 package com.sun.syndication.feed.atom;
18
19 import com.sun.syndication.feed.impl.ObjectBean;
20
21 import java.io.Serializable;
22
23 /**
24 * Bean for link elements of Atom feeds.
25 * <p>
26 * @author Alejandro Abdelnur
27 * @author Dave Johnson (updated for Atom 1.0)
28 */
29 public class Link implements Cloneable,Serializable {
30
31 private ObjectBean _objBean;
32
33 private String _href;
34 private String _rel = "alternate";
35 private String _type;
36 private String _hreflang;
37 private String _title;
38 private long _length;
39
40 /**
41 * Default constructor. All properties are set to <b>null</b>.
42 * <p>
43 *
44 */
45 public Link() {
46 _objBean = new ObjectBean(this.getClass(),this);
47 }
48
49 /**
50 * Creates a deep 'bean' clone of the object.
51 * <p>
52 * @return a clone of the object.
53 * @throws CloneNotSupportedException thrown if an element of the object cannot be cloned.
54 *
55 */
56 public Object clone() throws CloneNotSupportedException {
57 return _objBean.clone();
58 }
59
60 /**
61 * Indicates whether some other object is "equal to" this one as defined by the Object equals() method.
62 * <p>
63 * @param other he reference object with which to compare.
64 * @return <b>true</b> if 'this' object is equal to the 'other' object.
65 *
66 */
67 public boolean equals(Object other) {
68 return _objBean.equals(other);
69 }
70
71 /**
72 * Returns a hashcode value for the object.
73 * <p>
74 * It follows the contract defined by the Object hashCode() method.
75 * <p>
76 * @return the hashcode of the bean object.
77 *
78 */
79 public int hashCode() {
80 return _objBean.hashCode();
81 }
82
83 /**
84 * Returns the String representation for the object.
85 * <p>
86 * @return String representation for the object.
87 *
88 */
89 public String toString() {
90 return _objBean.toString();
91 }
92
93 /**
94 * Returns the link rel.
95 * <p>
96 * @return the link rel, <b>null</b> if none.
97 *
98 */
99 public String getRel() {
100 return _rel;
101 }
102
103 /**
104 * Sets the link rel.
105 * <p>
106 * @param rel the link rel,, <b>null</b> if none.
107 *
108 */
109 public void setRel(String rel) {
110 //TODO add check, ask P@ about the check
111 _rel = rel;
112 }
113
114 /**
115 * Returns the link type.
116 * <p>
117 * @return the link type, <b>null</b> if none.
118 *
119 */
120 public String getType() {
121 return _type;
122 }
123
124 /**
125 * Sets the link type.
126 * <p>
127 * @param type the link type, <b>null</b> if none.
128 *
129 */
130 public void setType(String type) {
131 _type = type;
132 }
133
134 /**
135 * Returns the link href.
136 * <p>
137 * @return the link href, <b>null</b> if none.
138 *
139 */
140 public String getHref() {
141 return _href;
142 }
143
144 /**
145 * Sets the link href.
146 * <p>
147 * @param href the link href, <b>null</b> if none.
148 *
149 */
150 public void setHref(String href) {
151 _href = href;
152 }
153
154 /**
155 * Returns the link title.
156 * <p>
157 * @return the link title, <b>null</b> if none.
158 *
159 */
160 public String getTitle() {
161 return _title;
162 }
163
164 /**
165 * Sets the link title.
166 * <p>
167 * @param title the link title, <b>null</b> if none.
168 *
169 */
170 public void setTitle(String title) {
171 _title = title;
172 }
173
174 /**
175 * Returns the hreflang
176 * <p>
177 * @return Returns the hreflang.
178 * @since Atom 1.0
179 */
180 public String getHreflang() {
181 return _hreflang;
182 }
183
184 /**
185 * Set the hreflang
186 * <p>
187 * @param hreflang The hreflang to set.
188 * @since Atom 1.0
189 */
190 public void setHreflang(String hreflang) {
191 _hreflang = hreflang;
192 }
193
194 /**
195 * Returns the length
196 * <p>
197 * @return Returns the length.
198 */
199 public long getLength() {
200 return _length;
201 }
202
203 /**
204 * Set the length
205 * <p>
206 * @param length The length to set.
207 */
208 public void setLength(long length) {
209 _length = length;
210 }
211 }