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.common.ObjectBean;
20  import com.sun.syndication.common.impl.CopyFromHelper;
21  
22  import java.util.Collections;
23  import java.util.HashMap;
24  import java.util.Map;
25  
26  /***
27   * Bean for content of SyndFeedImpl entries.
28   * <p>
29   * @author Alejandro Abdelnur
30   *
31   */
32  public class SyndContentImpl extends ObjectBean implements SyndContent {
33      private String _type;
34      private String _value;
35  
36  
37      /***
38       * For implementations extending SyndContentImpl to be able to use the ObjectBean functionality
39       * with extended interfaces.
40       * <p>
41       * @param beanClass
42       */
43      protected SyndContentImpl(Class beanClass) {
44          super(beanClass);
45      }
46  
47      /***
48       * Default constructor. All properties are set to <b>null</b>.
49       * <p>
50       *
51       */
52      public SyndContentImpl() {
53          this(SyndContent.class);
54      }
55  
56      /***
57       * Returns the content type.
58       * <p>
59       * When used for the description of an entry, if <b>null</b> 'text/plain' must be assumed.
60       * <p>
61       * @return the content type, <b>null</b> if none.
62       *
63       */
64      public String getType() {
65          return _type;
66      }
67  
68      /***
69       * Sets the content type.
70       * <p>
71       * When used for the description of an entry, if <b>null</b> 'text/plain' must be assumed.
72       * <p>
73       * @param type the content type to set, <b>null</b> if none.
74       *
75       */
76      public void setType(String type) {
77          _type = type;
78      }
79  
80      /***
81       * Returns the content value.
82       * <p>
83       * @return the content value, <b>null</b> if none.
84       *
85       */
86      public String getValue() {
87          return _value;
88      }
89  
90      /***
91       * Sets the content value.
92       * <p>
93       * @param value the content value to set, <b>null</b> if none.
94       *
95       */
96      public void setValue(String value) {
97          _value = value;
98      }
99  
100 
101     public Class getInterface() {
102         return SyndContent.class;
103     }
104 
105     public void copyFrom(Object obj) {
106         COPY_FROM_HELPER.copy(this,obj);
107     }
108 
109     private static final CopyFromHelper COPY_FROM_HELPER;
110 
111     static {
112         Map basePropInterfaceMap = new HashMap();
113         basePropInterfaceMap.put("type",String.class);
114         basePropInterfaceMap.put("value",String.class);
115 
116         Map basePropClassImplMap = Collections.EMPTY_MAP;
117 
118         COPY_FROM_HELPER = new CopyFromHelper(SyndContent.class,basePropInterfaceMap,basePropClassImplMap);
119     }
120 
121 }