You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@marmotta.apache.org by ja...@apache.org on 2014/01/08 16:25:35 UTC
[19/51] [abbrv] [partial] MARMOTTA-397: Reorganized and renamed
Marmotta Sesame Tools
http://git-wip-us.apache.org/repos/asf/marmotta/blob/00c22e7c/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/org/rometools/feed/module/sse/modules/History.java
----------------------------------------------------------------------
diff --git a/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/org/rometools/feed/module/sse/modules/History.java b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/org/rometools/feed/module/sse/modules/History.java
new file mode 100644
index 0000000..6bd6c3d
--- /dev/null
+++ b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/org/rometools/feed/module/sse/modules/History.java
@@ -0,0 +1,112 @@
+package org.rometools.feed.module.sse.modules;
+
+import com.sun.syndication.feed.CopyFrom;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * <pre><sx:history></pre>Element within <pre><sx:sync></pre>.
+ */
+public class History extends SSEModule {
+ // A date-time attribute.
+ private Date when;
+
+ // A string attribute.
+ private String by;
+
+ public static final String NAME = "history";
+
+ public static final String WHEN_ATTRIBUTE = "when";
+ public static final String BY_ATTRIBUTE = "by";
+
+ private List updates;
+
+ public History() {
+ }
+
+ public void copyFrom(CopyFrom other) {
+ History otherHistory = (History)other;
+ when = otherHistory.when == null ? null : (Date) otherHistory.when.clone();
+ // dont copy immutable
+ by = otherHistory.by;
+
+ if (otherHistory.updates != null) {
+ updates = new ArrayList();
+ updates.addAll(otherHistory.updates);
+ }
+ }
+
+ /**
+ * Get the date-time when the most recent modification took place.
+ * <p/>
+ * This is the date-time when the most recent modification took place. If this attribute is omitted the value
+ * defaults to the earliest time representable in RFC 822.
+ *
+ * @return the date-time when the most recent modification took place.
+ */
+ public Date getWhen() {
+ // TODO: convert to the earliest time in RFC 822 (which is what?)
+ return when;
+ }
+
+ /**
+ * Set the date-time when the most recent modification took place.
+ * <p/>
+ * Either or both of the when or by attributes MUST be present; it is invalid to have neither.
+ *
+ * @param when the date-time when the most recent modification took place.
+ */
+ public void setWhen(Date when) {
+ this.when = when;
+ }
+
+ /**
+ * Provides access to a text attribute identifying the unique endpoint that made the most recent modification. This
+ * SHOULD be some combination of user and device (so that a given user can edit a feed on multiple devices). This
+ * attribute is used programmatically to break ties in case two changes happened at the same time (within the same
+ * second).
+ * <p/>
+ * Either or both of the when or by must be present; it is invalid to have neither.
+ * <p/>
+ * If this attribute is omitted the value defaults to the empty string (which must be less than all other values for
+ * purposes of collation).
+ *
+ * @return A text attribute identifying the unique endpoint that made the most recent modification.
+ */
+ public String getBy() {
+ return by;
+ }
+
+ /**
+ * Sets the endpoint that made the most recent modification.
+ * <p/>
+ * Either or both of the when or by attributes MUST be present; it is invalid to have neither.
+ *
+ * @param by the endpoint that made the most recent modification.
+ */
+ public void setBy(String by) {
+ this.by = by;
+ }
+
+ /**
+ * Add an update to this history
+ *
+ * @param update an update to add to the list of updates for this history.
+ */
+ public void addUpdate(Update update) {
+ if (updates == null) {
+ updates = new ArrayList();
+ }
+ updates.add(update);
+ }
+
+ /**
+ * Return the list of updates for this history.
+ *
+ * @return the list of updates for this history.
+ */
+ public List getUpdates() {
+ return updates;
+ }
+}
http://git-wip-us.apache.org/repos/asf/marmotta/blob/00c22e7c/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/org/rometools/feed/module/sse/modules/Related.java
----------------------------------------------------------------------
diff --git a/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/org/rometools/feed/module/sse/modules/Related.java b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/org/rometools/feed/module/sse/modules/Related.java
new file mode 100644
index 0000000..69f56df
--- /dev/null
+++ b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/org/rometools/feed/module/sse/modules/Related.java
@@ -0,0 +1,147 @@
+package org.rometools.feed.module.sse.modules;
+
+import com.sun.syndication.feed.CopyFrom;
+import java.util.Date;
+
+/**
+ * <pre><sx:related></pre>Element within <pre><sx:sharing></pre>.
+ */
+public class Related extends SSEModule {
+ public static final String NAME = "related";
+
+ /**
+ * Indicates whether the link points to a file containing the complete collection of items for
+ * this feed.
+ */
+ public static final int COMPLETE = 0;
+
+ /**
+ * Indicates whether the link points to a feed whose contents are being incorporated into this
+ * feed by the publisher.
+ */
+ public static final int AGGREGATED = 1;
+
+ // url for related feeds
+ private String link;
+ // name or description of the related feed
+ private String title;
+ // the type of the relation "complete" or "aggregated"
+ private Integer type;
+ // starting point of the related feed
+ private Date since;
+ // ending point of a feed
+ private Date until;
+
+ public static final String LINK_ATTRIBUTE = "link";
+ public static final String SINCE_ATTRIBUTE = "since";
+ public static final String TITLE_ATTRIBUTE = "title";
+ public static final String TYPE_ATTRIBUTE = "type";
+ public static final String UNTIL_ATTRIBUTE = "until";
+
+ public void copyFrom(CopyFrom obj) {
+ Related related = (Related)obj;
+ related.link = link;
+ related.since = since == null ? null : (Date) since.clone();
+ related.title = title;
+ related.type = type;
+ related.until = until == null ? null : (Date) until.clone();
+ }
+
+ /**
+ * link A required, URL attribute. The URL for related feeds.
+ *
+ * @return the URL for related feeds
+ */
+ // TODO: use a java.net.URL?
+ public String getLink() {
+ return link;
+ }
+
+ /**
+ * Set the URL for related feeds.
+ *
+ * @param link the URL for related feeds.
+ */
+ public void setLink(String link) {
+ this.link = link;
+ }
+
+
+ /**
+ * title An optional, string attribute. The name or description of the related feed.
+ *
+ * @return The name or description of the related feed.
+ */
+ public String getTitle() {
+ return title;
+ }
+
+ /**
+ * Set the name or description of the related feed.
+ *
+ * @param title the name or description of the related feed.
+ */
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ /**
+ * type A required, string attribute. This attribute can have one of the following values:
+ * <p>
+ * "complete" if the link points to file containing the complete collection of items for this feed.
+ * <p>
+ * "aggregated" if the link points to a feed whose contents are being incorporated into this feed
+ * by the publisher.
+ *
+ * @return the type of the releated feed.
+ */
+ public Integer getType() {
+ return type;
+ }
+
+ /**
+ * Set the type of relationship, complete or aggregated.
+ *
+ * @param type the type of relationship, complete or aggregated.
+ */
+ public void setType(Integer type) {
+ this.type = type;
+ }
+
+ /**
+ * An optional, date-time attribute. This is the starting point of the related feed. If this attribute
+ * is omitted or blank, it is assumed that this is a complete feed.
+ *
+ * @return the starting point of the related feed.
+ */
+ public Date getSince() {
+ return since;
+ }
+
+ /**
+ * Set the starting point of the related feed.
+ *
+ * @param since the starting point of the related feed.
+ */
+ public void setSince(Date since) {
+ this.since = since;
+ }
+
+ /**
+ * An optional, date-time attribute. This is the ending point of a feed.
+ *
+ * @return the ending point of the feed, until.
+ */
+ public Date getUntil() {
+ return until;
+ }
+
+ /**
+ * Set the ending point of the feed, until. An optional, date-time attribute.
+ *
+ * @param until the ending point of the feed.
+ */
+ public void setUntil(Date until) {
+ this.until = until;
+ }
+}
http://git-wip-us.apache.org/repos/asf/marmotta/blob/00c22e7c/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/org/rometools/feed/module/sse/modules/SSEModule.java
----------------------------------------------------------------------
diff --git a/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/org/rometools/feed/module/sse/modules/SSEModule.java b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/org/rometools/feed/module/sse/modules/SSEModule.java
new file mode 100644
index 0000000..d88b2dd
--- /dev/null
+++ b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/org/rometools/feed/module/sse/modules/SSEModule.java
@@ -0,0 +1,54 @@
+package org.rometools.feed.module.sse.modules;
+
+import com.sun.syndication.feed.CopyFrom;
+import com.sun.syndication.feed.module.Module;
+import org.jdom2.Namespace;
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * The base module for SSE data synchronization. Defines a namespace, uri, and basic
+ * copying operations.
+ */
+public abstract class SSEModule implements Module {
+ public static final String SSE_SCHEMA_URI = "http://www.microsoft.com/schemas/rss/sse";
+
+ // a default prefix to use for sse tags
+ public static final String PREFIX = "sx";
+ public static final Namespace SSE_NS = Namespace.getNamespace(PREFIX, SSE_SCHEMA_URI);
+
+ public static final Set NAMESPACES;
+
+ static {
+ Set nss = new HashSet();
+ nss.add(SSEModule.SSE_NS);
+ NAMESPACES = Collections.unmodifiableSet(nss);
+ }
+
+ public String getUri() {
+ return SSE_SCHEMA_URI;
+ }
+
+ public Class getInterface() {
+ return getClass();
+ }
+
+ public Object clone() {
+ SSEModule clone = null;
+ try {
+ clone = (SSEModule) this.getClass().newInstance();
+ clone.copyFrom(this);
+ } catch (InstantiationException e) {
+ // TODO: use logging
+ e.printStackTrace();
+ } catch (IllegalAccessException e) {
+ // TODO: use logging
+ e.printStackTrace();
+ }
+ return clone;
+ }
+
+ public abstract void copyFrom(CopyFrom obj);
+}
http://git-wip-us.apache.org/repos/asf/marmotta/blob/00c22e7c/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/org/rometools/feed/module/sse/modules/Sharing.java
----------------------------------------------------------------------
diff --git a/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/org/rometools/feed/module/sse/modules/Sharing.java b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/org/rometools/feed/module/sse/modules/Sharing.java
new file mode 100644
index 0000000..ce11ab4
--- /dev/null
+++ b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/org/rometools/feed/module/sse/modules/Sharing.java
@@ -0,0 +1,138 @@
+package org.rometools.feed.module.sse.modules;
+
+import com.sun.syndication.feed.CopyFrom;
+import java.util.Date;
+
+/**
+ * <pre><sx:sharing></pre>Element within RSS <pre><channel></pre> or OPML <pre><head></pre>.
+ */
+public class Sharing extends SSEModule {
+ public static final String NAME = "sharing";
+
+ public static final String UNTIL_ATTRIBUTE = "until";
+ public static final String SINCE_ATTRIBUTE = "since";
+ public static final String ORDERED_ATTRIBUTE = "ordered";
+ public static final String WINDOW_ATTRIBUTE = "window";
+ public static final String VERSION_ATTRIBUTE = "version";
+
+ public static final String VERSION = "0.91";
+
+ // whether subscribers MUST treat the item list as an ordered set
+ private Boolean ordered;
+ // expresses size of the window of change history kept by the published.
+ private Integer window;
+ // date after which updated items are included in the feed.
+ private Date since;
+ // date after which updated items are not included in the feed.
+
+ // version of the sse in shared channel
+ private String version;
+
+ private Date until;
+ private Related related;
+
+ public void copyFrom(CopyFrom obj) {
+ Sharing sharing = (Sharing)obj;
+ ordered = sharing.ordered;
+ since = sharing.since == null ? null : (Date) sharing.since.clone();
+ window = sharing.window;
+ until = sharing.until == null ? null : (Date) sharing.until.clone();
+ version = sharing.version;
+ }
+
+ /**
+ * ordered An optional, Boolean attribute. If present and its value is "true" (lower-case), subscribers MUST treat
+ * the item list as an ordered set (see section 3.2). If this attribute is omitted or blank, it is assumed that this
+ * is an unordered feed.
+ *
+ * @return a Boolean indicating if subscribers must treat the item list as an ordered set.
+ */
+ public Boolean getOrdered() {
+ return ordered;
+ }
+
+ /**
+ * Set whether subscribers MUST tread the item list as an ordered set.
+ *
+ * @param ordered whether subscribers MUST tread the item list as an ordered set.
+ */
+ public void setOrdered(Boolean ordered) {
+ this.ordered = ordered;
+ }
+
+ /**
+ * Provides an Integer that expresses the size of the window of change history kept by the publisher. Subscribers
+ * MAY use this value to determine the frequency with which they must read a feed.
+ *
+ * @return an Integer that expresses the size of the window of change history kept by the publisher.
+ */
+ public Integer getWindow() {
+ return window;
+ }
+
+ /**
+ * Set an Integer that expresses the size of the window of change history kept by the publisher.
+ *
+ * @param window an Integer that expresses the size of the window of change history kept by the publisher.
+ */
+ public void setWindow(Integer window) {
+ this.window = window;
+ }
+
+ /**
+ * since An optional date-time attribute. All items updated on or after this date-time are included in the feed. If
+ * not present or null, the "beginning of time" is assumed and the feed contains the node's complete item set as of
+ * the until date-time.
+ *
+ * @return An optional date-time attribute.
+ */
+ public Date getSince() {
+ return since;
+ }
+
+ /**
+ * Sets the optional date-time attribute where all items updated on or after this date-time are included in the
+ * feed.
+ *
+ * @param since An optional date-time attribute.
+ */
+ public void setSince(Date since) {
+ this.since = since;
+ }
+
+ /**
+ * until An optional date-time attribute. Items updated after this date are not included in the feed. The publisher
+ * must guarantee that the value of until will increase if any items in the feed are updated. If this attribute is
+ * omitted or blank, the subscriber cannot make assumptions about when the feed was updated.
+ *
+ * @return the date where items updated after this date are not included in the feed.
+ */
+ public Date getUntil() {
+ return until;
+ }
+
+ /**
+ * Set the date where items updated after this date are not included in the feed.
+ *
+ * @param until the date where items updated after this date are not included in the feed.
+ */
+ public void setUntil(Date until) {
+ this.until = until;
+ }
+
+ public void setRelated(Related related) {
+ this.related = related;
+ }
+
+ public Related getRelated() {
+ return related;
+ }
+
+ public void setVersion(String version) {
+ this.version = version;
+ }
+
+ public Object getVersion() {
+ return version;
+ }
+}
http://git-wip-us.apache.org/repos/asf/marmotta/blob/00c22e7c/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/org/rometools/feed/module/sse/modules/Sync.java
----------------------------------------------------------------------
diff --git a/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/org/rometools/feed/module/sse/modules/Sync.java b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/org/rometools/feed/module/sse/modules/Sync.java
new file mode 100644
index 0000000..e0db7de
--- /dev/null
+++ b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/org/rometools/feed/module/sse/modules/Sync.java
@@ -0,0 +1,156 @@
+package org.rometools.feed.module.sse.modules;
+
+import com.sun.syndication.feed.CopyFrom;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * <pre><sx:sync></pre>Element within RSS <pre><item></pre> or OPML <pre><outline></pre>.
+ */
+public class Sync extends SSEModule {
+ public static final String NAME = "sync";
+
+ public static final String ID_ATTRIBUTE = "id";
+ public static final String VERSION_ATTRIBUTE = "version";
+ public static final String CONFLICT_ATTRIBUTE = "conflict";
+ public static final String DELETED_ATTRIBUTE = "deleted";
+
+ // item identifier
+ private String id;
+ // item sequence modification number
+ private Integer version;
+ // indication of whether the item is deleted and is a tombstone
+ private Boolean deleted;
+ // an indication of whether there was an update conflict
+ private Boolean conflict;
+
+ private History history;
+ private List conflicts;
+
+ public void copyFrom(CopyFrom obj) {
+ Sync sync = (Sync)obj;
+ deleted = sync.deleted;
+ version = sync.version;
+ conflict = sync.conflict;
+ id = sync.id;
+ history = (sync.history == null ? null : (History)sync.history.clone());
+ if (sync.conflicts != null) {
+ conflicts = new ArrayList();
+ conflicts.addAll(sync.conflicts);
+ }
+ }
+
+ /**
+ * Provides access to the sync id, a required, string attribute. This is the identifier for the item.
+ * <p/>
+ * The ID is assigned by the creator of the item, and MUST NOT be changed by subsequent publishers. Applications
+ * will collate and compare these identifiers, therefore they MUST conform to the syntax for Namespace Specific
+ * Strings (the NSS portion of a URN) in RFC 2141.
+ */
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * Set the identifier for the item. The ID MUST be globally unique within the feed and it MUST be identical across
+ * feeds if an item is being shared or replicated as part of multiple distinct independent feeds.
+ *
+ * @param id the identifier for the item.
+ */
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ /**
+ * Provides access to a required, integer attribute. This is the modification sequence number of the item, starting
+ * at 1 and incrementing by 1 indefinitely for each subsequent modification.
+ */
+ public Integer getVersion() {
+ return version;
+ }
+
+ /**
+ * Set the modification sequence number of the item.
+ *
+ * @param version the modification sequence number of the item.
+ */
+ public void setVersion(Integer version) {
+ this.version = version;
+ }
+
+ /**
+ * Provide access to an optional, Boolean attribute. If present and its value is "true" (lower-case), it indicates
+ * that the item has been deleted and this is a tombstone. If not present, or if present with value of "false" or
+ * "", then the item is not deleted. All other values are invalid.
+ */
+ public Boolean isDeleted() {
+ return deleted;
+ }
+
+ /**
+ * Set an indication of whether this item has been deleted and is a tombstone.
+ *
+ * @param deleted an indication of whether this item has been deleted and is a tombstone.
+ */
+ public void setDeleted(Boolean deleted) {
+ this.deleted = deleted;
+ }
+
+ /**
+ * Provides access to an optional, Boolean conflict attribute. If present and its value is "true" (lower-case), it
+ * indicates there was an update conflict detected when processing an update of this item, and it should potentially
+ * be examined by the user. If not present, or present with value of "false" or "", Then no conflict has been
+ * detected. All other values are invalid.
+ *
+ * @return indicates there was an update conflict detected when processing an update of this item.
+ */
+ public Boolean isConflict() {
+ return conflict;
+ }
+
+ /**
+ * Set an indication of whether there was an update conflict detected when processing an update of this item.
+ *
+ * @param conflict an indication of whether there was an update conflict detected when processing an update of this
+ * item.
+ */
+ public void setConflict(Boolean conflict) {
+ this.conflict = conflict;
+ }
+
+ // TODO: does it make sense for the sync element to have a history?
+ // TODO: should the history be a module?
+
+ /**
+ * The history history for this sync object
+ *
+ * @param history the history for this sync object.
+ */
+ public void setHistory(History history) {
+ this.history = history;
+ }
+
+ /**
+ * Get the history for this sync object
+ *
+ * @return get the history for this sync object.
+ */
+ public History getHistory() {
+ return history;
+ }
+
+ public void addConflict(Conflict conflict) {
+ if (conflicts == null) {
+ conflicts = new ArrayList();
+ }
+ conflicts.add(conflict);
+ }
+
+ public List getConflicts() {
+ return conflicts;
+ }
+
+ public void setConflicts(List conflicts) {
+ this.conflicts = conflicts;
+ }
+}
http://git-wip-us.apache.org/repos/asf/marmotta/blob/00c22e7c/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/org/rometools/feed/module/sse/modules/Update.java
----------------------------------------------------------------------
diff --git a/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/org/rometools/feed/module/sse/modules/Update.java b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/org/rometools/feed/module/sse/modules/Update.java
new file mode 100644
index 0000000..13d39d1
--- /dev/null
+++ b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/org/rometools/feed/module/sse/modules/Update.java
@@ -0,0 +1,62 @@
+package org.rometools.feed.module.sse.modules;
+
+import com.sun.syndication.feed.CopyFrom;
+import java.util.Date;
+
+/**
+ * <pre><sx:update></pre>Element within <pre><sx:history></pre>.
+ */
+public class Update extends SSEModule {
+ public static final String NAME = "update";
+ public static final String BY_ATTRIBUTE = "by";
+ public static final String WHEN_ATTRIBUTE = "when";
+
+ private Date when;
+ private String by;
+
+ public void copyFrom(CopyFrom other) {
+ Update otherUpdate = (Update)other;
+ otherUpdate.when = when == null ? null : (Date) when.clone();
+ // dont copy immutable
+ otherUpdate.by = by;
+ }
+
+ /**
+ * Provides access to the date-time when the modification took place. If this attribute is omitted
+ * the value defaults to the earliest time representable in RFC 822. Either or both of the when or by attributes
+ * MUST be present; it is invalid to have neither.
+ */
+ public Date getWhen() {
+ return when;
+ }
+
+ /**
+ * Set the date-time when the modification took place.
+ *
+ * @param when the date-time when the modification took place.
+ */
+ public void setWhen(Date when) {
+ this.when = when;
+ }
+
+ /**
+ * Provides access to a text attribute identifying the unique endpoint that made a modification. This SHOULD be
+ * some combination of user and device (so that a given user can edit a feed on multiple devices). This attribute is
+ * used programmatically to break ties in case two changes happened at the same time (within the same second).
+ * Either or both of the when or by must be present; it is invalid to have neither.
+ *
+ * @return access to a text attribute identifying the unique endpoint that made a modification.
+ */
+ public String getBy() {
+ return by;
+ }
+
+ /**
+ * Sets a text attribute identifying the unique endpoint that made a modification.
+ *
+ * @param by a text attribute identifying the unique endpoint that made a modification.
+ */
+ public void setBy(String by) {
+ this.by = by;
+ }
+}
http://git-wip-us.apache.org/repos/asf/marmotta/blob/00c22e7c/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/org/rometools/feed/module/yahooweather/YWeatherEntryModule.java
----------------------------------------------------------------------
diff --git a/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/org/rometools/feed/module/yahooweather/YWeatherEntryModule.java b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/org/rometools/feed/module/yahooweather/YWeatherEntryModule.java
new file mode 100644
index 0000000..941f4c5
--- /dev/null
+++ b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/org/rometools/feed/module/yahooweather/YWeatherEntryModule.java
@@ -0,0 +1,72 @@
+/*
+ *
+ * This library is provided under dual licenses.
+ * You may choose the terms of the Lesser General Public License or the Apache
+ * License at your discretion.
+ *
+ * Copyright (C) 2008 Robert Cooper, Temple of the Screaming Penguin
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.rometools.feed.module.yahooweather;
+
+import org.rometools.feed.module.yahooweather.types.Condition;
+import org.rometools.feed.module.yahooweather.types.Forecast;
+
+
+/**
+ * An interface describing the entry/item level data for Yahoo Weather.
+ * @version $Id: YWeatherEntryModule.java,v 1.2 2008/01/22 14:50:06 kebernet Exp $
+ * @author <a href="mailto:cooper@screaming-penguin.com">Robert "kebernet" Cooper</a>
+ */
+public interface YWeatherEntryModule extends YWeatherModule {
+ /**
+ * The current conditions.
+ * @return The current conditions.
+ */
+ public Condition getCondition();
+
+ /**
+ * The current conditions.
+ * @param condition The current conditions.
+ */
+ public void setCondition(Condition condition);
+
+ /**
+ * Forecasts for this location.
+ * @return Forecasts for this location.
+ */
+ public Forecast[] getForecasts();
+
+ /**
+ * Forecasts for this location.
+ * @param forecasts Forecasts for this location.
+ */
+ public void setForecasts(Forecast[] forecasts);
+}
http://git-wip-us.apache.org/repos/asf/marmotta/blob/00c22e7c/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/org/rometools/feed/module/yahooweather/YWeatherFeedModule.java
----------------------------------------------------------------------
diff --git a/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/org/rometools/feed/module/yahooweather/YWeatherFeedModule.java b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/org/rometools/feed/module/yahooweather/YWeatherFeedModule.java
new file mode 100644
index 0000000..1e3df6c
--- /dev/null
+++ b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/org/rometools/feed/module/yahooweather/YWeatherFeedModule.java
@@ -0,0 +1,110 @@
+/*
+ * This library is provided under dual licenses.
+ * You may choose the terms of the Lesser General Public License or the Apache
+ * License at your discretion.
+ *
+ * Copyright (C) 2008 Robert Cooper, Temple of the Screaming Penguin
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.rometools.feed.module.yahooweather;
+
+import org.rometools.feed.module.yahooweather.types.Astronomy;
+import org.rometools.feed.module.yahooweather.types.Atmosphere;
+import org.rometools.feed.module.yahooweather.types.Location;
+import org.rometools.feed.module.yahooweather.types.Units;
+import org.rometools.feed.module.yahooweather.types.Wind;
+
+
+/**
+ * An interface describing feed/channel level data for Yahoo Weather.
+ * @version $Id: YWeatherFeedModule.java,v 1.3 2008/03/29 16:19:12 kebernet Exp $
+ * @author <a href="mailto:cooper@screaming-penguin.com">Robert "kebernet" Cooper</a>
+ */
+public interface YWeatherFeedModule extends YWeatherModule {
+ /**
+ * The location the feed is for.
+ * @return The location the feed is for.
+ */
+ public Location getLocation();
+
+ /**
+ * The location the feed is for.
+ * @param location The location the feed is for.
+ */
+ public void setLocation(Location location);
+
+ /**
+ * Astronomical information for the location.
+ * @return Astronomical information for the location.
+ */
+ public Astronomy getAstronomy();
+
+ /**
+ * Astronomical information for the location.
+ * @param astronomy Astronomical information for the location.
+ */
+ public void setAstronomy(Astronomy astronomy);
+
+ /**
+ * Units that data in the feed is provided in.
+ * @return Units that data in the feed is provided in.
+ */
+ public Units getUnits();
+
+ /**
+ * Units that data in the feed is provided in.
+ * @param units Units that data in the feed is provided in.
+ */
+ public void setUnits(Units units);
+
+ /**
+ * Current wind conditions at the location.
+ * @return Current wind conditions at the location.
+ */
+ public Wind getWind();
+
+ /**
+ * Current wind conditions at the location.
+ * @param wind Current wind conditions at the location.
+ */
+ public void setWind(Wind wind);
+
+ /**
+ * The current atmospheric conditions.
+ * @return Atmosphere object.
+ */
+ public Atmosphere getAtmosphere();
+
+ /**
+ * Sets the current atmopheric condictions
+ * @param value Atmosphere object.
+ */
+ public void setAtmosphere(Atmosphere value);
+}
http://git-wip-us.apache.org/repos/asf/marmotta/blob/00c22e7c/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/org/rometools/feed/module/yahooweather/YWeatherModule.java
----------------------------------------------------------------------
diff --git a/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/org/rometools/feed/module/yahooweather/YWeatherModule.java b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/org/rometools/feed/module/yahooweather/YWeatherModule.java
new file mode 100644
index 0000000..59146f6
--- /dev/null
+++ b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/org/rometools/feed/module/yahooweather/YWeatherModule.java
@@ -0,0 +1,52 @@
+/*
+ * This library is provided under dual licenses.
+ * You may choose the terms of the Lesser General Public License or the Apache
+ * License at your discretion.
+ *
+ * Copyright (C) 2008 Robert Cooper, Temple of the Screaming Penguin
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.rometools.feed.module.yahooweather;
+
+import com.sun.syndication.feed.module.Module;
+
+
+/**
+ * A simple parent interface that defines the feed URI
+ *
+ * @version $Id: YWeatherModule.java,v 1.2 2008/01/22 14:50:06 kebernet Exp $
+ * @author <a href="mailto:cooper@screaming-penguin.com">Robert "kebernet" Cooper</a>
+ */
+public interface YWeatherModule extends Module {
+ /**
+ * "http://xml.weather.yahoo.com/ns/rss/1.0"
+ */
+ public static String URI = "http://xml.weather.yahoo.com/ns/rss/1.0";
+}
http://git-wip-us.apache.org/repos/asf/marmotta/blob/00c22e7c/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/org/rometools/feed/module/yahooweather/YWeatherModuleImpl.java
----------------------------------------------------------------------
diff --git a/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/org/rometools/feed/module/yahooweather/YWeatherModuleImpl.java b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/org/rometools/feed/module/yahooweather/YWeatherModuleImpl.java
new file mode 100644
index 0000000..3dc2013
--- /dev/null
+++ b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/org/rometools/feed/module/yahooweather/YWeatherModuleImpl.java
@@ -0,0 +1,159 @@
+/*
+ * This library is provided under dual licenses.
+ * You may choose the terms of the Lesser General Public License or the Apache
+ * License at your discretion.
+ *
+ * Copyright (C) 2008 Robert Cooper, Temple of the Screaming Penguin
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.rometools.feed.module.yahooweather;
+
+import com.sun.syndication.feed.CopyFrom;
+import com.sun.syndication.feed.module.ModuleImpl;
+import org.rometools.feed.module.yahooweather.types.Astronomy;
+import org.rometools.feed.module.yahooweather.types.Atmosphere;
+import org.rometools.feed.module.yahooweather.types.Condition;
+import org.rometools.feed.module.yahooweather.types.Forecast;
+import org.rometools.feed.module.yahooweather.types.Location;
+import org.rometools.feed.module.yahooweather.types.Units;
+import org.rometools.feed.module.yahooweather.types.Wind;
+
+
+/**
+ * A Module implementation for entry or feed level information.
+ * @version $Id: YWeatherModuleImpl.java,v 1.2 2008/01/22 14:50:06 kebernet Exp $
+ * @author <a href="mailto:cooper@screaming-penguin.com">Robert "kebernet" Cooper</a>
+ */
+public class YWeatherModuleImpl extends ModuleImpl
+ implements YWeatherEntryModule, YWeatherFeedModule {
+ private Location location;
+ private Astronomy astronomy;
+ private Atmosphere atmosphere;
+ private Units units;
+ private Condition condition;
+ private Wind wind;
+ private Forecast[] forecasts;
+
+ public YWeatherModuleImpl() {
+ super(YWeatherModuleImpl.class, YWeatherModule.URI);
+ }
+
+ public Class getInterface() {
+ return CopyFromInterface.class;
+ }
+
+ public void copyFrom(CopyFrom o) {
+ YWeatherModuleImpl from = (YWeatherModuleImpl) o;
+ this.setAstronomy((from.getAstronomy() != null)
+ ? (Astronomy) from.getAstronomy().clone() : null);
+ this.setCondition((from.getCondition() != null)
+ ? (Condition) from.getCondition().clone() : null);
+ this.setLocation((from.getLocation() != null)
+ ? (Location) from.getLocation().clone() : null);
+ this.setUnits((from.getUnits() != null)
+ ? (Units) from.getUnits().clone() : null);
+ this.setWind((from.getWind() != null) ? (Wind) from.getWind().clone()
+ : null);
+
+ this.setAtmosphere((from.getAtmosphere() != null)
+ ? (Atmosphere) from.getAtmosphere().clone() : null);
+
+ if(from.getForecasts() != null) {
+ this.forecasts = new Forecast[from.forecasts.length];
+
+ for(int i = 0; i < from.forecasts.length; i++) {
+ this.forecasts[i] = (from.forecasts[i] != null)
+ ? (Forecast) from.forecasts[i].clone() : null;
+ }
+ } else {
+ this.forecasts = null;
+ }
+ }
+
+ public Location getLocation() {
+ return location;
+ }
+
+ public void setLocation(Location location) {
+ this.location = location;
+ }
+
+ public Astronomy getAstronomy() {
+ return astronomy;
+ }
+
+ public void setAstronomy(Astronomy astronomy) {
+ this.astronomy = astronomy;
+ }
+
+ public Units getUnits() {
+ return units;
+ }
+
+ public void setUnits(Units units) {
+ this.units = units;
+ }
+
+ public Condition getCondition() {
+ return condition;
+ }
+
+ public void setCondition(Condition condition) {
+ this.condition = condition;
+ }
+
+ public Forecast[] getForecasts() {
+ return forecasts;
+ }
+
+ public void setForecasts(Forecast[] forecasts) {
+ this.forecasts = forecasts;
+ }
+
+ public Wind getWind() {
+ return wind;
+ }
+
+ public void setWind(Wind wind) {
+ this.wind = wind;
+ }
+
+ public Atmosphere getAtmosphere() {
+ return atmosphere;
+ }
+
+ public void setAtmosphere(Atmosphere atmosphere) {
+ this.atmosphere = atmosphere;
+ }
+
+ public static interface CopyFromInterface extends YWeatherFeedModule,
+ YWeatherEntryModule {
+ }
+}
http://git-wip-us.apache.org/repos/asf/marmotta/blob/00c22e7c/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/org/rometools/feed/module/yahooweather/io/WeatherModuleGenerator.java
----------------------------------------------------------------------
diff --git a/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/org/rometools/feed/module/yahooweather/io/WeatherModuleGenerator.java b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/org/rometools/feed/module/yahooweather/io/WeatherModuleGenerator.java
new file mode 100644
index 0000000..becf3e4
--- /dev/null
+++ b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/org/rometools/feed/module/yahooweather/io/WeatherModuleGenerator.java
@@ -0,0 +1,241 @@
+/*
+ * WeatherModuleGenerator.java
+ *
+ * This library is provided under dual licenses.
+ * You may choose the terms of the Lesser General Public License or the Apache
+ * License at your discretion.
+ *
+ * Copyright (C) 2008 Robert Cooper, Temple of the Screaming Penguin
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.rometools.feed.module.yahooweather.io;
+
+import java.text.SimpleDateFormat;
+
+import java.util.HashSet;
+
+import com.sun.syndication.feed.module.Module;
+import org.rometools.feed.module.yahooweather.YWeatherModule;
+import org.rometools.feed.module.yahooweather.YWeatherModuleImpl;
+import org.rometools.feed.module.yahooweather.types.Forecast;
+import com.sun.syndication.io.ModuleGenerator;
+
+import org.jdom2.Element;
+import org.jdom2.Namespace;
+
+
+/** The ModuleGenerator implementation for the Yahoo Weather plug in.
+ * @version $Revision: 1.3 $
+ * @author <a href="mailto:cooper@screaming-penguin.com">Robert "kebernet" Cooper</a>
+ */
+public class WeatherModuleGenerator implements ModuleGenerator {
+ private static final Namespace NS = Namespace.getNamespace("yweather",
+ YWeatherModule.URI);
+ private static final SimpleDateFormat TIME_ONLY = new SimpleDateFormat(
+ "h:mm a");
+ private static final SimpleDateFormat LONG_DATE = new SimpleDateFormat(
+ "EEE, d MMM yyyy h:mm a zzz");
+ private static final SimpleDateFormat SHORT_DATE = new SimpleDateFormat(
+ "d MMM yyyy");
+
+ /** Creates a new instance of SlashModuleGenerator */
+ public WeatherModuleGenerator() {
+ }
+
+ public void generate(Module module, Element element) {
+ if(!(module instanceof YWeatherModuleImpl)) {
+ return;
+ }
+
+ YWeatherModuleImpl weather = (YWeatherModuleImpl) module;
+
+ if(weather.getAstronomy() != null) {
+ Element astro = new Element("astronomy", WeatherModuleGenerator.NS);
+
+ if(weather.getAstronomy().getSunrise() != null) {
+ astro.setAttribute("sunrise",
+ TIME_ONLY.format(weather.getAstronomy().getSunrise())
+ .toLowerCase());
+ }
+
+ if(weather.getAstronomy().getSunrise() != null) {
+ astro.setAttribute("sunset",
+ TIME_ONLY.format(weather.getAstronomy().getSunset())
+ .toLowerCase());
+ }
+
+ element.addContent(astro);
+ }
+
+ if(weather.getAtmosphere() != null) {
+ Element atmos = new Element("atmosphere", WeatherModuleGenerator.NS);
+ atmos.setAttribute("humidity",
+ Integer.toString(weather.getAtmosphere().getHumidity()));
+ atmos.setAttribute("visibility",
+ Integer.toString(
+ (int) (weather.getAtmosphere().getVisibility() * 100d)));
+ atmos.setAttribute("pressure",
+ Double.toString(weather.getAtmosphere().getPressure()));
+
+ if(weather.getAtmosphere().getChange() != null) {
+ atmos.setAttribute("rising",
+ Integer.toString(weather.getAtmosphere().getChange()
+ .getCode()));
+ }
+
+ element.addContent(atmos);
+ }
+
+ if(weather.getCondition() != null) {
+ Element condition = new Element("condition",
+ WeatherModuleGenerator.NS);
+
+ if(weather.getCondition().getText() != null) {
+ condition.setAttribute("text", weather.getCondition().getText());
+ }
+
+ if(weather.getCondition().getCode() != null) {
+ condition.setAttribute("code",
+ Integer.toString(weather.getCondition().getCode().getCode()));
+ }
+
+ if(weather.getCondition().getDate() != null) {
+ condition.setAttribute("date",
+ LONG_DATE.format(weather.getCondition().getDate())
+ .replaceAll("AM", "am").replaceAll("PM", "pm"));
+ }
+
+ condition.setAttribute("temp",
+ Integer.toString(weather.getCondition().getTemperature()));
+ element.addContent(condition);
+ }
+
+ if(weather.getLocation() != null) {
+ Element location = new Element("location", WeatherModuleGenerator.NS);
+
+ if(weather.getLocation().getCity() != null) {
+ location.setAttribute("city", weather.getLocation().getCity());
+ }
+
+ if(weather.getLocation().getRegion() != null) {
+ location.setAttribute("region",
+ weather.getLocation().getRegion());
+ }
+
+ if(weather.getLocation().getCountry() != null) {
+ location.setAttribute("country",
+ weather.getLocation().getCountry());
+ }
+
+ element.addContent(location);
+ }
+
+ if(weather.getUnits() != null) {
+ Element units = new Element("units", WeatherModuleGenerator.NS);
+
+ if(weather.getUnits().getDistance() != null) {
+ units.setAttribute("distance", weather.getUnits().getDistance());
+ }
+
+ if(weather.getUnits().getPressure() != null) {
+ units.setAttribute("pressure", weather.getUnits().getPressure());
+ }
+
+ if(weather.getUnits().getSpeed() != null) {
+ units.setAttribute("speed", weather.getUnits().getSpeed());
+ }
+
+ if(weather.getUnits().getTemperature() != null) {
+ units.setAttribute("temperature",
+ weather.getUnits().getTemperature());
+ }
+
+ element.addContent(units);
+ }
+
+ if(weather.getWind() != null) {
+ Element wind = new Element("wind", WeatherModuleGenerator.NS);
+ wind.setAttribute("chill",
+ Integer.toString(weather.getWind().getChill()));
+ wind.setAttribute("direction",
+ Integer.toString(weather.getWind().getDirection()));
+ wind.setAttribute("speed",
+ Integer.toString(weather.getWind().getSpeed()));
+ element.addContent(wind);
+ }
+
+ if(weather.getForecasts() != null) {
+ for(int i = 0; i < weather.getForecasts().length; i++) {
+ Element forecast = new Element("forecast",
+ WeatherModuleGenerator.NS);
+ Forecast f = weather.getForecasts()[i];
+
+ if(f.getCode() != null) {
+ forecast.setAttribute("code",
+ Integer.toString(f.getCode().getCode()));
+ }
+
+ if(f.getDate() != null) {
+ forecast.setAttribute("date", SHORT_DATE.format(f.getDate()));
+ }
+
+ if(f.getDay() != null) {
+ forecast.setAttribute("day", f.getDay());
+ }
+
+ if(f.getText() != null) {
+ forecast.setAttribute("text", f.getText());
+ }
+
+ forecast.setAttribute("high", Integer.toString(f.getHigh()));
+ forecast.setAttribute("low", Integer.toString(f.getLow()));
+ element.addContent(forecast);
+ }
+ }
+ }
+
+ protected Element generateSimpleElement(String name, String value) {
+ Element element = new Element(name, WeatherModuleGenerator.NS);
+ element.addContent(value);
+
+ return element;
+ }
+
+ public java.util.Set getNamespaces() {
+ HashSet set = new HashSet();
+ set.add(WeatherModuleGenerator.NS);
+
+ return set;
+ }
+
+ public String getNamespaceUri() {
+ return YWeatherModule.URI;
+ }
+}
http://git-wip-us.apache.org/repos/asf/marmotta/blob/00c22e7c/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/org/rometools/feed/module/yahooweather/io/WeatherModuleParser.java
----------------------------------------------------------------------
diff --git a/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/org/rometools/feed/module/yahooweather/io/WeatherModuleParser.java b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/org/rometools/feed/module/yahooweather/io/WeatherModuleParser.java
new file mode 100644
index 0000000..da27cc4
--- /dev/null
+++ b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/org/rometools/feed/module/yahooweather/io/WeatherModuleParser.java
@@ -0,0 +1,213 @@
+/*
+ * WeatherModuleParser.java
+ *
+ *
+ * This library is provided under dual licenses.
+ * You may choose the terms of the Lesser General Public License or the Apache
+ * License at your discretion.
+ *
+ * Copyright (C) 2008 Robert Cooper, Temple of the Screaming Penguin
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.rometools.feed.module.yahooweather.io;
+
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.logging.Logger;
+
+import com.sun.syndication.feed.module.Module;
+import org.rometools.feed.module.yahooweather.YWeatherModule;
+import org.rometools.feed.module.yahooweather.YWeatherModuleImpl;
+import org.rometools.feed.module.yahooweather.types.Astronomy;
+import org.rometools.feed.module.yahooweather.types.Atmosphere;
+import org.rometools.feed.module.yahooweather.types.Condition;
+import org.rometools.feed.module.yahooweather.types.ConditionCode;
+import org.rometools.feed.module.yahooweather.types.Forecast;
+import org.rometools.feed.module.yahooweather.types.Location;
+import org.rometools.feed.module.yahooweather.types.Units;
+import org.rometools.feed.module.yahooweather.types.Wind;
+import com.sun.syndication.io.ModuleParser;
+
+import org.jdom2.Element;
+import org.jdom2.Namespace;
+
+
+/** ModuleParser implementation for Slash RSS.
+ * @version $Revision: 1.2 $
+ * @author <a href="mailto:cooper@screaming-penguin.com">Robert "kebernet" Cooper</a>
+ */
+public class WeatherModuleParser implements ModuleParser {
+ private static final SimpleDateFormat TIME_ONLY = new SimpleDateFormat(
+ "h:mm a");
+ private static final SimpleDateFormat LONG_DATE = new SimpleDateFormat(
+ "EEE, d MMM yyyy h:mm a zzz");
+ private static final SimpleDateFormat SHORT_DATE = new SimpleDateFormat(
+ "d MMM yyyy");
+ private static final Namespace NS = Namespace.getNamespace(YWeatherModule.URI);
+
+ /** Creates a new instance of SlashModuleParser */
+ public WeatherModuleParser() {
+ super();
+ }
+
+ public String getNamespaceUri() {
+ return YWeatherModule.URI;
+ }
+
+ public Module parse(Element element) {
+ YWeatherModuleImpl module = new YWeatherModuleImpl();
+ Element location = element.getChild("location", WeatherModuleParser.NS);
+
+ if(location != null) {
+ Location l = new Location(location.getAttributeValue("city"),
+ location.getAttributeValue("region"),
+ location.getAttributeValue("country"));
+ module.setLocation(l);
+ }
+
+ Element units = element.getChild("units", WeatherModuleParser.NS);
+
+ if(units != null) {
+ Units u = new Units(units.getAttributeValue("temperature"),
+ units.getAttributeValue("distance"),
+ units.getAttributeValue("pressure"),
+ units.getAttributeValue("speed"));
+ module.setUnits(u);
+ }
+
+ Element wind = element.getChild("wind", WeatherModuleParser.NS);
+
+ if(wind != null) {
+ try {
+ Wind w = new Wind(Integer.parseInt(wind.getAttributeValue(
+ "chill")),
+ Integer.parseInt(wind.getAttributeValue("direction")),
+ Integer.parseInt(wind.getAttributeValue("speed")));
+ module.setWind(w);
+ } catch(NumberFormatException nfe) {
+ Logger.getAnonymousLogger()
+ .warning("NumberFormatException processing <wind> tag.");
+ }
+ }
+
+ Element atmosphere = element.getChild("atmosphere",
+ WeatherModuleParser.NS);
+
+ if(atmosphere != null) {
+ try {
+ Atmosphere a = new Atmosphere(Integer.parseInt(
+ atmosphere.getAttributeValue("humidity")),
+ Double.parseDouble(atmosphere.getAttributeValue(
+ "visibility")) / 100,
+ Double.parseDouble(atmosphere.getAttributeValue(
+ "pressure")),
+ Atmosphere.PressureChange.fromCode(Integer.parseInt(
+ atmosphere.getAttributeValue("rising"))));
+ module.setAtmosphere(a);
+ } catch(NumberFormatException nfe) {
+ Logger.getAnonymousLogger()
+ .warning("NumberFormatException processing <atmosphere> tag.");
+ }
+ }
+
+ Element astronomy = element.getChild("astronomy", WeatherModuleParser.NS);
+
+ if(astronomy != null) {
+ try {
+ Astronomy a = new Astronomy(TIME_ONLY.parse(
+ astronomy.getAttributeValue("sunrise")
+ .replaceAll("am", "AM")
+ .replaceAll("pm", "PM")),
+ TIME_ONLY.parse(astronomy.getAttributeValue("sunset")
+ .replaceAll("am", "AM")
+ .replaceAll("pm", "PM")));
+ module.setAstronomy(a);
+ } catch(ParseException pe) {
+ Logger.getAnonymousLogger()
+ .warning("ParseException processing <astronomy> tag.");
+ }
+ }
+
+ Element condition = element.getChild("condition", WeatherModuleParser.NS);
+
+ if(condition != null) {
+ try {
+ Condition c = new Condition(condition.getAttributeValue("text"),
+ ConditionCode.fromCode(Integer.parseInt(
+ condition.getAttributeValue("code"))),
+ Integer.parseInt(condition.getAttributeValue("temp")),
+ LONG_DATE.parse(condition.getAttributeValue("date")
+ .replaceAll("pm", "PM")
+ .replaceAll("am", "AM")));
+ module.setCondition(c);
+ } catch(NumberFormatException nfe) {
+ Logger.getAnonymousLogger()
+ .warning("NumberFormatException processing <condition> tag.");
+ } catch(ParseException pe) {
+ Logger.getAnonymousLogger()
+ .warning("ParseException processing <condition> tag.");
+ }
+ }
+
+ List forecasts = element.getChildren("forecast", WeatherModuleParser.NS);
+
+ if(forecasts != null) {
+ Forecast[] f = new Forecast[forecasts.size()];
+ int i = 0;
+
+ for(Iterator it = forecasts.iterator(); it.hasNext(); i++) {
+ Element forecast = (Element) it.next();
+
+ try {
+ f[i] = new Forecast(forecast.getAttributeValue("day"),
+ SHORT_DATE.parse(forecast.getAttributeValue("date")),
+ Integer.parseInt(forecast.getAttributeValue("low")),
+ Integer.parseInt(forecast.getAttributeValue("high")),
+ forecast.getAttributeValue("text"),
+ ConditionCode.fromCode(Integer.parseInt(
+ forecast.getAttributeValue("code"))));
+ } catch(NumberFormatException nfe) {
+ Logger.getAnonymousLogger()
+ .warning("NumberFormatException processing <forecast> tag.");
+ } catch(ParseException pe) {
+ Logger.getAnonymousLogger()
+ .warning("ParseException processing <forecast> tag.");
+ }
+ }
+
+ module.setForecasts(f);
+ }
+
+ return module;
+ }
+}
http://git-wip-us.apache.org/repos/asf/marmotta/blob/00c22e7c/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/org/rometools/feed/module/yahooweather/io/package.html
----------------------------------------------------------------------
diff --git a/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/org/rometools/feed/module/yahooweather/io/package.html b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/org/rometools/feed/module/yahooweather/io/package.html
new file mode 100644
index 0000000..4790779
--- /dev/null
+++ b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/org/rometools/feed/module/yahooweather/io/package.html
@@ -0,0 +1,45 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+
+<html>
+ <head>
+ <title></title>
+ </head>
+ <body>
+ This package contains the parser and generator for ROME.
+ <pre>
+ * This library is provided under dual licenses.
+ * You may choose the terms of the Lesser General Public License or the Apache
+ * License at your discretion.
+ *
+ * Copyright (C) 2005 Robert Cooper, Temple of the Screaming Penguin
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ </pre>
+ </body>
+</html>
http://git-wip-us.apache.org/repos/asf/marmotta/blob/00c22e7c/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/org/rometools/feed/module/yahooweather/package.html
----------------------------------------------------------------------
diff --git a/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/org/rometools/feed/module/yahooweather/package.html b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/org/rometools/feed/module/yahooweather/package.html
new file mode 100644
index 0000000..d815c8e
--- /dev/null
+++ b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/org/rometools/feed/module/yahooweather/package.html
@@ -0,0 +1,64 @@
+<html>
+ <head>
+ <title></title>
+ </head>
+ <body>
+ This package contains Modules for working with
+ <a href="http://developer.yahoo.com/weather/">Yahoo! Weather</a>.
+
+ <h2>Example usage:</h2>
+ <p> Retrieving information from a feed:
+ <code><pre>
+ SyndFeed feed = input.build( ... );
+ YWeatherFeedModule yfeed = (YWeatherFeedModule) feed.getModule( YWeatherFeedModule.URI );
+ System.out.println( yfeed.getLocation().getCity() );
+ SyndEntry entry = (SyndEntry) feed.getEntries().get(0);
+ YWeatherEntryModule yentry = (YWeatherEntryModule) entry.getModule( YWeatherEntryModule.URI );
+ System.out.println( yentry.getForecasts()[0].getHigh();
+ </pre></code>
+ </p>
+ <p> To add information to a feed, construct a YWeatherModuleImpl and cast it to
+ the appropriate interface:
+ <code><pre>
+ SyndEntry entry = new SyndEntryImpl();
+ YWeatherEntryModule yentry = new YWeatherModuleImpl();
+ yentry.setCondition( Condition("Partly Cloudy", ConditionCode.PARTLY_CLOUDY, 65, new Date() ) );
+ entry.getModules.add(yentry);
+ </pre></code>
+ <pre>
+ * This library is provided under dual licenses.
+ * You may choose the terms of the Lesser General Public License or the Apache
+ * License at your discretion.
+ *
+ * Copyright (C) 2005 Robert Cooper, Temple of the Screaming Penguin
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ </pre>
+ </body>
+</html>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/marmotta/blob/00c22e7c/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/org/rometools/feed/module/yahooweather/types/Astronomy.java
----------------------------------------------------------------------
diff --git a/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/org/rometools/feed/module/yahooweather/types/Astronomy.java b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/org/rometools/feed/module/yahooweather/types/Astronomy.java
new file mode 100644
index 0000000..2f0fe0e
--- /dev/null
+++ b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/org/rometools/feed/module/yahooweather/types/Astronomy.java
@@ -0,0 +1,132 @@
+/*
+ *
+ *
+ * This library is provided under dual licenses.
+ * You may choose the terms of the Lesser General Public License or the Apache
+ * License at your discretion.
+ *
+ * Copyright (C) 2008 Robert Cooper, Temple of the Screaming Penguin
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.rometools.feed.module.yahooweather.types;
+
+import java.io.Serializable;
+
+import java.util.Date;
+
+import com.sun.syndication.feed.impl.EqualsBean;
+import com.sun.syndication.feed.impl.ToStringBean;
+
+
+/**
+ * Forecast information about current astronomical conditions. Attributes:
+ * <ul class="topspace">
+ * <li>sunrise: today's sunrise time. The time is a string in a local
+ * time format of "h:mm am/pm", for example "7:02 am" (string)</li>
+ * <li>sunset today's sunset time. The time is a string in a local time
+ * format of "h:mm am/pm", for example "4:51 pm" (string)</li>
+ * </ul>
+ * @version $Id: Astronomy.java,v 1.2 2008/01/22 14:50:05 kebernet Exp $
+ * @author <a href="mailto:cooper@screaming-penguin.com">Robert "kebernet" Cooper</a>
+ */
+public class Astronomy implements Serializable, Cloneable {
+ private EqualsBean equals = new EqualsBean(Astronomy.class, this);
+ private ToStringBean toString = new ToStringBean(Astronomy.class, this);
+ private Date sunrise;
+ private Date sunset;
+
+ /**
+ * Simple constructor.
+ */
+ public Astronomy() {
+ super();
+ }
+
+ /**
+ * Constructs a new Astronomy object
+ * @param sunrise time of sunrise (from 0ms)
+ * @param sunset time of sunset (from 0ms)
+ */
+ public Astronomy(Date sunrise, Date sunset) {
+ this.sunrise = sunrise;
+ this.sunset = sunset;
+ }
+
+ public Object clone() {
+ return new Astronomy((this.getSunrise() != null)
+ ? new Date(this.getSunrise().getTime()) : null,
+ (this.getSunset() != null) ? new Date(this.getSunset().getTime())
+ : null);
+ }
+
+ public boolean equals(Object o) {
+ return this.equals.equals(o);
+ }
+
+ public int hashCode() {
+ return this.equals.hashCode();
+ }
+
+ public String toString() {
+ return this.toString.toString();
+ }
+
+ /**
+ * Time of sunrise
+ * @return ime of sunrise (from 0ms)
+ */
+ public Date getSunrise() {
+ return sunrise;
+ }
+
+ /**
+ * Time of sunrise
+ * @param sunrise ime of sunrise (from 0ms)
+ */
+ public void setSunrise(Date sunrise) {
+ this.sunrise = sunrise;
+ }
+
+ /**
+ * Time of sunset
+ * @return time of sunset (from 0ms)
+ */
+ public Date getSunset() {
+ return sunset;
+ }
+
+ /**
+ * Time of sunset
+ * @param sunset time of sunset (from 0ms)
+ */
+ public void setSunset(Date sunset) {
+ this.sunset = sunset;
+ }
+}
http://git-wip-us.apache.org/repos/asf/marmotta/blob/00c22e7c/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/org/rometools/feed/module/yahooweather/types/Atmosphere.java
----------------------------------------------------------------------
diff --git a/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/org/rometools/feed/module/yahooweather/types/Atmosphere.java b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/org/rometools/feed/module/yahooweather/types/Atmosphere.java
new file mode 100644
index 0000000..c09900a
--- /dev/null
+++ b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/org/rometools/feed/module/yahooweather/types/Atmosphere.java
@@ -0,0 +1,226 @@
+/*
+ *
+ *
+ * This library is provided under dual licenses.
+ * You may choose the terms of the Lesser General Public License or the Apache
+ * License at your discretion.
+ *
+ * Copyright (C) 2008 Robert Cooper, Temple of the Screaming Penguin
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.rometools.feed.module.yahooweather.types;
+
+import java.io.Serializable;
+
+import com.sun.syndication.feed.impl.EqualsBean;
+import com.sun.syndication.feed.impl.ToStringBean;
+
+
+/**
+ * Forecast information about current atmospheric pressure, humidity,
+ * and visibility. Attributes:
+ * <ul class="topspace">
+ * <li>humidity: humidity, in percent (integer)</li>
+ * <li>visibility, in the units specified by the distance attribute of
+ * the yweather:units element (mi or km). Note that the visibility is
+ * specified as the actual value * 100. For example, a visibility of
+ * 16.5 miles will be specified as 1650. A visibility of 14 kilometers
+ * will appear as 1400. (integer) [<em>A double here, and adjusted accordingly</em>]</li>
+ * <li>pressure: barometric pressure, in the units specified by the pressure
+ * attribute of the yweather:units element (in or mb). (float).</li>
+ * <li>rising: state of the barometric pressure: steady (0), rising (1),
+ * or falling (2). (integer: 0, 1, 2)</li>
+ * </ul>
+ * @version $Id: Atmosphere.java,v 1.2 2008/01/22 14:50:05 kebernet Exp $
+ * @author <a href="mailto:cooper@screaming-penguin.com">Robert "kebernet" Cooper</a>
+ */
+public class Atmosphere implements Serializable, Cloneable {
+ private EqualsBean equals = new EqualsBean(Atmosphere.class, this);
+ private ToStringBean toString = new ToStringBean(Atmosphere.class, this);
+ private int humidity;
+ private double visibility;
+ private double pressure;
+ private PressureChange change;
+
+ /**
+ * Simple constructor.
+ */
+ public Atmosphere() {
+ super();
+ }
+
+ /**
+ * Constructs a new Atmosphere object
+ * @param humidity humidity, in percent
+ * @param visibility visibility distance (value beyond 1/100ths of a unit will be truncated)
+ * @param pressure barometric pressure
+ * @param change state of the barometric pressure
+ */
+ public Atmosphere(int humidity, double visibility, double pressure,
+ PressureChange change) {
+ super();
+ this.humidity = humidity;
+ this.visibility = visibility;
+ this.pressure = pressure;
+ this.change = change;
+ }
+
+ public boolean equals(Object o) {
+ return this.equals.equals(o);
+ }
+
+ public int hashCode() {
+ return this.equals.hashCode();
+ }
+
+ public String toString() {
+ return this.toString.toString();
+ }
+
+ /**
+ * Relative humidity
+ * @return humidity, in percent
+ */
+ public int getHumidity() {
+ return humidity;
+ }
+
+ /**
+ * Relative humidity
+ * @param humidity humidity, in percent
+ */
+ public void setHumidity(int humidity) {
+ this.humidity = humidity;
+ }
+
+ /**
+ * Visibility distance
+ * @return distance
+ */
+ public double getVisibility() {
+ return visibility;
+ }
+
+ /**
+ * Visibility distance
+ * @param visibility distance (value beyond 1/100ths of a unit will be truncated)
+ */
+ public void setVisibility(double visibility) {
+ this.visibility = visibility;
+ }
+
+ /**
+ * Barometric pressure
+ * @return pressure
+ */
+ public double getPressure() {
+ return pressure;
+ }
+
+ /**
+ * Barometric pressure
+ *
+ * @param pressure pressure
+ */
+ public void setPressure(double pressure) {
+ this.pressure = pressure;
+ }
+
+ /**
+ * Change in pressure
+ * @return Atmosphere.PressureChange object
+ */
+ public PressureChange getChange() {
+ return change;
+ }
+
+ /**
+ * Change in pressure
+ * @param change PressureChange object
+ */
+ public void setChange(PressureChange change) {
+ this.change = change;
+ }
+
+ public Object clone() {
+ return new Atmosphere(this.humidity, this.visibility, this.pressure,
+ this.change);
+ }
+
+ public static class PressureChange implements Serializable {
+ public static final PressureChange RISING = new PressureChange(1,
+ "rising");
+ public static final PressureChange STEADY = new PressureChange(0,
+ "steady");
+ public static final PressureChange FALLING = new PressureChange(2,
+ "falling");
+ private int code;
+ private String text;
+
+ private PressureChange(int code, String text) {
+ this.code = code;
+ this.text = text;
+ }
+
+ public String toString() {
+ return "[ code: " + this.code + " (" + this.text + ")]";
+ }
+
+ /**
+ * The integer code for this chage state
+ * @return int code
+ */
+ public int getCode() {
+ return this.code;
+ }
+
+ /**
+ * Gets a PressureChange instance for this int code.
+ * @param code int code value
+ * @return PressureChange instance
+ * @throws RuntimeException if no 0, 1, or 2.
+ */
+ public static PressureChange fromCode(int code) {
+ switch(code) {
+ case 0:
+ return STEADY;
+
+ case 1:
+ return RISING;
+
+ case 2:
+ return FALLING;
+
+ default:
+ throw new RuntimeException("Invalid pressure change code.");
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/marmotta/blob/00c22e7c/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/org/rometools/feed/module/yahooweather/types/Condition.java
----------------------------------------------------------------------
diff --git a/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/org/rometools/feed/module/yahooweather/types/Condition.java b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/org/rometools/feed/module/yahooweather/types/Condition.java
new file mode 100644
index 0000000..e919f89
--- /dev/null
+++ b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/org/rometools/feed/module/yahooweather/types/Condition.java
@@ -0,0 +1,183 @@
+/*
+ *
+ *
+ * This library is provided under dual licenses.
+ * You may choose the terms of the Lesser General Public License or the Apache
+ * License at your discretion.
+ *
+ * Copyright (C) 2008 Robert Cooper, Temple of the Screaming Penguin
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.rometools.feed.module.yahooweather.types;
+
+import java.io.Serializable;
+
+import java.util.Date;
+
+import com.sun.syndication.feed.impl.EqualsBean;
+import com.sun.syndication.feed.impl.ToStringBean;
+
+
+/**
+ * The current weather conditions. Attributes:
+ * <ul class="topspace">
+ * <li>text: a textual description of conditions, for example, "Partly
+ * Cloudy" (string)</li>
+ * <li>code: the condition code for this forecast. You could use this
+ * code to choose a text description or image for the forecast. The
+ * possible values for this element are described in <a href="#codes">Condition
+ * Codes</a> (integer)</li>
+ * <li>temp: the current temperature, in the units specified by the yweather:units
+ * element (integer)</li>
+ * <li>date: the current date and time for which this forecast applies.
+ * [<em>I believe this should be the time this condition information was captured</em>]
+ * The date is in <a href="http://www.rfc-editor.org/rfc/rfc822.txt">RFC822
+ * Section 5</a> format, for example "Wed, 30 Nov 2005 1:56 pm
+ * PST" (string)</li>
+ * </ul>
+ * @version $Id: Condition.java,v 1.2 2008/01/22 14:50:05 kebernet Exp $
+ * @author <a href="mailto:cooper@screaming-penguin.com">Robert "kebernet" Cooper</a>
+ */
+public class Condition implements Serializable, Cloneable {
+ private EqualsBean equals = new EqualsBean(Condition.class, this);
+ private ToStringBean toString = new ToStringBean(Condition.class, this);
+ private String text;
+ private ConditionCode code;
+ private int temperature;
+ private Date date;
+
+ /**
+ * Simple constructor
+ */
+ public Condition() {
+ super();
+ }
+
+ /**
+ * Constructs a new Condition.
+ * @param text a textual description of conditions, for example, "Partly
+ * Cloudy"
+ * @param code the condition code for this forecast.
+ * @param temperature the current temperature
+ * @param date the current date and time
+ */
+ public Condition(String text, ConditionCode code, int temperature, Date date) {
+ super();
+ this.text = text;
+ this.code = code;
+ this.temperature = temperature;
+ this.date = date;
+ }
+
+ /**
+ * Description of condition
+ * @return a textual description of conditions, for example, "Partly
+ * Cloudy"
+ */
+ public String getText() {
+ return text;
+ }
+
+ /**
+ * Description of condition
+ * @param text a textual description of conditions, for example, "Partly
+ * Cloudy"
+ */
+ public void setText(String text) {
+ this.text = text;
+ }
+
+ /**
+ * Condition code
+ * @return condition code
+ */
+ public ConditionCode getCode() {
+ return code;
+ }
+
+ /**
+ * Condition code
+ * @param code Condition code
+ */
+ public void setCode(ConditionCode code) {
+ this.code = code;
+ }
+
+ /**
+ * Current Temperature
+ * @return the current temperature
+ * @see Units
+ */
+ public int getTemperature() {
+ return temperature;
+ }
+
+ /**
+ * Current Temperature
+ * @param temperature the current temperature
+ * @see Units
+ */
+ public void setTemperature(int temperature) {
+ this.temperature = temperature;
+ }
+
+ /**
+ * Date recorded
+ * @return the current date and time
+ */
+ public Date getDate() {
+ return date;
+ }
+
+ /**
+ * Date recorded
+ * @param date the current date and time
+ */
+ public void setDate(Date date) {
+ this.date = date;
+ }
+
+ public boolean equals(Object o) {
+ return this.equals.equals(o);
+ }
+
+ public int hashCode() {
+ return this.equals.hashCode();
+ }
+
+ public String toString() {
+ return this.toString.toString();
+ }
+
+ public Object clone() {
+ return new Condition(this.text, this.code, this.temperature,
+ (this.date != null) ? new Date(this.date.getTime()) : null);
+ }
+}