001: /**
002: * Copyright (c) 2003-2007, David A. Czarnecki
003: * All rights reserved.
004: *
005: * Redistribution and use in source and binary forms, with or without
006: * modification, are permitted provided that the following conditions are met:
007: *
008: * Redistributions of source code must retain the above copyright notice, this list of conditions and the
009: * following disclaimer.
010: * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
011: * following disclaimer in the documentation and/or other materials provided with the distribution.
012: * Neither the name of "David A. Czarnecki" and "blojsom" nor the names of its contributors may be used to
013: * endorse or promote products derived from this software without specific prior written permission.
014: * Products derived from this software may not be called "blojsom", nor may "blojsom" appear in their name,
015: * without prior written permission of David A. Czarnecki.
016: *
017: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
018: * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
019: * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
020: * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
021: * EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
022: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
023: * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
024: * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
025: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
026: * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
027: * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
028: * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
029: * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
030: */package org.blojsom.plugin.syndication.module;
031:
032: import com.sun.syndication.feed.module.ModuleImpl;
033:
034: import java.util.ArrayList;
035: import java.util.List;
036:
037: /**
038: * Implementation of module for parsing blojsom-specific information using ROME
039: *
040: * @author David Czarnecki
041: * @since blojsom 3.0
042: * @version $Id: BlojsomImplementation.java,v 1.5 2007/01/17 02:35:06 czarneckid Exp $
043: */
044: public class BlojsomImplementation extends ModuleImpl implements
045: Blojsom {
046:
047: private String _author;
048: private String _technoratiTags;
049: private String _postSlug;
050: private boolean _allowsComments;
051: private boolean _allowsTrackbacks;
052: private boolean _allowsPingbacks;
053: private List _comments;
054: private List _trackbacks;
055: private List _pingbacks;
056: private List _metadata;
057:
058: public BlojsomImplementation() {
059: super (Blojsom.class, Blojsom.BLOJSOM_URI);
060: }
061:
062: public Class getInterface() {
063: return Blojsom.class;
064: }
065:
066: public void copyFrom(Object object) {
067: Blojsom blojsom = (Blojsom) object;
068:
069: setAuthor(blojsom.getAuthor());
070: setTechnoratiTags(blojsom.getTechnoratiTags());
071: setPostSlug(blojsom.getPostSlug());
072: setAllowsComments(blojsom.getAllowsComments());
073: setAllowsTrackbacks(blojsom.getAllowsTrackbacks());
074: setAllowsPingbacks(blojsom.getAllowsPingbacks());
075:
076: // Process comments
077: List comments = blojsom.getComments();
078: List copiedComments = new ArrayList();
079: for (int i = 0; i < comments.size(); i++) {
080: SimpleComment comment = (SimpleComment) comments.get(i);
081: SimpleComment copiedComment = new SimpleComment();
082: copiedComment.setAuthor(comment.getAuthor());
083: copiedComment.setAuthorEmail(comment.getAuthorEmail());
084: copiedComment.setAuthorURL(comment.getAuthorURL());
085: copiedComment.setComment(comment.getComment());
086: copiedComment.setIp(comment.getIp());
087: copiedComment.setCommentDate(comment.getCommentDate());
088: copiedComment.setStatus(comment.getStatus());
089: copiedComment.setMetadata(comment.getMetadata());
090:
091: copiedComments.add(copiedComment);
092: }
093: setComments(copiedComments);
094:
095: // Process trackbacks
096: List trackbacks = blojsom.getTrackbacks();
097: List copiedTrackbacks = new ArrayList();
098: for (int i = 0; i < trackbacks.size(); i++) {
099: SimpleTrackback trackback = (SimpleTrackback) trackbacks
100: .get(i);
101: SimpleTrackback copiedTrackback = new SimpleTrackback();
102: copiedTrackback.setBlogName(trackback.getBlogName());
103: copiedTrackback.setExcerpt(trackback.getExcerpt());
104: copiedTrackback.setIp(trackback.getIp());
105: copiedTrackback.setStatus(trackback.getStatus());
106: copiedTrackback.setTitle(trackback.getTitle());
107: copiedTrackback.setTrackbackDate(trackback
108: .getTrackbackDate());
109: copiedTrackback.setUrl(trackback.getUrl());
110: copiedTrackback.setMetadata(trackback.getMetadata());
111:
112: copiedTrackbacks.add(copiedTrackback);
113: }
114: setTrackbacks(copiedTrackbacks);
115:
116: // Process pingbacks
117: List pingbacks = blojsom.getPingbacks();
118: List copiedPingbacks = new ArrayList();
119: for (int i = 0; i < pingbacks.size(); i++) {
120: SimplePingback pingback = (SimplePingback) pingbacks.get(i);
121: SimplePingback copiedPingback = new SimplePingback();
122: copiedPingback.setBlogName(pingback.getBlogName());
123: copiedPingback.setExcerpt(pingback.getExcerpt());
124: copiedPingback.setIp(pingback.getIp());
125: copiedPingback.setStatus(pingback.getStatus());
126: copiedPingback.setTitle(pingback.getTitle());
127: copiedPingback.setPingbackDate(pingback.getPingbackDate());
128: copiedPingback.setUrl(pingback.getUrl());
129: copiedPingback.setSourceURI(pingback.getSourceURI());
130: copiedPingback.setTargetURI(pingback.getTargetURI());
131: copiedPingback.setMetadata(pingback.getMetadata());
132:
133: copiedPingbacks.add(copiedPingback);
134: }
135: setPingbacks(copiedPingbacks);
136:
137: // Process metadata
138: List metadata = blojsom.getMetadata();
139: List copiedMetadata = new ArrayList();
140: for (int i = 0; i < metadata.size(); i++) {
141: Metadata metadataItem = (Metadata) metadata.get(i);
142: Metadata copiedMetadataItem = new Metadata();
143: copiedMetadataItem.setKey(metadataItem.getKey());
144: copiedMetadataItem.setValue(metadataItem.getValue());
145:
146: copiedMetadata.add(copiedMetadataItem);
147: }
148: setMetadata(copiedMetadata);
149: }
150:
151: public String getAuthor() {
152: return _author;
153: }
154:
155: public void setAuthor(String author) {
156: _author = author;
157: }
158:
159: public String getTechnoratiTags() {
160: return _technoratiTags;
161: }
162:
163: public void setTechnoratiTags(String technoratiTags) {
164: _technoratiTags = technoratiTags;
165: }
166:
167: public String getPostSlug() {
168: return _postSlug;
169: }
170:
171: public void setPostSlug(String postSlug) {
172: _postSlug = postSlug;
173: }
174:
175: public boolean getAllowsComments() {
176: return _allowsComments;
177: }
178:
179: public void setAllowsComments(boolean allowsComments) {
180: _allowsComments = allowsComments;
181: }
182:
183: public boolean getAllowsTrackbacks() {
184: return _allowsTrackbacks;
185: }
186:
187: public void setAllowsTrackbacks(boolean allowsTrackbacks) {
188: _allowsTrackbacks = allowsTrackbacks;
189: }
190:
191: public boolean getAllowsPingbacks() {
192: return _allowsPingbacks;
193: }
194:
195: public void setAllowsPingbacks(boolean allowsPingbacks) {
196: _allowsPingbacks = allowsPingbacks;
197: }
198:
199: public List getComments() {
200: return _comments;
201: }
202:
203: public void setComments(List comments) {
204: _comments = comments;
205: }
206:
207: public List getTrackbacks() {
208: return _trackbacks;
209: }
210:
211: public void setTrackbacks(List trackbacks) {
212: _trackbacks = trackbacks;
213: }
214:
215: public List getPingbacks() {
216: return _pingbacks;
217: }
218:
219: public void setPingbacks(List pingbacks) {
220: _pingbacks = pingbacks;
221: }
222:
223: public List getMetadata() {
224: return _metadata;
225: }
226:
227: public void setMetadata(List metadata) {
228: _metadata = metadata;
229: }
230:
231: public String getUri() {
232: return Blojsom.BLOJSOM_URI;
233: }
234: }
|