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.module;
018:
019: import com.sun.syndication.feed.impl.CopyFromHelper;
020:
021: import java.util.*;
022:
023: /**
024: * Syndication ModuleImpl, default implementation.
025: * <p>
026: * @see <a href="http://web.resource.org/rss/1.0/modules/syndication/">Syndication module</a>.
027: * @author Alejandro Abdelnur
028: *
029: */
030: public class SyModuleImpl extends ModuleImpl implements SyModule {
031: private static final Set PERIODS = new HashSet();
032:
033: static {
034: PERIODS.add(HOURLY);
035: PERIODS.add(DAILY);
036: PERIODS.add(WEEKLY);
037: PERIODS.add(MONTHLY);
038: PERIODS.add(YEARLY);
039: }
040:
041: private String _updatePeriod;
042: private int _updateFrequency;
043: private Date _updateBase;
044:
045: /**
046: * Default constructor. All properties are set to <b>null</b>.
047: * <p>
048: *
049: */
050: public SyModuleImpl() {
051: super (SyModule.class, URI);
052: }
053:
054: /**
055: * Returns the Syndication module update period.
056: * <p>
057: * @return the Syndication module update period, <b>null</b> if none.
058: *
059: */
060: public String getUpdatePeriod() {
061: return _updatePeriod;
062: }
063:
064: /**
065: * Sets the Syndication module update period.
066: * <p>
067: * @param updatePeriod the Syndication module update period to set, <b>null</b> if none.
068: *
069: */
070: public void setUpdatePeriod(String updatePeriod) {
071: if (!PERIODS.contains(updatePeriod)) {
072: throw new IllegalArgumentException("Invalid period ["
073: + updatePeriod + "]");
074: }
075: _updatePeriod = updatePeriod;
076: }
077:
078: /**
079: * Returns the Syndication module update frequency.
080: * <p>
081: * @return the Syndication module update frequency, <b>null</b> if none.
082: *
083: */
084: public int getUpdateFrequency() {
085: return _updateFrequency;
086: }
087:
088: /**
089: * Sets the Syndication module update frequency.
090: * <p>
091: * @param updateFrequency the Syndication module update frequency to set, <b>null</b> if none.
092: *
093: */
094: public void setUpdateFrequency(int updateFrequency) {
095: _updateFrequency = updateFrequency;
096: }
097:
098: /**
099: * Returns the Syndication module update base date.
100: * <p>
101: * @return the Syndication module update base date, <b>null</b> if none.
102: *
103: */
104: public Date getUpdateBase() {
105: return _updateBase;
106: }
107:
108: /**
109: * Sets the Syndication module update base date.
110: * <p>
111: * @param updateBase the Syndication module update base date to set, <b>null</b> if none.
112: *
113: */
114: public void setUpdateBase(Date updateBase) {
115: _updateBase = updateBase;
116: }
117:
118: public Class getInterface() {
119: return SyModule.class;
120: }
121:
122: public void copyFrom(Object obj) {
123: COPY_FROM_HELPER.copy(this , obj);
124: }
125:
126: private static final CopyFromHelper COPY_FROM_HELPER;
127:
128: static {
129: Map basePropInterfaceMap = new HashMap();
130: basePropInterfaceMap.put("updatePeriod", String.class);
131: basePropInterfaceMap.put("updateFrequency", Integer.TYPE);
132: basePropInterfaceMap.put("updateBase", Date.class);
133:
134: Map basePropClassImplMap = Collections.EMPTY_MAP;
135:
136: COPY_FROM_HELPER = new CopyFromHelper(SyModule.class,
137: basePropInterfaceMap, basePropClassImplMap);
138: }
139:
140: }
|