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.ObjectBean;
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 content of SyndFeedImpl entries.
30   * <p>
31   * @author Alejandro Abdelnur
32   *
33   */
34  public class SyndContentImpl implements Serializable,SyndContent {
35      private ObjectBean _objBean;
36      private String _type;
37      private String _value;
38  
39  
40      /***
41       * Default constructor. All properties are set to <b>null</b>.
42       * <p>
43       *
44       */
45      public SyndContentImpl() {
46          _objBean = new ObjectBean(SyndContent.class,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 content type.
95       * <p>
96       * When used for the description of an entry, if <b>null</b> 'text/plain' must be assumed.
97       * <p>
98       * @return the content type, <b>null</b> if none.
99       *
100      */
101     public String getType() {
102         return _type;
103     }
104 
105     /***
106      * Sets the content type.
107      * <p>
108      * When used for the description of an entry, if <b>null</b> 'text/plain' must be assumed.
109      * <p>
110      * @param type the content type to set, <b>null</b> if none.
111      *
112      */
113     public void setType(String type) {
114         _type = type;
115     }
116 
117     /***
118      * Returns the content value.
119      * <p>
120      * @return the content value, <b>null</b> if none.
121      *
122      */
123     public String getValue() {
124         return _value;
125     }
126 
127     /***
128      * Sets the content value.
129      * <p>
130      * @param value the content value to set, <b>null</b> if none.
131      *
132      */
133     public void setValue(String value) {
134         _value = value;
135     }
136 
137 
138     public Class getInterface() {
139         return SyndContent.class;
140     }
141 
142     public void copyFrom(Object obj) {
143         COPY_FROM_HELPER.copy(this,obj);
144     }
145 
146     private static final CopyFromHelper COPY_FROM_HELPER;
147 
148     static {
149         Map basePropInterfaceMap = new HashMap();
150         basePropInterfaceMap.put("type",String.class);
151         basePropInterfaceMap.put("value",String.class);
152 
153         Map basePropClassImplMap = Collections.EMPTY_MAP;
154 
155         COPY_FROM_HELPER = new CopyFromHelper(SyndContent.class,basePropInterfaceMap,basePropClassImplMap);
156     }
157 
158 }