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.module;
18  
19  import com.sun.syndication.feed.impl.CopyFromHelper;
20  import com.sun.syndication.feed.impl.CopyFromHelper;
21  
22  import java.util.*;
23  
24  /***
25   * Syndication ModuleImpl, default implementation.
26   * <p>
27   * @see <a href="http://web.resource.org/rss/1.0/modules/syndication/">Syndication module</a>.
28   * @author Alejandro Abdelnur
29   *
30   */
31  public class SyModuleImpl extends ModuleImpl implements SyModule {
32      private static final Set PERIODS = new HashSet();
33  
34      static {
35          PERIODS.add(HOURLY );
36          PERIODS.add(DAILY  );
37          PERIODS.add(WEEKLY );
38          PERIODS.add(MONTHLY);
39          PERIODS.add(YEARLY );
40      }
41  
42  
43      private String _updatePeriod;
44      private int _updateFrequency;
45      private Date _updateBase;
46  
47      /***
48       * Default constructor. All properties are set to <b>null</b>.
49       * <p>
50       *
51       */
52      public SyModuleImpl() {
53          super(SyModule.class,URI);
54      }
55  
56      /***
57       * Returns the Syndication module update period.
58       * <p>
59       * @return the Syndication module update period, <b>null</b> if none.
60       *
61       */
62      public String getUpdatePeriod() {
63          return _updatePeriod;
64      }
65  
66      /***
67       * Sets the Syndication module update period.
68       * <p>
69       * @param updatePeriod the Syndication module update period to set, <b>null</b> if none.
70       *
71       */
72      public void setUpdatePeriod(String updatePeriod) {
73          if (!PERIODS.contains(updatePeriod)) {
74              throw new IllegalArgumentException("Invalid period ["+updatePeriod+"]");
75          }
76          _updatePeriod = updatePeriod;
77      }
78  
79      /***
80       * Returns the Syndication module update frequency.
81       * <p>
82       * @return the Syndication module update frequency, <b>null</b> if none.
83       *
84       */
85      public int getUpdateFrequency() {
86          return _updateFrequency;
87      }
88  
89      /***
90       * Sets the Syndication module update frequency.
91       * <p>
92       * @param updateFrequency the Syndication module update frequency to set, <b>null</b> if none.
93       *
94       */
95      public void setUpdateFrequency(int updateFrequency) {
96          _updateFrequency = updateFrequency;
97      }
98  
99      /***
100      * Returns the Syndication module update base date.
101      * <p>
102      * @return the Syndication module update base date, <b>null</b> if none.
103      *
104      */
105     public Date getUpdateBase() {
106         return _updateBase;
107     }
108 
109     /***
110      * Sets the Syndication module update base date.
111      * <p>
112      * @param updateBase the Syndication module update base date to set, <b>null</b> if none.
113      *
114      */
115     public void setUpdateBase(Date updateBase) {
116         _updateBase = updateBase;
117     }
118 
119     public Class getInterface() {
120         return SyModule.class;
121     }
122 
123     public void copyFrom(Object obj) {
124         COPY_FROM_HELPER.copy(this,obj);
125     }
126 
127     private static final CopyFromHelper COPY_FROM_HELPER;
128 
129     static {
130         Map basePropInterfaceMap = new HashMap();
131         basePropInterfaceMap.put("updatePeriod",String.class);
132         basePropInterfaceMap.put("updateFrequency",Integer.TYPE);
133         basePropInterfaceMap.put("updateBase",Date.class);
134 
135         Map basePropClassImplMap = Collections.EMPTY_MAP;
136 
137         COPY_FROM_HELPER = new CopyFromHelper(SyModule.class,basePropInterfaceMap,basePropClassImplMap);
138     }
139 
140 }