View Javadoc

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.synd;
18  
19  import com.sun.syndication.feed.impl.ObjectBean;
20  
21  import java.io.Serializable;
22  
23  /**
24   * Represents a link or an enclosure.
25   * <p>
26   * @author Alejandro Abdelnur
27   * @author Dave Johnson (updated for Atom 1.0)
28   */
29  public class SyndLinkImpl implements Cloneable,Serializable, SyndLink {
30      
31      private ObjectBean _objBean;
32      
33      private String _href;
34      private String _rel;
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 SyndLinkImpl() {
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      */
179     public String getHreflang() {
180         return _hreflang;
181     }
182     
183     /**
184      * Set the hreflang
185      * <p>
186      * @param hreflang The hreflang to set.
187      */
188     public void setHreflang(String hreflang) {
189         _hreflang = hreflang;
190     }
191     
192     /**
193      * Returns the length
194      * <p>
195      * @return Returns the length.
196      */
197     public long getLength() {
198         return _length;
199     }
200     
201     /**
202      * Set the length
203      * <p>
204      * @param length The length to set.
205      */
206     public void setLength(long length) {
207         _length = length;
208     }
209 }