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  import com.sun.syndication.feed.impl.CopyFromHelper;
21  import com.sun.syndication.feed.impl.CopyFromHelper;
22  
23  import java.util.Collections;
24  import java.util.HashMap;
25  import java.util.Map;
26  import java.io.Serializable;
27  
28  /***
29   * Bean for images of SyndFeedImpl feeds.
30   * <p>
31   * @author Alejandro Abdelnur
32   *
33   */
34  public class SyndImageImpl implements Serializable,SyndImage {
35      private ObjectBean _objBean;
36      private String _title;
37      private String _url;
38      private String _link;
39      private String _description;
40  
41      /***
42       * Default constructor. All properties are set to <b>null</b>.
43       * <p>
44       *
45       */
46      public SyndImageImpl() {
47          _objBean = new ObjectBean(SyndImage.class,this);
48      }
49  
50      /***
51       * Creates a deep 'bean' clone of the object.
52       * <p>
53       * @return a clone of the object.
54       * @throws CloneNotSupportedException thrown if an element of the object cannot be cloned.
55       *
56       */
57      public Object clone() throws CloneNotSupportedException {
58          return _objBean.clone();
59      }
60  
61      /***
62       * Indicates whether some other object is "equal to" this one as defined by the Object equals() method.
63       * <p>
64       * @param other he reference object with which to compare.
65       * @return <b>true</b> if 'this' object is equal to the 'other' object.
66       *
67       */
68      public boolean equals(Object other) {
69          return _objBean.equals(other);
70      }
71  
72      /***
73       * Returns a hashcode value for the object.
74       * <p>
75       * It follows the contract defined by the Object hashCode() method.
76       * <p>
77       * @return the hashcode of the bean object.
78       *
79       */
80      public int hashCode() {
81          return _objBean.hashCode();
82      }
83  
84      /***
85       * Returns the String representation for the object.
86       * <p>
87       * @return String representation for the object.
88       *
89       */
90      public String toString() {
91          return _objBean.toString();
92      }
93  
94      /***
95       * Returns the image title.
96       * <p>
97       * @return the image title, <b>null</b> if none.
98       *
99       */
100     public String getTitle() {
101         return _title;
102     }
103 
104     /***
105      * Sets the image title.
106      * <p>
107      * @param title the image title to set, <b>null</b> if none.
108      *
109      */
110     public void setTitle(String title) {
111         _title = title;
112     }
113 
114     /***
115      * Returns the image URL.
116      * <p>
117      * @return the image URL, <b>null</b> if none.
118      *
119      */
120     public String getUrl() {
121         return _url;
122     }
123 
124     /***
125      * Sets the image URL.
126      * <p>
127      * @param url the image URL to set, <b>null</b> if none.
128      *
129      */
130     public void setUrl(String url) {
131         _url = url;
132     }
133 
134     /***
135      * Returns the image link.
136      * <p>
137      * @return the image link, <b>null</b> if none.
138      *
139      */
140     public String getLink() {
141         return _link;
142     }
143 
144     /***
145      * Sets the image link.
146      * <p>
147      * @param link the image link to set, <b>null</b> if none.
148      *
149      */
150     public void setLink(String link) {
151         _link = link;
152     }
153 
154     /***
155      * Returns the image description.
156      * <p>
157      * @return the image description, <b>null</b> if none.
158      *
159      */
160     public String getDescription() {
161         return _description;
162     }
163 
164     /***
165      * Sets the image description.
166      * <p>
167      * @param description the image description to set, <b>null</b> if none.
168      *
169      */
170     public void setDescription(String description) {
171         _description = description;
172     }
173 
174     public Class getInterface() {
175         return SyndImage.class;
176     }
177 
178     public void copyFrom(Object syndImage) {
179         COPY_FROM_HELPER.copy(this,syndImage);
180     }
181 
182     private static final CopyFromHelper COPY_FROM_HELPER;
183 
184     static {
185         Map basePropInterfaceMap = new HashMap();
186         basePropInterfaceMap.put("title",String.class);
187         basePropInterfaceMap.put("url",String.class);
188         basePropInterfaceMap.put("link",String.class);
189         basePropInterfaceMap.put("description",String.class);
190 
191         Map basePropClassImplMap = Collections.EMPTY_MAP;
192 
193         COPY_FROM_HELPER = new CopyFromHelper(SyndImage.class,basePropInterfaceMap,basePropClassImplMap);
194     }
195 
196 }