001: /*
002: * Copyright 2004 Sun Microsystems, Inc.
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: *
016: */
017: package com.sun.syndication.feed.atom;
018:
019: import com.sun.syndication.feed.impl.ObjectBean;
020:
021: import java.io.Serializable;
022:
023: /**
024: * Bean for link elements of Atom feeds.
025: * <p>
026: * @author Alejandro Abdelnur
027: * @author Dave Johnson (updated for Atom 1.0)
028: */
029: public class Link implements Cloneable, Serializable {
030:
031: private ObjectBean _objBean;
032:
033: private String _href;
034: private String _rel = "alternate";
035: private String _type;
036: private String _hreflang;
037: private String _title;
038: private long _length;
039:
040: /**
041: * Default constructor. All properties are set to <b>null</b>.
042: * <p>
043: *
044: */
045: public Link() {
046: _objBean = new ObjectBean(this .getClass(), this );
047: }
048:
049: /**
050: * Creates a deep 'bean' clone of the object.
051: * <p>
052: * @return a clone of the object.
053: * @throws CloneNotSupportedException thrown if an element of the object cannot be cloned.
054: *
055: */
056: public Object clone() throws CloneNotSupportedException {
057: return _objBean.clone();
058: }
059:
060: /**
061: * Indicates whether some other object is "equal to" this one as defined by the Object equals() method.
062: * <p>
063: * @param other he reference object with which to compare.
064: * @return <b>true</b> if 'this' object is equal to the 'other' object.
065: *
066: */
067: public boolean equals(Object other) {
068: return _objBean.equals(other);
069: }
070:
071: /**
072: * Returns a hashcode value for the object.
073: * <p>
074: * It follows the contract defined by the Object hashCode() method.
075: * <p>
076: * @return the hashcode of the bean object.
077: *
078: */
079: public int hashCode() {
080: return _objBean.hashCode();
081: }
082:
083: /**
084: * Returns the String representation for the object.
085: * <p>
086: * @return String representation for the object.
087: *
088: */
089: public String toString() {
090: return _objBean.toString();
091: }
092:
093: /**
094: * Returns the link rel.
095: * <p>
096: * @return the link rel, <b>null</b> if none.
097: *
098: */
099: 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: }
|