KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > syndication > feed > module > SyModuleImpl


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.module;
18
19 import com.sun.syndication.feed.impl.CopyFromHelper;
20
21 import java.util.*;
22
23 /**
24  * Syndication ModuleImpl, default implementation.
25  * <p>
26  * @see <a HREF="http://web.resource.org/rss/1.0/modules/syndication/">Syndication module</a>.
27  * @author Alejandro Abdelnur
28  *
29  */

30 public class SyModuleImpl extends ModuleImpl implements SyModule {
31     private static final Set PERIODS = new HashSet();
32
33     static {
34         PERIODS.add(HOURLY );
35         PERIODS.add(DAILY );
36         PERIODS.add(WEEKLY );
37         PERIODS.add(MONTHLY);
38         PERIODS.add(YEARLY );
39     }
40
41
42     private String JavaDoc _updatePeriod;
43     private int _updateFrequency;
44     private Date _updateBase;
45
46     /**
47      * Default constructor. All properties are set to <b>null</b>.
48      * <p>
49      *
50      */

51     public SyModuleImpl() {
52         super(SyModule.class,URI);
53     }
54
55     /**
56      * Returns the Syndication module update period.
57      * <p>
58      * @return the Syndication module update period, <b>null</b> if none.
59      *
60      */

61     public String JavaDoc getUpdatePeriod() {
62         return _updatePeriod;
63     }
64
65     /**
66      * Sets the Syndication module update period.
67      * <p>
68      * @param updatePeriod the Syndication module update period to set, <b>null</b> if none.
69      *
70      */

71     public void setUpdatePeriod(String JavaDoc updatePeriod) {
72         if (!PERIODS.contains(updatePeriod)) {
73             throw new IllegalArgumentException JavaDoc("Invalid period ["+updatePeriod+"]");
74         }
75         _updatePeriod = updatePeriod;
76     }
77
78     /**
79      * Returns the Syndication module update frequency.
80      * <p>
81      * @return the Syndication module update frequency, <b>null</b> if none.
82      *
83      */

84     public int getUpdateFrequency() {
85         return _updateFrequency;
86     }
87
88     /**
89      * Sets the Syndication module update frequency.
90      * <p>
91      * @param updateFrequency the Syndication module update frequency to set, <b>null</b> if none.
92      *
93      */

94     public void setUpdateFrequency(int updateFrequency) {
95         _updateFrequency = updateFrequency;
96     }
97
98     /**
99      * 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 JavaDoc getInterface() {
119         return SyModule.class;
120     }
121
122     public void copyFrom(Object JavaDoc 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 JavaDoc.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,basePropInterfaceMap,basePropClassImplMap);
137     }
138
139 }
140
Popular Tags