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  
22  import java.util.Collections;
23  import java.util.HashMap;
24  import java.util.Map;
25  import java.io.Serializable;
26  
27  /***
28   * Bean for content of SyndFeedImpl entries.
29   * <p>
30   * @author Alejandro Abdelnur
31   *
32   */
33  public class SyndContentImpl implements Serializable,SyndContent {
34      private ObjectBean _objBean;
35      private String _type;
36      private String _value;
37  
38  
39      /***
40       * Default constructor. All properties are set to <b>null</b>.
41       * <p>
42       *
43       */
44      public SyndContentImpl() {
45          _objBean = new ObjectBean(SyndContent.class,this);
46      }
47  
48      /***
49       * Creates a deep 'bean' clone of the object.
50       * <p>
51       * @return a clone of the object.
52       * @throws CloneNotSupportedException thrown if an element of the object cannot be cloned.
53       *
54       */
55      public Object clone() throws CloneNotSupportedException {
56          return _objBean.clone();
57      }
58  
59      /***
60       * Indicates whether some other object is "equal to" this one as defined by the Object equals() method.
61       * <p>
62       * @param other he reference object with which to compare.
63       * @return <b>true</b> if 'this' object is equal to the 'other' object.
64       *
65       */
66      public boolean equals(Object other) {
67          return _objBean.equals(other);
68      }
69  
70      /***
71       * Returns a hashcode value for the object.
72       * <p>
73       * It follows the contract defined by the Object hashCode() method.
74       * <p>
75       * @return the hashcode of the bean object.
76       *
77       */
78      public int hashCode() {
79          return _objBean.hashCode();
80      }
81  
82      /***
83       * Returns the String representation for the object.
84       * <p>
85       * @return String representation for the object.
86       *
87       */
88      public String toString() {
89          return _objBean.toString();
90      }
91  
92      /***
93       * Returns the content type.
94       * <p>
95       * When used for the description of an entry, if <b>null</b> 'text/plain' must be assumed.
96       * <p>
97       * @return the content type, <b>null</b> if none.
98       *
99       */
100     public String getType() {
101         return _type;
102     }
103 
104     /***
105      * Sets the content type.
106      * <p>
107      * When used for the description of an entry, if <b>null</b> 'text/plain' must be assumed.
108      * <p>
109      * @param type the content type to set, <b>null</b> if none.
110      *
111      */
112     public void setType(String type) {
113         _type = type;
114     }
115 
116     /***
117      * Returns the content value.
118      * <p>
119      * @return the content value, <b>null</b> if none.
120      *
121      */
122     public String getValue() {
123         return _value;
124     }
125 
126     /***
127      * Sets the content value.
128      * <p>
129      * @param value the content value to set, <b>null</b> if none.
130      *
131      */
132     public void setValue(String value) {
133         _value = value;
134     }
135 
136 
137     public Class getInterface() {
138         return SyndContent.class;
139     }
140 
141     public void copyFrom(Object obj) {
142         COPY_FROM_HELPER.copy(this,obj);
143     }
144 
145     private static final CopyFromHelper COPY_FROM_HELPER;
146 
147     static {
148         Map basePropInterfaceMap = new HashMap();
149         basePropInterfaceMap.put("type",String.class);
150         basePropInterfaceMap.put("value",String.class);
151 
152         Map basePropClassImplMap = Collections.EMPTY_MAP;
153 
154         COPY_FROM_HELPER = new CopyFromHelper(SyndContent.class,basePropInterfaceMap,basePropClassImplMap);
155     }
156 
157 }