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.synd;
018:
019: import com.sun.syndication.feed.impl.ObjectBean;
020: import com.sun.syndication.feed.impl.CopyFromHelper;
021:
022: import java.util.Collections;
023: import java.util.HashMap;
024: import java.util.Map;
025: import java.io.Serializable;
026:
027: /**
028: * Bean for content of SyndFeedImpl entries.
029: * <p>
030: * @author Alejandro Abdelnur
031: *
032: */
033: public class SyndContentImpl implements Serializable, SyndContent {
034: private ObjectBean _objBean;
035: private String _type;
036: private String _value;
037: private String _mode;
038:
039: /**
040: * Default constructor. All properties are set to <b>null</b>.
041: * <p>
042: *
043: */
044: public SyndContentImpl() {
045: _objBean = new ObjectBean(SyndContent.class, this );
046: }
047:
048: /**
049: * Creates a deep 'bean' clone of the object.
050: * <p>
051: * @return a clone of the object.
052: * @throws CloneNotSupportedException thrown if an element of the object cannot be cloned.
053: *
054: */
055: public Object clone() throws CloneNotSupportedException {
056: return _objBean.clone();
057: }
058:
059: /**
060: * Indicates whether some other object is "equal to" this one as defined by the Object equals() method.
061: * <p>
062: * @param other he reference object with which to compare.
063: * @return <b>true</b> if 'this' object is equal to the 'other' object.
064: *
065: */
066: public boolean equals(Object other) {
067: return _objBean.equals(other);
068: }
069:
070: /**
071: * Returns a hashcode value for the object.
072: * <p>
073: * It follows the contract defined by the Object hashCode() method.
074: * <p>
075: * @return the hashcode of the bean object.
076: *
077: */
078: public int hashCode() {
079: return _objBean.hashCode();
080: }
081:
082: /**
083: * Returns the String representation for the object.
084: * <p>
085: * @return String representation for the object.
086: *
087: */
088: public String toString() {
089: return _objBean.toString();
090: }
091:
092: /**
093: * Returns the content type.
094: * <p>
095: * When used for the description of an entry, if <b>null</b> 'text/plain' must be assumed.
096: * <p>
097: * @return the content type, <b>null</b> if none.
098: *
099: */
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 mode.
118: * @return the content mode, <b>null</b> if none.
119: *
120: */
121: public String getMode() {
122: return _mode;
123: }
124:
125: /**
126: * Sets the content mode.
127: * @param type the content mode to set, <b>null</b> if none.
128: *
129: */
130: public void setMode(String mode) {
131: _mode = mode;
132: }
133:
134: /**
135: * Returns the content value.
136: * <p>
137: * @return the content value, <b>null</b> if none.
138: *
139: */
140: public String getValue() {
141: return _value;
142: }
143:
144: /**
145: * Sets the content value.
146: * <p>
147: * @param value the content value to set, <b>null</b> if none.
148: *
149: */
150: public void setValue(String value) {
151: _value = value;
152: }
153:
154: public Class getInterface() {
155: return SyndContent.class;
156: }
157:
158: public void copyFrom(Object obj) {
159: COPY_FROM_HELPER.copy(this , obj);
160: }
161:
162: private static final CopyFromHelper COPY_FROM_HELPER;
163:
164: static {
165: Map basePropInterfaceMap = new HashMap();
166: basePropInterfaceMap.put("type", String.class);
167: basePropInterfaceMap.put("value", String.class);
168:
169: Map basePropClassImplMap = Collections.EMPTY_MAP;
170:
171: COPY_FROM_HELPER = new CopyFromHelper(SyndContent.class,
172: basePropInterfaceMap, basePropClassImplMap);
173: }
174:
175: }
|