diff --git a/.gitignore b/.gitignore
index 5966e2d..6ef042a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,3 @@
-/.checkstyle
-/.classpath
-/.project
/.settings
+/.project
/target
\ No newline at end of file
diff --git a/LICENSE b/LICENSE
index d4ba69e..ad410e1 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,16 +1,201 @@
-Copyright 2004 Sun Microsystems, Inc.
-Copyright 2011 The ROME Team
+Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-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
+ 1. Definitions.
- http://www.apache.org/licenses/LICENSE-2.0
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
-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.
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "{}"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright {yyyy} {name of copyright owner}
+
+ 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.
\ No newline at end of file
diff --git a/README.md b/README.md
index b1c6816..716e0ab 100644
--- a/README.md
+++ b/README.md
@@ -1,27 +1,4 @@
-# ROME
+rome-parent
+===========
-ROME is a set of RSS and Atom Utilities for Java. It makes it easy to work in Java with most syndication formats: RSS 0.90, RSS 0.91 Netscape,
-RSS 0.91 Userland, RSS 0.92, RSS 0.93, RSS 0.94, RSS 1.0, RSS 2.0, Atom 0.3, Atom 1.0
-
-More Information: http://rometools.github.io/rome/
-
-## Changelog
-
-### 1.5.1
-
-- solved an [XML bomb](https://en.wikipedia.org/wiki/Billion_laughs) vulnerability
-
-Important note: due to the security fix ROME now forbids all Doctype declarations by default. This will break compatibility with RSS 0.91 Netscape
-because it requires a Doctype declaration. When you experience problems you have to activate the property **allowDoctypes** on the SyndFeedInput object. You
-should only use this possibility when the feeds that you process are absolutely trustful.
-
-### 1.5.0
-
-- many (untracked) enhancements
-- code cleanup
-- renamed packages (was required to be able to push to Maven Central after years again)
-- updated sourcecode to Java 1.6
-
-### Prior to 1.5.0
-
-- see [http://rometools.github.io/rome/ROMEReleases](http://rometools.github.io/rome/ROMEReleases)
\ No newline at end of file
+Parent for all ROME projects
diff --git a/conf/checkstyle/checkstyle.xml b/conf/checkstyle/checkstyle.xml
new file mode 100644
index 0000000..2a344a7
--- /dev/null
+++ b/conf/checkstyle/checkstyle.xml
@@ -0,0 +1,115 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/conf/eclipse/cleanup.xml b/conf/eclipse/cleanup.xml
new file mode 100644
index 0000000..feca0d5
--- /dev/null
+++ b/conf/eclipse/cleanup.xml
@@ -0,0 +1,59 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/conf/eclipse/formatter.xml b/conf/eclipse/formatter.xml
new file mode 100644
index 0000000..f3d99da
--- /dev/null
+++ b/conf/eclipse/formatter.xml
@@ -0,0 +1,295 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/pom.xml b/pom.xml
index de35703..f9f21cd 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,130 +4,133 @@
4.0.0
- com.rometools
- rome-parent
- 1.6.0-SNAPSHOT
+ org.sonatype.oss
+ oss-parent
+ 9
- rome
+ com.rometools
+ rome-parent1.6.0-SNAPSHOT
- jar
+ pom
- rome
+
+ rome
+ rome-certiorem
+ rome-certiorem-webapp
+ rome-fetcher
+ rome-modules
+ rome-opml
+ rome-propono
+ rome-utils
+
- All Roads Lead to ROME. ROME is a set of Atom/RSS Java utilities that make it
- easy to work in Java with most syndication formats. Today it accepts all flavors of RSS
- (0.90, 0.91, 0.92, 0.93, 0.94, 1.0 and 2.0), Atom 0.3 and Atom 1.0 feeds. Rome includes
- a set of parsers and generators for the various flavors of feeds, as well as converters
- to convert from one format to another. The parsers can give you back Java objects that
- are either specific for the format you want to work with, or a generic normalized
- SyndFeed object that lets you work on with the data without bothering about the
- underlying format.
-
+ rome-parent
- http://rometools.github.io/rome/
+ Parent for all ROME projects
+
+ http://rometools.github.io/rome-parent/
+
+
+
+ The Apache Software License, Version 2.0
+ http://www.apache.org/licenses/LICENSE-2.0.txt
+ repo
+
+
- scm:git:ssh://github.com/rometools/rome.git
- scm:git:ssh://git@github.com/rometools/rome.git
- https://github.com/rometools/rome
+ scm:git:ssh://github.com/rometools/rome-parent.git
+ scm:git:ssh://git@github.com/rometools/rome-parent.git
+ https://github.com/rometools/rome-parent
-
- Alejandro Abdelnur
- http://blog.sun.com/roller/page/tucu
- 0
-
-
- Dave Johnson
- http://rollerweblogger.org/roller
- -5
-
-
- Elaine Chien
- 0
-
-
- Patrick Chanezon
- http://www.chanezon.com/pat/weblog
- -9
- Patrick Gotthard
+ patrick@patrick-gotthard.dehttp://www.patrick-gotthard.de+1
-
- Robert Cooper
- kebernet@gmail.com
- http://www.screaming-penguin.com
- -4
-
-
- farrukhnajmi
- Farrukh Najmi
- http://www.wellfleetsoftware.com/farrukh
-
-
- imk
- Martin Kurz
- Europe/Berlin
-
-
-
- sonatype-nexus-snapshots
- https://oss.sonatype.org/content/repositories/snapshots
-
- false
-
-
- true
-
-
-
+
+ UTF-8
+ UTF-8
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 3.1
+
+ 1.6
+ 1.6
+
+
+
+ org.apache.maven.plugins
+ maven-site-plugin
+ 3.3
+
+
+ org.apache.maven.plugins
+ maven-scm-publish-plugin
+ 1.0
+
+
+
+ org.eclipse.m2e
+ lifecycle-mapping
+ 1.0.0
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-enforcer-plugin
+ [1.0.0,)
+
+ enforce
+
+
+
+
+
+
+
+
+
+
+
+ org.apache.felix
+ maven-bundle-plugin
+ 3.0.1
+
+
+ bundle
+ package
+
+ bundle
+
+
+
+
+
+
+
+
+ org.apache.maven.plugins
- maven-jar-plugin
- 2.4
-
-
-
- true
- true
-
-
-
-
-
- org.apache.maven.plugins
- maven-site-plugin
-
-
- org.apache.maven.doxia
- doxia-module-markdown
- 1.5
-
-
- org.apache.maven.doxia
- doxia-module-confluence
- 1.5
-
-
-
-
- org.apache.maven.plugins
- maven-scm-publish-plugin
-
- gh-pages
- ${project.scm.developerConnection}
- ${project.build.directory}/site
-
+ maven-project-info-reports-plugin
+ 2.7org.apache.felix
@@ -159,32 +162,96 @@
-
+
-
-
- com.rometools
- rome-utils
- 1.6.0-SNAPSHOT
-
-
- org.jdom
- jdom2
-
-
- org.slf4j
- slf4j-api
-
-
- ch.qos.logback
- logback-classic
- test
-
-
- junit
- junit
- test
-
-
+
+
+
+
+ org.jdom
+ jdom2
+ 2.0.5
+
+
+
+ org.slf4j
+ slf4j-api
+ 1.7.10
+
+
+ ch.qos.logback
+ logback-classic
+ 1.1.2
+
+
+
+ junit
+ junit
+ 4.12
+
+
+
+ org.hamcrest
+ hamcrest-library
+ 1.3
+
+
+
+ javax.servlet
+ servlet-api
+ 2.5
+
+
+ javax.servlet.jsp
+ jsp-api
+ 2.1
+
+
+ javax.persistence
+ persistence-api
+ 1.0.2
+
+
+
+ com.google.inject.extensions
+ guice-servlet
+ 2.0
+
+
+
+ commons-httpclient
+ commons-httpclient
+ 3.1
+
+
+ org.apache.commons
+ commons-lang3
+ 3.3.2
+
+
+ commons-beanutils
+ commons-beanutils
+ 1.9.2
+
+
+
+ jetty
+ jetty
+ 4.2.12
+
+
+
+ org.apache.xmlrpc
+ xmlrpc-client
+ 3.1.3
+
+
+
+ net.oauth.core
+ oauth
+ 20100527
+
+
+
diff --git a/rome-certiorem-webapp/.gitignore b/rome-certiorem-webapp/.gitignore
new file mode 100644
index 0000000..2e975ff
--- /dev/null
+++ b/rome-certiorem-webapp/.gitignore
@@ -0,0 +1,4 @@
+/.classpath
+/.project
+/.settings
+/target
\ No newline at end of file
diff --git a/rome-certiorem-webapp/README.md b/rome-certiorem-webapp/README.md
new file mode 100644
index 0000000..4679522
--- /dev/null
+++ b/rome-certiorem-webapp/README.md
@@ -0,0 +1,4 @@
+rome-certiorem-webapp
+=====================
+
+Example project using rome-certiorem
diff --git a/rome-certiorem-webapp/pom.xml b/rome-certiorem-webapp/pom.xml
new file mode 100644
index 0000000..1d3f5a1
--- /dev/null
+++ b/rome-certiorem-webapp/pom.xml
@@ -0,0 +1,61 @@
+
+
+ 4.0.0
+
+
+ com.rometools
+ rome-parent
+ 1.6.0-SNAPSHOT
+
+
+ rome-certiorem-webapp
+ war
+
+ rome-certiorem-webapp
+
+
+
+ The Apache Software License, Version 2.0
+ http://www.apache.org/licenses/LICENSE-2.0.txt
+ repo
+
+
+
+
+ scm:git:git@github.com:rometools/rome-certiorem-webapp.git
+ scm:git:git@github.com:rometools/rome-certiorem-webapp.git
+ https://github.com/rometools/rome-certiorem-webapp/
+
+
+
+
+ sonatype-nexus-snapshots
+ https://oss.sonatype.org/content/repositories/snapshots
+
+ false
+
+
+ true
+
+
+
+
+
+
+ com.rometools
+ rome-certiorem
+ 1.5.0
+
+
+ com.google.inject.extensions
+ guice-servlet
+
+
+ javax.servlet
+ servlet-api
+ provided
+
+
+
+
diff --git a/rome-certiorem-webapp/src/main/java/com/rometools/certiorem/webapp/HubServlet.java b/rome-certiorem-webapp/src/main/java/com/rometools/certiorem/webapp/HubServlet.java
new file mode 100644
index 0000000..ea4e3bc
--- /dev/null
+++ b/rome-certiorem-webapp/src/main/java/com/rometools/certiorem/webapp/HubServlet.java
@@ -0,0 +1,27 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package com.rometools.certiorem.webapp;
+
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import com.rometools.certiorem.hub.Hub;
+import com.rometools.certiorem.web.AbstractHubServlet;
+
+/**
+ *
+ * @author robert.cooper
+ */
+@Singleton
+public class HubServlet extends AbstractHubServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Inject
+ public HubServlet(final Hub hub) {
+ super(hub);
+ }
+
+}
diff --git a/rome-certiorem-webapp/src/main/java/com/rometools/certiorem/webapp/NotifyTest.java b/rome-certiorem-webapp/src/main/java/com/rometools/certiorem/webapp/NotifyTest.java
new file mode 100644
index 0000000..3430e0f
--- /dev/null
+++ b/rome-certiorem-webapp/src/main/java/com/rometools/certiorem/webapp/NotifyTest.java
@@ -0,0 +1,42 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package com.rometools.certiorem.webapp;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.inject.Singleton;
+import com.rometools.certiorem.pub.NotificationException;
+import com.rometools.certiorem.pub.Publisher;
+
+/**
+ *
+ * @author robert.cooper
+ */
+@Singleton
+public class NotifyTest extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ private static final Logger LOG = LoggerFactory.getLogger(NotifyTest.class);
+
+ @Override
+ public void doGet(final HttpServletRequest request, final HttpServletResponse response) throws ServletException {
+ final Publisher pub = new Publisher();
+ try {
+ pub.sendUpdateNotification("http://localhost/webapp/hub", "http://localhost/webapp/research-atom.xml");
+ } catch (final NotificationException ex) {
+ LOG.error(null, ex);
+ throw new ServletException(ex);
+ }
+ }
+
+}
diff --git a/rome-certiorem-webapp/src/main/java/com/rometools/certiorem/webapp/ServerModule.java b/rome-certiorem-webapp/src/main/java/com/rometools/certiorem/webapp/ServerModule.java
new file mode 100644
index 0000000..865cc55
--- /dev/null
+++ b/rome-certiorem-webapp/src/main/java/com/rometools/certiorem/webapp/ServerModule.java
@@ -0,0 +1,71 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package com.rometools.certiorem.webapp;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.inject.AbstractModule;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+import com.google.inject.Provides;
+import com.google.inject.Singleton;
+import com.google.inject.servlet.GuiceServletContextListener;
+import com.google.inject.servlet.ServletModule;
+import com.rometools.certiorem.hub.Hub;
+import com.rometools.certiorem.hub.data.ram.InMemoryHubDAO;
+import com.rometools.certiorem.hub.notify.standard.UnthreadedNotifier;
+import com.rometools.certiorem.hub.verify.standard.UnthreadedVerifier;
+import com.rometools.certiorem.sub.Subscriptions;
+import com.rometools.certiorem.sub.data.ram.InMemorySubDAO;
+import com.rometools.certiorem.sub.request.AsyncRequester;
+import com.rometools.fetcher.FeedFetcher;
+import com.rometools.fetcher.impl.HashMapFeedInfoCache;
+import com.rometools.fetcher.impl.HttpURLFeedFetcher;
+
+/**
+ *
+ * @author robert.cooper
+ */
+public class ServerModule extends GuiceServletContextListener {
+
+ private static final Logger LOG = LoggerFactory.getLogger(ServerModule.class);
+
+ @Override
+ protected Injector getInjector() {
+ return Guice.createInjector(new AbstractModule() {
+ @Override
+ protected void configure() {
+ }
+
+ @Provides
+ @Singleton
+ public Hub buildHub() {
+ final FeedFetcher fetcher = new HttpURLFeedFetcher(new HashMapFeedInfoCache());
+ final Hub hub = new Hub(new InMemoryHubDAO(), new UnthreadedVerifier(), new UnthreadedNotifier(), fetcher);
+
+ return hub;
+ }
+
+ @Provides
+ @Singleton
+ public Subscriptions buildSubs() {
+ LOG.debug("buildSubs");
+ final Subscriptions subs = new Subscriptions(new HashMapFeedInfoCache(), new AsyncRequester(), "http://localhost/webapp/subscriptions/",
+ new InMemorySubDAO());
+
+ return subs;
+ }
+ }, new ServletModule() {
+ @Override
+ protected void configureServlets() {
+ serve("/hub*").with(HubServlet.class);
+ serve("/subscriptions/*").with(SubServlet.class);
+ serve("/test/sub").with(SubTest.class);
+ serve("/test/pub").with(NotifyTest.class);
+ }
+ });
+ }
+}
diff --git a/rome-certiorem-webapp/src/main/java/com/rometools/certiorem/webapp/SubServlet.java b/rome-certiorem-webapp/src/main/java/com/rometools/certiorem/webapp/SubServlet.java
new file mode 100644
index 0000000..8e78ece
--- /dev/null
+++ b/rome-certiorem-webapp/src/main/java/com/rometools/certiorem/webapp/SubServlet.java
@@ -0,0 +1,27 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package com.rometools.certiorem.webapp;
+
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import com.rometools.certiorem.sub.Subscriptions;
+import com.rometools.certiorem.web.AbstractSubServlet;
+
+/**
+ *
+ * @author robert.cooper
+ */
+@Singleton
+public class SubServlet extends AbstractSubServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Inject
+ public SubServlet(final Subscriptions subscriptions) {
+ super(subscriptions);
+ }
+
+}
diff --git a/rome-certiorem-webapp/src/main/java/com/rometools/certiorem/webapp/SubTest.java b/rome-certiorem-webapp/src/main/java/com/rometools/certiorem/webapp/SubTest.java
new file mode 100644
index 0000000..c728b16
--- /dev/null
+++ b/rome-certiorem-webapp/src/main/java/com/rometools/certiorem/webapp/SubTest.java
@@ -0,0 +1,67 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package com.rometools.certiorem.webapp;
+
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import com.rometools.certiorem.sub.Subscriptions;
+import com.rometools.certiorem.sub.data.Subscription;
+import com.rometools.certiorem.sub.data.SubscriptionCallback;
+import com.rometools.fetcher.impl.SyndFeedInfo;
+
+/**
+ *
+ * @author robert.cooper
+ */
+@Singleton
+public class SubTest extends HttpServlet {
+
+ private static final Logger LOG = LoggerFactory.getLogger(SubTest.class);
+
+ private static final long serialVersionUID = 1L;
+
+ private final Subscriptions subs;
+
+ @Inject
+ public SubTest(final Subscriptions subs) {
+ this.subs = subs;
+ }
+
+ @Override
+ public void doGet(final HttpServletRequest request, final HttpServletResponse response) {
+ subs.subscribe("http://localhost/webapp/hub", "http://localhost/webapp/research-atom.xml", true, -1L, null, new SubscriptionCallback() {
+
+ @Override
+ public void onFailure(final Exception e) {
+ e.printStackTrace();
+ }
+
+ @Override
+ public void onSubscribe(final Subscription subscribed) {
+ LOG.debug("Subscribed {} {}", subscribed.getId(), subscribed.getSourceUrl());
+ }
+
+ @Override
+ public void onNotify(final Subscription subscribed, final SyndFeedInfo feedInfo) {
+ // TODO Auto-generated method stub
+ }
+
+ @Override
+ public void onUnsubscribe(final Subscription subscribed) {
+ // TODO Auto-generated method stub
+ }
+
+ });
+ }
+
+}
diff --git a/rome-certiorem-webapp/src/main/resources/.gitignore b/rome-certiorem-webapp/src/main/resources/.gitignore
new file mode 100644
index 0000000..53b845b
--- /dev/null
+++ b/rome-certiorem-webapp/src/main/resources/.gitignore
@@ -0,0 +1 @@
+# needed to commit empty folder
\ No newline at end of file
diff --git a/rome-certiorem-webapp/src/main/webapp/WEB-INF/sun-web.xml b/rome-certiorem-webapp/src/main/webapp/WEB-INF/sun-web.xml
new file mode 100644
index 0000000..0599c81
--- /dev/null
+++ b/rome-certiorem-webapp/src/main/webapp/WEB-INF/sun-web.xml
@@ -0,0 +1,11 @@
+
+
+
+ /webapp
+
+
+
+ Keep a copy of the generated servlet class' java code.
+
+
+
diff --git a/rome-certiorem-webapp/src/main/webapp/WEB-INF/web.xml b/rome-certiorem-webapp/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000..bec632b
--- /dev/null
+++ b/rome-certiorem-webapp/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,31 @@
+
+
+
+ rome-certiorem-webapp
+
+
+ 30
+
+
+
+ index.jsp
+
+
+
+ guiceFilter
+ com.google.inject.servlet.GuiceFilter
+
+
+
+ guiceFilter
+ /*
+
+
+
+ Guice config
+ com.rometools.certiorem.example.ServerModule
+
+
+
diff --git a/rome-certiorem-webapp/src/main/webapp/index.jsp b/rome-certiorem-webapp/src/main/webapp/index.jsp
new file mode 100644
index 0000000..ab292c3
--- /dev/null
+++ b/rome-certiorem-webapp/src/main/webapp/index.jsp
@@ -0,0 +1,13 @@
+<%@page contentType="text/html" pageEncoding="UTF-8"%>
+
+
+
+
+
+ JSP Page
+
+
+
Hello World!
+
+
diff --git a/rome-certiorem-webapp/src/main/webapp/research-atom.xml b/rome-certiorem-webapp/src/main/webapp/research-atom.xml
new file mode 100644
index 0000000..fcac7d3
--- /dev/null
+++ b/rome-certiorem-webapp/src/main/webapp/research-atom.xml
@@ -0,0 +1,59 @@
+
+
+
+
+The name of your feed
+
+
+2003-12-13T18:30:02Z
+
+
+ The name of the author
+
+
+
+
+ Analysis of tsunami on the economy
+ Analysis of the recent tsumani on the economy
+
+ tag:providers-website-item1.com,2003:3.2397
+ 2003-12-13T08:29:29-04:00
+ 2003-12-13T18:30:02Z
+ http://www.providers-website.com/image1.jpg
+ 2005-12-20
+ Economy
+ Tsunami
+
+ 2005-02-25
+ James Smith
+ Tsunami and the Economy
+ III
+ 5
+
+
+
+
+
+ Google and the internet
+ Analysis of Google's impact on the internet
+
+ tag:providers-website-item1.com,2003:3.2397
+ 2003-12-13T08:29:29-04:00
+ 2003-12-13T18:30:02Z
+ http://www.providers-website.com/image2.jpg
+ 2005-12-20
+ Internet
+ Search Engine
+
+ 2004-01-29
+ Sue Smith
+ Google and the Internet
+ VI
+ 23
+
+
+
diff --git a/rome-certiorem-webapp/src/test/java/.gitignore b/rome-certiorem-webapp/src/test/java/.gitignore
new file mode 100644
index 0000000..53b845b
--- /dev/null
+++ b/rome-certiorem-webapp/src/test/java/.gitignore
@@ -0,0 +1 @@
+# needed to commit empty folder
\ No newline at end of file
diff --git a/rome-certiorem-webapp/src/test/resources/.gitignore b/rome-certiorem-webapp/src/test/resources/.gitignore
new file mode 100644
index 0000000..53b845b
--- /dev/null
+++ b/rome-certiorem-webapp/src/test/resources/.gitignore
@@ -0,0 +1 @@
+# needed to commit empty folder
\ No newline at end of file
diff --git a/rome-certiorem/.gitignore b/rome-certiorem/.gitignore
new file mode 100644
index 0000000..2e975ff
--- /dev/null
+++ b/rome-certiorem/.gitignore
@@ -0,0 +1,4 @@
+/.classpath
+/.project
+/.settings
+/target
\ No newline at end of file
diff --git a/rome-certiorem/LICENSE b/rome-certiorem/LICENSE
new file mode 100644
index 0000000..7a4a3ea
--- /dev/null
+++ b/rome-certiorem/LICENSE
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ 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.
\ No newline at end of file
diff --git a/rome-certiorem/README b/rome-certiorem/README
new file mode 100644
index 0000000..dc568e4
--- /dev/null
+++ b/rome-certiorem/README
@@ -0,0 +1,9 @@
+ROME Certiorem
+
+Build Instructions
+-------------------------------------------------------------------------------
+
+To build with Maven 2+:
+
+> mvn package
+
diff --git a/rome-certiorem/pom.xml b/rome-certiorem/pom.xml
new file mode 100644
index 0000000..a92e869
--- /dev/null
+++ b/rome-certiorem/pom.xml
@@ -0,0 +1,111 @@
+
+
+ 4.0.0
+
+
+ com.rometools
+ rome-parent
+ 1.6.0-SNAPSHOT
+
+
+ rome-certiorem
+ 1.6.0-SNAPSHOT
+ jar
+
+ rome-certiorem
+
+ A PubSubHubub implementation for Java based on ROME
+
+
+ scm:git:ssh://github.com/rometools/rome-certiorem.git
+ scm:git:ssh://git@github.com/rometools/rome-certiorem.git
+ https://github.com/rometools/rome-certiorem
+
+
+
+
+ Robert Cooper
+ kebernet@gmail.comM
+ http://www.kebernet.net
+
+
+ Farrukh Najmi
+ http://wellfleetsoftware.com
+
+
+
+
+
+ sonatype-nexus-snapshots
+ https://oss.sonatype.org/content/repositories/snapshots
+
+ false
+
+
+ true
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-site-plugin
+
+ 9000
+ ${basedir}/target/site/tempdir
+
+
+
+ org.apache.maven.plugins
+ maven-scm-publish-plugin
+
+ gh-pages
+ ${project.scm.developerConnection}
+ ${project.build.directory}/site
+
+
+
+
+
+
+
+ com.rometools
+ rome-fetcher
+ 1.6.0-SNAPSHOT
+
+
+ commons-httpclient
+ commons-httpclient
+
+
+
+
+ javax.servlet
+ servlet-api
+ provided
+
+
+ javax.persistence
+ persistence-api
+ provided
+
+
+ org.slf4j
+ slf4j-api
+
+
+ ch.qos.logback
+ logback-classic
+ test
+
+
+ junit
+ junit
+ test
+
+
+
+
diff --git a/rome-certiorem/src/main/java/com/rometools/certiorem/HttpStatusCodeException.java b/rome-certiorem/src/main/java/com/rometools/certiorem/HttpStatusCodeException.java
new file mode 100644
index 0000000..013ce71
--- /dev/null
+++ b/rome-certiorem/src/main/java/com/rometools/certiorem/HttpStatusCodeException.java
@@ -0,0 +1,40 @@
+/**
+ *
+ * Copyright (C) The ROME Team 2011
+ *
+ *
+ * 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 com.rometools.certiorem;
+
+/**
+ *
+ * @author robert.cooper
+ */
+public class HttpStatusCodeException extends RuntimeException {
+
+ private static final long serialVersionUID = 1L;
+
+ private final int status;
+
+ public HttpStatusCodeException(final int status, final String message, final Throwable cause) {
+ super(message, cause);
+ this.status = status;
+ }
+
+ public int getStatus() {
+ return status;
+ }
+
+}
diff --git a/rome-certiorem/src/main/java/com/rometools/certiorem/hub/DeltaFeedInfoCache.java b/rome-certiorem/src/main/java/com/rometools/certiorem/hub/DeltaFeedInfoCache.java
new file mode 100644
index 0000000..d197fd1
--- /dev/null
+++ b/rome-certiorem/src/main/java/com/rometools/certiorem/hub/DeltaFeedInfoCache.java
@@ -0,0 +1,51 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package com.rometools.certiorem.hub;
+
+import java.net.URL;
+
+import com.rometools.fetcher.impl.FeedFetcherCache;
+import com.rometools.fetcher.impl.SyndFeedInfo;
+
+/**
+ * Wrapper FeedFetcherCache that wraps a backing FeedFetcherCache and makes sure that any
+ * SyndFeedInfo used within it are replaced with a DeltaSyndFeedInfo which is capable of tracking
+ * changes to entries in the underlying feed.
+ *
+ * @author najmi
+ */
+public class DeltaFeedInfoCache implements FeedFetcherCache {
+
+ FeedFetcherCache backingCache;
+
+ public DeltaFeedInfoCache(final FeedFetcherCache backingCache) {
+ this.backingCache = backingCache;
+ }
+
+ @Override
+ public SyndFeedInfo getFeedInfo(final URL feedUrl) {
+ return backingCache.getFeedInfo(feedUrl);
+ }
+
+ @Override
+ public void setFeedInfo(final URL feedUrl, SyndFeedInfo syndFeedInfo) {
+ // Make sure that syndFeedInfo is an instance of DeltaSyndFeedInfo
+ if (!(syndFeedInfo instanceof DeltaSyndFeedInfo)) {
+ syndFeedInfo = new DeltaSyndFeedInfo(syndFeedInfo);
+ }
+ backingCache.setFeedInfo(feedUrl, syndFeedInfo);
+ }
+
+ @Override
+ public void clear() {
+ backingCache.clear();
+ }
+
+ @Override
+ public SyndFeedInfo remove(final URL feedUrl) {
+ return backingCache.remove(feedUrl);
+ }
+
+}
diff --git a/rome-certiorem/src/main/java/com/rometools/certiorem/hub/DeltaSyndFeedInfo.java b/rome-certiorem/src/main/java/com/rometools/certiorem/hub/DeltaSyndFeedInfo.java
new file mode 100644
index 0000000..9f14f47
--- /dev/null
+++ b/rome-certiorem/src/main/java/com/rometools/certiorem/hub/DeltaSyndFeedInfo.java
@@ -0,0 +1,133 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package com.rometools.certiorem.hub;
+
+import java.math.BigInteger;
+import java.security.MessageDigest;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import com.rometools.fetcher.impl.SyndFeedInfo;
+import com.rometools.rome.feed.synd.SyndEntry;
+import com.rometools.rome.feed.synd.SyndFeed;
+
+/**
+ * Extends SyndFeedInfo to also track etags for individual entries. This may be used with
+ * DeltaFeedInfoCache to only return feed with a subset of entries that have changed since last
+ * fetch.
+ *
+ * @author najmi
+ */
+public class DeltaSyndFeedInfo extends SyndFeedInfo {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ Map entryTagsMap = new HashMap();
+ Map changedMap = new HashMap();
+
+ public DeltaSyndFeedInfo(final SyndFeedInfo backingFeedInfo) {
+ setETag(backingFeedInfo.getETag());
+ setId(backingFeedInfo.getId());
+ setLastModified(backingFeedInfo.getLastModified());
+ setSyndFeed(backingFeedInfo.getSyndFeed());
+ }
+
+ /**
+ * Gets a filtered version of the SyndFeed that only has entries that were changed in the last
+ * setSyndFeed() call.
+ *
+ * @return
+ */
+ @Override
+ public synchronized SyndFeed getSyndFeed() {
+ try {
+ final SyndFeed feed = (SyndFeed) super.getSyndFeed().clone();
+
+ final List changedEntries = new ArrayList();
+
+ final List entries = feed.getEntries();
+ for (final SyndEntry entry : entries) {
+ if (changedMap.containsKey(entry.getUri())) {
+ changedEntries.add(entry);
+ }
+ }
+
+ feed.setEntries(changedEntries);
+
+ return feed;
+ } catch (final CloneNotSupportedException ex) {
+ throw new RuntimeException(ex);
+ }
+ }
+
+ /**
+ * Overrides super class method to update changedMap and entryTagsMap for tracking changed
+ * entries.
+ *
+ * @param feed
+ */
+ @Override
+ public final synchronized void setSyndFeed(final SyndFeed feed) {
+ super.setSyndFeed(feed);
+
+ changedMap.clear();
+ final List entries = feed.getEntries();
+ for (final SyndEntry entry : entries) {
+ final String currentEntryTag = computeEntryTag(entry);
+ final String previousEntryTag = entryTagsMap.get(entry.getUri());
+
+ if (previousEntryTag == null || !currentEntryTag.equals(previousEntryTag)) {
+ // Entry has changed
+ changedMap.put(entry.getUri(), Boolean.TRUE);
+ }
+ entryTagsMap.put(entry.getUri(), currentEntryTag);
+ }
+ }
+
+ private String computeEntryTag(final SyndEntry entry) {
+
+ // Following hash algorithm suggested by Robert Cooper needs to be
+ // evaluated in future.
+ // int hash = ( entry.getUri() != null ? entry.getUri().hashCode() :
+ // entry.getLink().hashCode() ) ^
+ // (entry.getUpdatedDate() != null ? entry.getUpdatedDate().hashCode() :
+ // entry.getPublishedDate().hashCode()) ^
+ // entry.getTitle().hashCode() ^
+ // entry.getDescription().hashCode();
+
+ final String id = entry.getUri();
+ Date updateDate = entry.getUpdatedDate();
+ final Date publishedDate = entry.getPublishedDate();
+ if (updateDate == null) {
+ if (publishedDate != null) {
+ updateDate = publishedDate;
+ } else {
+ // For misbehaving feeds that do not set updateDate or
+ // publishedDate we use current tiem which pretty mucg assures
+ // that it will be viewed as
+ // changed even when it is not
+ updateDate = new Date();
+ }
+ }
+ final String key = id + ":" + entry.getUpdatedDate();
+ return computeDigest(key);
+ }
+
+ private String computeDigest(final String content) {
+ try {
+ final MessageDigest md = MessageDigest.getInstance("SHA");
+ final byte[] digest = md.digest(content.getBytes());
+ final BigInteger bi = new BigInteger(digest);
+ return bi.toString(16);
+ } catch (final Exception e) {
+ return "";
+ }
+ }
+}
diff --git a/rome-certiorem/src/main/java/com/rometools/certiorem/hub/Hub.java b/rome-certiorem/src/main/java/com/rometools/certiorem/hub/Hub.java
new file mode 100644
index 0000000..81feb4f
--- /dev/null
+++ b/rome-certiorem/src/main/java/com/rometools/certiorem/hub/Hub.java
@@ -0,0 +1,259 @@
+/**
+ *
+ * Copyright (C) The ROME Team 2011
+ *
+ *
+ * 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 com.rometools.certiorem.hub;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.rometools.certiorem.HttpStatusCodeException;
+import com.rometools.certiorem.hub.Notifier.SubscriptionSummaryCallback;
+import com.rometools.certiorem.hub.Verifier.VerificationCallback;
+import com.rometools.certiorem.hub.data.HubDAO;
+import com.rometools.certiorem.hub.data.Subscriber;
+import com.rometools.certiorem.hub.data.SubscriptionSummary;
+import com.rometools.fetcher.FeedFetcher;
+import com.rometools.rome.feed.synd.SyndFeed;
+
+/**
+ * The basic business logic controller for the Hub implementation. It is intended to be usable under
+ * a very thin servlet wrapper, or other, non-HTTP notification methods you might want to use.
+ *
+ * @author robert.cooper
+ */
+public class Hub {
+
+ private static final Logger LOG = LoggerFactory.getLogger(Hub.class);
+
+ private static final HashSet STANDARD_SCHEMES = new HashSet();
+
+ static {
+ STANDARD_SCHEMES.add("http");
+ STANDARD_SCHEMES.add("https");
+ }
+
+ private final FeedFetcher fetcher;
+ private final HubDAO dao;
+ private final Notifier notifier;
+ private final Set validPorts;
+ private final Set validSchemes;
+ private final Set validTopics;
+ private final Verifier verifier;
+
+ /**
+ * Constructs a new Hub instance
+ *
+ * @param dao The persistence HubDAO to use
+ * @param verifier The verification strategy to use.
+ */
+ public Hub(final HubDAO dao, final Verifier verifier, final Notifier notifier, final FeedFetcher fetcher) {
+ this.dao = dao;
+ this.verifier = verifier;
+ this.notifier = notifier;
+ this.fetcher = fetcher;
+ validSchemes = STANDARD_SCHEMES;
+ validPorts = Collections.emptySet();
+ validTopics = Collections.emptySet();
+ }
+
+ /**
+ * Constructs a new Hub instance.
+ *
+ * @param dao The persistence HubDAO to use
+ * @param verifier The verification strategy to use
+ * @param validSchemes A list of valid URI schemes for callbacks (default: http, https)
+ * @param validPorts A list of valid port numbers for callbacks (default: any)
+ * @param validTopics A set of valid topic URIs which can be subscribed to (default: any)
+ */
+ public Hub(final HubDAO dao, final Verifier verifier, final Notifier notifier, final FeedFetcher fetcher, final Set validSchemes,
+ final Set validPorts, final Set validTopics) {
+ this.dao = dao;
+ this.verifier = verifier;
+ this.notifier = notifier;
+ this.fetcher = fetcher;
+
+ final Set readOnlySchemes = Collections.unmodifiableSet(validSchemes);
+ this.validSchemes = readOnlySchemes == null ? STANDARD_SCHEMES : readOnlySchemes;
+
+ final Set readOnlyPorts = Collections.unmodifiableSet(validPorts);
+ if (readOnlyPorts == null) {
+ this.validPorts = Collections.emptySet();
+ } else {
+ this.validPorts = readOnlyPorts;
+ }
+
+ final Set readOnlyTopics = Collections.unmodifiableSet(validTopics);
+ if (validTopics == null) {
+ this.validTopics = Collections.emptySet();
+ } else {
+ this.validTopics = readOnlyTopics;
+ }
+
+ }
+
+ /**
+ * Sends a notification to the subscribers
+ *
+ * @param requestHost the host name the hub is running on. (Used for the user agent)
+ * @param topic the URL of the topic that was updated.
+ * @throws HttpStatusCodeException a wrapper exception with a recommended status code for the
+ * request.
+ */
+ public void sendNotification(final String requestHost, final String topic) {
+ // FIXME assert should not be used for validation because it can be disabled
+ assert validTopics.isEmpty() || validTopics.contains(topic) : "That topic is not supported by this hub. " + topic;
+ LOG.debug("Sending notification for {}", topic);
+ try {
+ final List extends Subscriber> subscribers = dao.subscribersForTopic(topic);
+
+ if (subscribers.isEmpty()) {
+ LOG.debug("No subscribers to notify for {}", topic);
+ return;
+ }
+
+ final List extends SubscriptionSummary> summaries = dao.summariesForTopic(topic);
+ int total = 0;
+ final StringBuilder hosts = new StringBuilder();
+
+ for (final SubscriptionSummary s : summaries) {
+ if (s.getSubscribers() > 0) {
+ total += s.getSubscribers();
+ hosts.append(" (").append(s.getHost()).append("; ").append(s.getSubscribers()).append(" subscribers)");
+ }
+ }
+
+ final StringBuilder userAgent = new StringBuilder("ROME-Certiorem (+http://").append(requestHost).append("; ").append(total)
+ .append(" subscribers)").append(hosts);
+ final SyndFeed feed = fetcher.retrieveFeed(userAgent.toString(), new URL(topic));
+ LOG.debug("Got feed for {} Sending to {} subscribers.", topic, subscribers.size());
+ notifier.notifySubscribers(subscribers, feed, new SubscriptionSummaryCallback() {
+ @Override
+ public void onSummaryInfo(final SubscriptionSummary summary) {
+ dao.handleSummary(topic, summary);
+ }
+ });
+ } catch (final Exception ex) {
+ LOG.debug("Exception getting " + topic, ex);
+ throw new HttpStatusCodeException(500, ex.getMessage(), ex);
+ }
+ }
+
+ /**
+ * Subscribes to a topic.
+ *
+ * @param callback Callback URI
+ * @param topic Topic URI
+ * @param verify Verification Type
+ * @param lease_seconds Duration of the lease
+ * @param secret Secret value
+ * @param verify_token verify_token;
+ * @return Boolean.TRUE if the subscription succeeded synchronously, Boolean.FALSE if the
+ * subscription failed synchronously, or null if the request is asynchronous.
+ * @throws HttpStatusCodeException a wrapper exception with a recommended status code for the
+ * request.
+ */
+ public Boolean subscribe(final String callback, final String topic, final String verify, final long lease_seconds, final String secret,
+ final String verify_token) {
+ LOG.debug("{} wants to subscribe to {}", callback, topic);
+ try {
+ try {
+ // FIXME assert should not be used for validation because it can be disabled
+ assert callback != null : "Callback URL is required.";
+ assert topic != null : "Topic URL is required.";
+
+ final URI uri = new URI(callback);
+ assert validSchemes.contains(uri.getScheme()) : "Not a valid protocol " + uri.getScheme();
+ assert validPorts.isEmpty() || validPorts.contains(uri.getPort()) : "Not a valid port " + uri.getPort();
+ assert validTopics.isEmpty() || validTopics.contains(topic) : "Not a supported topic " + topic;
+ } catch (final URISyntaxException ex) {
+ assert false : "Not a valid URI " + callback;
+ }
+ assert verify != null && (verify.equals(Subscriber.VERIFY_ASYNC) || verify.equals(Subscriber.VERIFY_SYNC)) : "Unexpected verify value " + verify;
+
+ final Subscriber subscriber = new Subscriber();
+ subscriber.setCallback(callback);
+ subscriber.setLeaseSeconds(lease_seconds);
+ subscriber.setSecret(secret);
+ subscriber.setTopic(topic);
+ subscriber.setVerify(verify);
+ subscriber.setVertifyToken(verify_token);
+
+ final VerificationCallback verified = new VerificationCallback() {
+ @Override
+ public void onVerify(final boolean verified) {
+ if (verified) {
+ LOG.debug("Verified {} subscribed to {}", subscriber.getCallback(), subscriber.getTopic());
+ dao.addSubscriber(subscriber);
+ }
+ }
+ };
+
+ if (Subscriber.VERIFY_SYNC.equals(subscriber.getVerify())) {
+ final boolean result = verifier.verifySubcribeSyncronously(subscriber);
+ verified.onVerify(result);
+
+ return result;
+ } else {
+ verifier.verifySubscribeAsyncronously(subscriber, verified);
+
+ return null;
+ }
+ } catch (final AssertionError ae) {
+ throw new HttpStatusCodeException(400, ae.getMessage(), ae);
+ } catch (final Exception e) {
+ throw new HttpStatusCodeException(500, e.getMessage(), e);
+ }
+ }
+
+ public Boolean unsubscribe(final String callback, final String topic, final String verify, final String secret, final String verifyToken) {
+ final Subscriber subscriber = dao.findSubscriber(topic, callback);
+ if (subscriber == null) {
+ throw new HttpStatusCodeException(400, "Not a valid subscription.", null);
+ }
+ subscriber.setVertifyToken(verifyToken);
+ subscriber.setSecret(secret);
+ if (Subscriber.VERIFY_SYNC.equals(verify)) {
+
+ final boolean ret = verifier.verifyUnsubcribeSyncronously(subscriber);
+ if (ret) {
+ dao.removeSubscriber(topic, callback);
+ }
+ } else {
+ verifier.verifyUnsubscribeAsyncronously(subscriber, new VerificationCallback() {
+
+ @Override
+ public void onVerify(final boolean verified) {
+ LOG.debug("Unsubscribe for {} at {} verified {}", subscriber.getTopic(), subscriber.getCallback(), verified);
+ if (verified) {
+ dao.removeSubscriber(topic, callback);
+ }
+ }
+
+ });
+ }
+ return null;
+ }
+}
diff --git a/rome-certiorem/src/main/java/com/rometools/certiorem/hub/Notifier.java b/rome-certiorem/src/main/java/com/rometools/certiorem/hub/Notifier.java
new file mode 100644
index 0000000..b7f7ae3
--- /dev/null
+++ b/rome-certiorem/src/main/java/com/rometools/certiorem/hub/Notifier.java
@@ -0,0 +1,51 @@
+/**
+ *
+ * Copyright (C) The ROME Team 2011
+ *
+ *
+ * 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 com.rometools.certiorem.hub;
+
+import java.util.List;
+
+import com.rometools.certiorem.hub.data.Subscriber;
+import com.rometools.certiorem.hub.data.SubscriptionSummary;
+import com.rometools.rome.feed.synd.SyndFeed;
+
+/**
+ *
+ * @author robert.cooper
+ */
+public interface Notifier {
+ /**
+ * Instructs the notifier to begin sending notifications to the list of subscribers
+ *
+ * @param subscribers Subscribers to notify
+ * @param value The SyndFeed to send them
+ * @param callback A callback that is invoked each time a subscriber is notified.
+ */
+ public void notifySubscribers(List extends Subscriber> subscribers, SyndFeed value, SubscriptionSummaryCallback callback);
+
+ /**
+ * A callback that is invoked each time a subscriber is notified.
+ */
+ public static interface SubscriptionSummaryCallback {
+ /**
+ *
+ * @param summary A summary of the data received from the subscriber
+ */
+ public void onSummaryInfo(SubscriptionSummary summary);
+ }
+}
diff --git a/rome-certiorem/src/main/java/com/rometools/certiorem/hub/Verifier.java b/rome-certiorem/src/main/java/com/rometools/certiorem/hub/Verifier.java
new file mode 100644
index 0000000..b50a3f1
--- /dev/null
+++ b/rome-certiorem/src/main/java/com/rometools/certiorem/hub/Verifier.java
@@ -0,0 +1,81 @@
+/**
+ *
+ * Copyright (C) The ROME Team 2011
+ *
+ *
+ * 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 com.rometools.certiorem.hub;
+
+import com.rometools.certiorem.hub.data.Subscriber;
+
+/**
+ * A strategy interface for verification of subscriptions.
+ *
+ * @author robert.cooper
+ */
+public interface Verifier {
+
+ /**
+ * Value for hub.mode = subscribe
+ */
+ public static final String MODE_SUBSCRIBE = "subscribe";
+ /**
+ * Value for hub.mode = unsubscribe
+ */
+ public static final String MODE_UNSUBSCRIBE = "unsubscribe";
+
+ /**
+ * Verifies a subscriber (possibly) asyncronously
+ *
+ * @param subscriber the Subscriber to verify
+ * @param callback a callback with the result of the verification.
+ */
+ public void verifySubscribeAsyncronously(Subscriber subscriber, VerificationCallback callback);
+
+ /**
+ * Verifies a subscriber syncronously
+ *
+ * @param subscriber The subscriber data
+ * @return boolean result;
+ */
+ public boolean verifySubcribeSyncronously(Subscriber subscriber);
+
+ /**
+ * Verifies am unsubscribe (possibly) asyncronously
+ *
+ * @param subscriber The subscriber data
+ * @param callback result
+ */
+ public void verifyUnsubscribeAsyncronously(Subscriber subscriber, VerificationCallback callback);
+
+ /**
+ * Verifies an unsubscribe syncronously
+ *
+ * @param subscriber The subscriber data
+ * @return boolean result;
+ */
+ public boolean verifyUnsubcribeSyncronously(Subscriber subscriber);
+
+ /**
+ * An interface for capturing the result of a verification (subscribe or unsubscribe)
+ */
+ public static interface VerificationCallback {
+ /**
+ *
+ * @param verified success state of the verification
+ */
+ public void onVerify(boolean verified);
+ }
+}
diff --git a/rome-certiorem/src/main/java/com/rometools/certiorem/hub/data/HubDAO.java b/rome-certiorem/src/main/java/com/rometools/certiorem/hub/data/HubDAO.java
new file mode 100644
index 0000000..b942746
--- /dev/null
+++ b/rome-certiorem/src/main/java/com/rometools/certiorem/hub/data/HubDAO.java
@@ -0,0 +1,41 @@
+/**
+ *
+ * Copyright (C) The ROME Team 2011
+ *
+ *
+ * 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 com.rometools.certiorem.hub.data;
+
+import java.util.List;
+
+/**
+ *
+ * @author robert.cooper
+ */
+public interface HubDAO {
+
+ public List extends Subscriber> subscribersForTopic(String topic);
+
+ public Subscriber addSubscriber(Subscriber subscriber);
+
+ public Subscriber findSubscriber(String topic, String callbackUrl);
+
+ public void removeSubscriber(String topic, String callback);
+
+ public void handleSummary(String topic, SubscriptionSummary summary);
+
+ public List extends SubscriptionSummary> summariesForTopic(String topic);
+
+}
diff --git a/rome-certiorem/src/main/java/com/rometools/certiorem/hub/data/Subscriber.java b/rome-certiorem/src/main/java/com/rometools/certiorem/hub/data/Subscriber.java
new file mode 100644
index 0000000..01b2b42
--- /dev/null
+++ b/rome-certiorem/src/main/java/com/rometools/certiorem/hub/data/Subscriber.java
@@ -0,0 +1,224 @@
+/**
+ *
+ * Copyright (C) The ROME Team 2011
+ *
+ *
+ * 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 com.rometools.certiorem.hub.data;
+
+import java.io.Serializable;
+
+/**
+ *
+ * @author robert.cooper
+ */
+public class Subscriber implements Serializable {
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ public static final String VERIFY_SYNC = "sync";
+ public static final String VERIFY_ASYNC = "async";
+ private String callback;
+ private String secret;
+ private String topic;
+ private String verify;
+ private String vertifyToken;
+ private long creationTime = System.currentTimeMillis();
+ private long leaseSeconds;
+
+ /**
+ * Set the value of callback
+ *
+ * @param newcallback new value of callback
+ */
+ public void setCallback(final String newcallback) {
+ callback = newcallback;
+ }
+
+ /**
+ * Get the value of callback
+ *
+ * @return the value of callback
+ */
+ public String getCallback() {
+ return callback;
+ }
+
+ /**
+ * Set the value of creationTime
+ *
+ * @param newcreationTime new value of creationTime
+ */
+ public void setCreationTime(final long newcreationTime) {
+ creationTime = newcreationTime;
+ }
+
+ /**
+ * Get the value of creationTime
+ *
+ * @return the value of creationTime
+ */
+ public long getCreationTime() {
+ return creationTime;
+ }
+
+ /**
+ * Set the value of leaseSeconds
+ *
+ * @param newleaseSeconds new value of leaseSeconds
+ */
+ public void setLeaseSeconds(final long newleaseSeconds) {
+ leaseSeconds = newleaseSeconds;
+ }
+
+ /**
+ * Get the value of leaseSeconds
+ *
+ * @return the value of leaseSeconds
+ */
+ public long getLeaseSeconds() {
+ return leaseSeconds;
+ }
+
+ /**
+ * Set the value of secret
+ *
+ * @param newsecret new value of secret
+ */
+ public void setSecret(final String newsecret) {
+ secret = newsecret;
+ }
+
+ /**
+ * Get the value of secret
+ *
+ * @return the value of secret
+ */
+ public String getSecret() {
+ return secret;
+ }
+
+ /**
+ * Set the value of topic
+ *
+ * @param newtopic new value of topic
+ */
+ public void setTopic(final String newtopic) {
+ topic = newtopic;
+ }
+
+ /**
+ * Get the value of topic
+ *
+ * @return the value of topic
+ */
+ public String getTopic() {
+ return topic;
+ }
+
+ /**
+ * Set the value of verify
+ *
+ * @param newverify new value of verify
+ */
+ public void setVerify(final String newverify) {
+ verify = newverify;
+ }
+
+ /**
+ * Get the value of verify
+ *
+ * @return the value of verify
+ */
+ public String getVerify() {
+ return verify;
+ }
+
+ /**
+ * Set the value of vertifyToken
+ *
+ * @param newvertifyToken new value of vertifyToken
+ */
+ public void setVertifyToken(final String newvertifyToken) {
+ vertifyToken = newvertifyToken;
+ }
+
+ /**
+ * Get the value of vertifyToken
+ *
+ * @return the value of vertifyToken
+ */
+ public String getVertifyToken() {
+ return vertifyToken;
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ if (obj == null) {
+ return false;
+ }
+
+ if (!(obj instanceof Subscriber)) {
+ return false;
+ }
+
+ final Subscriber other = (Subscriber) obj;
+
+ if (callback == null ? other.callback != null : !callback.equals(other.callback)) {
+ return false;
+ }
+
+ if (secret == null ? other.secret != null : !secret.equals(other.secret)) {
+ return false;
+ }
+
+ if (topic == null ? other.topic != null : !topic.equals(other.topic)) {
+ return false;
+ }
+
+ if (verify == null ? other.verify != null : !verify.equals(other.verify)) {
+ return false;
+ }
+
+ if (vertifyToken == null ? other.vertifyToken != null : !vertifyToken.equals(other.vertifyToken)) {
+ return false;
+ }
+
+ if (creationTime != other.creationTime) {
+ return false;
+ }
+
+ if (leaseSeconds != other.leaseSeconds) {
+ return false;
+ }
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int hash = 7;
+ hash = 67 * hash + (callback != null ? callback.hashCode() : 0);
+ hash = 67 * hash + (secret != null ? secret.hashCode() : 0);
+ hash = 67 * hash + (topic != null ? topic.hashCode() : 0);
+ hash = 67 * hash + (verify != null ? verify.hashCode() : 0);
+ hash = 67 * hash + (vertifyToken != null ? vertifyToken.hashCode() : 0);
+ hash = 67 * hash + (int) (creationTime ^ creationTime >>> 32);
+ hash = 67 * hash + (int) (leaseSeconds ^ leaseSeconds >>> 32);
+
+ return hash;
+ }
+}
diff --git a/rome-certiorem/src/main/java/com/rometools/certiorem/hub/data/SubscriptionSummary.java b/rome-certiorem/src/main/java/com/rometools/certiorem/hub/data/SubscriptionSummary.java
new file mode 100644
index 0000000..42e63fa
--- /dev/null
+++ b/rome-certiorem/src/main/java/com/rometools/certiorem/hub/data/SubscriptionSummary.java
@@ -0,0 +1,89 @@
+/**
+ *
+ * Copyright (C) The ROME Team 2011
+ *
+ *
+ * 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 com.rometools.certiorem.hub.data;
+
+import java.io.Serializable;
+
+/**
+ *
+ * @author robert.cooper
+ */
+public class SubscriptionSummary implements Serializable {
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ private String host;
+ private boolean lastPublishSuccessful = true;
+ private int subscribers = 0;
+
+ /**
+ * Set the value of host
+ *
+ * @param newhost new value of host
+ */
+ public void setHost(final String newhost) {
+ host = newhost;
+ }
+
+ /**
+ * Get the value of host
+ *
+ * @return the value of host
+ */
+ public String getHost() {
+ return host;
+ }
+
+ /**
+ * Set the value of lastPublishSuccessful
+ *
+ * @param newlastPublishSuccessful new value of lastPublishSuccessful
+ */
+ public void setLastPublishSuccessful(final boolean newlastPublishSuccessful) {
+ lastPublishSuccessful = newlastPublishSuccessful;
+ }
+
+ /**
+ * Get the value of lastPublishSuccessful
+ *
+ * @return the value of lastPublishSuccessful
+ */
+ public boolean isLastPublishSuccessful() {
+ return lastPublishSuccessful;
+ }
+
+ /**
+ * Set the value of subscribers
+ *
+ * @param newsubscribers new value of subscribers
+ */
+ public void setSubscribers(final int newsubscribers) {
+ subscribers = newsubscribers;
+ }
+
+ /**
+ * Get the value of subscribers
+ *
+ * @return the value of subscribers
+ */
+ public int getSubscribers() {
+ return subscribers;
+ }
+}
diff --git a/rome-certiorem/src/main/java/com/rometools/certiorem/hub/data/jpa/JPADAO.java b/rome-certiorem/src/main/java/com/rometools/certiorem/hub/data/jpa/JPADAO.java
new file mode 100644
index 0000000..4c084a3
--- /dev/null
+++ b/rome-certiorem/src/main/java/com/rometools/certiorem/hub/data/jpa/JPADAO.java
@@ -0,0 +1,131 @@
+/**
+ *
+ * Copyright (C) The ROME Team 2011
+ *
+ *
+ * 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 com.rometools.certiorem.hub.data.jpa;
+
+import java.util.LinkedList;
+import java.util.List;
+import java.util.UUID;
+
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.EntityTransaction;
+import javax.persistence.NoResultException;
+import javax.persistence.Query;
+
+import com.rometools.certiorem.hub.data.HubDAO;
+import com.rometools.certiorem.hub.data.Subscriber;
+import com.rometools.certiorem.hub.data.SubscriptionSummary;
+
+/**
+ *
+ * @author robert.cooper
+ */
+public class JPADAO implements HubDAO {
+
+ private final EntityManagerFactory factory;
+ private final boolean purgeExpired;
+
+ public JPADAO(final EntityManagerFactory factory, final boolean purgeExpired) {
+ this.factory = factory;
+ this.purgeExpired = purgeExpired;
+ }
+
+ @Override
+ public List extends Subscriber> subscribersForTopic(final String topic) {
+ final LinkedList result = new LinkedList();
+ final EntityManager em = factory.createEntityManager();
+ final EntityTransaction tx = em.getTransaction();
+ tx.begin();
+
+ final Query query = em.createNamedQuery("Subcriber.forTopic");
+ query.setParameter("topic", topic);
+
+ try {
+ @SuppressWarnings("unchecked")
+ final List subscribers = query.getResultList();
+ for (final JPASubscriber subscriber : subscribers) {
+ if (subscriber.getLeaseSeconds() == -1) {
+ result.add(subscriber);
+ continue;
+ }
+
+ if (subscriber.getSubscribedAt().getTime() < System.currentTimeMillis() - 1000 * subscriber.getLeaseSeconds()) {
+ subscriber.setExpired(true);
+ } else {
+ result.add(subscriber);
+ }
+
+ if (subscriber.isExpired() && purgeExpired) {
+ em.remove(subscriber);
+ }
+ }
+ } catch (final NoResultException e) {
+ tx.rollback();
+ em.close();
+
+ return result;
+ }
+
+ if (!tx.getRollbackOnly()) {
+ tx.commit();
+ } else {
+ tx.rollback();
+ }
+
+ em.close();
+
+ return result;
+ }
+
+ @Override
+ public Subscriber addSubscriber(final Subscriber subscriber) {
+ // FIXME assert should not be used for validation because it can be disabled
+ assert subscriber != null : "Attempt to store a null subscriber";
+ final EntityManager em = factory.createEntityManager();
+ final EntityTransaction tx = em.getTransaction();
+ tx.begin();
+ final JPASubscriber data = new JPASubscriber();
+ data.copyFrom(subscriber);
+ data.setId(UUID.randomUUID().toString());
+ em.persist(data);
+ tx.commit();
+ em.close();
+ return data;
+ }
+
+ @Override
+ public Subscriber findSubscriber(final String topic, final String callbackUrl) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void handleSummary(final String topic, final SubscriptionSummary summary) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public List extends SubscriptionSummary> summariesForTopic(final String topic) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void removeSubscriber(final String topic, final String callback) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+}
diff --git a/rome-certiorem/src/main/java/com/rometools/certiorem/hub/data/jpa/JPASubscriber.java b/rome-certiorem/src/main/java/com/rometools/certiorem/hub/data/jpa/JPASubscriber.java
new file mode 100644
index 0000000..7620bf4
--- /dev/null
+++ b/rome-certiorem/src/main/java/com/rometools/certiorem/hub/data/jpa/JPASubscriber.java
@@ -0,0 +1,111 @@
+/**
+ *
+ * Copyright (C) The ROME Team 2011
+ *
+ *
+ * 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 com.rometools.certiorem.hub.data.jpa;
+
+import java.io.Serializable;
+import java.util.Date;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+
+import com.rometools.certiorem.hub.data.Subscriber;
+
+/**
+ *
+ * @author robert.cooper
+ */
+@Entity
+@NamedQueries({ @NamedQuery(name = "Subcriber.forTopic", query = "SELECT o FROM JPASubscriber o WHERE o.topic = :topic AND o.expired = false ORDER BY o.subscribedAt") })
+public class JPASubscriber extends Subscriber implements Serializable {
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ private Date subscribedAt = new Date();
+ private String id;
+ private boolean expired = false;
+
+ /**
+ * Set the value of expired
+ *
+ * @param newexpired new value of expired
+ */
+ public void setExpired(final boolean newexpired) {
+ expired = newexpired;
+ }
+
+ /**
+ * Get the value of expired
+ *
+ * @return the value of expired
+ */
+ public boolean isExpired() {
+ return expired;
+ }
+
+ /**
+ * Set the value of id
+ *
+ * @param newid new value of id
+ */
+ public void setId(final String newid) {
+ id = newid;
+ }
+
+ /**
+ * Get the value of id
+ *
+ * @return the value of id
+ */
+ @Id
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * Set the value of subscribedAt
+ *
+ * @param newsubscribedAt new value of subscribedAt
+ */
+ public void setSubscribedAt(final Date newsubscribedAt) {
+ subscribedAt = newsubscribedAt;
+ }
+
+ /**
+ * Get the value of subscribedAt
+ *
+ * @return the value of subscribedAt
+ */
+ @Temporal(TemporalType.TIMESTAMP)
+ public Date getSubscribedAt() {
+ return subscribedAt;
+ }
+
+ public void copyFrom(final Subscriber source) {
+ setLeaseSeconds(source.getLeaseSeconds());
+ setSecret(source.getSecret());
+ setTopic(source.getTopic());
+ setVerify(source.getVerify());
+ setVertifyToken(source.getVertifyToken());
+ }
+}
diff --git a/rome-certiorem/src/main/java/com/rometools/certiorem/hub/data/jpa/package.html b/rome-certiorem/src/main/java/com/rometools/certiorem/hub/data/jpa/package.html
new file mode 100644
index 0000000..a5c2c5e
--- /dev/null
+++ b/rome-certiorem/src/main/java/com/rometools/certiorem/hub/data/jpa/package.html
@@ -0,0 +1,28 @@
+
+
+
+
+ jpa
+
+
+ A stock data implementation based on the Java Persistence API.
+
+
\ No newline at end of file
diff --git a/rome-certiorem/src/main/java/com/rometools/certiorem/hub/data/package.html b/rome-certiorem/src/main/java/com/rometools/certiorem/hub/data/package.html
new file mode 100644
index 0000000..663de72
--- /dev/null
+++ b/rome-certiorem/src/main/java/com/rometools/certiorem/hub/data/package.html
@@ -0,0 +1,29 @@
+
+
+
+
+ data
+
+
+ This package defines the basic data types and persistence mechanisms
+ that are required for a hub implementation.
+
+
\ No newline at end of file
diff --git a/rome-certiorem/src/main/java/com/rometools/certiorem/hub/data/ram/InMemoryHubDAO.java b/rome-certiorem/src/main/java/com/rometools/certiorem/hub/data/ram/InMemoryHubDAO.java
new file mode 100644
index 0000000..b9ed4a3
--- /dev/null
+++ b/rome-certiorem/src/main/java/com/rometools/certiorem/hub/data/ram/InMemoryHubDAO.java
@@ -0,0 +1,136 @@
+/**
+ *
+ * Copyright (C) The ROME Team 2011
+ *
+ *
+ * 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 com.rometools.certiorem.hub.data.ram;
+
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.CopyOnWriteArrayList;
+
+import com.rometools.certiorem.hub.data.HubDAO;
+import com.rometools.certiorem.hub.data.Subscriber;
+import com.rometools.certiorem.hub.data.SubscriptionSummary;
+
+/**
+ * A Simple In-Memory HubDAO for subscribers.
+ *
+ * @author robert.cooper
+ */
+public class InMemoryHubDAO implements HubDAO {
+ private final ConcurrentHashMap> subscribers = new ConcurrentHashMap>();
+ private final ConcurrentHashMap> summaries = new ConcurrentHashMap>();
+
+ @Override
+ public Subscriber addSubscriber(final Subscriber subscriber) {
+ // FIXME assert should not be used for validation because it can be disabled
+ assert subscriber != null : "Attempt to store a null subscriber";
+
+ List subList = subscribers.get(subscriber.getTopic());
+
+ if (subList == null) {
+ synchronized (this) {
+ subList = new CopyOnWriteArrayList();
+ subscribers.put(subscriber.getTopic(), subList);
+ }
+ }
+
+ subList.add(subscriber);
+
+ return subscriber;
+ }
+
+ @Override
+ public void handleSummary(final String topic, final SubscriptionSummary summary) {
+ ConcurrentHashMap hostsToSummaries = summaries.get(topic);
+
+ if (hostsToSummaries == null) {
+ synchronized (this) {
+ hostsToSummaries = new ConcurrentHashMap();
+ summaries.put(topic, hostsToSummaries);
+ }
+ }
+
+ hostsToSummaries.put(summary.getHost(), summary);
+ }
+
+ @Override
+ public List extends Subscriber> subscribersForTopic(final String topic) {
+ if (subscribers.containsKey(topic)) {
+ final List result = new LinkedList();
+ final LinkedList expired = new LinkedList();
+
+ for (final Subscriber s : subscribers.get(topic)) {
+ if (s.getLeaseSeconds() > 0 && System.currentTimeMillis() >= s.getCreationTime() + s.getLeaseSeconds() * 1000L) {
+ expired.add(s);
+ } else {
+ result.add(s);
+ }
+ }
+
+ if (!expired.isEmpty()) {
+ subscribers.get(topic).removeAll(expired);
+ }
+
+ return result;
+ } else {
+ return Collections.emptyList();
+ }
+ }
+
+ @Override
+ public List extends SubscriptionSummary> summariesForTopic(final String topic) {
+ final LinkedList result = new LinkedList();
+
+ if (summaries.containsKey(topic)) {
+ result.addAll(summaries.get(topic).values());
+ }
+
+ return result;
+ }
+
+ @Override
+ public Subscriber findSubscriber(final String topic, final String callbackUrl) {
+
+ for (final Subscriber s : subscribersForTopic(topic)) {
+ if (callbackUrl.equals(s.getCallback())) {
+ return s;
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public void removeSubscriber(final String topic, final String callback) {
+ final List subs = subscribers.get(topic);
+ if (subs == null) {
+ return;
+ }
+ Subscriber match = null;
+ for (final Subscriber s : subs) {
+ if (s.getCallback().equals(callback)) {
+ match = s;
+ break;
+ }
+ }
+ if (match != null) {
+ subs.remove(match);
+ }
+ }
+}
diff --git a/rome-certiorem/src/main/java/com/rometools/certiorem/hub/data/ram/package.html b/rome-certiorem/src/main/java/com/rometools/certiorem/hub/data/ram/package.html
new file mode 100644
index 0000000..daecce8
--- /dev/null
+++ b/rome-certiorem/src/main/java/com/rometools/certiorem/hub/data/ram/package.html
@@ -0,0 +1,25 @@
+
+
+
+ Contains a Memory-Resident implemtnation of the Hub DAO.
+
+
+
diff --git a/rome-certiorem/src/main/java/com/rometools/certiorem/hub/notify/standard/AbstractNotifier.java b/rome-certiorem/src/main/java/com/rometools/certiorem/hub/notify/standard/AbstractNotifier.java
new file mode 100644
index 0000000..4195ef1
--- /dev/null
+++ b/rome-certiorem/src/main/java/com/rometools/certiorem/hub/notify/standard/AbstractNotifier.java
@@ -0,0 +1,162 @@
+/**
+ *
+ * Copyright (C) The ROME Team 2011
+ *
+ *
+ * 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 com.rometools.certiorem.hub.notify.standard;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.net.HttpURLConnection;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.List;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.rometools.certiorem.hub.Notifier;
+import com.rometools.certiorem.hub.data.Subscriber;
+import com.rometools.certiorem.hub.data.SubscriptionSummary;
+import com.rometools.rome.feed.synd.SyndFeed;
+import com.rometools.rome.io.FeedException;
+import com.rometools.rome.io.SyndFeedOutput;
+
+/**
+ *
+ * @author robert.cooper
+ */
+public abstract class AbstractNotifier implements Notifier {
+
+ private static final Logger LOG = LoggerFactory.getLogger(AbstractNotifier.class);
+
+ /**
+ * This method will serialize the synd feed and build Notifications for the implementation class
+ * to handle.
+ *
+ * @see enqueueNotification
+ *
+ * @param subscribers List of subscribers to notify
+ * @param value The SyndFeed object to send
+ * @param callback A callback that will be invoked each time a subscriber is notified.
+ *
+ */
+ @Override
+ public void notifySubscribers(final List extends Subscriber> subscribers, final SyndFeed value, final SubscriptionSummaryCallback callback) {
+
+ String mimeType = null;
+
+ if (value.getFeedType().startsWith("rss")) {
+ mimeType = "application/rss+xml";
+ } else {
+ mimeType = "application/atom+xml";
+ }
+
+ final SyndFeedOutput output = new SyndFeedOutput();
+ final ByteArrayOutputStream baos = new ByteArrayOutputStream();
+
+ try {
+ output.output(value, new OutputStreamWriter(baos));
+ baos.close();
+ } catch (final IOException ex) {
+ LOG.error("Unable to output the feed", ex);
+ throw new RuntimeException("Unable to output the feed.", ex);
+ } catch (final FeedException ex) {
+ LOG.error("Unable to output the feed", ex);
+ throw new RuntimeException("Unable to output the feed.", ex);
+ }
+
+ final byte[] payload = baos.toByteArray();
+
+ for (final Subscriber s : subscribers) {
+ final Notification not = new Notification();
+ not.callback = callback;
+ not.lastRun = 0;
+ not.mimeType = mimeType;
+ not.payload = payload;
+ not.retryCount = 0;
+ not.subscriber = s;
+ enqueueNotification(not);
+ }
+ }
+
+ /**
+ * Implementation method that queues/sends a notification
+ *
+ * @param not notification to send.
+ */
+ protected abstract void enqueueNotification(Notification not);
+
+ /**
+ * POSTs the payload to the subscriber's callback and returns a SubscriptionSummary with
+ * subscriber counts (where possible) and the success state of the notification.
+ *
+ * @param subscriber subscriber data.
+ * @param mimeType MIME type for the request
+ * @param payload payload of the feed to send
+ * @return SubscriptionSummary with the returned data.
+ */
+ protected SubscriptionSummary postNotification(final Subscriber subscriber, final String mimeType, final byte[] payload) {
+ final SubscriptionSummary result = new SubscriptionSummary();
+
+ try {
+ final URL target = new URL(subscriber.getCallback());
+ LOG.info("Posting notification to subscriber {}", subscriber.getCallback());
+ result.setHost(target.getHost());
+
+ final HttpURLConnection connection = (HttpURLConnection) target.openConnection();
+ connection.setRequestMethod("POST");
+ connection.setRequestProperty("Content-Type", mimeType);
+ connection.setDoOutput(true);
+ connection.connect();
+
+ final OutputStream os = connection.getOutputStream();
+ os.write(payload);
+ os.close();
+
+ final int responseCode = connection.getResponseCode();
+ final String subscribers = connection.getHeaderField("X-Hub-On-Behalf-Of");
+ connection.disconnect();
+
+ if (responseCode != 200) {
+ LOG.warn("Got code {} from {}", responseCode, target);
+ result.setLastPublishSuccessful(false);
+ return result;
+ }
+
+ if (subscribers != null) {
+ try {
+ result.setSubscribers(Integer.parseInt(subscribers));
+ } catch (final NumberFormatException nfe) {
+ LOG.warn("Invalid subscriber value " + subscribers + " " + target, nfe);
+ result.setSubscribers(-1);
+ }
+ } else {
+ result.setSubscribers(-1);
+ }
+ } catch (final MalformedURLException ex) {
+ LOG.warn(null, ex);
+ result.setLastPublishSuccessful(false);
+ } catch (final IOException ex) {
+ LOG.error(null, ex);
+ result.setLastPublishSuccessful(false);
+ }
+
+ return result;
+ }
+}
diff --git a/rome-certiorem/src/main/java/com/rometools/certiorem/hub/notify/standard/Notification.java b/rome-certiorem/src/main/java/com/rometools/certiorem/hub/notify/standard/Notification.java
new file mode 100644
index 0000000..d3ffdff
--- /dev/null
+++ b/rome-certiorem/src/main/java/com/rometools/certiorem/hub/notify/standard/Notification.java
@@ -0,0 +1,37 @@
+/**
+ *
+ * Copyright (C) The ROME Team 2011
+ *
+ *
+ * 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 com.rometools.certiorem.hub.notify.standard;
+
+import com.rometools.certiorem.hub.Notifier.SubscriptionSummaryCallback;
+import com.rometools.certiorem.hub.data.Subscriber;
+
+/**
+ *
+ * @author robert.cooper
+ */
+public class Notification {
+
+ int retryCount = 0;
+ long lastRun = 0;
+ Subscriber subscriber;
+ String mimeType;
+ byte[] payload;
+ SubscriptionSummaryCallback callback;
+
+}
diff --git a/rome-certiorem/src/main/java/com/rometools/certiorem/hub/notify/standard/ThreadPoolNotifier.java b/rome-certiorem/src/main/java/com/rometools/certiorem/hub/notify/standard/ThreadPoolNotifier.java
new file mode 100644
index 0000000..12e30e1
--- /dev/null
+++ b/rome-certiorem/src/main/java/com/rometools/certiorem/hub/notify/standard/ThreadPoolNotifier.java
@@ -0,0 +1,112 @@
+/**
+ *
+ * Copyright (C) The ROME Team 2011
+ *
+ *
+ * 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 com.rometools.certiorem.hub.notify.standard;
+
+import java.util.Timer;
+import java.util.TimerTask;
+import java.util.concurrent.ConcurrentSkipListSet;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
+
+import com.rometools.certiorem.hub.data.SubscriptionSummary;
+
+/**
+ * A notifier implementation that uses a thread pool to deliver notifications to subscribers
+ *
+ * @author robert.cooper
+ */
+public class ThreadPoolNotifier extends AbstractNotifier {
+ private static final long TWO_MINUTES = 2 * 60 * 1000;
+ protected final ThreadPoolExecutor exeuctor;
+ private final Timer timer = new Timer();
+ private final ConcurrentSkipListSet pendings = new ConcurrentSkipListSet();
+
+ public ThreadPoolNotifier() {
+ this(2, 5, 5);
+ }
+
+ public ThreadPoolNotifier(final int startPoolSize, final int maxPoolSize, final int queueSize) {
+ exeuctor = new ThreadPoolExecutor(startPoolSize, maxPoolSize, 300, TimeUnit.SECONDS, new LinkedBlockingQueue(queueSize));
+ }
+
+ protected ThreadPoolNotifier(final ThreadPoolExecutor executor) {
+ exeuctor = executor;
+ }
+
+ /**
+ * Enqueues a notification to run. If the notification fails, it will be retried every two
+ * minutes until 5 attempts are completed. Notifications to the same callback should be
+ * delivered successfully in order.
+ *
+ * @param not
+ */
+ @Override
+ protected void enqueueNotification(final Notification not) {
+ final Runnable r = new Runnable() {
+ @Override
+ public void run() {
+ not.lastRun = System.currentTimeMillis();
+
+ final SubscriptionSummary summary = postNotification(not.subscriber, not.mimeType, not.payload);
+
+ if (!summary.isLastPublishSuccessful()) {
+ not.retryCount++;
+
+ if (not.retryCount <= 5) {
+ retry(not);
+ }
+ }
+
+ not.callback.onSummaryInfo(summary);
+ }
+ };
+
+ exeuctor.execute(r);
+ }
+
+ /**
+ * Schedules a notification to retry in two minutes.
+ *
+ * @param not Notification to retry
+ */
+ protected void retry(final Notification not) {
+ if (!pendings.contains(not.subscriber.getCallback())) {
+ // We don't have a current retry for this callback pending, so we
+ // will schedule the retry
+ pendings.add(not.subscriber.getCallback());
+ timer.schedule(new TimerTask() {
+ @Override
+ public void run() {
+ pendings.remove(not.subscriber.getCallback());
+ enqueueNotification(not);
+ }
+ }, TWO_MINUTES);
+ } else {
+ // There is a retry in front of this one, so we will just schedule
+ // it to retry again in a bit
+ timer.schedule(new TimerTask() {
+ @Override
+ public void run() {
+ retry(not);
+ }
+ }, TWO_MINUTES);
+ }
+ }
+}
diff --git a/rome-certiorem/src/main/java/com/rometools/certiorem/hub/notify/standard/UnthreadedNotifier.java b/rome-certiorem/src/main/java/com/rometools/certiorem/hub/notify/standard/UnthreadedNotifier.java
new file mode 100644
index 0000000..b1228eb
--- /dev/null
+++ b/rome-certiorem/src/main/java/com/rometools/certiorem/hub/notify/standard/UnthreadedNotifier.java
@@ -0,0 +1,43 @@
+/**
+ *
+ * Copyright (C) The ROME Team 2011
+ *
+ *
+ * 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 com.rometools.certiorem.hub.notify.standard;
+
+import com.rometools.certiorem.hub.data.SubscriptionSummary;
+
+/**
+ * A notifier that does not use threads. All calls are blocking and synchronous.
+ *
+ * @author robert.cooper
+ */
+public class UnthreadedNotifier extends AbstractNotifier {
+
+ /**
+ * A blocking call that performs a notification. If there are pending retries that are older
+ * than two minutes old, they will be retried before the method returns.
+ *
+ * @param not
+ */
+ @Override
+ protected void enqueueNotification(final Notification not) {
+ not.lastRun = System.currentTimeMillis();
+ final SubscriptionSummary summary = postNotification(not.subscriber, not.mimeType, not.payload);
+ not.callback.onSummaryInfo(summary);
+ }
+
+}
diff --git a/rome-certiorem/src/main/java/com/rometools/certiorem/hub/notify/standard/package.html b/rome-certiorem/src/main/java/com/rometools/certiorem/hub/notify/standard/package.html
new file mode 100644
index 0000000..c38c288
--- /dev/null
+++ b/rome-certiorem/src/main/java/com/rometools/certiorem/hub/notify/standard/package.html
@@ -0,0 +1,32 @@
+
+
+
+
+ verify
+
+
+ This package contains a set of standard Verifier implementations.
+
+ These implementations all use the standard java.net.* classes for
+ making requests to URLs.
+
+
+
\ No newline at end of file
diff --git a/rome-certiorem/src/main/java/com/rometools/certiorem/hub/package.html b/rome-certiorem/src/main/java/com/rometools/certiorem/hub/package.html
new file mode 100644
index 0000000..9e6bac7
--- /dev/null
+++ b/rome-certiorem/src/main/java/com/rometools/certiorem/hub/package.html
@@ -0,0 +1,30 @@
+
+
+
+
+ hub
+
+
+ This package contains the core of the Hub implementation.
+
Getting Started
+
The Hub implementation
+
+
\ No newline at end of file
diff --git a/rome-certiorem/src/main/java/com/rometools/certiorem/hub/verify/standard/AbstractVerifier.java b/rome-certiorem/src/main/java/com/rometools/certiorem/hub/verify/standard/AbstractVerifier.java
new file mode 100644
index 0000000..7a8398c
--- /dev/null
+++ b/rome-certiorem/src/main/java/com/rometools/certiorem/hub/verify/standard/AbstractVerifier.java
@@ -0,0 +1,99 @@
+/**
+ *
+ * Copyright (C) The ROME Team 2011
+ *
+ *
+ * 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 com.rometools.certiorem.hub.verify.standard;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.UnsupportedEncodingException;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.net.URLEncoder;
+import java.util.UUID;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.rometools.certiorem.hub.Verifier;
+import com.rometools.certiorem.hub.data.Subscriber;
+
+/**
+ * An abstract verifier based on the java.net HTTP classes. This implements only synchronous
+ * operations, and expects a child class to do Async ops.
+ *
+ * @author robert.cooper
+ */
+public abstract class AbstractVerifier implements Verifier {
+
+ private static final Logger LOG = LoggerFactory.getLogger(AbstractVerifier.class);
+
+ @Override
+ public boolean verifySubcribeSyncronously(final Subscriber subscriber) {
+ return doOp(Verifier.MODE_SUBSCRIBE, subscriber);
+ }
+
+ @Override
+ public boolean verifyUnsubcribeSyncronously(final Subscriber subscriber) {
+ return doOp(Verifier.MODE_UNSUBSCRIBE, subscriber);
+ }
+
+ private boolean doOp(final String mode, final Subscriber subscriber) {
+ try {
+ final String challenge = UUID.randomUUID().toString();
+ final StringBuilder queryString = new StringBuilder();
+ queryString.append("hub.mode=").append(mode).append("&hub.topic=").append(URLEncoder.encode(subscriber.getTopic(), "UTF-8"))
+ .append("&hub.challenge=").append(challenge);
+
+ if (subscriber.getLeaseSeconds() != -1) {
+ queryString.append("&hub.lease_seconds=").append(subscriber.getLeaseSeconds());
+ }
+
+ if (subscriber.getVertifyToken() != null) {
+ queryString.append("&hub.verify_token=").append(URLEncoder.encode(subscriber.getVertifyToken(), "UTF-8"));
+ }
+
+ final URL url = new URL(subscriber.getCallback() + "?" + queryString.toString());
+ final HttpURLConnection connection = (HttpURLConnection) url.openConnection();
+ connection.setDoInput(true);
+ // connection.setRequestProperty("Host", url.getHost());
+ // connection.setRequestProperty("Port",
+ // Integer.toString(url.getPort()));
+ connection.setRequestProperty("User-Agent", "ROME-Certiorem");
+ connection.connect();
+ final int rc = connection.getResponseCode();
+ final InputStream is = connection.getInputStream();
+ final BufferedReader reader = new BufferedReader(new InputStreamReader(is));
+ final String result = reader.readLine();
+ reader.close();
+ connection.disconnect();
+ if (rc != 200 || !challenge.equals(result.trim())) {
+ return false;
+ } else {
+ return true;
+ }
+ } catch (final UnsupportedEncodingException ex) {
+ LOG.error("Unsupported encoding", ex);
+ throw new RuntimeException("Should not happen. UTF-8 threw unsupported encoding", ex);
+ } catch (final IOException ex) {
+ LOG.error("An IOException occured", ex);
+ return false;
+ }
+ }
+}
diff --git a/rome-certiorem/src/main/java/com/rometools/certiorem/hub/verify/standard/ThreadPoolVerifier.java b/rome-certiorem/src/main/java/com/rometools/certiorem/hub/verify/standard/ThreadPoolVerifier.java
new file mode 100644
index 0000000..1c5f599
--- /dev/null
+++ b/rome-certiorem/src/main/java/com/rometools/certiorem/hub/verify/standard/ThreadPoolVerifier.java
@@ -0,0 +1,66 @@
+/**
+ *
+ * Copyright (C) The ROME Team 2011
+ *
+ *
+ * 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 com.rometools.certiorem.hub.verify.standard;
+
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
+
+import com.rometools.certiorem.hub.data.Subscriber;
+
+/**
+ * Uses a ThreadPoolExecutor to do async verifications.
+ *
+ * @author robert.cooper
+ */
+public class ThreadPoolVerifier extends AbstractVerifier {
+ protected final ThreadPoolExecutor exeuctor;
+
+ protected ThreadPoolVerifier(final ThreadPoolExecutor executor) {
+ exeuctor = executor;
+ }
+
+ public ThreadPoolVerifier() {
+ this(2, 5, 5);
+ }
+
+ public ThreadPoolVerifier(final int startPoolSize, final int maxPoolSize, final int queueSize) {
+ exeuctor = new ThreadPoolExecutor(startPoolSize, maxPoolSize, 300, TimeUnit.SECONDS, new LinkedBlockingQueue(queueSize));
+ }
+
+ @Override
+ public void verifySubscribeAsyncronously(final Subscriber subscriber, final VerificationCallback callback) {
+ exeuctor.execute(new Runnable() {
+ @Override
+ public void run() {
+ callback.onVerify(verifySubcribeSyncronously(subscriber));
+ }
+ });
+ }
+
+ @Override
+ public void verifyUnsubscribeAsyncronously(final Subscriber subscriber, final VerificationCallback callback) {
+ exeuctor.execute(new Runnable() {
+ @Override
+ public void run() {
+ callback.onVerify(verifyUnsubcribeSyncronously(subscriber));
+ }
+ });
+ }
+}
diff --git a/rome-certiorem/src/main/java/com/rometools/certiorem/hub/verify/standard/ThreadpoolVerifierAdvanced.java b/rome-certiorem/src/main/java/com/rometools/certiorem/hub/verify/standard/ThreadpoolVerifierAdvanced.java
new file mode 100644
index 0000000..8751b27
--- /dev/null
+++ b/rome-certiorem/src/main/java/com/rometools/certiorem/hub/verify/standard/ThreadpoolVerifierAdvanced.java
@@ -0,0 +1,33 @@
+/**
+ *
+ * Copyright (C) The ROME Team 2011
+ *
+ *
+ * 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 com.rometools.certiorem.hub.verify.standard;
+
+import java.util.concurrent.ThreadPoolExecutor;
+
+/**
+ *
+ * @author robert.cooper
+ */
+public class ThreadpoolVerifierAdvanced extends ThreadPoolVerifier {
+
+ public ThreadpoolVerifierAdvanced(final ThreadPoolExecutor executor) {
+ super(executor);
+ }
+
+}
diff --git a/rome-certiorem/src/main/java/com/rometools/certiorem/hub/verify/standard/UnthreadedVerifier.java b/rome-certiorem/src/main/java/com/rometools/certiorem/hub/verify/standard/UnthreadedVerifier.java
new file mode 100644
index 0000000..8f2fac9
--- /dev/null
+++ b/rome-certiorem/src/main/java/com/rometools/certiorem/hub/verify/standard/UnthreadedVerifier.java
@@ -0,0 +1,40 @@
+/**
+ *
+ * Copyright (C) The ROME Team 2011
+ *
+ *
+ * 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 com.rometools.certiorem.hub.verify.standard;
+
+import com.rometools.certiorem.hub.data.Subscriber;
+
+/**
+ * A verifier that does not use threads. Suitable for Google App Engine.
+ *
+ * @author robert.cooper
+ */
+public class UnthreadedVerifier extends AbstractVerifier {
+
+ @Override
+ public void verifySubscribeAsyncronously(final Subscriber subscriber, final VerificationCallback callback) {
+ callback.onVerify(verifySubcribeSyncronously(subscriber));
+ }
+
+ @Override
+ public void verifyUnsubscribeAsyncronously(final Subscriber subscriber, final VerificationCallback callback) {
+ callback.onVerify(verifyUnsubcribeSyncronously(subscriber));
+ }
+
+}
diff --git a/rome-certiorem/src/main/java/com/rometools/certiorem/hub/verify/standard/package.html b/rome-certiorem/src/main/java/com/rometools/certiorem/hub/verify/standard/package.html
new file mode 100644
index 0000000..c38c288
--- /dev/null
+++ b/rome-certiorem/src/main/java/com/rometools/certiorem/hub/verify/standard/package.html
@@ -0,0 +1,32 @@
+
+
+
+
+ verify
+
+
+ This package contains a set of standard Verifier implementations.
+
+ These implementations all use the standard java.net.* classes for
+ making requests to URLs.
+
+
+
\ No newline at end of file
diff --git a/rome-certiorem/src/main/java/com/rometools/certiorem/package.html b/rome-certiorem/src/main/java/com/rometools/certiorem/package.html
new file mode 100644
index 0000000..3da23c0
--- /dev/null
+++ b/rome-certiorem/src/main/java/com/rometools/certiorem/package.html
@@ -0,0 +1,30 @@
+
+
+
+
+ A pub sub hubub implementation for Java.
+
+
+
+
+
+
+
diff --git a/rome-certiorem/src/main/java/com/rometools/certiorem/pub/NotificationException.java b/rome-certiorem/src/main/java/com/rometools/certiorem/pub/NotificationException.java
new file mode 100644
index 0000000..91c5c58
--- /dev/null
+++ b/rome-certiorem/src/main/java/com/rometools/certiorem/pub/NotificationException.java
@@ -0,0 +1,40 @@
+/**
+ *
+ * Copyright (C) The ROME Team 2011
+ *
+ *
+ * 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 com.rometools.certiorem.pub;
+
+/**
+ *
+ * @author robert.cooper
+ */
+public class NotificationException extends Exception {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+ public NotificationException(final String message) {
+ super(message);
+ }
+
+ public NotificationException(final String message, final Throwable cause) {
+ super(message, cause);
+ }
+
+}
diff --git a/rome-certiorem/src/main/java/com/rometools/certiorem/pub/Publisher.java b/rome-certiorem/src/main/java/com/rometools/certiorem/pub/Publisher.java
new file mode 100644
index 0000000..6857d55
--- /dev/null
+++ b/rome-certiorem/src/main/java/com/rometools/certiorem/pub/Publisher.java
@@ -0,0 +1,251 @@
+/**
+ *
+ * Copyright (C) The ROME Team 2011
+ *
+ *
+ * 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 com.rometools.certiorem.pub;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.UnsupportedEncodingException;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.net.URLEncoder;
+import java.util.concurrent.ThreadPoolExecutor;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.rometools.rome.feed.synd.SyndFeed;
+import com.rometools.rome.feed.synd.SyndLink;
+
+/**
+ * A class for sending update notifications to a hub.
+ *
+ * @author robert.cooper
+ */
+public class Publisher {
+
+ private static final Logger LOG = LoggerFactory.getLogger(Publisher.class);
+
+ private ThreadPoolExecutor executor;
+
+ /**
+ * Constructs a new publisher. This publisher will spawn a new thread for each async send.
+ */
+ public Publisher() {
+ }
+
+ /**
+ * Constructs a new publisher with an optional ThreadPoolExector for sending updates.
+ */
+ public Publisher(final ThreadPoolExecutor executor) {
+ this.executor = executor;
+ }
+
+ /**
+ * Sends the HUB url a notification of a change in topic
+ *
+ * @param hub URL of the hub to notify.
+ * @param topic The Topic that has changed
+ * @throws NotificationException Any failure
+ */
+ public void sendUpdateNotification(final String hub, final String topic) throws NotificationException {
+ try {
+ final StringBuilder sb = new StringBuilder("hub.mode=publish&hub.url=").append(URLEncoder.encode(topic, "UTF-8"));
+ final URL hubUrl = new URL(hub);
+ final HttpURLConnection connection = (HttpURLConnection) hubUrl.openConnection();
+ // connection.setRequestProperty("Host", hubUrl.getHost());
+ connection.setRequestProperty("User-Agent", "ROME-Certiorem");
+ connection.setRequestProperty("ContentType", "application/x-www-form-urlencoded");
+ connection.setDoOutput(true);
+ connection.connect();
+
+ final OutputStream os = connection.getOutputStream();
+ os.write(sb.toString().getBytes("UTF-8"));
+ os.close();
+
+ final int rc = connection.getResponseCode();
+ connection.disconnect();
+
+ if (rc != 204) {
+ throw new NotificationException("Server returned an unexcepted response code: " + rc + " " + connection.getResponseMessage());
+ }
+
+ } catch (final UnsupportedEncodingException ex) {
+ LOG.error("Could not encode URL", ex);
+ throw new NotificationException("Could not encode URL", ex);
+ } catch (final IOException ex) {
+ LOG.error("Communication error", ex);
+ throw new NotificationException("Unable to communicate with " + hub, ex);
+ }
+ }
+
+ /**
+ * Sends a notification for a feed located at "topic". The feed MUST contain rel="hub".
+ *
+ * @param topic URL for the feed
+ * @param feed The feed itself
+ * @throws NotificationException Any failure
+ */
+ public void sendUpdateNotification(final String topic, final SyndFeed feed) throws NotificationException {
+ for (final SyndLink link : feed.getLinks()) {
+ if ("hub".equals(link.getRel())) {
+ sendUpdateNotification(link.getRel(), topic);
+
+ return;
+ }
+ }
+ throw new NotificationException("Hub link not found.");
+ }
+
+ /**
+ * Sends a notification for a feed. The feed MUST contain rel="hub" and rel="self" links.
+ *
+ * @param feed The feed to notify
+ * @throws NotificationException Any failure
+ */
+ public void sendUpdateNotification(final SyndFeed feed) throws NotificationException {
+ SyndLink hub = null;
+ SyndLink self = null;
+
+ for (final SyndLink link : feed.getLinks()) {
+ if ("hub".equals(link.getRel())) {
+ hub = link;
+ }
+
+ if ("self".equals(link.getRel())) {
+ self = link;
+ }
+
+ if (hub != null && self != null) {
+ break;
+ }
+ }
+
+ if (hub == null) {
+ throw new NotificationException("A link rel='hub' was not found in the feed.");
+ }
+
+ if (self == null) {
+ throw new NotificationException("A link rel='self' was not found in the feed.");
+ }
+
+ sendUpdateNotification(hub.getRel(), self.getHref());
+ }
+
+ /**
+ * Sends the HUB url a notification of a change in topic asynchronously
+ *
+ * @param hub URL of the hub to notify.
+ * @param topic The Topic that has changed
+ * @param callback A callback invoked when the notification completes.
+ * @throws NotificationException Any failure
+ */
+ public void sendUpdateNotificationAsyncronously(final String hub, final String topic, final AsyncNotificationCallback callback) {
+ final Runnable r = new Runnable() {
+ @Override
+ public void run() {
+ try {
+ sendUpdateNotification(hub, topic);
+ callback.onSuccess();
+ } catch (final Throwable t) {
+ callback.onFailure(t);
+ }
+ }
+ };
+
+ if (executor != null) {
+ executor.execute(r);
+ } else {
+ new Thread(r).start();
+ }
+ }
+
+ /**
+ * Asynchronously sends a notification for a feed located at "topic". The feed MUST contain
+ * rel="hub".
+ *
+ * @param topic URL for the feed
+ * @param feed The feed itself
+ * @param callback A callback invoked when the notification completes.
+ * @throws NotificationException Any failure
+ */
+ public void sendUpdateNotificationAsyncronously(final String topic, final SyndFeed feed, final AsyncNotificationCallback callback) {
+ final Runnable r = new Runnable() {
+ @Override
+ public void run() {
+ try {
+ sendUpdateNotification(topic, feed);
+ callback.onSuccess();
+ } catch (final Throwable t) {
+ callback.onFailure(t);
+ }
+ }
+ };
+
+ if (executor != null) {
+ executor.execute(r);
+ } else {
+ new Thread(r).start();
+ }
+ }
+
+ /**
+ * Asyncronously sends a notification for a feed. The feed MUST contain rel="hub" and rel="self"
+ * links.
+ *
+ * @param feed The feed to notify
+ * @param callback A callback invoked when the notification completes.
+ * @throws NotificationException Any failure
+ */
+ public void sendUpdateNotificationAsyncronously(final SyndFeed feed, final AsyncNotificationCallback callback) {
+ final Runnable r = new Runnable() {
+ @Override
+ public void run() {
+ try {
+ sendUpdateNotification(feed);
+ callback.onSuccess();
+ } catch (final Throwable t) {
+ callback.onFailure(t);
+ }
+ }
+ };
+
+ if (executor != null) {
+ executor.execute(r);
+ } else {
+ new Thread(r).start();
+ }
+ }
+
+ /**
+ * A callback interface for asynchronous notifications.
+ */
+ public static interface AsyncNotificationCallback {
+ /**
+ * Called when a notification fails
+ *
+ * @param thrown Whatever was thrown during the failure
+ */
+ public void onFailure(Throwable thrown);
+
+ /**
+ * Invoked with the asyncronous notification completes successfully.
+ */
+ public void onSuccess();
+ }
+}
diff --git a/rome-certiorem/src/main/java/com/rometools/certiorem/pub/package.html b/rome-certiorem/src/main/java/com/rometools/certiorem/pub/package.html
new file mode 100644
index 0000000..9f56bb1
--- /dev/null
+++ b/rome-certiorem/src/main/java/com/rometools/certiorem/pub/package.html
@@ -0,0 +1,29 @@
+
+
+
+
+ pub
+
+
+ This package contains a utility class to send update notifications.
+
+
+
\ No newline at end of file
diff --git a/rome-certiorem/src/main/java/com/rometools/certiorem/sub/Requester.java b/rome-certiorem/src/main/java/com/rometools/certiorem/sub/Requester.java
new file mode 100644
index 0000000..016f37d
--- /dev/null
+++ b/rome-certiorem/src/main/java/com/rometools/certiorem/sub/Requester.java
@@ -0,0 +1,38 @@
+/**
+ *
+ * Copyright (C) The ROME Team 2011
+ *
+ *
+ * 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 com.rometools.certiorem.sub;
+
+import com.rometools.certiorem.sub.data.Subscription;
+
+/**
+ *
+ * @author robert.cooper
+ */
+public interface Requester {
+ public void sendSubscribeRequest(String hubUrl, Subscription subscription, String verifySync, long leaseSeconds, String secret, String callbackUrl,
+ RequestCallback callback);
+
+ public void sendUnsubscribeRequest(String hubUrl, Subscription subscription, String verifySync, String secret, String callbackUrl, RequestCallback callback);
+
+ public static interface RequestCallback {
+ public void onFailure(Exception e);
+
+ public void onSuccess();
+ }
+}
diff --git a/rome-certiorem/src/main/java/com/rometools/certiorem/sub/Subscriptions.java b/rome-certiorem/src/main/java/com/rometools/certiorem/sub/Subscriptions.java
new file mode 100644
index 0000000..5989389
--- /dev/null
+++ b/rome-certiorem/src/main/java/com/rometools/certiorem/sub/Subscriptions.java
@@ -0,0 +1,284 @@
+/**
+ *
+ * Copyright (C) The ROME Team 2011
+ *
+ *
+ * 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 com.rometools.certiorem.sub;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.UnsupportedEncodingException;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.UUID;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.rometools.certiorem.HttpStatusCodeException;
+import com.rometools.certiorem.sub.Requester.RequestCallback;
+import com.rometools.certiorem.sub.data.SubDAO;
+import com.rometools.certiorem.sub.data.Subscription;
+import com.rometools.certiorem.sub.data.SubscriptionCallback;
+import com.rometools.fetcher.impl.FeedFetcherCache;
+import com.rometools.fetcher.impl.SyndFeedInfo;
+import com.rometools.rome.feed.synd.SyndFeed;
+import com.rometools.rome.feed.synd.SyndLink;
+import com.rometools.rome.io.FeedException;
+import com.rometools.rome.io.SyndFeedInput;
+
+/**
+ *
+ * @author robert.cooper
+ */
+public class Subscriptions {
+
+ private static final Logger LOG = LoggerFactory.getLogger(Subscriptions.class);
+
+ // TODO unsubscribe.
+ private FeedFetcherCache cache;
+ private Requester requester;
+ private String callbackPrefix;
+ private SubDAO dao;
+
+ public Subscriptions() {
+ }
+
+ public Subscriptions(final FeedFetcherCache cache, final Requester requester, final String callbackPrefix, final SubDAO dao) {
+ this.cache = cache;
+ this.requester = requester;
+ this.callbackPrefix = callbackPrefix;
+ this.dao = dao;
+ }
+
+ public void callback(final String callbackPath, final String feed) {
+ try {
+ this.callback(callbackPath, feed.getBytes("UTF-8"));
+ } catch (final UnsupportedEncodingException ex) {
+ LOG.error("Unable to parse feed", ex);
+ throw new HttpStatusCodeException(400, "Unable to parse feed.", ex);
+ }
+ }
+
+ public void callback(final String callbackPath, final InputStream feed) {
+ final SyndFeedInput input = new SyndFeedInput();
+
+ try {
+ this.callback(callbackPath, input.build(new InputStreamReader(feed)));
+ } catch (final IllegalArgumentException ex) {
+ LOG.error("Unable to parse feed", ex);
+ throw new HttpStatusCodeException(500, "Unable to parse feed.", ex);
+ } catch (final FeedException ex) {
+ LOG.error("Unable to parse feed", ex);
+ throw new HttpStatusCodeException(400, "Unable to parse feed.", ex);
+ }
+ }
+
+ public void callback(final String callbackPath, final byte[] feed) {
+ this.callback(callbackPath, new ByteArrayInputStream(feed));
+ }
+
+ public void callback(final String callbackPath, final SyndFeed feed) {
+
+ if (!callbackPath.startsWith(callbackPrefix)) {
+ throw new HttpStatusCodeException(404, "Not a valid callback prefix.", new Exception(callbackPath + " doesnt start with " + callbackPrefix));
+ }
+
+ final String id = callbackPath.substring(callbackPrefix.length());
+ LOG.debug("Got callback for {}", id);
+ final Subscription s = dao.findById(id);
+
+ if (s == null) {
+ throw new HttpStatusCodeException(404, "Not a valid callback.", null);
+ }
+
+ validateLink(feed, s.getSourceUrl());
+
+ SyndFeedInfo info = null;
+ URL url = null;
+
+ try {
+ url = new URL(s.getSourceUrl());
+ info = cache.getFeedInfo(url);
+ } catch (final MalformedURLException ex) {
+ LOG.error("Malformed URL", ex);
+ }
+
+ if (info == null) {
+ info = new SyndFeedInfo();
+ info.setId(s.getId());
+ info.setUrl(url);
+ }
+
+ info.setLastModified(System.currentTimeMillis());
+ info.setSyndFeed(feed);
+ cache.setFeedInfo(url, info);
+
+ s.getCallback().onNotify(s, info);
+ }
+
+ public void unsubscribe(final Subscription subscription, final String hubUrl, final boolean sync, final String secret, final SubscriptionCallback callback) {
+
+ subscription.setUnsubscribed(true);
+ requester.sendUnsubscribeRequest(hubUrl, subscription, sync ? "sync" : "async", secret, callbackPrefix + subscription.getId(), new RequestCallback() {
+ @Override
+ public void onSuccess() {
+ callback.onUnsubscribe(subscription);
+ }
+
+ @Override
+ public void onFailure(final Exception e) {
+ callback.onFailure(e);
+ }
+ });
+ }
+
+ public void subscribe(final String hubUrl, final String topic, final boolean sync, final long leaseSeconds, final String secret,
+ final SubscriptionCallback callback) {
+ final Subscription s = new Subscription();
+ s.setId(UUID.randomUUID().toString());
+ s.setVerifyToken(UUID.randomUUID().toString());
+ s.setSourceUrl(topic);
+ s.setCallback(callback);
+ if (leaseSeconds > 0) {
+ s.setExpirationTime(System.currentTimeMillis() + leaseSeconds * 1000);
+ }
+
+ final Subscription stored = dao.addSubscription(s);
+
+ requester.sendSubscribeRequest(hubUrl, stored, sync ? "sync" : "async", leaseSeconds, secret, callbackPrefix + stored.getId(), new RequestCallback() {
+ @Override
+ public void onSuccess() {
+ callback.onSubscribe(stored);
+ }
+
+ @Override
+ public void onFailure(final Exception e) {
+ callback.onFailure(e);
+ }
+ });
+ }
+
+ public void subscribe(final String topic, final boolean sync, final long leaseSeconds, final String secret, final SubscriptionCallback callback)
+ throws IllegalArgumentException, IOException, FeedException {
+ final SyndFeedInput input = new SyndFeedInput();
+ final SyndFeed feed = input.build(new InputStreamReader(new URL(topic).openStream()));
+ final String hubUrl = findHubUrl(feed);
+
+ if (hubUrl == null) {
+ throw new FeedException("No hub link");
+ }
+
+ this.subscribe(hubUrl, topic, sync, leaseSeconds, secret, callback);
+ }
+
+ public String validate(final String callbackPath, final String topic, final String mode, final String challenge, final String leaseSeconds,
+ final String verifyToken) {
+ if (!callbackPath.startsWith(callbackPrefix)) {
+ throw new HttpStatusCodeException(404, "Not a valid callback prefix.", new Exception(callbackPath + " doesnt start with " + callbackPrefix));
+ }
+
+ final String id = callbackPath.substring(callbackPrefix.length());
+ LOG.debug("Handling validation request for id {}", id);
+ final Subscription s = dao.findById(id);
+ if (s == null) {
+ throw new HttpStatusCodeException(404, "Not a valid subscription id", null);
+ }
+ if (!s.getVerifyToken().equals(verifyToken)) {
+ throw new HttpStatusCodeException(403, "Verification Token Mismatch.", null);
+ }
+
+ if ("unsubscribe".equals(mode)) {
+ if (!s.isUnsubscribed()) {
+ throw new HttpStatusCodeException(400, "Unsubscribe not requested.", null);
+ }
+
+ dao.removeSubscription(s);
+ } else if ("subscribe".equals(mode)) {
+ if (s.isValidated()) {
+ throw new HttpStatusCodeException(400, "Duplicate validation.", null);
+ }
+
+ s.setValidated(true);
+ dao.updateSubscription(s);
+ } else {
+ throw new HttpStatusCodeException(400, "Unsupported mode " + mode, null);
+ }
+ LOG.debug("Validated. Returning {}", challenge);
+ return challenge;
+ }
+
+ private String findHubUrl(final SyndFeed feed) {
+ for (final SyndLink l : feed.getLinks()) {
+ if ("hub".equals(l.getRel())) {
+ return l.getHref();
+ }
+ }
+
+ return null;
+ }
+
+ private void validateLink(final SyndFeed feed, final String source) {
+ for (final SyndLink l : feed.getLinks()) {
+ if ("self".equalsIgnoreCase(l.getRel())) {
+ try {
+ final URI u = new URI(l.getHref());
+ final URI t = new URI(source);
+
+ if (!u.equals(t)) {
+ throw new HttpStatusCodeException(400, "Feed self link does not match the subscribed URI.", null);
+ }
+
+ break;
+ } catch (final URISyntaxException ex) {
+ LOG.error(null, ex);
+ }
+ }
+ }
+ }
+
+ /**
+ * @param cache the cache to set
+ */
+ public void setCache(final FeedFetcherCache cache) {
+ this.cache = cache;
+ }
+
+ /**
+ * @param requester the requester to set
+ */
+ public void setRequester(final Requester requester) {
+ this.requester = requester;
+ }
+
+ /**
+ * @param callbackPrefix the callbackPrefix to set
+ */
+ public void setCallbackPrefix(final String callbackPrefix) {
+ this.callbackPrefix = callbackPrefix;
+ }
+
+ /**
+ * @param dao the dao to set
+ */
+ public void setDao(final SubDAO dao) {
+ this.dao = dao;
+ }
+}
diff --git a/rome-certiorem/src/main/java/com/rometools/certiorem/sub/data/SubDAO.java b/rome-certiorem/src/main/java/com/rometools/certiorem/sub/data/SubDAO.java
new file mode 100644
index 0000000..cef1930
--- /dev/null
+++ b/rome-certiorem/src/main/java/com/rometools/certiorem/sub/data/SubDAO.java
@@ -0,0 +1,35 @@
+/**
+ *
+ * Copyright (C) The ROME Team 2011
+ *
+ *
+ * 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 com.rometools.certiorem.sub.data;
+
+/**
+ *
+ * @author robert.cooper
+ */
+public interface SubDAO {
+
+ public Subscription findById(String id);
+
+ public Subscription addSubscription(Subscription s);
+
+ public Subscription updateSubscription(Subscription s);
+
+ public void removeSubscription(Subscription s);
+
+}
diff --git a/rome-certiorem/src/main/java/com/rometools/certiorem/sub/data/Subscription.java b/rome-certiorem/src/main/java/com/rometools/certiorem/sub/data/Subscription.java
new file mode 100644
index 0000000..8344df0
--- /dev/null
+++ b/rome-certiorem/src/main/java/com/rometools/certiorem/sub/data/Subscription.java
@@ -0,0 +1,161 @@
+/**
+ *
+ * Copyright (C) The ROME Team 2011
+ *
+ *
+ * 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 com.rometools.certiorem.sub.data;
+
+import java.io.Serializable;
+
+/**
+ *
+ * @author robert.cooper
+ */
+public class Subscription implements Serializable {
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ private String id;
+ private String sourceUrl;
+ private String verifyToken;
+ private boolean unsubscribed;
+ private boolean validated;
+ private long expirationTime;
+ private SubscriptionCallback callback;
+
+ /**
+ * Set the value of expirationTime
+ *
+ * @param newexpirationTime new value of expirationTime
+ */
+ public void setExpirationTime(final long newexpirationTime) {
+ expirationTime = newexpirationTime;
+ }
+
+ /**
+ * Get the value of expirationTime
+ *
+ * @return the value of expirationTime
+ */
+ public long getExpirationTime() {
+ return expirationTime;
+ }
+
+ /**
+ * Set the value of id
+ *
+ * @param newid new value of id
+ */
+ public void setId(final String newid) {
+ id = newid;
+ }
+
+ /**
+ * Get the value of id
+ *
+ * @return the value of id
+ */
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * Set the value of sourceUrl
+ *
+ * @param newsourceUrl new value of sourceUrl
+ */
+ public void setSourceUrl(final String newsourceUrl) {
+ sourceUrl = newsourceUrl;
+ }
+
+ /**
+ * Get the value of sourceUrl
+ *
+ * @return the value of sourceUrl
+ */
+ public String getSourceUrl() {
+ return sourceUrl;
+ }
+
+ /**
+ * Set the value of unsubscribed
+ *
+ * @param newunsubscribed new value of unsubscribed
+ */
+ public void setUnsubscribed(final boolean newunsubscribed) {
+ unsubscribed = newunsubscribed;
+ }
+
+ /**
+ * Get the value of unsubscribed
+ *
+ * @return the value of unsubscribed
+ */
+ public boolean isUnsubscribed() {
+ return unsubscribed;
+ }
+
+ /**
+ * Set the value of validated
+ *
+ * @param newvalidated new value of validated
+ */
+ public void setValidated(final boolean newvalidated) {
+ validated = newvalidated;
+ }
+
+ /**
+ * Get the value of validated
+ *
+ * @return the value of validated
+ */
+ public boolean isValidated() {
+ return validated;
+ }
+
+ /**
+ * Set the value of verifyToken
+ *
+ * @param newverifyToken new value of verifyToken
+ */
+ public void setVerifyToken(final String newverifyToken) {
+ verifyToken = newverifyToken;
+ }
+
+ /**
+ * Get the value of verifyToken
+ *
+ * @return the value of verifyToken
+ */
+ public String getVerifyToken() {
+ return verifyToken;
+ }
+
+ /**
+ * @return the callback
+ */
+ public SubscriptionCallback getCallback() {
+ return callback;
+ }
+
+ /**
+ * @param callback the callback to set
+ */
+ public void setCallback(final SubscriptionCallback callback) {
+ this.callback = callback;
+ }
+}
diff --git a/rome-certiorem/src/main/java/com/rometools/certiorem/sub/data/SubscriptionCallback.java b/rome-certiorem/src/main/java/com/rometools/certiorem/sub/data/SubscriptionCallback.java
new file mode 100644
index 0000000..ce9e560
--- /dev/null
+++ b/rome-certiorem/src/main/java/com/rometools/certiorem/sub/data/SubscriptionCallback.java
@@ -0,0 +1,23 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package com.rometools.certiorem.sub.data;
+
+import com.rometools.fetcher.impl.SyndFeedInfo;
+
+/**
+ *
+ * @author najmi
+ */
+public interface SubscriptionCallback {
+
+ void onNotify(Subscription subscribed, SyndFeedInfo feedInfo);
+
+ void onFailure(Exception e);
+
+ void onSubscribe(Subscription subscribed);
+
+ void onUnsubscribe(Subscription subscribed);
+}
diff --git a/rome-certiorem/src/main/java/com/rometools/certiorem/sub/data/package.html b/rome-certiorem/src/main/java/com/rometools/certiorem/sub/data/package.html
new file mode 100644
index 0000000..625b5a4
--- /dev/null
+++ b/rome-certiorem/src/main/java/com/rometools/certiorem/sub/data/package.html
@@ -0,0 +1,28 @@
+
+
+
+
+ data
+
+
+ Data classes for the Subscription management.
+
+
diff --git a/rome-certiorem/src/main/java/com/rometools/certiorem/sub/data/ram/InMemorySubDAO.java b/rome-certiorem/src/main/java/com/rometools/certiorem/sub/data/ram/InMemorySubDAO.java
new file mode 100644
index 0000000..d631d6c
--- /dev/null
+++ b/rome-certiorem/src/main/java/com/rometools/certiorem/sub/data/ram/InMemorySubDAO.java
@@ -0,0 +1,78 @@
+/**
+ *
+ * Copyright (C) The ROME Team 2011
+ *
+ *
+ * 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.
+ */
+
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package com.rometools.certiorem.sub.data.ram;
+
+import java.util.Date;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.rometools.certiorem.sub.data.SubDAO;
+import com.rometools.certiorem.sub.data.Subscription;
+
+/**
+ *
+ * @author robert.cooper
+ */
+public class InMemorySubDAO implements SubDAO {
+
+ private static final Logger LOG = LoggerFactory.getLogger(InMemorySubDAO.class);
+
+ private final ConcurrentHashMap subscriptions = new ConcurrentHashMap();
+
+ @Override
+ public Subscription findById(final String id) {
+ final Subscription s = subscriptions.get(id);
+ if (s == null) {
+ return null;
+ }
+ if (s.getExpirationTime() > 0 && s.getExpirationTime() <= System.currentTimeMillis()) {
+ LOG.debug("Subscription {} expired at {}", s.getSourceUrl(), new Date(s.getExpirationTime()));
+ subscriptions.remove(id);
+
+ return null;
+ }
+ return s;
+ }
+
+ @Override
+ public Subscription addSubscription(final Subscription s) {
+ subscriptions.put(s.getId(), s);
+ LOG.debug("Stored subscription {} {}", s.getSourceUrl(), s.getId());
+ return s;
+ }
+
+ @Override
+ public Subscription updateSubscription(final Subscription s) {
+ subscriptions.put(s.getId(), s);
+ return s;
+ }
+
+ @Override
+ public void removeSubscription(final Subscription s) {
+ subscriptions.remove(s.getId());
+ }
+
+}
diff --git a/rome-certiorem/src/main/java/com/rometools/certiorem/sub/data/ram/package.html b/rome-certiorem/src/main/java/com/rometools/certiorem/sub/data/ram/package.html
new file mode 100644
index 0000000..3333549
--- /dev/null
+++ b/rome-certiorem/src/main/java/com/rometools/certiorem/sub/data/ram/package.html
@@ -0,0 +1,28 @@
+
+
+
+
+ ram
+
+
+ An In-Memory DAO for subscriptions.
+
+
\ No newline at end of file
diff --git a/rome-certiorem/src/main/java/com/rometools/certiorem/sub/package.html b/rome-certiorem/src/main/java/com/rometools/certiorem/sub/package.html
new file mode 100644
index 0000000..44aab1c
--- /dev/null
+++ b/rome-certiorem/src/main/java/com/rometools/certiorem/sub/package.html
@@ -0,0 +1,30 @@
+
+
+
+
+ sub
+
+
+ This package contains the business class Subscriptions that manages subscriptions and updates a
+ FeedInfoCache.
+
+
+
diff --git a/rome-certiorem/src/main/java/com/rometools/certiorem/sub/request/AbstractRequester.java b/rome-certiorem/src/main/java/com/rometools/certiorem/sub/request/AbstractRequester.java
new file mode 100644
index 0000000..ec663df
--- /dev/null
+++ b/rome-certiorem/src/main/java/com/rometools/certiorem/sub/request/AbstractRequester.java
@@ -0,0 +1,72 @@
+/**
+ *
+ * Copyright (C) The ROME Team 2011
+ *
+ *
+ * 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 com.rometools.certiorem.sub.request;
+
+import java.io.IOException;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.net.URLEncoder;
+
+import com.rometools.certiorem.sub.Requester;
+import com.rometools.certiorem.sub.data.Subscription;
+
+/**
+ *
+ * @author robert.cooper
+ */
+public abstract class AbstractRequester implements Requester {
+
+ protected boolean sendRequest(final String hubUrl, final String mode, final Subscription subscription, final String verifySync, final long leaseSeconds,
+ final String secret, final String callbackUrl, final RequestCallback callback) throws IOException {
+ final StringBuilder sb = new StringBuilder("hub.callback=").append(URLEncoder.encode(callbackUrl, "UTF-8")).append("&hub.topic=")
+ .append(URLEncoder.encode(subscription.getSourceUrl(), "UTF-8")).append("&hub.verify=").append(URLEncoder.encode(verifySync, "UTF-8"))
+ .append("&hub.mode=").append(URLEncoder.encode(mode, "UTF-8"));
+
+ if (leaseSeconds > 0) {
+ sb.append("&hub.lease_seconds=").append(Long.toString(leaseSeconds));
+ }
+
+ if (secret != null) {
+ sb.append("&hub.secret=").append(URLEncoder.encode(secret, "UTF-8"));
+ }
+
+ if (subscription.getVerifyToken() != null) {
+ sb.append("&hub.verify_token=").append(URLEncoder.encode(subscription.getVerifyToken(), "UTF-8"));
+ }
+
+ final URL url = new URL(hubUrl);
+ final HttpURLConnection connection = (HttpURLConnection) url.openConnection();
+ connection.setRequestMethod("POST");
+ connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
+ connection.setDoOutput(true);
+ // connection.setRequestProperty("Host", url.getHost());
+ connection.setRequestProperty("User-Agent", "ROME-Certiorem");
+ connection.connect();
+ connection.getOutputStream().write(sb.toString().getBytes("UTF-8"));
+
+ final int rc = connection.getResponseCode();
+ connection.disconnect();
+
+ if (rc != 204) {
+ throw new RuntimeException("Unexpected repsonse code. " + rc);
+ }
+
+ return true;
+ }
+}
diff --git a/rome-certiorem/src/main/java/com/rometools/certiorem/sub/request/AsyncRequester.java b/rome-certiorem/src/main/java/com/rometools/certiorem/sub/request/AsyncRequester.java
new file mode 100644
index 0000000..bae5291
--- /dev/null
+++ b/rome-certiorem/src/main/java/com/rometools/certiorem/sub/request/AsyncRequester.java
@@ -0,0 +1,72 @@
+/**
+ *
+ * Copyright (C) The ROME Team 2011
+ *
+ *
+ * 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 com.rometools.certiorem.sub.request;
+
+import java.io.IOException;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.rometools.certiorem.sub.data.Subscription;
+
+/**
+ * A simple requester implementation that always makes requests as Async.
+ *
+ * @author robert.cooper
+ */
+public class AsyncRequester extends AbstractRequester {
+
+ private static final Logger LOG = LoggerFactory.getLogger(AsyncRequester.class);
+
+ @Override
+ public void sendSubscribeRequest(final String hubUrl, final Subscription subscription, final String verifySync, final long leaseSeconds,
+ final String secret, final String callbackUrl, final RequestCallback callback) {
+ LOG.debug("Sending subscribe request to {} for {} to {}", hubUrl, subscription.getSourceUrl(), callbackUrl);
+ final Runnable r = new Runnable() {
+ @Override
+ public void run() {
+ try {
+ sendRequest(hubUrl, "subscribe", subscription, verifySync, leaseSeconds, secret, callbackUrl, callback);
+ } catch (final Exception ex) {
+ LOG.error(null, ex);
+ callback.onFailure(ex);
+ }
+ }
+ };
+ new Thread(r).start();
+ }
+
+ @Override
+ public void sendUnsubscribeRequest(final String hubUrl, final Subscription subscription, final String verifySync, final String secret,
+ final String callbackUrl, final RequestCallback callback) {
+ LOG.debug("Sending unsubscribe request to {} for {} to {}", hubUrl, subscription.getSourceUrl(), callbackUrl);
+ final Runnable r = new Runnable() {
+ @Override
+ public void run() {
+ try {
+ sendRequest(hubUrl, "unsubscribe", subscription, verifySync, -1, secret, callbackUrl, callback);
+ } catch (final IOException ex) {
+ LOG.error(null, ex);
+ callback.onFailure(ex);
+ }
+ }
+ };
+ new Thread(r).start();
+ }
+}
diff --git a/rome-certiorem/src/main/java/com/rometools/certiorem/sub/request/SyncRequester.java b/rome-certiorem/src/main/java/com/rometools/certiorem/sub/request/SyncRequester.java
new file mode 100644
index 0000000..721b0c8
--- /dev/null
+++ b/rome-certiorem/src/main/java/com/rometools/certiorem/sub/request/SyncRequester.java
@@ -0,0 +1,66 @@
+/**
+ *
+ * Copyright (C) The ROME Team 2011
+ *
+ *
+ * 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.
+ */
+
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package com.rometools.certiorem.sub.request;
+
+import java.io.IOException;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.rometools.certiorem.sub.data.Subscription;
+
+/**
+ * A simple requester implementation that always makes requests as Async.
+ *
+ * @author Farrukh Najmi
+ */
+public class SyncRequester extends AbstractRequester {
+
+ private static final Logger LOG = LoggerFactory.getLogger(SyncRequester.class);
+
+ @Override
+ public void sendSubscribeRequest(final String hubUrl, final Subscription subscription, final String verifySync, final long leaseSeconds,
+ final String secret, final String callbackUrl, final RequestCallback callback) {
+ LOG.info("Sending subscribe request to {} for {} to {}", hubUrl, subscription.getSourceUrl(), callbackUrl);
+ try {
+ sendRequest(hubUrl, "subscribe", subscription, verifySync, leaseSeconds, secret, callbackUrl, callback);
+ callback.onSuccess();
+ } catch (final Exception ex) {
+ LOG.error(null, ex);
+ callback.onFailure(ex);
+ }
+ }
+
+ @Override
+ public void sendUnsubscribeRequest(final String hubUrl, final Subscription subscription, final String verifySync, final String secret,
+ final String callbackUrl, final RequestCallback callback) {
+ LOG.info("Sending unsubscribe request to {} for {} to {}", hubUrl, subscription.getSourceUrl(), callbackUrl);
+ try {
+ sendRequest(hubUrl, "unsubscribe", subscription, verifySync, -1, secret, callbackUrl, callback);
+ callback.onSuccess();
+ } catch (final IOException ex) {
+ LOG.error(null, ex);
+ callback.onFailure(ex);
+ }
+ }
+}
diff --git a/rome-certiorem/src/main/java/com/rometools/certiorem/sub/request/package.html b/rome-certiorem/src/main/java/com/rometools/certiorem/sub/request/package.html
new file mode 100644
index 0000000..b2bd746
--- /dev/null
+++ b/rome-certiorem/src/main/java/com/rometools/certiorem/sub/request/package.html
@@ -0,0 +1,28 @@
+
+
+
+
+ request
+
+
+ Standard requester implementations.
+
+
\ No newline at end of file
diff --git a/rome-certiorem/src/main/java/com/rometools/certiorem/web/AbstractHubServlet.java b/rome-certiorem/src/main/java/com/rometools/certiorem/web/AbstractHubServlet.java
new file mode 100644
index 0000000..28ee4bf
--- /dev/null
+++ b/rome-certiorem/src/main/java/com/rometools/certiorem/web/AbstractHubServlet.java
@@ -0,0 +1,84 @@
+/**
+ *
+ * Copyright (C) The ROME Team 2011
+ *
+ *
+ * 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 com.rometools.certiorem.web;
+
+import java.io.IOException;
+import java.util.Arrays;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import com.rometools.certiorem.HttpStatusCodeException;
+import com.rometools.certiorem.hub.Hub;
+
+/**
+ *
+ * @author robert.cooper
+ */
+public abstract class AbstractHubServlet extends HttpServlet {
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ public static final String HUBMODE = "hub.mode";
+ private final Hub hub;
+
+ protected AbstractHubServlet(final Hub hub) {
+ super();
+ this.hub = hub;
+ }
+
+ @Override
+ protected void doPost(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException {
+ try {
+ if ("publish".equals(req.getParameter(HUBMODE))) {
+ hub.sendNotification(req.getServerName(), req.getParameter("hub.url"));
+ } else {
+ final String callback = req.getParameter("hub.callback");
+ final String topic = req.getParameter("hub.topic");
+ final String[] verifies = req.getParameterValues("hub.verify");
+ final String leaseString = req.getParameter("hub.lease_seconds");
+ final String secret = req.getParameter("hub.secret");
+ final String verifyToken = req.getParameter("hub.verify_token");
+ final String verifyMode = Arrays.asList(verifies).contains("async") ? "async" : "sync";
+ Boolean result = null;
+
+ if ("subscribe".equals(req.getParameter(HUBMODE))) {
+ final long leaseSeconds = leaseString != null ? Long.parseLong(leaseString) : -1;
+ result = hub.subscribe(callback, topic, verifyMode, leaseSeconds, secret, verifyToken);
+ } else if ("unsubscribe".equals(req.getParameter(HUBMODE))) {
+ result = hub.unsubscribe(callback, topic, verifyMode, secret, verifyToken);
+ }
+
+ if (result != null && !result) {
+ throw new HttpStatusCodeException(500, "Operation failed.", null);
+ }
+ }
+ } catch (final HttpStatusCodeException sc) {
+ resp.setStatus(sc.getStatus());
+ resp.getWriter().println(sc.getMessage());
+
+ return;
+ }
+
+ resp.setStatus(204);
+ }
+}
diff --git a/rome-certiorem/src/main/java/com/rometools/certiorem/web/AbstractSubServlet.java b/rome-certiorem/src/main/java/com/rometools/certiorem/web/AbstractSubServlet.java
new file mode 100644
index 0000000..3b6f343
--- /dev/null
+++ b/rome-certiorem/src/main/java/com/rometools/certiorem/web/AbstractSubServlet.java
@@ -0,0 +1,77 @@
+/**
+ *
+ * Copyright (C) The ROME Team 2011
+ *
+ *
+ * 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 com.rometools.certiorem.web;
+
+import java.io.IOException;
+
+import javax.servlet.ServletException;
+import javax.servlet.ServletInputStream;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import com.rometools.certiorem.HttpStatusCodeException;
+import com.rometools.certiorem.sub.Subscriptions;
+
+/**
+ *
+ * @author robert.cooper
+ */
+public abstract class AbstractSubServlet extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ private final Subscriptions subscriptions;
+
+ protected AbstractSubServlet(final Subscriptions subscriptions) {
+ this.subscriptions = subscriptions;
+ }
+
+ @Override
+ protected void doGet(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException {
+ final String mode = req.getParameter("hub.mode");
+ final String topic = req.getParameter("hub.topic");
+ final String challenge = req.getParameter("hub.challenge");
+ final String leaseString = req.getParameter("hub.lease_seconds");
+ final String verifyToken = req.getParameter("hub.verify_token");
+ try {
+ final String result = subscriptions.validate(req.getRequestURL().toString(), topic, mode, challenge, leaseString, verifyToken);
+ resp.setStatus(200);
+ resp.getWriter().print(result);
+ } catch (final HttpStatusCodeException e) {
+ e.printStackTrace();
+ resp.setStatus(e.getStatus());
+ resp.getWriter().print(e.getMessage());
+ }
+ }
+
+ @Override
+ protected void doPost(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException {
+ try {
+ final String requestUrl = req.getRequestURL().toString();
+ final ServletInputStream inputStream = req.getInputStream();
+ subscriptions.callback(requestUrl, inputStream);
+ } catch (final HttpStatusCodeException e) {
+ e.printStackTrace();
+ resp.setStatus(e.getStatus());
+ resp.getWriter().println(e.getMessage());
+ }
+ }
+
+}
diff --git a/rome-certiorem/src/main/java/com/rometools/certiorem/web/package.html b/rome-certiorem/src/main/java/com/rometools/certiorem/web/package.html
new file mode 100644
index 0000000..17f6703
--- /dev/null
+++ b/rome-certiorem/src/main/java/com/rometools/certiorem/web/package.html
@@ -0,0 +1,31 @@
+
+
+
+
+ web
+
+
+ Contains base servlet implementations for doing hub and sub services.
+
+ Extends these as needed in your web application.
+
+
+
\ No newline at end of file
diff --git a/rome-certiorem/src/main/resources/META-INF/persistence.xml b/rome-certiorem/src/main/resources/META-INF/persistence.xml
new file mode 100644
index 0000000..6237669
--- /dev/null
+++ b/rome-certiorem/src/main/resources/META-INF/persistence.xml
@@ -0,0 +1,30 @@
+
+
+
+
+
+ jdbc/certiorem-datasource
+
+
+
+
+
+
\ No newline at end of file
diff --git a/rome-certiorem/src/site/apt/CertioremTutorial.apt b/rome-certiorem/src/site/apt/CertioremTutorial.apt
new file mode 100644
index 0000000..6a81dfc
--- /dev/null
+++ b/rome-certiorem/src/site/apt/CertioremTutorial.apt
@@ -0,0 +1,124 @@
+ -----
+ Certiorem Tutorial
+ -----
+ kebernet
+ -----
+ 2011-12-06 19:23:15.220
+ -----
+
+Certiorem Tutorial
+
+ Certiorem is a PubSubHubub (PSH) implementation for ROME. It isn't an application, but an API for building each of the three components (Publisher, Subscriber and Hub) into your web apps.
+
+ You can see an {{{https://github.com/rometools/rome-incubator/tree/master/pubsubhubub/webapp}example webapp here}}.
+
+Creating a Hub
+
+ Hubs take notifications, or "Pings" that tell it the content of a feed has been updated, fetch the feed, then notify each of the subscribers of the change. As you will begin to see, Certiorem is very much about "Composition" of classes. The Hub class is a prime example of this.
+
+ Looking at the example webapp we see:
+
++------+
+@Provides
+@Singleton
+public Hub buildHub() {
+ FeedFetcher fetcher = new HttpURLFeedFetcher(new DeltaFeedInfoCache());
+ Hub hub = new Hub(new InMemoryHubDAO(), new UnthreadedVerifier(), new UnthreadedNotifier(), fetcher);
+
+ return hub;
+}
++------+
+
+ First we construct an instance of FeedFetcher, from the Fetcher subproject. This will be used to fetch feeds from remote hosts. There are a number of implementations for FeedFetcher and FeedInfoCache in the Fetcher project. Please look there for info on what is what.
+
+ Next we need a HubDAO implementation. This is a DAO for managing Subscriber and SubscriptionSummary classes. Here we are using an in\-memory DAO, which like the HashMapFeedInfoCache will evaporate if we restart our web application. A JPA implementation for persistence is also available, but incomplete at time of writing.
+
+ Next we need two implementations of network client interfaces: a Verifier, and a Notifier. The Verifier calls back to the Subscribers and verifies their subscribe/unsubscribe operations. A Notifier is used to send updates to to the clients. There are two basic implementations of these provided: A ThreadPool\* and Unthreaded\* version of each. The thread pool version uses a ThreadPoolExecutor to run queues of outbound calls. The Unthreaded version of each, makes the network calls in\-line with the request to the hub. These are suitable for environments like Google App Engine where spawning threads from servlets is absolutely verboten.
+
+ There are other constructors that contain lists of restrictions for what the hub will support: acceptable topic feeds, ports, protocols, etc.
+
+ The hub here is just a business logic class. In order to have a functioning hub, we need a servlet exposing the Hub. In the "web" package, there is an abstract servlet you can use to do just this. In the Guice wired example, we simply create a servlet with an injected Hub implementation.
+
++------+
+@Singleton
+public class HubServlet extends AbstractHubServlet {
+
+ @Inject
+ public HubServlet(final Hub hub){
+ super(hub);
+ }
+}
+//... in the ServerModule...
+
+serve("/hub*").with(HubServlet.class);
++------+
+
+ We can now include a \ value in our feeds and publish notifications of changes.
+
+Publishing Ping Notifications
+
+ This is perhaps the easiest thing to do. The Publisher class will take various combinations of URLs and SyndFeeds and send the appropriate notification. If your SyndFeed contains a \ and \ you can just pass the SyndFeed object. Otherwise, you can use the URL strings where appropriate.
+
+ The example couldn't be simpler:
+
++------+
+Publisher pub = new Publisher();
+try {
+ pub.sendUpdateNotification("http://localhost/webapp/hub", "http://localhost/webapp/research-atom.xml");
+} catch (NotificationException ex) {
+ Logger.getLogger(NotifyTest.class.getName()).log(Level.SEVERE, null, ex);
+ throw new ServletException(ex);
+}
++------+
+
+ Once this notification is sent, the hub will make a request to the feed and notify the clients of new entries.
+
+Subscribing to Feeds
+
+ To set up a feed subscriber, you need to go through a process very much like setting up a Hub. First, create the Subscriptions class by composition:
+
++------+
+@Provides
+@Singleton
+public Subscriptions buildSubs(){
+ Subscriptions subs = new Subscriptions(new HashMapFeedInfoCache(), new AsyncRequester(),
+ "http://localhost/webapp/subscriptions/", new InMemorySubDAO());
+ return subs;
+}
++------+
+
+ First we need a FeedInfoCache implementation. This will be updated as notifications come in, so in your web app, you want to make sure this is shared with the FeedFetcher implementation you are using to read feeds. Next you need a Requester, this is a network class that makes subscription requests to remote hubs. Next, a URL prefix for where the callbacks will live. This really means the URL to the SubServlet that is resolvable externally. Finally, a DAO for storing and retrieving Subscription objects.
+
+ As in the Hub, we need a wrapper servlet to call into the Subscriptions class
+
++------+
+@Singleton
+public class SubServlet extends AbstractSubServlet {
+
+ @Inject
+ public SubServlet(final Subscriptions subscriptions){
+ super(subscriptions);
+ }
+}
+
+// In the ServerModule...
+serve("/subscriptions/*").with(SubServlet.class)
++------+
+
+ Now if we want to subscribe to a feed, we get a reference to the Subscriptions object, and pass in either the SyndFeed (with appropriate rel\="hub" and rel\="self" links) or simply a couple of URLs:
+
++------+
+ subs.subscribe("http://localhost/webapp/hub", "http://localhost/webapp/research-atom.xml", true, -1, null, new SubscriptionCallback(){
+
+ public void onFailure(Exception e) {
+ e.printStackTrace();
+ }
+
+ public void onSubscribe(Subscription subscribed) {
+ System.out.println("Subscribed "+subscribed.getId() +" "+subscribed.getSourceUrl());
+ }
+
+ });
++------+
+
+ Here we pass in the URL of the Hub, the URL of the feed, a boolean indicating we want to make the subscription request synchronously, the lease seconds we want to keep the subscription for, a null cryptographic secret, and a Callback invoked when the subscribe request completes.
diff --git a/rome-certiorem/src/site/apt/index.apt b/rome-certiorem/src/site/apt/index.apt
new file mode 100644
index 0000000..d240e48
--- /dev/null
+++ b/rome-certiorem/src/site/apt/index.apt
@@ -0,0 +1,47 @@
+ -----
+ certiorem
+ -----
+ kebernet
+ -----
+ 2011-03-19 10:30:35.292
+ -----
+
+Certiorem
+
+ Certiorem is an implementation of the {{{http://pubsubhubbub.googlecode.com/svn/trunk/pubsubhubbub\-core\-0.3.html}PubSubHubub }}protocol for ROME.
+
+ It is dependent on ROME and ROME\-Fetcher for the base implementations, and will provide standard plugins for Propono to allow for publish eventing, where applicable.
+
+*Primary Components
+
+*Hub Implementation and Scaffolding (Done)
+
+ The first part of Certiorem is a basic set of scaffolding classes that can be used to create a PSH notification hub. Initially, this will include a non\-guaranteed delivery hub, with standard implementations suitable for deployment on most JavaEE application servers or Google App Engine. It is intended that there should be at least one simple, drop in WAR file, utilizing JavaEE classes that can work in a default configuration for various standard web containers. Subsequently, each of the classes in the PSH implementation up through the primary Controller class use constructor\-time composition/configuration so that the user/developer can easily construct a custom configuration of the Hub.
+
+**Client Implementation Integrated with ROME\-Fetcher (Done)
+
+ For web\-based applications that use ROME\-Fetcher, an extended push\-notified store wrapper that will update based on callbacks from a Hub of change notifications. This will include a highly configurable callback servlet to write into the Fetcher cache as changes are made. Additionally, the system should support (semi\-)real time notifications of changes in the form of a listener that exectutes in a TBD thread state relative to the callback servlet. This should be packaged as a simple JAR with no more deps than fetcher that defines the callback servlet, and automagically does subscribes where link\=rel appropriate.
+
+**Notification Implementation for Propono based and JAX\-RS based Servers (In Progress)
+
+ This should be a simple API call to notify a Hub of changes to topics. Again, this should provide real\-time notifications either synchronously or asynchronously. Importantly for Asynchronous notifications, they should block subsequent change notifications pending a notification to the Hub.
+
+ References:
+
+ {{{https://github.com/nlothian/RTUpdates/blob/master/src/com/nicklothian/pubsubhub/PubSubHubSubscriptionServlet.java}https://github.com/nlothian/RTUpdates/blob/master/src/com/nicklothian/pubsubhub/PubSubHubSubscriptionServlet.java}}
+
+ {{{http://grack.com/blog/2009/09/09/parsing\-the\-pubsubhubbub\-notifications/}http://grack.com/blog/2009/09/09/parsing\-the\-pubsubhubbub\-notifications/}}
+
+Notes on the Code
+
+ It is still mostly a rough sketch, but the big outlines are there:
+
+ There are three main packages: pub, sub and hub.
+
+ The pub package is basically just a single utility class for pushing notifications to a hub.
+
+ The hub package contains the Hub class. This is a general business controller that is intended to allow you to build a servlet around it with a very, very thin veneer, but you could also use it to drive an XMPP or JMS version too. It is basically built by composition of a number of classes, for which there are some default implementations: A Verifier, which makes the callback to verify new subscriptions, the HubDAO which stores the current subscriptions and subscriber statistics, and a Notifier which actually sends notifications to the subscribers. There are a couple of implementations of each of these (though the JPA HubDAO is still in process). Mostly the implementations for the Verifier and Notifier support threadpooling or no\-threads (for App Engine use).
+
+ I have just started sketching out the sub package, but it basically has a "Subscriptions" class that will take in notifications (using the same "thin veneer" pattern that the Hub class uses). It is also constructed with some impls: A SubscriptionDAO that stores you current subscription information, a FeedFetcherCache that holds the received data, and a Requester that makes the subscription requests to hubs.
+
+ I am hoping to have a basic end to end example working sometime in the next week or so, but if anyone wants to look over what is there, feel free.
diff --git a/src/site/resources/.nojekyll b/rome-certiorem/src/site/resources/.nojekyll
similarity index 100%
rename from src/site/resources/.nojekyll
rename to rome-certiorem/src/site/resources/.nojekyll
diff --git a/src/site/resources/css/site.css b/rome-certiorem/src/site/resources/css/site.css
similarity index 100%
rename from src/site/resources/css/site.css
rename to rome-certiorem/src/site/resources/css/site.css
diff --git a/src/site/resources/images/romelogo.png b/rome-certiorem/src/site/resources/images/romelogo.png
similarity index 100%
rename from src/site/resources/images/romelogo.png
rename to rome-certiorem/src/site/resources/images/romelogo.png
diff --git a/rome-certiorem/src/site/site.xml b/rome-certiorem/src/site/site.xml
new file mode 100644
index 0000000..61433df
--- /dev/null
+++ b/rome-certiorem/src/site/site.xml
@@ -0,0 +1,42 @@
+
+
+
+
+ org.apache.maven.skins
+ maven-fluido-skin
+ 1.3.0
+
+
+
+
+
+ rometools/rome-certiorem
+ right
+ gray
+
+
+
+
+
+ ROME
+ images/romelogo.png
+ http://github.com/rometools/
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/rome-certiorem/src/test/java/com/rometools/certiorem/hub/AlwaysVerifier.java b/rome-certiorem/src/test/java/com/rometools/certiorem/hub/AlwaysVerifier.java
new file mode 100644
index 0000000..af5f9fb
--- /dev/null
+++ b/rome-certiorem/src/test/java/com/rometools/certiorem/hub/AlwaysVerifier.java
@@ -0,0 +1,50 @@
+/**
+ *
+ * Copyright (C) The ROME Team 2011
+ *
+ *
+ * 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 com.rometools.certiorem.hub;
+
+import com.rometools.certiorem.hub.Verifier;
+import com.rometools.certiorem.hub.data.Subscriber;
+
+/**
+ *
+ * @author robert.cooper
+ */
+public class AlwaysVerifier implements Verifier {
+
+ @Override
+ public void verifySubscribeAsyncronously(final Subscriber subscriber, final VerificationCallback callback) {
+ callback.onVerify(true);
+ }
+
+ @Override
+ public boolean verifySubcribeSyncronously(final Subscriber subscriber) {
+ return true;
+ }
+
+ @Override
+ public void verifyUnsubscribeAsyncronously(final Subscriber subscriber, final VerificationCallback callback) {
+ callback.onVerify(true);
+ }
+
+ @Override
+ public boolean verifyUnsubcribeSyncronously(final Subscriber subscriber) {
+ return true;
+ }
+
+}
diff --git a/rome-certiorem/src/test/java/com/rometools/certiorem/hub/ControllerTest.java b/rome-certiorem/src/test/java/com/rometools/certiorem/hub/ControllerTest.java
new file mode 100644
index 0000000..7d5b1cd
--- /dev/null
+++ b/rome-certiorem/src/test/java/com/rometools/certiorem/hub/ControllerTest.java
@@ -0,0 +1,131 @@
+/**
+ *
+ * Copyright (C) The ROME Team 2011
+ *
+ *
+ * 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 com.rometools.certiorem.hub;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.rometools.certiorem.HttpStatusCodeException;
+import com.rometools.certiorem.hub.Hub;
+import com.rometools.certiorem.hub.Notifier;
+import com.rometools.certiorem.hub.data.HubDAO;
+import com.rometools.certiorem.hub.data.ram.InMemoryHubDAO;
+import com.rometools.fetcher.FeedFetcher;
+import com.rometools.fetcher.impl.HashMapFeedInfoCache;
+import com.rometools.fetcher.impl.HttpURLFeedFetcher;
+
+/**
+ *
+ * @author robert.cooper
+ */
+public class ControllerTest {
+
+ private static final Logger LOG = LoggerFactory.getLogger(ControllerTest.class);
+
+ public ControllerTest() {
+ }
+
+ @BeforeClass
+ public static void setUpClass() throws Exception {
+ }
+
+ @AfterClass
+ public static void tearDownClass() throws Exception {
+ }
+
+ @Before
+ public void setUp() {
+ }
+
+ @After
+ public void tearDown() {
+ }
+
+ /**
+ * Test of subscribe method, of class Hub.
+ */
+ @Test
+ public void testSubscribe() {
+
+ LOG.info("subscribe");
+
+ final String callback = "http://localhost/doNothing";
+ final String topic = "http://feeds.feedburner.com/screaming-penguin";
+ final long lease_seconds = -1;
+ final String secret = null;
+ final String verify_token = "MyVoiceIsMyPassport";
+ final HubDAO dao = new InMemoryHubDAO();
+ final Notifier notifier = null;
+ final FeedFetcher fetcher = new HttpURLFeedFetcher(HashMapFeedInfoCache.getInstance());
+ Hub instance = new Hub(dao, new AlwaysVerifier(), notifier, fetcher);
+
+ Boolean result = instance.subscribe(callback, topic, "sync", lease_seconds, secret, verify_token);
+ assertEquals(true, result);
+
+ instance = new Hub(dao, new NeverVerifier(), notifier, fetcher);
+ result = instance.subscribe(callback, topic, "sync", lease_seconds, secret, verify_token);
+ assertEquals(false, result);
+
+ result = instance.subscribe(callback, topic, "async", lease_seconds, secret, verify_token);
+ assertEquals(null, result);
+
+ // Test internal assertions
+ try {
+ instance.subscribe(null, topic, "async", lease_seconds, secret, verify_token);
+ fail();
+ } catch (final HttpStatusCodeException e) {
+ assertEquals(400, e.getStatus());
+ LOG.info(e.getMessage());
+ }
+
+ try {
+ instance.subscribe(callback, null, "async", lease_seconds, secret, verify_token);
+ fail();
+ } catch (final HttpStatusCodeException e) {
+ assertEquals(400, e.getStatus());
+ LOG.info(e.getMessage());
+ }
+
+ try {
+ instance.subscribe(callback, topic, "foo", lease_seconds, secret, verify_token);
+ fail();
+ } catch (final HttpStatusCodeException e) {
+ assertEquals(400, e.getStatus());
+ LOG.info(e.getMessage());
+ }
+
+ // test general exception
+ instance = new Hub(dao, new ExceptionVerifier(), notifier, fetcher);
+
+ try {
+ result = instance.subscribe(callback, topic, "sync", lease_seconds, secret, verify_token);
+ fail();
+ } catch (final HttpStatusCodeException e) {
+ assertEquals(500, e.getStatus());
+ }
+ }
+}
diff --git a/rome-certiorem/src/test/java/com/rometools/certiorem/hub/DeltaSyndFeedInfoTest.java b/rome-certiorem/src/test/java/com/rometools/certiorem/hub/DeltaSyndFeedInfoTest.java
new file mode 100644
index 0000000..00b25f0
--- /dev/null
+++ b/rome-certiorem/src/test/java/com/rometools/certiorem/hub/DeltaSyndFeedInfoTest.java
@@ -0,0 +1,62 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package com.rometools.certiorem.hub;
+
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.List;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import com.rometools.certiorem.hub.DeltaFeedInfoCache;
+import com.rometools.fetcher.impl.HashMapFeedInfoCache;
+import com.rometools.fetcher.impl.HttpURLFeedFetcher;
+import com.rometools.rome.feed.synd.SyndEntry;
+import com.rometools.rome.feed.synd.SyndFeed;
+
+/**
+ *
+ * @author najmi
+ */
+public class DeltaSyndFeedInfoTest {
+
+ private DeltaFeedInfoCache feedInfoCache;
+ private HttpURLFeedFetcher feedFetcher;
+ private SyndFeed feed;
+
+ @Before
+ public void setUp() {
+ feedInfoCache = new DeltaFeedInfoCache(new HashMapFeedInfoCache());
+ feedFetcher = new HttpURLFeedFetcher(feedInfoCache);
+ }
+
+ /**
+ * Test of getSyndFeed method, of class DeltaSyndFeedInfo.
+ */
+ @Test
+ public void testGetSyndFeed() throws Exception {
+
+ feed = feedFetcher.retrieveFeed(getFeedUrl());
+ List entries = feed.getEntries();
+ assertTrue(!entries.isEmpty());
+
+ // Fetch again and this time the entries should be empty as none have
+ // changed.
+ feed = feedFetcher.retrieveFeed(getFeedUrl());
+ entries = feed.getEntries();
+ assertTrue(entries.isEmpty());
+ }
+
+ private URL getFeedUrl() throws IOException {
+ final URL feedUrl = new URL("http://news.google.com/news?pz=1&cf=all&ned=us&hl=en&output=rss");
+ // URL feedUrl = new
+ // URL("http://newsrss.bbc.co.uk/rss/newsonline_world_edition/front_page/rss.xml");
+ return feedUrl;
+ }
+
+}
diff --git a/rome-certiorem/src/test/java/com/rometools/certiorem/hub/ExceptionVerifier.java b/rome-certiorem/src/test/java/com/rometools/certiorem/hub/ExceptionVerifier.java
new file mode 100644
index 0000000..3aa877c
--- /dev/null
+++ b/rome-certiorem/src/test/java/com/rometools/certiorem/hub/ExceptionVerifier.java
@@ -0,0 +1,50 @@
+/**
+ *
+ * Copyright (C) The ROME Team 2011
+ *
+ *
+ * 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 com.rometools.certiorem.hub;
+
+import com.rometools.certiorem.hub.Verifier;
+import com.rometools.certiorem.hub.data.Subscriber;
+
+/**
+ *
+ * @author robert.cooper
+ */
+public class ExceptionVerifier implements Verifier {
+
+ @Override
+ public void verifySubscribeAsyncronously(final Subscriber subscriber, final VerificationCallback callback) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public boolean verifySubcribeSyncronously(final Subscriber subscriber) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void verifyUnsubscribeAsyncronously(final Subscriber subscriber, final VerificationCallback callback) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public boolean verifyUnsubcribeSyncronously(final Subscriber subscriber) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+}
diff --git a/rome-certiorem/src/test/java/com/rometools/certiorem/hub/NeverVerifier.java b/rome-certiorem/src/test/java/com/rometools/certiorem/hub/NeverVerifier.java
new file mode 100644
index 0000000..a5aa95e
--- /dev/null
+++ b/rome-certiorem/src/test/java/com/rometools/certiorem/hub/NeverVerifier.java
@@ -0,0 +1,50 @@
+/**
+ *
+ * Copyright (C) The ROME Team 2011
+ *
+ *
+ * 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 com.rometools.certiorem.hub;
+
+import com.rometools.certiorem.hub.Verifier;
+import com.rometools.certiorem.hub.data.Subscriber;
+
+/**
+ *
+ * @author robert.cooper
+ */
+public class NeverVerifier implements Verifier {
+
+ @Override
+ public void verifySubscribeAsyncronously(final Subscriber subscriber, final VerificationCallback callback) {
+ callback.onVerify(false);
+ }
+
+ @Override
+ public boolean verifySubcribeSyncronously(final Subscriber subscriber) {
+ return false;
+ }
+
+ @Override
+ public void verifyUnsubscribeAsyncronously(final Subscriber subscriber, final VerificationCallback callback) {
+ callback.onVerify(false);
+ }
+
+ @Override
+ public boolean verifyUnsubcribeSyncronously(final Subscriber subscriber) {
+ return false;
+ }
+
+}
diff --git a/rome-certiorem/src/test/java/com/rometools/certiorem/hub/data/AbstractDAOTest.java b/rome-certiorem/src/test/java/com/rometools/certiorem/hub/data/AbstractDAOTest.java
new file mode 100644
index 0000000..e70016a
--- /dev/null
+++ b/rome-certiorem/src/test/java/com/rometools/certiorem/hub/data/AbstractDAOTest.java
@@ -0,0 +1,97 @@
+/**
+ *
+ * Copyright (C) The ROME Team 2011
+ *
+ *
+ * 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 com.rometools.certiorem.hub.data;
+
+import java.util.List;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.rometools.certiorem.hub.data.HubDAO;
+import com.rometools.certiorem.hub.data.Subscriber;
+
+/**
+ *
+ * @author robert.cooper
+ */
+public abstract class AbstractDAOTest {
+
+ private static final Logger LOG = LoggerFactory.getLogger(AbstractDAOTest.class);
+
+ protected abstract HubDAO get();
+
+ @Test
+ public void testSubscribe() {
+ final HubDAO instance = get();
+ LOG.info("{} testSubscribe", instance.getClass().getName());
+ final Subscriber subscriber = new Subscriber();
+ subscriber.setCallback("http://localhost:9797/noop");
+ subscriber.setTopic("http://feeds.feedburner.com/screaming-penguin");
+ subscriber.setLeaseSeconds(-1);
+ subscriber.setVerify("VerifyMe");
+
+ final Subscriber result = instance.addSubscriber(subscriber);
+
+ Assert.assertTrue("Subscriber not equal", result.equals(subscriber));
+
+ final List extends Subscriber> subscribers = instance.subscribersForTopic(subscriber.getTopic());
+
+ Assert.assertTrue("Subscriber not in result", subscribers.contains(result));
+
+ }
+
+ @Test
+ public void testLeaseExpire() throws InterruptedException {
+ final HubDAO instance = get();
+ LOG.info("{} testLeaseExpire", instance.getClass().getName());
+ final Subscriber subscriber = new Subscriber();
+ subscriber.setCallback("http://localhost:9797/noop");
+ subscriber.setTopic("http://feeds.feedburner.com/screaming-penguin");
+ subscriber.setLeaseSeconds(1);
+ subscriber.setVerify("VerifyMe");
+
+ final Subscriber result = instance.addSubscriber(subscriber);
+
+ Assert.assertEquals("Subscriber not equal", subscriber, result);
+ // quick test for store.
+ List extends Subscriber> subscribers = instance.subscribersForTopic(subscriber.getTopic());
+ Assert.assertTrue("Subscriber not in result", subscribers.contains(result));
+ // sleep past expiration
+ Thread.sleep(1100);
+ subscribers = instance.subscribersForTopic(subscriber.getTopic());
+ Assert.assertFalse("Subscriber should have expired", subscribers.contains(result));
+ }
+
+ @Test
+ public void testUnsubscribe() throws InterruptedException {
+ final HubDAO instance = get();
+ LOG.info("{} testUnsubscribe", instance.getClass().getName());
+ final Subscriber subscriber = new Subscriber();
+ subscriber.setCallback("http://localhost:9797/noop");
+ subscriber.setTopic("http://feeds.feedburner.com/screaming-penguin");
+ subscriber.setLeaseSeconds(1);
+ subscriber.setVerify("VerifyMe");
+
+ // TODO
+ // final Subscriber result = instance.addSubscriber(subscriber);
+
+ }
+}
diff --git a/rome-certiorem/src/test/java/com/rometools/certiorem/hub/data/ram/InMemoryDAOTest.java b/rome-certiorem/src/test/java/com/rometools/certiorem/hub/data/ram/InMemoryDAOTest.java
new file mode 100644
index 0000000..26917e3
--- /dev/null
+++ b/rome-certiorem/src/test/java/com/rometools/certiorem/hub/data/ram/InMemoryDAOTest.java
@@ -0,0 +1,40 @@
+/**
+ *
+ * Copyright (C) The ROME Team 2011
+ *
+ *
+ * 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 com.rometools.certiorem.hub.data.ram;
+
+import com.rometools.certiorem.hub.data.AbstractDAOTest;
+import com.rometools.certiorem.hub.data.HubDAO;
+import com.rometools.certiorem.hub.data.ram.InMemoryHubDAO;
+
+/**
+ *
+ * @author robert.cooper
+ */
+public class InMemoryDAOTest extends AbstractDAOTest {
+ private final InMemoryHubDAO dao = new InMemoryHubDAO();
+
+ public InMemoryDAOTest() {
+ }
+
+ @Override
+ protected HubDAO get() {
+ return dao;
+ }
+
+}
\ No newline at end of file
diff --git a/rome-certiorem/src/test/resources/.gitignore b/rome-certiorem/src/test/resources/.gitignore
new file mode 100644
index 0000000..53b845b
--- /dev/null
+++ b/rome-certiorem/src/test/resources/.gitignore
@@ -0,0 +1 @@
+# needed to commit empty folder
\ No newline at end of file
diff --git a/src/test/resources/logback-test.xml b/rome-certiorem/src/test/resources/logback-test.xml
similarity index 90%
rename from src/test/resources/logback-test.xml
rename to rome-certiorem/src/test/resources/logback-test.xml
index 44dea42..c34b099 100644
--- a/src/test/resources/logback-test.xml
+++ b/rome-certiorem/src/test/resources/logback-test.xml
@@ -1,13 +1,13 @@
-
-
-
-
- %d{HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n
-
-
-
-
-
-
-
+
+
+
+
+ %d{HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/rome-fetcher/.gitignore b/rome-fetcher/.gitignore
new file mode 100644
index 0000000..83a7c0c
--- /dev/null
+++ b/rome-fetcher/.gitignore
@@ -0,0 +1,7 @@
+.classpath
+.project
+.settings
+target
+.idea
+*.iml
+atlassian-ide-plugin.xml
diff --git a/rome-fetcher/LICENSE b/rome-fetcher/LICENSE
new file mode 100644
index 0000000..f43cdb1
--- /dev/null
+++ b/rome-fetcher/LICENSE
@@ -0,0 +1,14 @@
+Copyright 2004 Sun Microsystems, Inc.
+
+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.
+
diff --git a/rome-fetcher/README.md b/rome-fetcher/README.md
new file mode 100644
index 0000000..49d2dfe
--- /dev/null
+++ b/rome-fetcher/README.md
@@ -0,0 +1,7 @@
+rome
+====
+
+ROME is a set of RSS and Atom Utilities for Java. It makes it easy to work in Java with most syndication formats: RSS 0.90, RSS 0.91 Netscape,
+RSS 0.91 Userland, RSS 0.92, RSS 0.93, RSS 0.94, RSS 1.0, RSS 2.0, Atom 0.3, Atom 1.0
+
+More Information: http://rometools.github.io/rome-fetcher/
diff --git a/rome-fetcher/pom.xml b/rome-fetcher/pom.xml
new file mode 100644
index 0000000..5d86063
--- /dev/null
+++ b/rome-fetcher/pom.xml
@@ -0,0 +1,123 @@
+
+
+
+ 4.0.0
+
+
+ com.rometools
+ rome-parent
+ 1.6.0-SNAPSHOT
+
+
+ rome-fetcher
+ 1.6.0-SNAPSHOT
+ jar
+
+ rome-fetcher
+
+ A well behaved feed fetcher API for ROME
+
+ http://rometools.github.io/rome-fetcher/
+
+
+ scm:git:ssh://github.com/rometools/rome-fetcher.git
+ scm:git:ssh://git@github.com/rometools/rome-fetcher.git
+ https://github.com/rometools/rome-fetcher
+
+
+
+
+ Nick Lothian
+ http://nicklothian.com
+
+
+ Robert Cooper
+ kebernet@gmail.comM
+
+
+
+
+
+ sonatype-nexus-snapshots
+ https://oss.sonatype.org/content/repositories/snapshots
+
+ false
+
+
+ true
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-scm-publish-plugin
+
+ gh-pages
+ ${project.scm.developerConnection}
+ ${project.build.directory}/site
+
+
+
+ org.apache.felix
+ maven-bundle-plugin
+
+
+
+ com.rometools.fetcher,
+ com.rometools.fetcher.impl
+
+
+ com.rometools.rome.feed.impl,
+ com.rometools.rome.feed.synd,
+ com.rometools.rome.io,
+ com.rometools.utils,
+ org.apache.commons.httpclient;resolution:=optional,
+ org.apache.commons.httpclient.auth;resolution:=optional,
+ org.apache.commons.httpclient.methods;resolution:=optional,
+ org.apache.commons.httpclient.params;resolution:=optional,
+ org.slf4j
+
+
+
+
+
+
+
+
+
+
+ com.rometools
+ rome
+ 1.6.0-SNAPSHOT
+
+
+ commons-httpclient
+ commons-httpclient
+
+
+
+ javax.servlet
+ servlet-api
+ test
+
+
+ jetty
+ jetty
+ test
+
+
+ ch.qos.logback
+ logback-classic
+ test
+
+
+ junit
+ junit
+ test
+
+
+
+
diff --git a/rome-fetcher/src/main/java/com/rometools/fetcher/FeedFetcher.java b/rome-fetcher/src/main/java/com/rometools/fetcher/FeedFetcher.java
new file mode 100644
index 0000000..05f0868
--- /dev/null
+++ b/rome-fetcher/src/main/java/com/rometools/fetcher/FeedFetcher.java
@@ -0,0 +1,120 @@
+/*
+ * Copyright 2004 Sun Microsystems, Inc.
+ *
+ * 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 com.rometools.fetcher;
+
+import java.io.IOException;
+import java.net.URL;
+
+import com.rometools.rome.feed.synd.SyndFeed;
+import com.rometools.rome.io.FeedException;
+
+public interface FeedFetcher {
+ /**
+ *
+ * The default user agent. It is not marked final so buggy java compiler will not write this
+ * string into all classes that reference it.
+ *
+ *
+ *
+ * http://tinyurl.com/64t5n points to https://rome.dev.java.net Some servers ban user agents
+ * with "Java" in the name.
+ *
+ *
+ */
+ public static String DEFAULT_USER_AGENT = "Rome Client (http://tinyurl.com/64t5n)";
+
+ /**
+ * @param string The User-Agent to sent to servers
+ */
+ public abstract void setUserAgent(String string);
+
+ /**
+ * @return the User-Agent currently being sent to servers
+ */
+ public abstract String getUserAgent();
+
+ /**
+ *
+ * Turn on or off rfc3229 delta encoding
+ *
+ *
+ *
+ * See http://www.ietf.org/rfc/rfc3229.txt and
+ * http://bobwyman.pubsub.com/main/2004/09/using_rfc3229_w.html
+ *
+ *
+ *
+ * NOTE: This is experimental and feedback is welcome!
+ *
+ * The FetcherListener will receive an FetcherEvent when a Fetcher event (feed polled,
+ * retrieved, etc) occurs
+ *
+ *
+ * @param listener The FetcherListener to recieve the event
+ */
+ public abstract void addFetcherEventListener(FetcherListener listener);
+
+ /**
+ *
+ * Remove a FetcherListener
+ *
+ *
+ * @param listener The FetcherListener to remove
+ */
+ public abstract void removeFetcherEventListener(FetcherListener listener);
+
+ /**
+ * Retrieve a feed over HTTP
+ *
+ * @param feedUrl A non-null URL of a RSS/Atom feed to retrieve
+ * @return A {@link com.rometools.rome.feed.synd.SyndFeed} object
+ * @throws IllegalArgumentException if the URL is null;
+ * @throws IOException if a TCP error occurs
+ * @throws FeedException if the feed is not valid
+ * @throws FetcherException if a HTTP error occurred
+ */
+ public abstract SyndFeed retrieveFeed(URL feedUrl) throws IllegalArgumentException, IOException, FeedException, FetcherException;
+
+ public SyndFeed retrieveFeed(String userAgent, URL url) throws IllegalArgumentException, IOException, FeedException, FetcherException;
+
+ /**
+ * If set to true, the WireFeed will be made accessible from the SyndFeed object returned from
+ * the Fetcher via the originalWireFeed() method. Each Entry in the feed will have the
+ * corresponding wireEntry property set.
+ */
+ void setPreserveWireFeed(boolean preserveWireFeed);
+}
diff --git a/rome-fetcher/src/main/java/com/rometools/fetcher/FetcherEvent.java b/rome-fetcher/src/main/java/com/rometools/fetcher/FetcherEvent.java
new file mode 100644
index 0000000..6ed4a0c
--- /dev/null
+++ b/rome-fetcher/src/main/java/com/rometools/fetcher/FetcherEvent.java
@@ -0,0 +1,90 @@
+package com.rometools.fetcher;
+
+import java.util.EventObject;
+
+import com.rometools.rome.feed.synd.SyndFeed;
+
+/**
+ * Implementation note: FetcherEvent is not thread safe. Make sure that they are only ever accessed
+ * by one thread. If necessary, make all getters and setters synchronized, or alternatively make all
+ * fields final.
+ *
+ * @author nl
+ */
+public class FetcherEvent extends EventObject {
+
+ private static final long serialVersionUID = 1L;
+
+ public static final String EVENT_TYPE_FEED_POLLED = "FEED_POLLED";
+ public static final String EVENT_TYPE_FEED_RETRIEVED = "FEED_RETRIEVED";
+ public static final String EVENT_TYPE_FEED_UNCHANGED = "FEED_UNCHANGED";
+
+ private String eventType;
+ private String urlString;
+ private SyndFeed feed;
+
+ public FetcherEvent(final Object source) {
+ super(source);
+ }
+
+ public FetcherEvent(final Object source, final String urlStr, final String eventType) {
+ this(source);
+ setUrlString(urlStr);
+ setEventType(eventType);
+ }
+
+ public FetcherEvent(final Object source, final String urlStr, final String eventType, final SyndFeed feed) {
+ this(source, urlStr, eventType);
+ setFeed(feed);
+ }
+
+ /**
+ * @return Returns the feed.
+ *
+ *
+ * The feed will only be set if the eventType is EVENT_TYPE_FEED_RETRIEVED
+ *
+ */
+ public SyndFeed getFeed() {
+ return feed;
+ }
+
+ /**
+ * @param feed The feed to set.
+ *
+ *
+ * The feed will only be set if the eventType is EVENT_TYPE_FEED_RETRIEVED
+ *
+ */
+ public void setFeed(final SyndFeed feed) {
+ this.feed = feed;
+ }
+
+ /**
+ * @return Returns the eventType.
+ */
+ public String getEventType() {
+ return eventType;
+ }
+
+ /**
+ * @param eventType The eventType to set.
+ */
+ public void setEventType(final String eventType) {
+ this.eventType = eventType;
+ }
+
+ /**
+ * @return Returns the urlString.
+ */
+ public String getUrlString() {
+ return urlString;
+ }
+
+ /**
+ * @param urlString The urlString to set.
+ */
+ public void setUrlString(final String urlString) {
+ this.urlString = urlString;
+ }
+}
diff --git a/rome-fetcher/src/main/java/com/rometools/fetcher/FetcherException.java b/rome-fetcher/src/main/java/com/rometools/fetcher/FetcherException.java
new file mode 100644
index 0000000..447ab2f
--- /dev/null
+++ b/rome-fetcher/src/main/java/com/rometools/fetcher/FetcherException.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2004 Sun Microsystems, Inc.
+ *
+ * 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 com.rometools.fetcher;
+
+/**
+ * @author Nick Lothian
+ *
+ */
+public class FetcherException extends Exception {
+ private static final long serialVersionUID = 1L;
+
+ int responseCode;
+
+ public FetcherException(final Throwable cause) {
+ super();
+ initCause(cause);
+ }
+
+ public FetcherException(final String message, final Throwable cause) {
+ super(message);
+ initCause(cause);
+ }
+
+ public FetcherException(final String message) {
+ super(message);
+ }
+
+ public FetcherException(final int responseCode, final String message) {
+ this(message);
+ this.responseCode = responseCode;
+ }
+
+ public int getResponseCode() {
+ return responseCode;
+ }
+
+}
diff --git a/rome-fetcher/src/main/java/com/rometools/fetcher/FetcherListener.java b/rome-fetcher/src/main/java/com/rometools/fetcher/FetcherListener.java
new file mode 100644
index 0000000..617532c
--- /dev/null
+++ b/rome-fetcher/src/main/java/com/rometools/fetcher/FetcherListener.java
@@ -0,0 +1,16 @@
+package com.rometools.fetcher;
+
+import java.util.EventListener;
+
+public interface FetcherListener extends EventListener {
+
+ /**
+ *
+ * Called when a fetcher event occurs
+ *
+ *
+ * @param event the event that fired
+ */
+ public void fetcherEvent(FetcherEvent event);
+
+}
diff --git a/rome-fetcher/src/main/java/com/rometools/fetcher/impl/AbstractFeedFetcher.java b/rome-fetcher/src/main/java/com/rometools/fetcher/impl/AbstractFeedFetcher.java
new file mode 100644
index 0000000..15f07ac
--- /dev/null
+++ b/rome-fetcher/src/main/java/com/rometools/fetcher/impl/AbstractFeedFetcher.java
@@ -0,0 +1,225 @@
+/*
+ * Copyright 2004 Sun Microsystems, Inc.
+ *
+ * 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 com.rometools.fetcher.impl;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URLConnection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Properties;
+import java.util.Set;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.rometools.fetcher.FeedFetcher;
+import com.rometools.fetcher.FetcherEvent;
+import com.rometools.fetcher.FetcherException;
+import com.rometools.fetcher.FetcherListener;
+import com.rometools.rome.feed.synd.SyndFeed;
+
+public abstract class AbstractFeedFetcher implements FeedFetcher {
+
+ private static final Logger LOG = LoggerFactory.getLogger(AbstractFeedFetcher.class);
+
+ private final Set listeners;
+ private String userAgent;
+ private boolean usingDeltaEncoding;
+ private boolean preserveWireFeed;
+
+ public AbstractFeedFetcher() {
+
+ listeners = Collections.synchronizedSet(new HashSet());
+
+ final Properties props = new Properties(System.getProperties());
+ final String resourceName = "fetcher.properties";
+
+ try {
+
+ InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream(resourceName);
+ if (inputStream == null) {
+ inputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream(resourceName);
+ }
+
+ if (inputStream != null) {
+ props.load(inputStream);
+ System.getProperties().putAll(props);
+ inputStream.close();
+ } else {
+ LOG.warn("Could not find {} on classpath", resourceName);
+ }
+
+ } catch (final IOException e) {
+ // do nothing - we don't want to fail just because we could not find the version
+ LOG.error("Error reading {} from classpath: {}", resourceName, e.getMessage());
+ }
+
+ setUserAgent(DEFAULT_USER_AGENT + " Ver: " + System.getProperty("rome.fetcher.version", "UNKNOWN"));
+ }
+
+ /**
+ * @return the User-Agent currently being sent to servers
+ */
+ @Override
+ public synchronized String getUserAgent() {
+ return userAgent;
+ }
+
+ /**
+ * @param string The User-Agent to sent to servers
+ */
+ @Override
+ public synchronized void setUserAgent(final String string) {
+ userAgent = string;
+ }
+
+ /**
+ * @param eventType The event type to fire
+ * @param connection the current connection
+ */
+ protected void fireEvent(final String eventType, final URLConnection connection) {
+ fireEvent(eventType, connection.getURL().toExternalForm(), null);
+ }
+
+ /**
+ * @param eventType The event type to fire
+ * @param connection the current connection
+ * @param feed The feed to pass to the event
+ */
+ protected void fireEvent(final String eventType, final URLConnection connection, final SyndFeed feed) {
+ fireEvent(eventType, connection.getURL().toExternalForm(), feed);
+ }
+
+ /**
+ * @param eventType The event type to fire
+ * @param urlStr the current url as a string
+ */
+ protected void fireEvent(final String eventType, final String urlStr) {
+ fireEvent(eventType, urlStr, null);
+ }
+
+ /**
+ * @param eventType The event type to fire
+ * @param urlStr the current url as a string
+ * @param feed The feed to pass to the event
+ */
+ protected void fireEvent(final String eventType, final String urlStr, final SyndFeed feed) {
+ final FetcherEvent fetcherEvent = new FetcherEvent(this, urlStr, eventType, feed);
+ synchronized (listeners) {
+ for (final FetcherListener fetcherEventListener : listeners) {
+ fetcherEventListener.fetcherEvent(fetcherEvent);
+ }
+ }
+ }
+
+ @Override
+ public void addFetcherEventListener(final FetcherListener listener) {
+ if (listener != null) {
+ listeners.add(listener);
+ }
+ }
+
+ @Override
+ public void removeFetcherEventListener(final FetcherListener listener) {
+ if (listener != null) {
+ listeners.remove(listener);
+ }
+ }
+
+ /**
+ * @return Returns the useDeltaEncoding.
+ */
+ @Override
+ public synchronized boolean isUsingDeltaEncoding() {
+ return usingDeltaEncoding;
+ }
+
+ /**
+ * @param useDeltaEncoding The useDeltaEncoding to set.
+ */
+ @Override
+ public synchronized void setUsingDeltaEncoding(final boolean useDeltaEncoding) {
+ usingDeltaEncoding = useDeltaEncoding;
+ }
+
+ /**
+ *
+ * Handles HTTP error codes.
+ *
+ *
+ * @param responseCode the HTTP response code
+ * @throws FetcherException if response code is in the range 400 to 599 inclusive
+ */
+ protected void handleErrorCodes(final int responseCode) throws FetcherException {
+ // Handle 2xx codes as OK, so ignore them here
+ // 3xx codes are handled by the HttpURLConnection class
+ if (responseCode == 403) {
+ // Authentication is required
+ throwAuthenticationError(responseCode);
+ } else if (responseCode >= 400 && responseCode < 500) {
+ throw4XXError(responseCode);
+ } else if (responseCode >= 500 && responseCode < 600) {
+ throw new FetcherException(responseCode, "The server encounted an error. HTTP Response code was:" + responseCode);
+ }
+ }
+
+ protected void throw4XXError(final int responseCode) throws FetcherException {
+ throw new FetcherException(responseCode, "The requested resource could not be found. HTTP Response code was:" + responseCode);
+ }
+
+ protected void throwAuthenticationError(final int responseCode) throws FetcherException {
+ throw new FetcherException(responseCode, "Authentication required for that resource. HTTP Response code was:" + responseCode);
+ }
+
+ /**
+ *
+ * Combine the entries in two feeds into a single feed.
+ *
+ *
+ *
+ * The returned feed will have the same data as the newFeed parameter, with the entries from
+ * originalFeed appended to the end of its entries.
+ *
+ *
+ * @param originalFeed
+ * @param newFeed
+ * @return
+ */
+ public static SyndFeed combineFeeds(final SyndFeed originalFeed, final SyndFeed newFeed) {
+ try {
+ final SyndFeed result = (SyndFeed) newFeed.clone();
+ result.getEntries().addAll(result.getEntries().size(), originalFeed.getEntries());
+ return result;
+ } catch (final CloneNotSupportedException e) {
+ final IllegalArgumentException iae = new IllegalArgumentException("Cannot clone feed");
+ iae.initCause(e);
+ throw iae;
+ }
+ }
+
+ public boolean isPreserveWireFeed() {
+ return preserveWireFeed;
+ }
+
+ @Override
+ public void setPreserveWireFeed(final boolean preserveWireFeed) {
+ this.preserveWireFeed = preserveWireFeed;
+ }
+
+}
diff --git a/rome-fetcher/src/main/java/com/rometools/fetcher/impl/AbstractFeedFetcherBeanInfo.java b/rome-fetcher/src/main/java/com/rometools/fetcher/impl/AbstractFeedFetcherBeanInfo.java
new file mode 100644
index 0000000..5bac21e
--- /dev/null
+++ b/rome-fetcher/src/main/java/com/rometools/fetcher/impl/AbstractFeedFetcherBeanInfo.java
@@ -0,0 +1,33 @@
+package com.rometools.fetcher.impl;
+
+import java.beans.EventSetDescriptor;
+import java.beans.SimpleBeanInfo;
+import java.lang.reflect.Method;
+
+import com.rometools.fetcher.FetcherEvent;
+import com.rometools.fetcher.FetcherListener;
+
+public class AbstractFeedFetcherBeanInfo extends SimpleBeanInfo {
+
+ @Override
+ public EventSetDescriptor[] getEventSetDescriptors() {
+
+ try {
+
+ // get the class object which we'll describe
+ final Class clz = AbstractFeedFetcher.class;
+ final Method addMethod = clz.getMethod("addFetcherEventListener", new Class[] { FetcherListener.class });
+ final Method removeMethod = clz.getMethod("removeFetcherEventListener", new Class[] { FetcherListener.class });
+ final Method listenerMethod = FetcherListener.class.getMethod("fetcherEvent", new Class[] { FetcherEvent.class });
+ final EventSetDescriptor est = new EventSetDescriptor("fetcherEvent", clz, new Method[] { listenerMethod }, addMethod, removeMethod);
+ return new EventSetDescriptor[] { est };
+
+ } catch (final Exception e) {
+ // IntrospectionException, SecurityException and/or NoSuchMethodException can be thrown
+ // here. The best we can do is to convert them to runtime exceptions
+ throw new RuntimeException(e);
+ }
+
+ }
+
+}
diff --git a/rome-fetcher/src/main/java/com/rometools/fetcher/impl/DiskFeedInfoCache.java b/rome-fetcher/src/main/java/com/rometools/fetcher/impl/DiskFeedInfoCache.java
new file mode 100644
index 0000000..92bc9b1
--- /dev/null
+++ b/rome-fetcher/src/main/java/com/rometools/fetcher/impl/DiskFeedInfoCache.java
@@ -0,0 +1,158 @@
+/*
+ * Copyright 2005 Sun Microsystems, Inc.
+ *
+ * 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 com.rometools.fetcher.impl;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.net.URL;
+
+import com.rometools.utils.IO;
+
+/**
+ * Disk based feed cache.
+ */
+public class DiskFeedInfoCache implements FeedFetcherCache {
+
+ protected String cachePath = null;
+
+ public DiskFeedInfoCache(final String cachePath) {
+ this.cachePath = cachePath;
+ }
+
+ @Override
+ public SyndFeedInfo getFeedInfo(final URL url) {
+ final String fileName = generateFilename(url);
+ return getFeedInfo(fileName);
+ }
+
+ @Override
+ public void setFeedInfo(final URL url, final SyndFeedInfo feedInfo) {
+
+ final String fileName = generateFilename(url);
+
+ FileOutputStream fos = null;
+ ObjectOutputStream oos = null;
+
+ try {
+
+ fos = new FileOutputStream(fileName);
+ oos = new ObjectOutputStream(fos);
+ oos.writeObject(feedInfo);
+ fos.flush();
+
+ } catch (final FileNotFoundException e) {
+
+ throw new RuntimeException("Error while writing to cache", e);
+
+ } catch (final IOException e) {
+
+ throw new RuntimeException("Error while writing to cache", e);
+
+ } finally {
+
+ IO.closeQuietly(fos);
+ IO.closeQuietly(oos);
+
+ }
+
+ }
+
+ @Override
+ public synchronized void clear() {
+ final File file = new File(cachePath);
+ // only do the delete if the directory exists
+ if (file.exists() && file.canWrite()) {
+ // make the directory empty
+ final String[] files = file.list();
+ final int len = files.length;
+ for (int i = 0; i < len; i++) {
+ final File deleteMe = new File(cachePath + File.separator + files[i]);
+ deleteMe.delete();
+ }
+ // don't delete the cache directory
+ }
+ }
+
+ @Override
+ public SyndFeedInfo remove(final URL url) {
+ final String fileName = generateFilename(url);
+ final SyndFeedInfo info = getFeedInfo(fileName);
+ if (info != null) {
+ final File file = new File(fileName);
+ if (file.exists()) {
+ file.delete();
+ }
+ }
+ return info;
+ }
+
+ private SyndFeedInfo getFeedInfo(final String fileName) {
+
+ SyndFeedInfo info = null;
+ FileInputStream fis = null;
+ ObjectInputStream ois = null;
+
+ try {
+
+ fis = new FileInputStream(fileName);
+ ois = new ObjectInputStream(fis);
+ info = (SyndFeedInfo) ois.readObject();
+
+ } catch (final FileNotFoundException e) {
+
+ // feed is not cached yet
+
+ } catch (final ClassNotFoundException e) {
+
+ throw new RuntimeException("Unable to read from cache", e);
+
+ } catch (final IOException e) {
+
+ throw new RuntimeException("Unable to read from cache", e);
+
+ } finally {
+
+ IO.closeQuietly(fis);
+ IO.closeQuietly(ois);
+
+ }
+
+ return info;
+
+ }
+
+ private static String replaceNonAlphanumeric(final String string, final char character) {
+ final StringBuffer buffer = new StringBuffer(string.length());
+ for (final char singleChar : string.toCharArray()) {
+ if (Character.isLetterOrDigit(singleChar)) {
+ buffer.append(singleChar);
+ } else {
+ buffer.append(character);
+ }
+ }
+ return buffer.toString();
+ }
+
+ private String generateFilename(final URL url) {
+ return cachePath + File.separator + "feed_" + replaceNonAlphanumeric(url.toString(), '_').trim();
+ }
+
+}
diff --git a/rome-fetcher/src/main/java/com/rometools/fetcher/impl/FeedFetcherCache.java b/rome-fetcher/src/main/java/com/rometools/fetcher/impl/FeedFetcherCache.java
new file mode 100644
index 0000000..4c0ff0a
--- /dev/null
+++ b/rome-fetcher/src/main/java/com/rometools/fetcher/impl/FeedFetcherCache.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright 2004 Sun Microsystems, Inc.
+ *
+ * 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 com.rometools.fetcher.impl;
+
+import java.net.URL;
+
+/**
+ *
+ * An interface to allow caching of feed details. Implementing this allows the
+ * {@link com.rometools.fetcher.io.HttpURLFeedFetcher} class to enable conditional gets
+ *
+ *
+ * @author Nick Lothian
+ *
+ */
+public interface FeedFetcherCache {
+
+ /**
+ * Get a SyndFeedInfo object from the cache.
+ *
+ * @param feedUrl The url of the feed
+ * @return A SyndFeedInfo or null if it is not in the cache
+ */
+ public SyndFeedInfo getFeedInfo(URL feedUrl);
+
+ /**
+ * Add a SyndFeedInfo object to the cache
+ *
+ * @param feedUrl The url of the feed
+ * @param syndFeedInfo A SyndFeedInfo for the feed
+ */
+ public void setFeedInfo(URL feedUrl, SyndFeedInfo syndFeedInfo);
+
+ /**
+ * Removes all items from the cache.
+ */
+ public void clear();
+
+ /**
+ * Removes the SyndFeedInfo identified by the url from the cache.
+ *
+ * @return The removed SyndFeedInfo
+ */
+ public SyndFeedInfo remove(URL feedUrl);
+
+}
diff --git a/rome-fetcher/src/main/java/com/rometools/fetcher/impl/HashMapFeedInfoCache.java b/rome-fetcher/src/main/java/com/rometools/fetcher/impl/HashMapFeedInfoCache.java
new file mode 100644
index 0000000..7508ce7
--- /dev/null
+++ b/rome-fetcher/src/main/java/com/rometools/fetcher/impl/HashMapFeedInfoCache.java
@@ -0,0 +1,139 @@
+/*
+ * Copyright 2004 Sun Microsystems, Inc.
+ *
+ * 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 com.rometools.fetcher.impl;
+
+import java.io.Serializable;
+import java.net.URL;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ *
+ * A very simple implementation of the {@link com.rometools.fetcher.impl.FeedFetcherCache}
+ * interface.
+ *
+ *
+ *
+ * This implementation uses a HashMap to cache retrieved feeds. This implementation is most suitible
+ * for sort term (client aggregator?) use, as the memory usage will increase over time as the number
+ * of feeds in the cache increases.
+ *
+ * Only use this if you want multiple instances of the cache. Usually getInstance() is more
+ * appropriate.
+ *
+ *
+ */
+ public HashMapFeedInfoCache() {
+ setInfoCache(createInfoCache());
+ }
+
+ /**
+ * Get the global instance of the cache
+ *
+ * @return an implementation of FeedFetcherCache
+ */
+ public static synchronized FeedFetcherCache getInstance() {
+ if (instance == null) {
+ instance = new HashMapFeedInfoCache();
+ }
+ return instance;
+ }
+
+ protected Map createInfoCache() {
+ return Collections.synchronizedMap(new HashMap());
+ }
+
+ protected Object get(final Object key) {
+ return getInfoCache().get(key);
+ }
+
+ /**
+ * @see extensions.io.FeedFetcherCache#getFeedInfo(java.net.URL)
+ */
+ @Override
+ public SyndFeedInfo getFeedInfo(final URL feedUrl) {
+ return (SyndFeedInfo) get(feedUrl.toString());
+ }
+
+ protected void put(final String key, final SyndFeedInfo value) {
+ getInfoCache().put(key, value);
+ }
+
+ /**
+ * @see extensions.io.FeedFetcherCache#setFeedInfo(java.net.URL, extensions.io.SyndFeedInfo)
+ */
+ @Override
+ public void setFeedInfo(final URL feedUrl, final SyndFeedInfo syndFeedInfo) {
+ put(feedUrl.toString(), syndFeedInfo);
+ }
+
+ protected synchronized final Map getInfoCache() {
+ return infoCache;
+ }
+
+ /**
+ * The API of this class indicates that map must thread safe. In other words, be sure to wrap it
+ * in a synchronized map unless you know what you are doing.
+ *
+ * @param map the map to use as the info cache.
+ */
+ protected synchronized final void setInfoCache(final Map map) {
+ infoCache = map;
+ }
+
+ /**
+ * @see com.rometools.rome.fetcher.impl.FeedFetcherCache#clear()
+ */
+ @Override
+ public void clear() {
+ synchronized (infoCache) {
+ infoCache.clear();
+ }
+ }
+
+ /**
+ * @see com.rometools.rome.fetcher.impl.FeedFetcherCache#remove(java.net.URL)
+ */
+ @Override
+ public SyndFeedInfo remove(final URL url) {
+ if (url == null) {
+ return null;
+ }
+
+ return infoCache.remove(url.toString());
+ }
+
+}
diff --git a/rome-fetcher/src/main/java/com/rometools/fetcher/impl/HttpClientFeedFetcher.java b/rome-fetcher/src/main/java/com/rometools/fetcher/impl/HttpClientFeedFetcher.java
new file mode 100644
index 0000000..c15833f
--- /dev/null
+++ b/rome-fetcher/src/main/java/com/rometools/fetcher/impl/HttpClientFeedFetcher.java
@@ -0,0 +1,386 @@
+/*
+ * Copyright 2004 Sun Microsystems, Inc.
+ *
+ * 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 com.rometools.fetcher.impl;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.HttpURLConnection;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Map;
+import java.util.zip.GZIPInputStream;
+
+import org.apache.commons.httpclient.Credentials;
+import org.apache.commons.httpclient.Header;
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpException;
+import org.apache.commons.httpclient.HttpMethod;
+import org.apache.commons.httpclient.HttpMethodRetryHandler;
+import org.apache.commons.httpclient.HttpState;
+import org.apache.commons.httpclient.auth.AuthScope;
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.apache.commons.httpclient.params.HttpClientParams;
+import org.apache.commons.httpclient.params.HttpMethodParams;
+
+import com.rometools.fetcher.FetcherEvent;
+import com.rometools.fetcher.FetcherException;
+import com.rometools.rome.feed.synd.SyndFeed;
+import com.rometools.rome.io.FeedException;
+import com.rometools.rome.io.SyndFeedInput;
+import com.rometools.rome.io.XmlReader;
+import com.rometools.utils.IO;
+
+/**
+ * @author Nick Lothian
+ */
+public class HttpClientFeedFetcher extends AbstractFeedFetcher {
+
+ private CredentialSupplier credentialSupplier;
+ private FeedFetcherCache feedInfoCache;
+ private volatile HttpClientMethodCallbackIntf httpClientMethodCallback;
+ private volatile HttpClientParams httpClientParams;
+ private Map customRequestHeaders;
+
+ public HttpClientFeedFetcher() {
+ this(null, null);
+ }
+
+ public HttpClientFeedFetcher(final FeedFetcherCache cache) {
+ this(cache, null);
+ }
+
+ public HttpClientFeedFetcher(final FeedFetcherCache cache, final CredentialSupplier credentialSupplier) {
+ setHttpClientParams(new HttpClientParams());
+ setFeedInfoCache(cache);
+ setCredentialSupplier(credentialSupplier);
+ }
+
+ @Override
+ public SyndFeed retrieveFeed(final URL url) throws IllegalArgumentException, IOException, FeedException, FetcherException {
+ return this.retrieveFeed(getUserAgent(), url);
+ }
+
+ @Override
+ public SyndFeed retrieveFeed(final String userAgent, final URL feedUrl) throws IllegalArgumentException, IOException, FeedException, FetcherException {
+
+ if (feedUrl == null) {
+ throw new IllegalArgumentException("null is not a valid URL");
+ }
+
+ final HttpClient client = new HttpClient(httpClientParams);
+
+ if (credentialSupplier != null) {
+
+ final HttpClientParams params = client.getParams();
+ params.setAuthenticationPreemptive(true);
+
+ final String host = feedUrl.getHost();
+ final Credentials credentials = credentialSupplier.getCredentials(null, host);
+ if (credentials != null) {
+ final AuthScope authScope = new AuthScope(host, -1);
+ final HttpState state = client.getState();
+ state.setCredentials(authScope, credentials);
+ }
+
+ }
+
+ System.setProperty("httpclient.useragent", userAgent);
+
+ final String urlStr = feedUrl.toString();
+ final HttpMethod method = new GetMethod(urlStr);
+
+ if (customRequestHeaders == null) {
+ method.addRequestHeader("Accept-Encoding", "gzip");
+ method.addRequestHeader("User-Agent", userAgent);
+
+ } else {
+ for (final Map.Entry entry : customRequestHeaders.entrySet()) {
+ method.addRequestHeader(entry.getKey(), entry.getValue());
+ }
+ if (!customRequestHeaders.containsKey("Accept-Encoding")) {
+ method.addRequestHeader("Accept-Encoding", "gzip");
+ }
+ if (!customRequestHeaders.containsKey("User-Agent")) {
+ method.addRequestHeader("User-Agent", userAgent);
+ }
+ }
+
+ method.setFollowRedirects(true);
+
+ if (httpClientMethodCallback != null) {
+ synchronized (httpClientMethodCallback) {
+ httpClientMethodCallback.afterHttpClientMethodCreate(method);
+ }
+ }
+
+ final FeedFetcherCache cache = getFeedInfoCache();
+
+ if (cache != null) {
+ // retrieve feed
+ try {
+
+ if (isUsingDeltaEncoding()) {
+ method.setRequestHeader("A-IM", "feed");
+ }
+
+ // try to get the feed info from the cache
+ SyndFeedInfo syndFeedInfo = cache.getFeedInfo(feedUrl);
+
+ if (syndFeedInfo != null) {
+
+ method.setRequestHeader("If-None-Match", syndFeedInfo.getETag());
+
+ final Object lastModifiedHeader = syndFeedInfo.getLastModified();
+ if (lastModifiedHeader instanceof String) {
+ method.setRequestHeader("If-Modified-Since", (String) lastModifiedHeader);
+ }
+
+ }
+
+ final int statusCode = client.executeMethod(method);
+ fireEvent(FetcherEvent.EVENT_TYPE_FEED_POLLED, urlStr);
+ handleErrorCodes(statusCode);
+
+ SyndFeed feed = getFeed(syndFeedInfo, urlStr, method, statusCode);
+
+ syndFeedInfo = buildSyndFeedInfo(feedUrl, urlStr, method, feed, statusCode);
+
+ cache.setFeedInfo(feedUrl, syndFeedInfo);
+
+ // the feed may have been modified to pick up cached values
+ // (eg - for delta encoding)
+ feed = syndFeedInfo.getSyndFeed();
+
+ return feed;
+
+ } finally {
+
+ method.releaseConnection();
+
+ }
+
+ } else {
+
+ // cache is not in use
+ try {
+
+ final int statusCode = client.executeMethod(method);
+ fireEvent(FetcherEvent.EVENT_TYPE_FEED_POLLED, urlStr);
+ handleErrorCodes(statusCode);
+
+ return getFeed(null, urlStr, method, statusCode);
+
+ } finally {
+
+ method.releaseConnection();
+
+ }
+
+ }
+
+ }
+
+ private SyndFeed getFeed(final SyndFeedInfo syndFeedInfo, final String urlStr, final HttpMethod method, final int statusCode) throws IOException,
+ HttpException, FetcherException, FeedException {
+
+ if (statusCode == HttpURLConnection.HTTP_NOT_MODIFIED && syndFeedInfo != null) {
+ fireEvent(FetcherEvent.EVENT_TYPE_FEED_UNCHANGED, urlStr);
+ return syndFeedInfo.getSyndFeed();
+ }
+
+ final SyndFeed feed = retrieveFeed(urlStr, method);
+ fireEvent(FetcherEvent.EVENT_TYPE_FEED_RETRIEVED, urlStr, feed);
+ return feed;
+ }
+
+ private SyndFeedInfo buildSyndFeedInfo(final URL feedUrl, final String urlStr, final HttpMethod method, SyndFeed feed, final int statusCode)
+ throws MalformedURLException {
+
+ SyndFeedInfo syndFeedInfo;
+ syndFeedInfo = new SyndFeedInfo();
+
+ // this may be different to feedURL because of 3XX redirects
+ syndFeedInfo.setUrl(new URL(urlStr));
+ syndFeedInfo.setId(feedUrl.toString());
+
+ final Header imHeader = method.getResponseHeader("IM");
+ if (imHeader != null && imHeader.getValue().contains("feed") && isUsingDeltaEncoding()) {
+
+ final FeedFetcherCache cache = getFeedInfoCache();
+
+ if (cache != null && statusCode == 226) {
+ // client is setup to use http delta encoding and the server supports it and has
+ // returned a delta encoded response. This response only includes new items
+ final SyndFeedInfo cachedInfo = cache.getFeedInfo(feedUrl);
+
+ if (cachedInfo != null) {
+ final SyndFeed cachedFeed = cachedInfo.getSyndFeed();
+
+ // set the new feed to be the orginal feed plus the new items
+ feed = combineFeeds(cachedFeed, feed);
+ }
+ }
+ }
+
+ final Header lastModifiedHeader = method.getResponseHeader("Last-Modified");
+ if (lastModifiedHeader != null) {
+ syndFeedInfo.setLastModified(lastModifiedHeader.getValue());
+ }
+
+ final Header eTagHeader = method.getResponseHeader("ETag");
+ if (eTagHeader != null) {
+ syndFeedInfo.setETag(eTagHeader.getValue());
+ }
+
+ syndFeedInfo.setSyndFeed(feed);
+
+ return syndFeedInfo;
+ }
+
+ private SyndFeed retrieveFeed(final String urlStr, final HttpMethod method) throws IOException, HttpException, FetcherException, FeedException {
+
+ final Header contentEncodingHeader = method.getResponseHeader("Content-Encoding");
+
+ final InputStream stream;
+ if (contentEncodingHeader != null && "gzip".equalsIgnoreCase(contentEncodingHeader.getValue())) {
+ stream = new GZIPInputStream(method.getResponseBodyAsStream());
+ } else {
+ stream = method.getResponseBodyAsStream();
+ }
+
+ try {
+
+ final Header contentTypeHeader = method.getResponseHeader("Content-Type");
+
+ final XmlReader reader;
+ if (contentTypeHeader != null) {
+ reader = new XmlReader(stream, contentTypeHeader.getValue(), true);
+ } else {
+ reader = new XmlReader(stream, true);
+ }
+
+ final SyndFeedInput syndFeedInput = new SyndFeedInput();
+ syndFeedInput.setPreserveWireFeed(isPreserveWireFeed());
+
+ return syndFeedInput.build(reader);
+
+ } finally {
+
+ IO.close(stream);
+
+ }
+
+ }
+
+ public synchronized void setRetryHandler(final HttpMethodRetryHandler handler) {
+ httpClientParams.setParameter(HttpMethodParams.RETRY_HANDLER, handler);
+ }
+
+ /**
+ * @param timeout Sets the connect timeout for the HttpClient but using the URLConnection method
+ * name. Uses the HttpClientParams method setConnectionManagerTimeout instead of
+ * setConnectTimeout
+ *
+ */
+ public synchronized void setConnectTimeout(final int timeout) {
+ httpClientParams.setConnectionManagerTimeout(timeout);
+ }
+
+ /**
+ * @return The currently used connect timeout for the HttpClient but using the URLConnection
+ * method name. Uses the HttpClientParams method getConnectionManagerTimeout instead of
+ * getConnectTimeout
+ *
+ */
+ public int getConnectTimeout() {
+ return (int) getHttpClientParams().getConnectionManagerTimeout();
+ }
+
+ public synchronized void setCredentialSupplier(final CredentialSupplier credentialSupplier) {
+ this.credentialSupplier = credentialSupplier;
+ }
+
+ public synchronized CredentialSupplier getCredentialSupplier() {
+ return credentialSupplier;
+ }
+
+ public synchronized void setFeedInfoCache(final FeedFetcherCache feedInfoCache) {
+ this.feedInfoCache = feedInfoCache;
+ }
+
+ public synchronized FeedFetcherCache getFeedInfoCache() {
+ return feedInfoCache;
+ }
+
+ public synchronized void setHttpClientMethodCallback(final HttpClientMethodCallbackIntf httpClientMethodCallback) {
+ this.httpClientMethodCallback = httpClientMethodCallback;
+ }
+
+ public HttpClientMethodCallbackIntf getHttpClientMethodCallback() {
+ return httpClientMethodCallback;
+ }
+
+ public synchronized void setHttpClientParams(final HttpClientParams httpClientParams) {
+ this.httpClientParams = httpClientParams;
+ }
+
+ public synchronized HttpClientParams getHttpClientParams() {
+ return httpClientParams;
+ }
+
+ /**
+ * @return The currently used read timeout for the URLConnection, 0 is unlimited, i.e. no
+ * timeout
+ */
+ public synchronized void setReadTimeout(final int timeout) {
+ httpClientParams.setSoTimeout(timeout);
+ }
+
+ /**
+ * @return timeout the read timeout for the URLConnection to a specified timeout, in
+ * milliseconds.
+ */
+ public int getReadTimeout() {
+ return getHttpClientParams().getSoTimeout();
+ }
+
+ /**
+ * Apply any request headers to the HTTP method call.
+ *
+ * @param customRequestHeaders
+ */
+ public synchronized void setCustomRequestHeaders(final Map customRequestHeaders) {
+ this.customRequestHeaders = customRequestHeaders;
+ }
+
+ public interface CredentialSupplier {
+ public Credentials getCredentials(String realm, String host);
+ }
+
+ public interface HttpClientMethodCallbackIntf {
+
+ /**
+ * Allows access to the underlying HttpClient HttpMethod object. Note that in most cases,
+ * method.setRequestHeader(String, String) is what you want to do (rather than
+ * method.addRequestHeader(String, String))
+ *
+ * @param method
+ */
+ public void afterHttpClientMethodCreate(HttpMethod method);
+ }
+
+}
diff --git a/rome-fetcher/src/main/java/com/rometools/fetcher/impl/HttpURLFeedFetcher.java b/rome-fetcher/src/main/java/com/rometools/fetcher/impl/HttpURLFeedFetcher.java
new file mode 100644
index 0000000..70a8863
--- /dev/null
+++ b/rome-fetcher/src/main/java/com/rometools/fetcher/impl/HttpURLFeedFetcher.java
@@ -0,0 +1,329 @@
+/*
+ * Copyright 2004 Sun Microsystems, Inc.
+ *
+ * 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 com.rometools.fetcher.impl;
+
+import java.io.BufferedInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.zip.GZIPInputStream;
+
+import com.rometools.fetcher.FetcherEvent;
+import com.rometools.fetcher.FetcherException;
+import com.rometools.rome.feed.synd.SyndFeed;
+import com.rometools.rome.io.FeedException;
+import com.rometools.rome.io.SyndFeedInput;
+import com.rometools.rome.io.XmlReader;
+import com.rometools.utils.IO;
+
+/**
+ *
+ * Class to retrieve syndication files via HTTP.
+ *
+ *
+ *
+ * If passed a {@link com.rometools.fetcher.impl.FeedFetcherCache} in the constructor it will use
+ * conditional gets to only retrieve modified content.
+ *
+ *
+ *
+ * The class uses the Accept-Encoding: gzip header to retrieve gzipped feeds where supported by the
+ * server.
+ *
+ *
+ *
+ * Simple usage:
+ *
+ *
+ * // create the cache
+ * FeedFetcherCache feedInfoCache = HashMapFeedInfoCache.getFeedInfoCache();
+ * // retrieve the feed the first time
+ * // any subsequent request will use conditional gets and only
+ * // retrieve the resource if it has changed
+ * SyndFeed feed = new HttpURLFeedFetcher(feedInfoCache).retrieveFeed(feedUrl);
+ *
+ *
+ *
+ *
+ * @see http://fishbowl.pastiche.org/2002/10/21/http_conditional_get_for_rss_hackers
+ * @see http://diveintomark.org/archives/2003/07/21/atom_aggregator_behavior_http_level
+ * @see http://bobwyman.pubsub.com/main/2004/09/using_rfc3229_w.html
+ * @author Nick Lothian
+ */
+public class HttpURLFeedFetcher extends AbstractFeedFetcher {
+
+ private volatile int connectTimeout = -1;
+
+ static final int POLL_EVENT = 1;
+ static final int RETRIEVE_EVENT = 2;
+ static final int UNCHANGED_EVENT = 3;
+
+ private FeedFetcherCache feedInfoCache;
+
+ /**
+ * Constructor to use HttpURLFeedFetcher without caching of feeds
+ *
+ */
+ public HttpURLFeedFetcher() {
+ this(null);
+ }
+
+ /**
+ * Constructor to enable HttpURLFeedFetcher to cache feeds
+ *
+ * @param feedInfoCache - an instance of the FeedFetcherCache interface
+ */
+ public HttpURLFeedFetcher(final FeedFetcherCache feedInfoCache) {
+ setFeedInfoCache(feedInfoCache);
+ }
+
+ @Override
+ public SyndFeed retrieveFeed(final URL feedUrl) throws IllegalArgumentException, IOException, FeedException, FetcherException {
+ return this.retrieveFeed(getUserAgent(), feedUrl);
+ }
+
+ /**
+ * Retrieve a feed over HTTP
+ *
+ * @param feedUrl A non-null URL of a RSS/Atom feed to retrieve
+ * @return A {@link com.rometools.rome.feed.synd.SyndFeed} object
+ * @throws IllegalArgumentException if the URL is null;
+ * @throws IOException if a TCP error occurs
+ * @throws FeedException if the feed is not valid
+ * @throws FetcherException if a HTTP error occurred
+ */
+ @Override
+ public SyndFeed retrieveFeed(final String userAgent, final URL feedUrl) throws IllegalArgumentException, IOException, FeedException, FetcherException {
+ if (feedUrl == null) {
+ throw new IllegalArgumentException("null is not a valid URL");
+ }
+
+ final URLConnection connection = feedUrl.openConnection();
+ if (!(connection instanceof HttpURLConnection)) {
+ throw new IllegalArgumentException(feedUrl.toExternalForm() + " is not a valid HTTP Url");
+ }
+ final HttpURLConnection httpConnection = (HttpURLConnection) connection;
+ if (connectTimeout >= 0) {
+ httpConnection.setConnectTimeout(connectTimeout);
+ }
+ // httpConnection.setInstanceFollowRedirects(true); // this is true by default, but can be
+ // changed on a claswide basis
+
+ final FeedFetcherCache cache = getFeedInfoCache();
+ if (cache != null) {
+ SyndFeedInfo syndFeedInfo = cache.getFeedInfo(feedUrl);
+ setRequestHeaders(connection, syndFeedInfo, userAgent);
+ httpConnection.connect();
+ try {
+ fireEvent(FetcherEvent.EVENT_TYPE_FEED_POLLED, connection);
+
+ if (syndFeedInfo == null) {
+ // this is a feed that hasn't been retrieved
+ syndFeedInfo = new SyndFeedInfo();
+ retrieveAndCacheFeed(feedUrl, syndFeedInfo, httpConnection);
+ } else {
+ // check the response code
+ final int responseCode = httpConnection.getResponseCode();
+ if (responseCode != HttpURLConnection.HTTP_NOT_MODIFIED) {
+ // the response code is not 304 NOT MODIFIED
+ // This is either because the feed server
+ // does not support condition gets
+ // or because the feed hasn't changed
+ retrieveAndCacheFeed(feedUrl, syndFeedInfo, httpConnection);
+ } else {
+ // the feed does not need retrieving
+ fireEvent(FetcherEvent.EVENT_TYPE_FEED_UNCHANGED, connection);
+ }
+ }
+
+ return syndFeedInfo.getSyndFeed();
+ } finally {
+ httpConnection.disconnect();
+ }
+ } else {
+ fireEvent(FetcherEvent.EVENT_TYPE_FEED_POLLED, connection);
+ InputStream inputStream = null;
+ setRequestHeaders(connection, null, userAgent);
+
+ httpConnection.connect();
+ try {
+ inputStream = httpConnection.getInputStream();
+ return getSyndFeedFromStream(inputStream, connection);
+ } catch (final java.io.IOException e) {
+ handleErrorCodes(((HttpURLConnection) connection).getResponseCode());
+ } finally {
+ IO.close(inputStream);
+ httpConnection.disconnect();
+ }
+ // we will never actually get to this line
+ return null;
+ }
+ }
+
+ protected void retrieveAndCacheFeed(final URL feedUrl, final SyndFeedInfo syndFeedInfo, final HttpURLConnection connection)
+ throws IllegalArgumentException, FeedException, FetcherException, IOException {
+ handleErrorCodes(connection.getResponseCode());
+
+ resetFeedInfo(feedUrl, syndFeedInfo, connection);
+ final FeedFetcherCache cache = getFeedInfoCache();
+ // resetting feed info in the cache
+ // could be needed for some implementations
+ // of FeedFetcherCache (eg, distributed HashTables)
+ if (cache != null) {
+ cache.setFeedInfo(feedUrl, syndFeedInfo);
+ }
+ }
+
+ protected void resetFeedInfo(final URL orignalUrl, final SyndFeedInfo syndFeedInfo, final HttpURLConnection connection) throws IllegalArgumentException,
+ IOException, FeedException {
+ // need to always set the URL because this may have changed due to 3xx redirects
+ syndFeedInfo.setUrl(connection.getURL());
+
+ // the ID is a persistant value that should stay the same even if the URL for the
+ // feed changes (eg, by 3xx redirects)
+ syndFeedInfo.setId(orignalUrl.toString());
+
+ // This will be 0 if the server doesn't support or isn't setting the last modified header
+ syndFeedInfo.setLastModified(connection.getLastModified());
+
+ // This will be null if the server doesn't support or isn't setting the ETag header
+ syndFeedInfo.setETag(connection.getHeaderField("ETag"));
+
+ // get the contents
+ InputStream inputStream = null;
+ try {
+ inputStream = connection.getInputStream();
+ SyndFeed syndFeed = getSyndFeedFromStream(inputStream, connection);
+
+ final String imHeader = connection.getHeaderField("IM");
+ if (isUsingDeltaEncoding() && imHeader != null && imHeader.contains("feed")) {
+ final FeedFetcherCache cache = getFeedInfoCache();
+ if (cache != null && connection.getResponseCode() == 226) {
+ // client is setup to use http delta encoding and the server supports it and has
+ // returned a delta encoded response
+ // This response only includes new items
+ final SyndFeedInfo cachedInfo = cache.getFeedInfo(orignalUrl);
+ if (cachedInfo != null) {
+ final SyndFeed cachedFeed = cachedInfo.getSyndFeed();
+
+ // set the new feed to be the orginal feed plus the new items
+ syndFeed = combineFeeds(cachedFeed, syndFeed);
+ }
+ }
+ }
+
+ syndFeedInfo.setSyndFeed(syndFeed);
+ } finally {
+ IO.close(inputStream);
+ }
+ }
+
+ /**
+ *
+ * Set appropriate HTTP headers, including conditional get and gzip encoding headers
+ *
+ *
+ * @param connection A URLConnection
+ * @param syndFeedInfo The SyndFeedInfo for the feed to be retrieved. May be null
+ * @param userAgent the name of the user-agent to be placed in HTTP-header.
+ */
+ protected void setRequestHeaders(final URLConnection connection, final SyndFeedInfo syndFeedInfo, final String userAgent) {
+ if (syndFeedInfo != null) {
+ // set the headers to get feed only if modified
+ // we support the use of both last modified and eTag headers
+ if (syndFeedInfo.getLastModified() != null) {
+ final Object lastModified = syndFeedInfo.getLastModified();
+ if (lastModified instanceof Long) {
+ connection.setIfModifiedSince((Long) syndFeedInfo.getLastModified());
+ }
+ }
+ if (syndFeedInfo.getETag() != null) {
+ connection.setRequestProperty("If-None-Match", syndFeedInfo.getETag());
+ }
+
+ }
+ // header to retrieve feed gzipped
+ connection.setRequestProperty("Accept-Encoding", "gzip");
+ connection.addRequestProperty("User-Agent", userAgent);
+
+ if (isUsingDeltaEncoding()) {
+ connection.addRequestProperty("A-IM", "feed");
+ }
+ }
+
+ private SyndFeed readSyndFeedFromStream(final InputStream inputStream, final URLConnection connection) throws IOException, IllegalArgumentException,
+ FeedException {
+ BufferedInputStream is;
+ if ("gzip".equalsIgnoreCase(connection.getContentEncoding())) {
+ // handle gzip encoded content
+ is = new BufferedInputStream(new GZIPInputStream(inputStream));
+ } else {
+ is = new BufferedInputStream(inputStream);
+ }
+
+ // InputStreamReader reader = new InputStreamReader(is,
+ // ResponseHandler.getCharacterEncoding(connection));
+
+ // SyndFeedInput input = new SyndFeedInput();
+
+ final XmlReader reader;
+ if (connection.getHeaderField("Content-Type") != null) {
+ reader = new XmlReader(is, connection.getHeaderField("Content-Type"), true);
+ } else {
+ reader = new XmlReader(is, true);
+ }
+
+ final SyndFeedInput syndFeedInput = new SyndFeedInput();
+ syndFeedInput.setPreserveWireFeed(isPreserveWireFeed());
+
+ return syndFeedInput.build(reader);
+
+ }
+
+ private SyndFeed getSyndFeedFromStream(final InputStream inputStream, final URLConnection connection) throws IOException, IllegalArgumentException,
+ FeedException {
+ final SyndFeed feed = readSyndFeedFromStream(inputStream, connection);
+ fireEvent(FetcherEvent.EVENT_TYPE_FEED_RETRIEVED, connection, feed);
+ return feed;
+ }
+
+ /**
+ * @return The FeedFetcherCache used by this fetcher (Could be null)
+ */
+ public synchronized FeedFetcherCache getFeedInfoCache() {
+ return feedInfoCache;
+ }
+
+ /**
+ * @param cache The cache to be used by this fetcher (pass null to stop using a cache)
+ */
+ public synchronized void setFeedInfoCache(final FeedFetcherCache cache) {
+ feedInfoCache = cache;
+ }
+
+ /**
+ * @param timeout see java.net.URLConnection.setConnectTimeout(int timeout)
+ */
+ public synchronized void setConnectTimeout(final int timeout) {
+ connectTimeout = timeout;
+ }
+}
diff --git a/rome-fetcher/src/main/java/com/rometools/fetcher/impl/LinkedHashMapFeedInfoCache.java b/rome-fetcher/src/main/java/com/rometools/fetcher/impl/LinkedHashMapFeedInfoCache.java
new file mode 100644
index 0000000..a398bf6
--- /dev/null
+++ b/rome-fetcher/src/main/java/com/rometools/fetcher/impl/LinkedHashMapFeedInfoCache.java
@@ -0,0 +1,81 @@
+package com.rometools.fetcher.impl;
+
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+/**
+ *
+ * An implementation of the {@link com.rometools.fetcher.impl.FeedFetcherCache} interface.
+ *
+ *
+ *
+ * Unlike the HashMapFeedInfoCache this implementation will not grow unbound
+ *
+ *
+ * @author Javier Kohen
+ * @author Nick Lothian
+ *
+ */
+public class LinkedHashMapFeedInfoCache extends HashMapFeedInfoCache {
+
+ private final class CacheImpl extends LinkedHashMap {
+
+ private static final long serialVersionUID = 1L;
+
+ public CacheImpl() {
+ super(16, 0.75F, true);
+ }
+
+ @Override
+ protected boolean removeEldestEntry(final Map.Entry eldest) {
+ return size() > getMaxEntries();
+ }
+
+ }
+
+ private static final int DEFAULT_MAX_ENTRIES = 20;
+ private static final long serialVersionUID = 1L;
+ private static final LinkedHashMapFeedInfoCache _instance = new LinkedHashMapFeedInfoCache();
+
+ private int maxEntries = DEFAULT_MAX_ENTRIES;
+
+ /**
+ * Get the global instance of the cache
+ *
+ * @return an implementation of FeedFetcherCache
+ */
+ public static final FeedFetcherCache getInstance() {
+ return _instance;
+ }
+
+ /**
+ *
+ * Constructor for HashMapFeedInfoCache
+ *
+ *
+ *
+ * Only use this if you want multiple instances of the cache. Usually {@link #getInstance()} is
+ * more appropriate.
+ *
+ *
+ * @see #getInstance()
+ */
+ public LinkedHashMapFeedInfoCache() {
+ super();
+ }
+
+ @Override
+ protected Map createInfoCache() {
+ return Collections.synchronizedMap(new CacheImpl());
+ }
+
+ public synchronized final int getMaxEntries() {
+ return maxEntries;
+ }
+
+ public synchronized final void setMaxEntries(final int maxEntries) {
+ this.maxEntries = maxEntries;
+ }
+
+}
diff --git a/rome-fetcher/src/main/java/com/rometools/fetcher/impl/ResponseHandler.java b/rome-fetcher/src/main/java/com/rometools/fetcher/impl/ResponseHandler.java
new file mode 100644
index 0000000..56b3ab8
--- /dev/null
+++ b/rome-fetcher/src/main/java/com/rometools/fetcher/impl/ResponseHandler.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright 2004 Sun Microsystems, Inc.
+ *
+ * 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 com.rometools.fetcher.impl;
+
+import java.net.URLConnection;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * Utility class to help deal with HTTP responses
+ *
+ */
+public class ResponseHandler {
+ public static final String defaultCharacterEncoding = "ISO-8859-1";
+
+ private final static Pattern characterEncodingPattern = Pattern.compile("charset=([.[^; ]]*)");
+
+ public static String getCharacterEncoding(final URLConnection connection) {
+ return getCharacterEncoding(connection.getContentType());
+ }
+
+ /**
+ *
+ *
+ * Gets the character encoding of a response. (Note that this is different to the
+ * content-encoding)
+ *
+ *
+ * @param contentTypeHeader the value of the content-type HTTP header eg: text/html;
+ * charset=ISO-8859-4
+ * @return the character encoding, eg: ISO-8859-4
+ */
+ public static String getCharacterEncoding(final String contentTypeHeader) {
+ if (contentTypeHeader == null) {
+ return defaultCharacterEncoding;
+ }
+
+ final Matcher m = characterEncodingPattern.matcher(contentTypeHeader);
+ // if (!m.matches()) {
+ if (!m.find()) {
+ return defaultCharacterEncoding;
+ } else {
+ return m.group(1);
+ }
+ }
+}
diff --git a/rome-fetcher/src/main/java/com/rometools/fetcher/impl/SyndFeedInfo.java b/rome-fetcher/src/main/java/com/rometools/fetcher/impl/SyndFeedInfo.java
new file mode 100644
index 0000000..07c9bfe
--- /dev/null
+++ b/rome-fetcher/src/main/java/com/rometools/fetcher/impl/SyndFeedInfo.java
@@ -0,0 +1,160 @@
+/*
+ * Copyright 2004 Sun Microsystems, Inc.
+ *
+ * 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 com.rometools.fetcher.impl;
+
+import java.io.Serializable;
+import java.net.URL;
+
+import com.rometools.rome.feed.impl.ObjectBean;
+import com.rometools.rome.feed.synd.SyndFeed;
+
+/**
+ *
+ * A class to represent a {@link com.rometools.rome.feed.synd.SyndFeed} and some useful information
+ * about it.
+ *
+ *
+ *
+ * This class is thread safe, as expected by the different feed fetcher implementations.
+ *
+ *
+ * @author Nick Lothian
+ */
+public class SyndFeedInfo implements Cloneable, Serializable {
+ private static final long serialVersionUID = 1L;
+
+ private final ObjectBean _objBean;
+ private String id;
+ private URL url;
+ private Object lastModified;
+ private String eTag;
+ private SyndFeed syndFeed;
+
+ public SyndFeedInfo() {
+ _objBean = new ObjectBean(this.getClass(), this);
+ }
+
+ /**
+ * Creates a deep 'bean' clone of the object.
+ *
+ *
+ * @return a clone of the object.
+ * @throws CloneNotSupportedException thrown if an element of the object cannot be cloned.
+ *
+ */
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ return _objBean.clone();
+ }
+
+ /**
+ * Indicates whether some other object is "equal to" this one as defined by the Object equals()
+ * method.
+ *
+ *
+ * @param other he reference object with which to compare.
+ * @return true if 'this' object is equal to the 'other' object.
+ *
+ */
+ @Override
+ public boolean equals(final Object other) {
+ return _objBean.equals(other);
+ }
+
+ /**
+ * Returns a hashcode value for the object.
+ *
+ * It follows the contract defined by the Object hashCode() method.
+ *
+ *
+ * @return the hashcode of the bean object.
+ *
+ */
+ @Override
+ public int hashCode() {
+ return _objBean.hashCode();
+ }
+
+ /**
+ * Returns the String representation for the object.
+ *
+ *
+ * @return String representation for the object.
+ *
+ */
+ @Override
+ public String toString() {
+ return _objBean.toString();
+ }
+
+ /**
+ * @return the ETag the feed was last retrieved with
+ */
+ public synchronized String getETag() {
+ return eTag;
+ }
+
+ /**
+ * @return the last modified date for the feed
+ */
+ public synchronized Object getLastModified() {
+ return lastModified;
+ }
+
+ /**
+ * @return the URL the feed was served from
+ */
+ public synchronized URL getUrl() {
+ return url;
+ }
+
+ public synchronized void setETag(final String string) {
+ eTag = string;
+ }
+
+ public synchronized void setLastModified(final Object o) {
+ lastModified = o;
+ }
+
+ public synchronized void setUrl(final URL url) {
+ this.url = url;
+ }
+
+ public synchronized SyndFeed getSyndFeed() {
+ return syndFeed;
+ }
+
+ public synchronized void setSyndFeed(final SyndFeed feed) {
+ syndFeed = feed;
+ }
+
+ /**
+ * @return A unique ID to identify the feed
+ */
+ public synchronized String getId() {
+ return id;
+ }
+
+ /**
+ * @param string A unique ID to identify the feed. Note that if the URL of the feed changes this
+ * will remain the same
+ */
+ public synchronized void setId(final String string) {
+ id = string;
+ }
+
+}
diff --git a/rome-fetcher/src/main/resources/.gitignore b/rome-fetcher/src/main/resources/.gitignore
new file mode 100644
index 0000000..53b845b
--- /dev/null
+++ b/rome-fetcher/src/main/resources/.gitignore
@@ -0,0 +1 @@
+# needed to commit empty folder
\ No newline at end of file
diff --git a/rome-fetcher/src/site/apt/BuildingTheRomeFetcher.apt b/rome-fetcher/src/site/apt/BuildingTheRomeFetcher.apt
new file mode 100644
index 0000000..83ecc7d
--- /dev/null
+++ b/rome-fetcher/src/site/apt/BuildingTheRomeFetcher.apt
@@ -0,0 +1,11 @@
+ -----
+ Building the Rome Fetcher
+ -----
+ mkurz
+ -----
+ 2011-08-15 17:34:51.402
+ -----
+
+Building the Rome Fetcher
+
+ The Rome Fetcher can build using Maven 2.
diff --git a/rome-fetcher/src/site/apt/ChangeLog.apt b/rome-fetcher/src/site/apt/ChangeLog.apt
new file mode 100644
index 0000000..135af0c
--- /dev/null
+++ b/rome-fetcher/src/site/apt/ChangeLog.apt
@@ -0,0 +1,113 @@
+ -----
+ Change Log
+ -----
+ mkurz
+ -----
+ 2011-08-15 17:27:20.212
+ -----
+
+Change Log
+
+*Prior to first release (on the way to v0.3)
+
+ [[1]] Updated to handle removal of IO methods using byte streams\
+ Byte Stream IO was removed from Rome itself. The Rome Fetcher is now updated to support this
+
+ [[1]] Add FeedFetcherI interface and FeedFetcherFactory class\
+ There is now a FeedFetcherI interface, which FeedFetcher implements. Use FeedFetcherFactory to create instances of
+ FeedFetcher (as suggested by Joseph Ottinger) (FeedFetcherFactory was later removed)
+
+ [[1]] Event Support Added to FeedFetcherI\
+ The FeedFetcherI interface now supports feed polled, feed retrieved and feed unchanged events
+
+ [[1]] Samples added\
+ Samples are now included with the Rome Fetcher
+
+ [[1]] Unit Tests Added\
+ JUnit based tests which invoke the Rome Fetcher against an embedded Jetty webserver are now included
+
+ [[1]] Bug fixes in the FeedFetcher event model\
+ The JUnit test suite uncovered some bugs in the event model used by the FeedFetcher. These bugs are now fixed.
+
+ [[1]] Refactored the SyndFeedInfo class\
+ SyndFeedInfo now extends ObjectBean
+
+ [[1]] Removed FeedFetcherFactory\
+ The benefit of the FeedFetcherFactory was arguable. Now the client code will need to manage the creation of specific implementations of the FeedFetcher
+
+ []
+
+*Prior to second release (on the way to v0.4)
+
+ [[1]] Refectored to match Rome naming standards\
+ FeedFetcherI renamed to FeedFetcher\
+ #. New FeedFetcher Implementation\
+ HttpClientFeedFetcher uses the Apache Commons HTTP Client
+
+ [[1]] Abstract test classes excluded in project.xml\
+ Tests now run correctly under Maven
+
+ [[1]] Added GZip support to HttpClientFeedFetcher\
+ HttpClientFeedFetcher now supports GZip compression. Tests have been added.
+
+ []
+
+*Prior to third release (on the way to v0.5)
+
+ [[1]] SyndFeedInfo implements Serializable\
+ SyndFeedInfo implements Serializable to make it easier to store
+
+ [[1]] Support for rfc3229 delta encoding\
+ The Fetcher now supports rfc3229 delta encoding. See {{{http://www.ietf.org/rfc/rfc3229.txt}http://www.ietf.org/rfc/rfc3229.txt}} and
+ {{{http://bobwyman.pubsub.com/main/2004/09/using_rfc3229_w.html}http://bobwyman.pubsub.com/main/2004/09/using_rfc3229_w.html}}.
+ Note that this is support is experimental and disabled by default
+
+ []
+
+*Prior to 0.6
+
+ [[1]] Feed passed to FetcherEvents\
+ When a feed is retrieved it is now passed to the Fetcher Event. This makes it easier to code applications using an event oriented style.
+
+ []
+
+*Prior to 0.7
+
+ [[1]] Fix for URL Connection leak\
+ In some circumstances URLConnection objects were not closed. This could cause problems in long\-running application.
+
+ []
+
+*0.8 was never released
+
+*Prior to 0.9
+
+ [[1]] Fix for potential synchronization issue\
+ There was the possibility of synchronization issues in the FeedFetcher. Fixed, thanks to suggestions from Javier Kohen.
+
+ [[1]] New LinkedHashMapFeedInfoCache FeedFetcherCache implementation\
+ The new LinkedHashMapFeedInfoCache has the advantage that it will not grow unbound
+
+ []
+
+*Prior to 1.0RC2
+
+ [[1]] BeanInfo class added for AbstractFeedFetcher\
+ com.rometools.rome.fetcher.impl.AbstractFeedFetcherBeanInfo was created to allow introspection to correctly find the events
+
+ [[1]] Callback to allow access to HttpClient HttpMethod object\
+ Add a HttpClientMethodCallbackIntf to allow the calling code to modify the HttpClient HttpMethod used to make the request
+ (eg, add additinal headers, etc.) Also fixes a reported bug where the user agent wasn't being set properly
+
+ [[1]] Support for clearing cache\
+ See {{{http://java.net/jira/browse/ROME\-119}http://java.net/jira/browse/ROME\-119}} for details
+
+ []
+
+*Prior to 1.0
+
+ [[1]] Support for preserving wire feed data.\
+ The fetcher now has a setPreserveWireFeed() method which will setup ROME to preserve WireFeed data. See
+ {{{http://rometools.github.io/rome/PreservingWireFeeds.html}PreservingWireFeeds}} for further information.
+
+ []
diff --git a/rome-fetcher/src/site/apt/Dependencies/HttpClientFeedFetcher.apt b/rome-fetcher/src/site/apt/Dependencies/HttpClientFeedFetcher.apt
new file mode 100644
index 0000000..e67bfdc
--- /dev/null
+++ b/rome-fetcher/src/site/apt/Dependencies/HttpClientFeedFetcher.apt
@@ -0,0 +1,13 @@
+ -----
+ HttpClientFeedFetcher
+ -----
+ mkurz
+ -----
+ 2011-08-15 17:40:11.468
+ -----
+
+HttpClientFeedFetcher
+
+
+ An implementation of the <<>> which uses the Jakarta HTTP Client. This HTTP client has many benefits over the standard Java implementation.
+
diff --git a/rome-fetcher/src/site/apt/Dependencies/index.apt b/rome-fetcher/src/site/apt/Dependencies/index.apt
new file mode 100644
index 0000000..e890d1c
--- /dev/null
+++ b/rome-fetcher/src/site/apt/Dependencies/index.apt
@@ -0,0 +1,36 @@
+ -----
+ Dependencies
+ -----
+ mkurz
+ -----
+ 2011-08-15 17:42:31.999
+ -----
+
+Dependencies
+
+ The Rome Fetcher aims to introduce the absolute minimum number of extra dependencies. Currently (30\-June\-2004) no extra dependencies over those required
+ by Rome are required to use the fetcher.
+
+ The current dependencies required to use the Rome Fetcher are:
+
+ * JDK 1.4\+
+
+ * Current version of Rome
+
+ * JDom v 1.0
+
+ []
+
+ To build the Rome Fetcher the {{{http://jakarta.apache.org/commons/httpclient/}Jakarta HTTP Client}} is required.
+
+ If the {{{./HttpClientFeedFetcher.html}HttpClientFeedFetcher (fetcher)}} fetcher implementation is used then the Jakarta HTTP Client and Jakarta Commons Logging is required.
+
+ To build and run the unit tests for the Rome Fetcher the following additional dependencies are required:
+
+ * servletapi version 2.3
+
+ * jetty 4.2.12
+
+ []
+
+ Note that Maven will automatically download the correct versions of all dependancies.
diff --git a/rome-fetcher/src/site/apt/KnownIssues.apt b/rome-fetcher/src/site/apt/KnownIssues.apt
new file mode 100644
index 0000000..38263e7
--- /dev/null
+++ b/rome-fetcher/src/site/apt/KnownIssues.apt
@@ -0,0 +1,43 @@
+ -----
+ Known Issues
+ -----
+ mkurz
+ -----
+ 2011-08-15 17:30:28.420
+ -----
+
+Known Issues
+
+*Version 0.3
+
+ * The Maven build does not run the <<>> tests because of a bug in Maven
+
+ * Version 0.3 does not have <<>> included in the project.xml (it is required to run the samples). Either get the latest <<>> from CVS, or
+ {{{https://rome.dev.java.net/source/browse/rome/subprojects/fetcher/project.xml?r1\=1.1&r2\=1.2}patch it yourself}}
+
+ * 0.3 had a bug that caused it to overwite system properties.
+
+ []
+
+*Version 0.4
+
+ * No known issues (yet!)
+
+ []
+
+*Version 0.5
+
+ * When listening to feed events using <<>>, there is no way to get to the retrieved content, because it is set after firing the event.
+ \-\- {{{http://wiki.java.net/twiki/bin/view/Javawsxml/Jawe}jawe}}
+
+ * When listening to feed events using <<>>, the feed URLs returned by the <<>> are prepended with
+ "sun.net.www.protocol.http.HttpURLConnection:" \-\- {{{http://wiki.java.net/twiki/bin/view/Javawsxml/Jawe}jawe}}
+
+ []
+
+*Version 0.7
+
+ * <<>> doesn't work quite right because <<>> does hostname resolution and treats virtual hosts with the same IP as equal,
+ so e.g. all RSS feeds from <<>> collide in the cache. Also, it's really slow. Fix is to use <<>> as the hash key instead of the URL itself.
+
+ []
diff --git a/rome-fetcher/src/site/apt/Releases/ROMEFetcher0.6.apt b/rome-fetcher/src/site/apt/Releases/ROMEFetcher0.6.apt
new file mode 100644
index 0000000..7a6e396
--- /dev/null
+++ b/rome-fetcher/src/site/apt/Releases/ROMEFetcher0.6.apt
@@ -0,0 +1,49 @@
+ -----
+ ROME Fetcher 0.6
+ -----
+ mkurz
+ -----
+ 2011-08-15 17:50:02.821
+ -----
+
+ROME Fetcher 0.6
+
+*Downloads
+
+ * {{{./rome\-fetcher\-0.6\-src.zip}rome\-fetcher\-0.6\-src.zip}}
+
+ * {{{./rome\-fetcher\-0.6.tar.gz}rome\-fetcher\-0.6.tar.gz}}
+
+ * {{{./rome\-fetcher\-0.6.zip}rome\-fetcher\-0.6.zip}}
+
+ * {{{./rome\-fetcher\-0.6\-src.tar.gz}rome\-fetcher\-0.6\-src.tar.gz}}
+
+ []
+
+*Tutorials
+
+ * {{{../BuildingTheRomeFetcher.html}Building the Rome Fetcher (fetcher)}}
+
+ * {{{../UsingTheRomeFetcherModuleToRetrieveFeeds.html}Using the Rome Fetcher module to retrieve feeds (fetcher)}}
+
+ * {{{../SampleProgramsIncluded.html}Sample programs included (fetcher)}}
+
+ []
+
+*Todo list
+
+ * {{{../TodoList.html}Todo list (fetcher)}}
+
+ []
+
+*Issues
+
+ * {{{../KnownIssues.html}Known Issues (fetcher)}}
+
+ []
+
+*Change Log
+
+ * {{{../ChangeLog.html}Change Log (fetcher)}}
+
+ []
diff --git a/rome-fetcher/src/site/apt/Releases/ROMEFetcher0.7.apt b/rome-fetcher/src/site/apt/Releases/ROMEFetcher0.7.apt
new file mode 100644
index 0000000..d574307
--- /dev/null
+++ b/rome-fetcher/src/site/apt/Releases/ROMEFetcher0.7.apt
@@ -0,0 +1,49 @@
+ -----
+ ROME Fetcher 0.7
+ -----
+ mkurz
+ -----
+ 2011-08-15 17:50:31.833
+ -----
+
+ROME Fetcher 0.7
+
+*Downloads
+
+ * {{{./rome\-fetcher\-0.7\-src.zip}rome\-fetcher\-0.7\-src.zip}}
+
+ * {{{./rome\-fetcher\-0.7.tar.gz}rome\-fetcher\-0.7.tar.gz}}
+
+ * {{{./rome\-fetcher\-0.7.zip}rome\-fetcher\-0.7.zip}}
+
+ * {{{./rome\-fetcher\-0.7\-src.tar.gz}rome\-fetcher\-0.7\-src.tar.gz}}
+
+ []
+
+*Tutorials
+
+ * {{{../BuildingTheRomeFetcher.html}Building the Rome Fetcher (fetcher)}}
+
+ * {{{../UsingTheRomeFetcherModuleToRetrieveFeeds.html}Using the Rome Fetcher module to retrieve feeds (fetcher)}}
+
+ * {{{../SampleProgramsIncluded.html}Sample programs included (fetcher)}}
+
+ []
+
+*Todo list
+
+ * {{{../TodoList.html}Todo list (fetcher)}}
+
+ []
+
+*Issues
+
+ * {{{../KnownIssues.html}Known Issues (fetcher)}}
+
+ []
+
+*Change Log
+
+ * {{{../ChangeLog.html}Change Log (fetcher)}}
+
+ []
diff --git a/rome-fetcher/src/site/apt/Releases/ROMEFetcher0.9.apt b/rome-fetcher/src/site/apt/Releases/ROMEFetcher0.9.apt
new file mode 100644
index 0000000..5bb4964
--- /dev/null
+++ b/rome-fetcher/src/site/apt/Releases/ROMEFetcher0.9.apt
@@ -0,0 +1,51 @@
+ -----
+ ROME Fetcher 0.9
+ -----
+ mkurz
+ -----
+ 2011-08-15 17:51:04.383
+ -----
+
+ROME Fetcher 0.9
+
+ Note that there was no 0.8 Fetcher release
+
+*Downloads
+
+ * {{{./rome\-fetcher\-0.9\-src.zip}rome\-fetcher\-0.9\-src.zip}}
+
+ * {{{./rome\-fetcher\-0.9.tar.gz}rome\-fetcher\-0.9.tar.gz}}
+
+ * {{{./rome\-fetcher\-0.9.zip}rome\-fetcher\-0.9.zip}}
+
+ * {{{./rome\-fetcher\-0.9\-src.tar.gz}rome\-fetcher\-0.9\-src.tar.gz}}
+
+ []
+
+*Tutorials
+
+ * {{{../BuildingTheRomeFetcher.html}Building the Rome Fetcher (fetcher)}}
+
+ * {{{../UsingTheRomeFetcherModuleToRetrieveFeeds.html}Using the Rome Fetcher module to retrieve feeds (fetcher)}}
+
+ * {{{../SampleProgramsIncluded.html}Sample programs included (fetcher)}}
+
+ []
+
+*Todo list
+
+ * {{{../TodoList.html}Todo list (fetcher)}}
+
+ []
+
+*Issues
+
+ * {{{../KnownIssues.html}Known Issues (fetcher)}}
+
+ []
+
+*Change Log
+
+ * {{{../ChangeLog.html}Change Log (fetcher)}}
+
+ []
diff --git a/rome-fetcher/src/site/apt/Releases/ROMEFetcher1.0.apt b/rome-fetcher/src/site/apt/Releases/ROMEFetcher1.0.apt
new file mode 100644
index 0000000..992a9b9
--- /dev/null
+++ b/rome-fetcher/src/site/apt/Releases/ROMEFetcher1.0.apt
@@ -0,0 +1,53 @@
+ -----
+ ROME Fetcher 1.0
+ -----
+ mkurz
+ -----
+ 2011-08-15 17:52:18.652
+ -----
+
+ROME Fetcher 1.0
+
+*Downloads
+
+ * {{{./rome\-fetcher\-1.0.jar}rome\-fetcher\-1.0.jar}}
+
+ * {{{./rome\-fetcher\-1.0\-javadoc.jar}rome\-fetcher\-1.0\-javadoc.jar}}
+
+ * {{{./rome\-fetcher\-1.0\-sources.jar}rome\-fetcher\-1.0\-sources.jar}}
+
+ []
+
+*Tutorials
+
+ * {{{../BuildingTheRomeFetcher.html}Building the Rome Fetcher (fetcher)}}
+
+ * {{{../UsingTheRomeFetcherModuleToRetrieveFeeds.html}Using the Rome Fetcher module to retrieve feeds (fetcher)}}
+
+ * {{{../SampleProgramsIncluded.html}Sample programs included (fetcher)}}
+
+ []
+
+*API Docs
+
+ * {{{./rome-fetcher-1.0-javadoc.jar}Fetcher API Docs}}
+
+ []
+
+*Todo list
+
+ * {{{../TodoList.html}Todo list (fetcher)}}
+
+ []
+
+*Issues
+
+ * {{{../KnownIssues.html}Known Issues (fetcher)}}
+
+ []
+
+*Change Log
+
+ * {{{../ChangeLog.html}Change Log (fetcher)}}
+
+ []
diff --git a/rome-fetcher/src/site/apt/Releases/ROMEFetcher1.0RC2.apt b/rome-fetcher/src/site/apt/Releases/ROMEFetcher1.0RC2.apt
new file mode 100644
index 0000000..0519218
--- /dev/null
+++ b/rome-fetcher/src/site/apt/Releases/ROMEFetcher1.0RC2.apt
@@ -0,0 +1,57 @@
+ -----
+ ROME Fetcher 1.0 RC2
+ -----
+ mkurz
+ -----
+ 2011-08-15 17:51:50.236
+ -----
+
+ROME Fetcher 1.0 RC2
+
+ Note that there was no 1.0 RC1 Fetcher release
+
+*Downloads
+
+ * {{{./rome\-fetcher\-1.0RC2\-src.zip}rome\-fetcher\-1.0RC2\-src.zip}}
+
+ * {{{./rome\-fetcher\-1.0RC2.jar}rome\-fetcher\-1.0RC2.jar}}
+
+ * {{{./rome\-fetcher\-1.0RC2\-javadoc.jar}rome\-fetcher\-1.0RC2\-javadoc.jar}}
+
+ * {{{./rome\-fetcher\-1.0RC2\-sources.jar}rome\-fetcher\-1.0RC2\-sources.jar}}
+
+ []
+
+*Tutorials
+
+ * {{{../BuildingTheRomeFetcher.html}Building the Rome Fetcher (fetcher)}}
+
+ * {{{../UsingTheRomeFetcherModuleToRetrieveFeeds.html}Using the Rome Fetcher module to retrieve feeds (fetcher)}}
+
+ * {{{../SampleProgramsIncluded.html}Sample programs included (fetcher)}}
+
+ []
+
+*API Docs
+
+ * {{{./rome-fetcher-1.0RC2-javadoc.jar}Fetcher API Docs}}
+
+ []
+
+*Todo list
+
+ * {{{../TodoList.html}Todo list (fetcher)}}
+
+ []
+
+*Issues
+
+ * {{{../KnownIssues.html}Known Issues (fetcher)}}
+
+ []
+
+*Change Log
+
+ * {{{../ChangeLog.html}Change Log (fetcher)}}
+
+ []
diff --git a/rome-fetcher/src/site/apt/Releases/RomeFetcher0.3.apt b/rome-fetcher/src/site/apt/Releases/RomeFetcher0.3.apt
new file mode 100644
index 0000000..21d024e
--- /dev/null
+++ b/rome-fetcher/src/site/apt/Releases/RomeFetcher0.3.apt
@@ -0,0 +1,51 @@
+ -----
+ Rome Fetcher 0.3
+ -----
+ mkurz
+ -----
+ 2011-08-15 17:46:45.860
+ -----
+
+Rome Fetcher 0.3
+
+ Rome Fetcher version 0.3 is inital release of the Rome Fetcher. It is released as version 0.3 to synchronize with the version number of the core Rome project release.
+
+*Downloads
+
+ * {{{./rome\-fetcher\-0.3\-src.zip}rome\-fetcher\-0.3\-src.zip}}
+
+ * {{{./rome\-fetcher\-0.3.tar.gz}rome\-fetcher\-0.3.tar.gz}}
+
+ * {{{./rome\-fetcher\-0.3.zip}rome\-fetcher\-0.3.zip}}
+
+ * {{{./rome\-fetcher\-0.3\-src.tar.gz}rome\-fetcher\-0.3\-src.tar.gz}}
+
+ []
+
+*Tutorials
+
+ * {{{../BuildingTheRomeFetcher.html}Building the Rome Fetcher (fetcher)}}
+
+ * {{{../UsingTheRomeFetcherModuleToRetrieveFeeds.html}Using the Rome Fetcher module to retrieve feeds (fetcher)}}
+
+ * {{{../SampleProgramsIncluded.html}Sample programs included (fetcher)}}
+
+ []
+
+*Todo list
+
+ * {{{../TodoList.html}Todo list (fetcher)}}
+
+ []
+
+*Issues
+
+ * {{{../KnownIssues.html}Known Issues (fetcher)}}
+
+ []
+
+*Change Log
+
+ * {{{../ChangeLog.html}Change Log (fetcher)}}
+
+ []
diff --git a/rome-fetcher/src/site/apt/Releases/RomeFetcher0.4.apt b/rome-fetcher/src/site/apt/Releases/RomeFetcher0.4.apt
new file mode 100644
index 0000000..a9abd8a
--- /dev/null
+++ b/rome-fetcher/src/site/apt/Releases/RomeFetcher0.4.apt
@@ -0,0 +1,49 @@
+ -----
+ Rome Fetcher 0.4
+ -----
+ mkurz
+ -----
+ 2011-08-15 17:47:58.203
+ -----
+
+Rome Fetcher 0.4
+
+*Downloads
+
+ * {{{./rome\-fetcher\-0.4\-src.zip}rome\-fetcher\-0.4\-src.zip}}
+
+ * {{{./rome\-fetcher\-0.4.tar.gz}rome\-fetcher\-0.4.tar.gz}}
+
+ * {{{./rome\-fetcher\-0.4.zip}rome\-fetcher\-0.4.zip}}
+
+ * {{{./rome\-fetcher\-0.4\-src.tar.gz}rome\-fetcher\-0.4\-src.tar.gz}}
+
+ []
+
+*Tutorials
+
+ * {{{../BuildingTheRomeFetcher.html}Building the Rome Fetcher (fetcher)}}
+
+ * {{{../UsingTheRomeFetcherModuleToRetrieveFeeds.html}Using the Rome Fetcher module to retrieve feeds (fetcher)}}
+
+ * {{{../SampleProgramsIncluded.html}Sample programs included (fetcher)}}
+
+ []
+
+*Todo list
+
+ * {{{../TodoList.html}Todo list (fetcher)}}
+
+ []
+
+*Issues
+
+ * {{{../KnownIssues.html}Known Issues (fetcher)}}
+
+ []
+
+*Change Log
+
+ * {{{../ChangeLog.html}Change Log (fetcher)}}
+
+ []
diff --git a/rome-fetcher/src/site/apt/Releases/RomeFetcher0.5.apt b/rome-fetcher/src/site/apt/Releases/RomeFetcher0.5.apt
new file mode 100644
index 0000000..9959793
--- /dev/null
+++ b/rome-fetcher/src/site/apt/Releases/RomeFetcher0.5.apt
@@ -0,0 +1,51 @@
+ -----
+ Rome Fetcher 0.5
+ -----
+ mkurz
+ -----
+ 2011-08-15 17:49:03.166
+ -----
+
+Rome Fetcher 0.5
+
+ The ROME Fetcher v 0.6 is now released. This page exists for historical purposes only.
+
+*Downloads
+
+ * {{{./rome\-fetcher\-0.5\-src.zip}rome\-fetcher\-0.5\-src.zip}}
+
+ * {{{./rome\-fetcher\-0.5.zip}rome\-fetcher\-0.5.zip}}
+
+ * {{{./rome\-fetcher\-0.5.tar.gz}rome\-fetcher\-0.5.tar.gz}}
+
+ * {{{./rome\-fetcher\-0.5\-src.tar.gz}rome\-fetcher\-0.5\-src.tar.gz}}
+
+ []
+
+*Tutorials
+
+ * {{{../BuildingTheRomeFetcher.html}Building the Rome Fetcher (fetcher)}}
+
+ * {{{../UsingTheRomeFetcherModuleToRetrieveFeeds.html}Using the Rome Fetcher module to retrieve feeds (fetcher)}}
+
+ * {{{../SampleProgramsIncluded.html}Sample programs included (fetcher)}}
+
+ []
+
+*Todo list
+
+ * {{{../TodoList.html}Todo list (fetcher)}}
+
+ []
+
+*Issues
+
+ * {{{../KnownIssues.html}Known Issues (fetcher)}}
+
+ []
+
+*Change Log
+
+ * {{{../ChangeLog.html}Change Log (fetcher)}}
+
+ []
diff --git a/rome-fetcher/src/site/apt/Releases/index.apt b/rome-fetcher/src/site/apt/Releases/index.apt
new file mode 100644
index 0000000..f5715b8
--- /dev/null
+++ b/rome-fetcher/src/site/apt/Releases/index.apt
@@ -0,0 +1,10 @@
+ -----
+ Releases
+ -----
+ mkurz
+ -----
+ 2011-08-15 17:57:59.422
+ -----
+
+Releases
+
diff --git a/rome-fetcher/src/site/apt/SampleProgramsIncluded.apt b/rome-fetcher/src/site/apt/SampleProgramsIncluded.apt
new file mode 100644
index 0000000..7c12649
--- /dev/null
+++ b/rome-fetcher/src/site/apt/SampleProgramsIncluded.apt
@@ -0,0 +1,18 @@
+ -----
+ Sample programs included
+ -----
+ mkurz
+ -----
+ 2011-08-15 17:38:21.664
+ -----
+
+Sample programs included
+
+ There are two sample programs included with Rome Fetcher.
+
+ {{{https://github.com/rometools/rome-fetcher/tree/master/src/main/java/org/rometools/fetcher/samples/FeedReader.java}FeedReader}}
+ is a program which demonstrates the use of the Fetcher to retrieve a feed and then to use the conditional get support to retrieve
+ it again only if it has changed. It also shows how to use the event API in the Fetcher. It can be run using the <<>> target.
+
+ {{{https://github.com/rometools/rome-fetcher/tree/master/src/main/java/org/rometools/fetcher/samples/FeedAggregator.java}FeedAggregator}}
+ is a program which aggregates a number of feeds together into a single feed. It can be run using the <<>> target.
diff --git a/rome-fetcher/src/site/apt/TodoList.apt b/rome-fetcher/src/site/apt/TodoList.apt
new file mode 100644
index 0000000..d6c2582
--- /dev/null
+++ b/rome-fetcher/src/site/apt/TodoList.apt
@@ -0,0 +1,29 @@
+ -----
+ Todo list
+ -----
+ mkurz
+ -----
+ 2011-08-15 17:33:17.559
+ -----
+
+Todo list
+
+ Please discuss items here on the rome dev mailing list
+
+ * Automatically update the
+ \-{{{https://github.com/rometools/rome-fetcher/blob/master/src/java/org/rometools/fetcher/FeedFetcher.java}default User\-Agent version number}}
+ via the build\- Done: 23\-June\-2004
+
+ * Listener Architecture (for URL changes via 3xx redirection etc) Done: 30\-June\-2004
+
+ * {{{http://radio.userland.com/userGuide/reference/howToRedirectRss}RSS Redirection}}
+
+ * Unit Tests: smart unit tests along the lines of Mark Pilgrim's tests, in his
+ \-{{{http://diveintomark.org/projects/feed_parser/}Python Universal Feed Parser}}. He instantiates a web server to a local directory where the samples live,
+ and then fetches the feeds from the server, which allows him to test in depth the behavior of gzip compression and etags handling.\- Done 30\-June\-2004
+
+ * Better character encoding handling \- See {{{http://diveintomark.org/archives/2004/02/13/xml\-media\-types}http://diveintomark.org/archives/2004/02/13/xml\-media\-types}}
+
+ * A caching feed fetcher
+
+ []
diff --git a/rome-fetcher/src/site/apt/UsingTheRomeFetcherModuleToRetrieveFeeds.apt b/rome-fetcher/src/site/apt/UsingTheRomeFetcherModuleToRetrieveFeeds.apt
new file mode 100644
index 0000000..cc2bcfa
--- /dev/null
+++ b/rome-fetcher/src/site/apt/UsingTheRomeFetcherModuleToRetrieveFeeds.apt
@@ -0,0 +1,36 @@
+ -----
+ Using the Rome Fetcher module to retrieve feeds
+ -----
+ mkurz
+ -----
+ 2011-08-15 17:36:41.844
+ -----
+
+Using the Rome Fetcher module to retrieve feeds
+
+ The HttpURLFeedFetcher class does the actual HTTP request. It relies on the FeedInfoCacheI interface which stores information
+ about each feed required for conditional gets. Currently there is a single implementation of FeedInfoCacheI supplied: <<>>.
+
+ The basic usage of FeedFetcher is as follows:
+
++------+
+FeedFetcherCache feedInfoCache = HashMapFeedInfoCache.getInstance();
+FeedFetcher feedFetcher = new HttpURLFeedFetcher(feedInfoCache);
+SyndFeed feed = feedFetcher.retrieveFeed(new URL("http://blogs.sun.com/roller/rss/pat"));
+System.out.println(feed);
++------+
+
+ Any subsequent fetches of {{{http://blogs.sun.com/roller/rss/pat}http://blogs.sun.com/roller/rss/pat}} by any FeedFetcher using feedInfoCache
+ will now only retrieve the feed if it has changed.
+
+ FeedFetcher can be used without a cache if required. Simply create it using the zero\-parameter constructor:
+
++------+
+FeedFetcher feedFetcher = new HttpURLFeedFetcher();
++------+
+
+ A more complete sample (including the use of listener on Fetcher events)
+ {{{https://github.com/rometools/rome-fetcher/blob/master/src/java/org/rometools/fetcher/samples/FeedReader.java}is included in the Rome Fetcher project}}
+
+ Note that there has been considerable discussion on the rome\-dev list about the best way to manage the creation of the feed fetcher.
+ Currently the client code needs to be responsible for creating specific implementations of the FeedFetcherI interface.
diff --git a/rome-fetcher/src/site/apt/WishList.apt b/rome-fetcher/src/site/apt/WishList.apt
new file mode 100644
index 0000000..f4cd90f
--- /dev/null
+++ b/rome-fetcher/src/site/apt/WishList.apt
@@ -0,0 +1,17 @@
+ -----
+ Wish list
+ -----
+ mkurz
+ -----
+ 2011-08-15 17:33:55.774
+ -----
+
+Wish list
+
+ * {{{http://diveintomark.org/archives/2002/05/31}RSS Autodiscovery}}
+
+ * {{{http://www.intertwingly.net/wiki/pie/PaceAutoDisco}Atom Autodiscovery}}
+
+ * Connection timeout and read settings.
+
+ []
diff --git a/rome-fetcher/src/site/apt/index.apt b/rome-fetcher/src/site/apt/index.apt
new file mode 100644
index 0000000..d3ae974
--- /dev/null
+++ b/rome-fetcher/src/site/apt/index.apt
@@ -0,0 +1,72 @@
+ -----
+ Home
+ -----
+ mkurz
+ -----
+ 2011-08-15 17:44:31.665
+ -----
+
+Rome Fetcher
+
+ The Rome Fetcher (see modules/fetcher) allows the retrieval of feeds via HTTP. It supports
+ {{{http://fishbowl.pastiche.org/2002/10/21/http_conditional_get_for_rss_hackers}HTTP conditional gets}}
+ (ie: last modified and ETag handling) and GZip encoded feeds. It should enable user to write aggregators that follow the
+ {{{http://diveintomark.org/archives/2003/07/21/atom_aggregator_behavior_http_level}Atom aggregator behaviour recommendations}}
+
+ As with the rest of Rome, the Fetcher subproject is ultra\-lean \- it requires {{{./Dependencies/index.html}no new dependencies}}
+ over the requirements for Rome.
+
+Tutorials
+
+ * {{{./BuildingTheRomeFetcher.html}Building the Rome Fetcher (fetcher)}}
+
+ * {{{./UsingTheRomeFetcherModuleToRetrieveFeeds.html}Using the Rome Fetcher module to retrieve feeds (fetcher)}}
+
+ * {{{./SampleProgramsIncluded.html}Sample programs included (fetcher)}}
+
+ []
+
+Todo list
+
+ * {{{./TodoList.html}Todo list (fetcher)}}
+
+ []
+
+Wish list
+
+ * {{{./WishList.html}Wish list (fetcher)}}
+
+ []
+
+Issues
+
+ * {{{./KnownIssues.html}Known Issues (fetcher)}}
+
+ []
+
+Releases
+
+ * {{{./Releases/RomeFetcher0.3.html}Rome Fetcher 0.3 (fetcher)}}
+
+ * {{{./Releases/RomeFetcher0.4.html}Rome Fetcher 0.4 (fetcher)}}
+
+ * {{{./Releases/RomeFetcher0.5.html}Rome Fetcher 0.5 (fetcher)}}
+
+ * {{{./Releases/ROMEFetcher0.6.html}ROME Fetcher 0.6 (fetcher)}}
+
+ * {{{./Releases/ROMEFetcher0.7.html}ROME Fetcher 0.7 (fetcher)}}
+
+ * {{{./Releases/ROMEFetcher0.9.html}ROME Fetcher 0.9 (fetcher)}}
+
+ * {{{./Releases/ROMEFetcher1.0RC2.html}ROME Fetcher 1.0 RC2 (fetcher)}}
+
+ * {{{./Releases/ROMEFetcher1.0.html}ROME Fetcher 1.0 (fetcher)}}
+
+ []
+
+Change Log
+
+ * {{{./ChangeLog.html}Change Log (fetcher)}}
+
+ []
+
\ No newline at end of file
diff --git a/rome-fetcher/src/site/resources/.nojekyll b/rome-fetcher/src/site/resources/.nojekyll
new file mode 100644
index 0000000..e69de29
diff --git a/rome-fetcher/src/site/resources/Releases/rome-fetcher-0.3-src.tar.gz b/rome-fetcher/src/site/resources/Releases/rome-fetcher-0.3-src.tar.gz
new file mode 100644
index 0000000..0043cc9
Binary files /dev/null and b/rome-fetcher/src/site/resources/Releases/rome-fetcher-0.3-src.tar.gz differ
diff --git a/rome-fetcher/src/site/resources/Releases/rome-fetcher-0.3-src.zip b/rome-fetcher/src/site/resources/Releases/rome-fetcher-0.3-src.zip
new file mode 100644
index 0000000..b806b31
Binary files /dev/null and b/rome-fetcher/src/site/resources/Releases/rome-fetcher-0.3-src.zip differ
diff --git a/rome-fetcher/src/site/resources/Releases/rome-fetcher-0.3.tar.gz b/rome-fetcher/src/site/resources/Releases/rome-fetcher-0.3.tar.gz
new file mode 100644
index 0000000..958b25e
Binary files /dev/null and b/rome-fetcher/src/site/resources/Releases/rome-fetcher-0.3.tar.gz differ
diff --git a/rome-fetcher/src/site/resources/Releases/rome-fetcher-0.3.zip b/rome-fetcher/src/site/resources/Releases/rome-fetcher-0.3.zip
new file mode 100644
index 0000000..ba85cd1
Binary files /dev/null and b/rome-fetcher/src/site/resources/Releases/rome-fetcher-0.3.zip differ
diff --git a/rome-fetcher/src/site/resources/Releases/rome-fetcher-0.4-src.tar.gz b/rome-fetcher/src/site/resources/Releases/rome-fetcher-0.4-src.tar.gz
new file mode 100644
index 0000000..0af41b0
Binary files /dev/null and b/rome-fetcher/src/site/resources/Releases/rome-fetcher-0.4-src.tar.gz differ
diff --git a/rome-fetcher/src/site/resources/Releases/rome-fetcher-0.4-src.zip b/rome-fetcher/src/site/resources/Releases/rome-fetcher-0.4-src.zip
new file mode 100644
index 0000000..697c2a6
Binary files /dev/null and b/rome-fetcher/src/site/resources/Releases/rome-fetcher-0.4-src.zip differ
diff --git a/rome-fetcher/src/site/resources/Releases/rome-fetcher-0.4.tar.gz b/rome-fetcher/src/site/resources/Releases/rome-fetcher-0.4.tar.gz
new file mode 100644
index 0000000..93adbc0
Binary files /dev/null and b/rome-fetcher/src/site/resources/Releases/rome-fetcher-0.4.tar.gz differ
diff --git a/rome-fetcher/src/site/resources/Releases/rome-fetcher-0.4.zip b/rome-fetcher/src/site/resources/Releases/rome-fetcher-0.4.zip
new file mode 100644
index 0000000..44f1d64
Binary files /dev/null and b/rome-fetcher/src/site/resources/Releases/rome-fetcher-0.4.zip differ
diff --git a/rome-fetcher/src/site/resources/Releases/rome-fetcher-0.5-src.tar.gz b/rome-fetcher/src/site/resources/Releases/rome-fetcher-0.5-src.tar.gz
new file mode 100644
index 0000000..ee71caa
Binary files /dev/null and b/rome-fetcher/src/site/resources/Releases/rome-fetcher-0.5-src.tar.gz differ
diff --git a/rome-fetcher/src/site/resources/Releases/rome-fetcher-0.5-src.zip b/rome-fetcher/src/site/resources/Releases/rome-fetcher-0.5-src.zip
new file mode 100644
index 0000000..eb6ce42
Binary files /dev/null and b/rome-fetcher/src/site/resources/Releases/rome-fetcher-0.5-src.zip differ
diff --git a/rome-fetcher/src/site/resources/Releases/rome-fetcher-0.5.tar.gz b/rome-fetcher/src/site/resources/Releases/rome-fetcher-0.5.tar.gz
new file mode 100644
index 0000000..cc58dd8
Binary files /dev/null and b/rome-fetcher/src/site/resources/Releases/rome-fetcher-0.5.tar.gz differ
diff --git a/rome-fetcher/src/site/resources/Releases/rome-fetcher-0.5.zip b/rome-fetcher/src/site/resources/Releases/rome-fetcher-0.5.zip
new file mode 100644
index 0000000..27c9b55
Binary files /dev/null and b/rome-fetcher/src/site/resources/Releases/rome-fetcher-0.5.zip differ
diff --git a/rome-fetcher/src/site/resources/Releases/rome-fetcher-0.6-src.tar.gz b/rome-fetcher/src/site/resources/Releases/rome-fetcher-0.6-src.tar.gz
new file mode 100644
index 0000000..0d69b1b
Binary files /dev/null and b/rome-fetcher/src/site/resources/Releases/rome-fetcher-0.6-src.tar.gz differ
diff --git a/rome-fetcher/src/site/resources/Releases/rome-fetcher-0.6-src.zip b/rome-fetcher/src/site/resources/Releases/rome-fetcher-0.6-src.zip
new file mode 100644
index 0000000..67ab51a
Binary files /dev/null and b/rome-fetcher/src/site/resources/Releases/rome-fetcher-0.6-src.zip differ
diff --git a/rome-fetcher/src/site/resources/Releases/rome-fetcher-0.6.tar.gz b/rome-fetcher/src/site/resources/Releases/rome-fetcher-0.6.tar.gz
new file mode 100644
index 0000000..c5a996a
Binary files /dev/null and b/rome-fetcher/src/site/resources/Releases/rome-fetcher-0.6.tar.gz differ
diff --git a/rome-fetcher/src/site/resources/Releases/rome-fetcher-0.6.zip b/rome-fetcher/src/site/resources/Releases/rome-fetcher-0.6.zip
new file mode 100644
index 0000000..8890994
Binary files /dev/null and b/rome-fetcher/src/site/resources/Releases/rome-fetcher-0.6.zip differ
diff --git a/rome-fetcher/src/site/resources/Releases/rome-fetcher-0.7-src.tar.gz b/rome-fetcher/src/site/resources/Releases/rome-fetcher-0.7-src.tar.gz
new file mode 100644
index 0000000..30bc5a8
Binary files /dev/null and b/rome-fetcher/src/site/resources/Releases/rome-fetcher-0.7-src.tar.gz differ
diff --git a/rome-fetcher/src/site/resources/Releases/rome-fetcher-0.7-src.zip b/rome-fetcher/src/site/resources/Releases/rome-fetcher-0.7-src.zip
new file mode 100644
index 0000000..ee788d4
Binary files /dev/null and b/rome-fetcher/src/site/resources/Releases/rome-fetcher-0.7-src.zip differ
diff --git a/rome-fetcher/src/site/resources/Releases/rome-fetcher-0.7.tar.gz b/rome-fetcher/src/site/resources/Releases/rome-fetcher-0.7.tar.gz
new file mode 100644
index 0000000..804aa97
Binary files /dev/null and b/rome-fetcher/src/site/resources/Releases/rome-fetcher-0.7.tar.gz differ
diff --git a/rome-fetcher/src/site/resources/Releases/rome-fetcher-0.7.zip b/rome-fetcher/src/site/resources/Releases/rome-fetcher-0.7.zip
new file mode 100644
index 0000000..45934eb
Binary files /dev/null and b/rome-fetcher/src/site/resources/Releases/rome-fetcher-0.7.zip differ
diff --git a/rome-fetcher/src/site/resources/Releases/rome-fetcher-0.9-src.tar.gz b/rome-fetcher/src/site/resources/Releases/rome-fetcher-0.9-src.tar.gz
new file mode 100644
index 0000000..2b1bdf9
Binary files /dev/null and b/rome-fetcher/src/site/resources/Releases/rome-fetcher-0.9-src.tar.gz differ
diff --git a/rome-fetcher/src/site/resources/Releases/rome-fetcher-0.9-src.zip b/rome-fetcher/src/site/resources/Releases/rome-fetcher-0.9-src.zip
new file mode 100644
index 0000000..1899ac7
Binary files /dev/null and b/rome-fetcher/src/site/resources/Releases/rome-fetcher-0.9-src.zip differ
diff --git a/rome-fetcher/src/site/resources/Releases/rome-fetcher-0.9.tar.gz b/rome-fetcher/src/site/resources/Releases/rome-fetcher-0.9.tar.gz
new file mode 100644
index 0000000..1560db9
Binary files /dev/null and b/rome-fetcher/src/site/resources/Releases/rome-fetcher-0.9.tar.gz differ
diff --git a/rome-fetcher/src/site/resources/Releases/rome-fetcher-0.9.zip b/rome-fetcher/src/site/resources/Releases/rome-fetcher-0.9.zip
new file mode 100644
index 0000000..43c48a9
Binary files /dev/null and b/rome-fetcher/src/site/resources/Releases/rome-fetcher-0.9.zip differ
diff --git a/rome-fetcher/src/site/resources/Releases/rome-fetcher-1.0-javadoc.jar b/rome-fetcher/src/site/resources/Releases/rome-fetcher-1.0-javadoc.jar
new file mode 100644
index 0000000..7ea9678
Binary files /dev/null and b/rome-fetcher/src/site/resources/Releases/rome-fetcher-1.0-javadoc.jar differ
diff --git a/rome-fetcher/src/site/resources/Releases/rome-fetcher-1.0-sources.jar b/rome-fetcher/src/site/resources/Releases/rome-fetcher-1.0-sources.jar
new file mode 100644
index 0000000..bf1be0f
Binary files /dev/null and b/rome-fetcher/src/site/resources/Releases/rome-fetcher-1.0-sources.jar differ
diff --git a/rome-fetcher/src/site/resources/Releases/rome-fetcher-1.0.jar b/rome-fetcher/src/site/resources/Releases/rome-fetcher-1.0.jar
new file mode 100644
index 0000000..b889d47
Binary files /dev/null and b/rome-fetcher/src/site/resources/Releases/rome-fetcher-1.0.jar differ
diff --git a/rome-fetcher/src/site/resources/Releases/rome-fetcher-1.0RC2-javadoc.jar b/rome-fetcher/src/site/resources/Releases/rome-fetcher-1.0RC2-javadoc.jar
new file mode 100644
index 0000000..4b08a4a
Binary files /dev/null and b/rome-fetcher/src/site/resources/Releases/rome-fetcher-1.0RC2-javadoc.jar differ
diff --git a/rome-fetcher/src/site/resources/Releases/rome-fetcher-1.0RC2-sources.jar b/rome-fetcher/src/site/resources/Releases/rome-fetcher-1.0RC2-sources.jar
new file mode 100644
index 0000000..a471611
Binary files /dev/null and b/rome-fetcher/src/site/resources/Releases/rome-fetcher-1.0RC2-sources.jar differ
diff --git a/src/site/resources/ROMEReleases/rome-fetcher-1.0RC2-src.zip b/rome-fetcher/src/site/resources/Releases/rome-fetcher-1.0RC2-src.zip
similarity index 100%
rename from src/site/resources/ROMEReleases/rome-fetcher-1.0RC2-src.zip
rename to rome-fetcher/src/site/resources/Releases/rome-fetcher-1.0RC2-src.zip
diff --git a/rome-fetcher/src/site/resources/Releases/rome-fetcher-1.0RC2.jar b/rome-fetcher/src/site/resources/Releases/rome-fetcher-1.0RC2.jar
new file mode 100644
index 0000000..c8a3f85
Binary files /dev/null and b/rome-fetcher/src/site/resources/Releases/rome-fetcher-1.0RC2.jar differ
diff --git a/rome-fetcher/src/site/resources/css/site.css b/rome-fetcher/src/site/resources/css/site.css
new file mode 100644
index 0000000..43c3cd8
--- /dev/null
+++ b/rome-fetcher/src/site/resources/css/site.css
@@ -0,0 +1,8 @@
+h1 {
+ padding: 4px 4px 4px 6px;
+ border: 1px solid #999;
+ color: #900;
+ background-color: #ddd;
+ font-weight:900;
+ font-size: x-large;
+}
\ No newline at end of file
diff --git a/src/site/resources/romelogo.png b/rome-fetcher/src/site/resources/images/romelogo.png
similarity index 100%
rename from src/site/resources/romelogo.png
rename to rome-fetcher/src/site/resources/images/romelogo.png
diff --git a/rome-fetcher/src/site/site.xml b/rome-fetcher/src/site/site.xml
new file mode 100644
index 0000000..4e8df2e
--- /dev/null
+++ b/rome-fetcher/src/site/site.xml
@@ -0,0 +1,41 @@
+
+
+
+
+ org.apache.maven.skins
+ maven-fluido-skin
+ 1.3.0
+
+
+
+ ROME fetcher
+ images/romelogo.png
+ http://github.com/rometools/
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/rome-fetcher/src/test/java/com/rometools/fetcher/AbstractJettyTest.java b/rome-fetcher/src/test/java/com/rometools/fetcher/AbstractJettyTest.java
new file mode 100644
index 0000000..141c2b2
--- /dev/null
+++ b/rome-fetcher/src/test/java/com/rometools/fetcher/AbstractJettyTest.java
@@ -0,0 +1,424 @@
+/*
+ * Copyright 2004 Sun Microsystems, Inc.
+ *
+ * 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 com.rometools.fetcher;
+
+import java.net.URL;
+
+import junit.framework.TestCase;
+
+import org.mortbay.http.BasicAuthenticator;
+import org.mortbay.http.HashUserRealm;
+import org.mortbay.http.HttpContext;
+import org.mortbay.http.HttpServer;
+import org.mortbay.http.SecurityConstraint;
+import org.mortbay.http.SocketListener;
+import org.mortbay.http.UserRealm;
+import org.mortbay.http.handler.SecurityHandler;
+import org.mortbay.jetty.servlet.ServletHandler;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.rometools.fetcher.impl.FeedFetcherCache;
+import com.rometools.fetcher.impl.HashMapFeedInfoCache;
+import com.rometools.rome.feed.atom.Entry;
+import com.rometools.rome.feed.synd.SyndEntry;
+import com.rometools.rome.feed.synd.SyndFeed;
+
+/**
+ * @author nl
+ */
+public abstract class AbstractJettyTest extends TestCase {
+
+ private static final Logger LOG = LoggerFactory.getLogger(AbstractJettyTest.class);
+
+ private HttpServer server;
+ private final int testPort = 8283;
+
+ /**
+ * @param s
+ */
+ public AbstractJettyTest(final String s) {
+ super(s);
+ }
+
+ protected HttpServer getServer() {
+ return server;
+ }
+
+ protected abstract FeedFetcher getFeedFetcher();
+
+ protected abstract FeedFetcher getFeedFetcher(FeedFetcherCache cache);
+
+ /**
+ * @see junit.framework.TestCase#setUp()
+ */
+ @Override
+ protected void setUp() throws Exception {
+ setupServer();
+
+ final HttpContext context = createContext();
+
+ final ServletHandler servlets = createServletHandler();
+ context.addHandler(servlets);
+
+ server.addContext(context);
+
+ server.start();
+ }
+
+ /**
+ * @throws InterruptedException
+ */
+ private void setupServer() throws InterruptedException {
+
+ // Create the server
+ if (server != null) {
+ server.stop();
+ server = null;
+ }
+ server = new HttpServer();
+
+ // Create a port listener
+ final SocketListener listener = new SocketListener();
+ listener.setPort(testPort);
+ server.addListener(listener);
+ }
+
+ /**
+ * @return
+ */
+ private ServletHandler createServletHandler() {
+ final ServletHandler servlets = new ServletHandler();
+ servlets.addServlet("FetcherTestServlet", FetcherTestServlet.SERVLET_MAPPING, "com.rometools.fetcher.FetcherTestServlet");
+ servlets.addServlet("FetcherTestServlet", FetcherTestServlet.SERVLET_MAPPING2, "com.rometools.fetcher.FetcherTestServlet");
+ return servlets;
+ }
+
+ /**
+ * @return
+ */
+ private HttpContext createContext() {
+ final HttpContext context = new HttpContext();
+ context.setContextPath("/rome/*");
+ return context;
+ }
+
+ /**
+ * @see junit.framework.TestCase#tearDown()
+ */
+ @Override
+ protected void tearDown() throws Exception {
+ if (server != null) {
+ server.stop();
+ server.destroy();
+ server = null;
+ }
+ }
+
+ class FetcherEventListenerImpl implements FetcherListener {
+ boolean polled = false;
+ boolean retrieved = false;
+ boolean unchanged = false;
+
+ public void reset() {
+ polled = false;
+ retrieved = false;
+ unchanged = false;
+ }
+
+ /**
+ * @see com.rometools.rome.fetcher.FetcherListener#fetcherEvent(com.rometools.rome.fetcher.FetcherEvent)
+ */
+ @Override
+ public void fetcherEvent(final FetcherEvent event) {
+ final String eventType = event.getEventType();
+ if (FetcherEvent.EVENT_TYPE_FEED_POLLED.equals(eventType)) {
+ LOG.debug("\tEVENT: Feed Polled. URL = " + event.getUrlString());
+ polled = true;
+ } else if (FetcherEvent.EVENT_TYPE_FEED_RETRIEVED.equals(eventType)) {
+ LOG.debug("\tEVENT: Feed Retrieved. URL = " + event.getUrlString());
+ retrieved = true;
+ } else if (FetcherEvent.EVENT_TYPE_FEED_UNCHANGED.equals(eventType)) {
+ LOG.debug("\tEVENT: Feed Unchanged. URL = " + event.getUrlString());
+ unchanged = true;
+ }
+ }
+ }
+
+ public void testRetrieveFeed() {
+ final FeedFetcher feedFetcher = getFeedFetcher();
+ try {
+ final SyndFeed feed = feedFetcher.retrieveFeed(new URL("http://localhost:" + testPort + "/rome/FetcherTestServlet/"));
+ assertNotNull(feed);
+ assertEquals("atom_1.0.feed.title", feed.getTitle());
+ } catch (final Exception e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+ }
+
+ public void testBasicAuthentication() {
+ try {
+ setupServer();
+
+ final HttpContext context = createContext();
+
+ final URL url = this.getClass().getResource("/testuser.properties");
+ final UserRealm ur = new HashUserRealm("test", url.getFile());
+ context.setRealm(ur);
+
+ final BasicAuthenticator ba = new BasicAuthenticator();
+ context.setAuthenticator(ba);
+
+ final SecurityHandler sh = new SecurityHandler();
+ context.addHandler(sh);
+
+ final SecurityConstraint sc = new SecurityConstraint();
+ sc.setName("test");
+ sc.addRole("*");
+ sc.setAuthenticate(true);
+ context.addSecurityConstraint("/", sc);
+
+ final ServletHandler servlets = createServletHandler();
+ context.addHandler(servlets);
+
+ server.addContext(context);
+
+ server.start();
+
+ final FeedFetcher feedFetcher = getAuthenticatedFeedFetcher();
+ final SyndFeed feed = feedFetcher.retrieveFeed(new URL("http://localhost:" + testPort + "/rome/FetcherTestServlet/"));
+ assertNotNull(feed);
+ assertEquals("atom_1.0.feed.title", feed.getTitle());
+
+ } catch (final Exception e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+
+ }
+
+ public abstract FeedFetcher getAuthenticatedFeedFetcher();
+
+ /**
+ * Test getting a feed via a http 301 redirect
+ *
+ */
+ public void testRetrieveRedirectedFeed() {
+ final FeedFetcher feedFetcher = getFeedFetcher();
+ try {
+ final SyndFeed feed = feedFetcher.retrieveFeed(new URL("http://localhost:" + testPort + "/rome/FetcherTestServlet?redirect=TRUE"));
+ assertNotNull(feed);
+ assertEquals("atom_1.0.feed.title", feed.getTitle());
+ } catch (final Exception e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+ }
+
+ /**
+ * Test error handling
+ *
+ */
+ public void testErrorHandling() {
+ final FeedFetcher feedFetcher = getFeedFetcher();
+ try {
+ feedFetcher.retrieveFeed(new URL("http://localhost:" + testPort + "/rome/FetcherTestServlet?error=404"));
+ fail("4xx error handling did not work correctly");
+ } catch (final FetcherException e) {
+ // expect this exception
+ assertEquals(404, e.getResponseCode());
+ } catch (final Exception e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+
+ try {
+ feedFetcher.retrieveFeed(new URL("http://localhost:" + testPort + "/rome/FetcherTestServlet?error=500"));
+ fail("5xx error handling did not work correctly");
+ } catch (final FetcherException e) {
+ // expect this exception
+ assertEquals(500, e.getResponseCode());
+ } catch (final Exception e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+ }
+
+ public void testUserAgent() {
+ final FeedFetcher feedFetcher = getFeedFetcher();
+ // LOG.debug(feedFetcher.getUserAgent());
+ // LOG.debug(System.getProperty("rome.fetcher.version", "UNKNOWN"));
+ assertEquals("Rome Client (http://tinyurl.com/64t5n) Ver: " + System.getProperty("rome.fetcher.version", "UNKNOWN"), feedFetcher.getUserAgent());
+ }
+
+ /**
+ * Test events fired when there is no cache in use
+ *
+ */
+ public void testFetchEvents() {
+ final FeedFetcher feedFetcher = getFeedFetcher();
+ final FetcherEventListenerImpl listener = new FetcherEventListenerImpl();
+ feedFetcher.addFetcherEventListener(listener);
+ try {
+ SyndFeed feed = feedFetcher.retrieveFeed(new URL("http://localhost:" + testPort + "/rome/FetcherTestServlet/"));
+ assertNotNull(feed);
+ assertTrue(listener.polled);
+ assertTrue(listener.retrieved);
+ assertFalse(listener.unchanged);
+ listener.reset();
+
+ // since there is no cache, the events fired should be exactly the same if
+ // we re-retrieve the feed
+ feed = feedFetcher.retrieveFeed(new URL("http://localhost:" + testPort + "/rome/FetcherTestServlet/"));
+ assertNotNull(feed);
+ assertTrue(listener.polled);
+ assertTrue(listener.retrieved);
+ assertFalse(listener.unchanged);
+ listener.reset();
+ } catch (final Exception e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+ }
+
+ /**
+ * Test events fired when there is a cache in use
+ *
+ */
+ public void testFetchEventsWithCache() {
+ final FeedFetcherCache feedInfoCache = new HashMapFeedInfoCache();
+ final FeedFetcher feedFetcher = getFeedFetcher(feedInfoCache);
+ final FetcherEventListenerImpl listener = new FetcherEventListenerImpl();
+ feedFetcher.addFetcherEventListener(listener);
+ try {
+ SyndFeed feed = feedFetcher.retrieveFeed(new URL("http://localhost:" + testPort + "/rome/FetcherTestServlet/"));
+ assertNotNull(feed);
+ assertTrue(listener.polled);
+ assertTrue(listener.retrieved);
+ assertFalse(listener.unchanged);
+ listener.reset();
+
+ // Since the feed is cached, the second request should not
+ // actually retrieve the feed
+ feed = feedFetcher.retrieveFeed(new URL("http://localhost:" + testPort + "/rome/FetcherTestServlet/"));
+ assertNotNull(feed);
+ assertTrue(listener.polled);
+ assertFalse(listener.retrieved);
+ assertTrue(listener.unchanged);
+ listener.reset();
+
+ // now simulate getting the feed after it has changed
+ feed = feedFetcher.retrieveFeed(new URL("http://localhost:" + testPort + "/rome/FetcherTestServlet?refreshfeed=TRUE"));
+ assertNotNull(feed);
+ assertTrue(listener.polled);
+ assertTrue(listener.retrieved);
+ assertFalse(listener.unchanged);
+ listener.reset();
+ } catch (final Exception e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+ }
+
+ /**
+ * Test handling of GZipped feed
+ *
+ */
+ public void testGZippedFeed() {
+ final FeedFetcher feedFetcher = getFeedFetcher();
+ try {
+ final SyndFeed feed = feedFetcher.retrieveFeed(new URL("http://localhost:" + testPort + "/rome/FetcherTestServlet?gzipfeed=TRUE"));
+ assertNotNull(feed);
+ assertEquals("atom_1.0.feed.title", feed.getTitle());
+ } catch (final Exception e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+ }
+
+ public void testPreserveWireFeed() throws Exception {
+ final FeedFetcher feedFetcher = getFeedFetcher();
+
+ // first check we the WireFeed is not preserved by default
+ SyndFeed feed = feedFetcher.retrieveFeed(new URL("http://localhost:" + testPort + "/rome/FetcherTestServlet/"));
+ assertNotNull(feed);
+ assertEquals("atom_1.0.feed.title", feed.getTitle());
+ assertNull(feed.originalWireFeed());
+
+ SyndEntry syndEntry = feed.getEntries().get(0);
+ assertNotNull(syndEntry);
+ assertNull(syndEntry.getWireEntry());
+
+ // now turn on WireFeed preservation
+ feedFetcher.setPreserveWireFeed(true);
+ try {
+ feed = feedFetcher.retrieveFeed(new URL("http://localhost:" + testPort + "/rome/FetcherTestServlet/"));
+ assertNotNull(feed);
+ assertEquals("atom_1.0.feed.title", feed.getTitle());
+ assertNotNull(feed.originalWireFeed());
+
+ syndEntry = feed.getEntries().get(0);
+ assertNotNull(syndEntry);
+ assertNotNull(syndEntry.getWireEntry());
+
+ final Entry entry = (Entry) syndEntry.getWireEntry();
+ assertEquals("atom_1.0.feed.entry[0].rights", entry.getRights());
+
+ } finally {
+ feedFetcher.setPreserveWireFeed(false); // reset
+ }
+
+ }
+
+ public void testDeltaEncoding() {
+ final FeedFetcherCache feedInfoCache = new HashMapFeedInfoCache();
+ final FeedFetcher feedFetcher = getFeedFetcher(feedInfoCache);
+ try {
+ feedFetcher.setUsingDeltaEncoding(true);
+
+ // first retrieval should just grab the default feed
+ final SyndFeed feed1 = feedFetcher.retrieveFeed(new URL("http://localhost:" + testPort
+ + "/rome/FetcherTestServlet?deltaencode=TRUE&refreshfeed=TRUE"));
+ assertNotNull(feed1);
+ assertEquals("atom_1.0.feed.title", feed1.getTitle());
+ assertEquals(2, feed1.getEntries().size());
+ SyndEntry entry1 = feed1.getEntries().get(0);
+ assertEquals("atom_1.0.feed.entry[0].title", entry1.getTitle());
+
+ // second retrieval should get only the new item
+ /*
+ * This is breaking with Rome 0.5 ??
+ */
+ final SyndFeed feed2 = feedFetcher.retrieveFeed(new URL("http://localhost:" + testPort
+ + "/rome/FetcherTestServlet?deltaencode=TRUE&refreshfeed=TRUE"));
+ assertNotNull(feed2);
+ assertEquals(FetcherTestServlet.DELTA_FEED_TITLE, feed2.getTitle());
+ assertEquals(3, feed2.getEntries().size());
+ entry1 = feed2.getEntries().get(0);
+ assertEquals(FetcherTestServlet.DELTA_FEED_ENTRY_TITLE, entry1.getTitle());
+
+ final SyndEntry entry2 = feed2.getEntries().get(1);
+ assertEquals("atom_1.0.feed.entry[0].title", entry2.getTitle());
+
+ } catch (final Exception e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+ }
+
+}
diff --git a/rome-fetcher/src/test/java/com/rometools/fetcher/FetcherTestServlet.java b/rome-fetcher/src/test/java/com/rometools/fetcher/FetcherTestServlet.java
new file mode 100644
index 0000000..c967517
--- /dev/null
+++ b/rome-fetcher/src/test/java/com/rometools/fetcher/FetcherTestServlet.java
@@ -0,0 +1,248 @@
+/*
+ * Copyright 2004 Sun Microsystems, Inc.
+ *
+ * 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 com.rometools.fetcher;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.zip.GZIPOutputStream;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import com.rometools.rome.feed.synd.SyndContent;
+import com.rometools.rome.feed.synd.SyndContentImpl;
+import com.rometools.rome.feed.synd.SyndEntry;
+import com.rometools.rome.feed.synd.SyndEntryImpl;
+import com.rometools.rome.feed.synd.SyndFeed;
+import com.rometools.rome.feed.synd.SyndFeedImpl;
+import com.rometools.rome.io.FeedException;
+import com.rometools.rome.io.SyndFeedOutput;
+
+public class FetcherTestServlet extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ public static final String ETAG_1 = "ETAG-1";
+ public static final String ETAG_2 = "ETAG-2";
+
+ public static final String DELTA_FEED_TITLE = "Delta Encoded Feed";
+ public static final String DELTA_FEED_ENTRY_TITLE = "Delta Encoded Feed Entry";
+
+ public static final String SERVLET_MAPPING = "/FetcherTestServlet/*";
+ public static final String SERVLET_MAPPING2 = "/FetcherTestServlet2/*";
+
+ /**
+ * @throws IOException
+ * @throws
+ * @see javax.servlet.http.HttpServlet#doGet(javax.servlet.http.HttpServletRequest,
+ * javax.servlet.http.HttpServletResponse)
+ */
+ @Override
+ protected void doGet(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException {
+
+ if ("TRUE".equalsIgnoreCase(request.getParameter("redirect"))) {
+ // testing redirection support
+ response.sendRedirect("/rome/FetcherTestServlet2/");
+ return;
+ } else if (request.getParameter("error") != null) {
+ // response.sendError(HttpServletResponse.SC_NOT_FOUND);
+ final int errorToThrow = Integer.parseInt(request.getParameter("error"));
+ response.sendError(errorToThrow);
+ return;
+ } else {
+
+ // We manually set the date headers using strings
+ // instead of the get/setDateHeader methods because
+ // those methods return longs, which has too much
+ // precision for the real date headers
+ // this is just a random date
+ String lastModifiedDate = "Thu, 08 Jan 2009 23:06:39 GMT";
+ String eTag = ETAG_1;
+
+ if ("TRUE".equalsIgnoreCase(request.getParameter("refreshfeed"))) {
+ lastModifiedDate = "Fri, 09 Jan 2009 12:06:39 GMT";
+ eTag = ETAG_2;
+ }
+
+ final boolean serveFeed = checkModified(request, lastModifiedDate, eTag) || "TRUE".equalsIgnoreCase(request.getParameter("deltaencode"));
+ final boolean gzip = "TRUE".equalsIgnoreCase(request.getParameter("gzipfeed"));
+
+ if (serveFeed) {
+ final String aimHeader = request.getHeader("A-IM");
+ final boolean serveDeltaEncodedFeed = aimHeader != null && aimHeader.indexOf("feed") >= 0
+ && "TRUE".equalsIgnoreCase(request.getParameter("deltaencode"));
+ if (serveDeltaEncodedFeed) {
+ try {
+ sendDeltaEncodedData(response, lastModifiedDate, request.getHeader("If-None-Match"), eTag, gzip);
+ } catch (final FeedException e) {
+ throw new ServletException(e);
+ }
+ } else {
+ sendFeedData(response, lastModifiedDate, eTag, gzip);
+ }
+ return;
+ } else {
+ response.sendError(HttpServletResponse.SC_NOT_MODIFIED);
+ return;
+ }
+ }
+ }
+
+ private boolean checkModified(final HttpServletRequest request, final String lastModifiedDate, final String eTag) {
+
+ final String requestedETag = request.getHeader("If-None-Match");
+ final String requestedLastModified = request.getHeader("If-Modified-Since");
+ boolean modified = true;
+ boolean mustServer = false;
+ if (requestedETag != null) {
+ if (eTag.equals(requestedETag)) {
+ modified = false;
+ } else {
+ modified = true;
+ mustServer = true;
+ }
+ }
+ if (requestedLastModified != null) {
+ if (lastModifiedDate.equals(requestedLastModified)) {
+ modified = false;
+ } else {
+ modified = true;
+ mustServer = true;
+ }
+ }
+ final boolean serveFeed = modified || mustServer;
+ return serveFeed;
+ }
+
+ /**
+ * @param request
+ * @param lastModifiedDate
+ * @param tag
+ * @param gzip
+ * @throws IOException
+ * @throws FeedException
+ */
+ private void sendDeltaEncodedData(final HttpServletResponse response, final String lastModifiedDate, final String requestedETag, final String responseETag,
+ final boolean gzip) throws IOException, FeedException {
+ if (ETAG_1.equals(requestedETag) || ETAG_2.equals(requestedETag)) {
+ OutputStream out = null;
+ if (gzip) {
+ response.setHeader("Content-Encoding", "gzip");
+ out = new GZIPOutputStream(response.getOutputStream());
+ } else {
+ out = response.getOutputStream();
+ }
+
+ response.setContentType("text/xml");
+ response.setStatus(226);
+ if (gzip) {
+ response.setHeader("IM", "feed, gzip");
+ } else {
+ response.setHeader("IM", "feed");
+ }
+
+ if (responseETag != null) {
+ response.setHeader("ETag", responseETag);
+ }
+ if (lastModifiedDate != null) {
+ response.setHeader("Last-Modified", lastModifiedDate);
+ }
+
+ final SyndFeed feed = new SyndFeedImpl();
+ feed.setFeedType("atom_1.0");
+
+ feed.setTitle(DELTA_FEED_TITLE);
+ feed.setLink("http://rome.dev.java.net");
+ feed.setDescription("This tests using rfc3229 delta encoding.");
+
+ final List entries = new ArrayList();
+ SyndEntry entry;
+ SyndContent description;
+
+ entry = new SyndEntryImpl();
+ entry.setTitle(DELTA_FEED_ENTRY_TITLE);
+ entry.setLink("http://bobwyman.pubsub.com/main/2004/09/using_rfc3229_w.html");
+ try {
+ final DateFormat dateParser = new SimpleDateFormat("yyyy-MM-dd");
+ entry.setPublishedDate(dateParser.parse("2004-11-25"));
+ } catch (final ParseException ex) {
+ //
+ }
+ description = new SyndContentImpl();
+ description.setType("text/plain");
+ description.setValue("Test for RFC3229 Delta Encoding");
+ entry.setDescription(description);
+ entries.add(entry);
+
+ feed.setEntries(entries);
+
+ final SyndFeedOutput output = new SyndFeedOutput();
+ output.output(feed, new OutputStreamWriter(out));
+ } else {
+ sendFeedData(response, lastModifiedDate, responseETag, gzip);
+ }
+ }
+
+ private void sendFeedData(final HttpServletResponse response, final String lastModifiedDate, final String eTag, final boolean gzip) throws IOException {
+ OutputStream out = null;
+ if (gzip) {
+ response.setHeader("Content-Encoding", "gzip");
+ out = new GZIPOutputStream(response.getOutputStream());
+ } else {
+ out = response.getOutputStream();
+ }
+
+ response.setContentType("text/xml");
+ if (eTag != null) {
+ response.setHeader("ETag", eTag);
+ }
+ if (lastModifiedDate != null) {
+ response.setHeader("Last-Modified", lastModifiedDate);
+ }
+
+ InputStream inputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream("/atom_1.0.xml");
+ if (inputStream == null) {
+ inputStream = this.getClass().getResourceAsStream("/atom_1.0.xml");
+ }
+
+ final BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
+ try {
+ String line;
+ while ((line = reader.readLine()) != null) {
+ out.write(line.getBytes());
+ line = null;
+ }
+ } finally {
+ if (reader != null) {
+ reader.close();
+ }
+ }
+
+ out.close();
+ }
+}
diff --git a/rome-fetcher/src/test/java/com/rometools/fetcher/TestBasicAuthenticator.java b/rome-fetcher/src/test/java/com/rometools/fetcher/TestBasicAuthenticator.java
new file mode 100644
index 0000000..355dd4b
--- /dev/null
+++ b/rome-fetcher/src/test/java/com/rometools/fetcher/TestBasicAuthenticator.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2004 Sun Microsystems, Inc.
+ *
+ * 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 com.rometools.fetcher;
+
+import java.net.Authenticator;
+import java.net.PasswordAuthentication;
+
+/**
+ * @author nl
+ */
+public class TestBasicAuthenticator extends Authenticator {
+
+ /**
+ * @see java.net.Authenticator#getPasswordAuthentication()
+ */
+ @Override
+ protected PasswordAuthentication getPasswordAuthentication() {
+ if ("localhost".equals(getRequestingHost())) {
+ return new PasswordAuthentication("username", "password".toCharArray());
+ } else {
+ return null;
+ }
+ }
+}
diff --git a/rome-fetcher/src/test/java/com/rometools/fetcher/impl/DiskFeedInfoCacheTest.java b/rome-fetcher/src/test/java/com/rometools/fetcher/impl/DiskFeedInfoCacheTest.java
new file mode 100644
index 0000000..59b17bc
--- /dev/null
+++ b/rome-fetcher/src/test/java/com/rometools/fetcher/impl/DiskFeedInfoCacheTest.java
@@ -0,0 +1,44 @@
+package com.rometools.fetcher.impl;
+
+import java.io.File;
+import java.net.URL;
+
+import junit.framework.TestCase;
+
+import com.rometools.fetcher.impl.DiskFeedInfoCache;
+import com.rometools.fetcher.impl.SyndFeedInfo;
+
+public class DiskFeedInfoCacheTest extends TestCase {
+
+ public void testClear() throws Exception {
+ final File cacheDir = new File("test-cache");
+ cacheDir.mkdir();
+ cacheDir.deleteOnExit();
+
+ final DiskFeedInfoCache cache = new DiskFeedInfoCache(cacheDir.getCanonicalPath());
+ final SyndFeedInfo info = new SyndFeedInfo();
+ final URL url = new URL("http://nowhere.com");
+ cache.setFeedInfo(url, info);
+
+ cache.clear();
+ final Object returned = cache.getFeedInfo(url);
+ assertTrue(returned == null);
+ }
+
+ public void testRemove() throws Exception {
+ final File cacheDir = new File("test-cache");
+ cacheDir.mkdir();
+ cacheDir.deleteOnExit();
+
+ final DiskFeedInfoCache cache = new DiskFeedInfoCache(cacheDir.getCanonicalPath());
+ final SyndFeedInfo info = new SyndFeedInfo();
+ final URL url = new URL("http://nowhere.com");
+ cache.setFeedInfo(url, info);
+
+ final SyndFeedInfo removedInfo = cache.remove(url);
+ assertTrue(removedInfo.equals(info));
+ final SyndFeedInfo shouldBeNull = cache.remove(url);
+ assertTrue(null == shouldBeNull);
+ }
+
+}
diff --git a/rome-fetcher/src/test/java/com/rometools/fetcher/impl/HashMapFeedInfoCacheTest.java b/rome-fetcher/src/test/java/com/rometools/fetcher/impl/HashMapFeedInfoCacheTest.java
new file mode 100644
index 0000000..1ab7878
--- /dev/null
+++ b/rome-fetcher/src/test/java/com/rometools/fetcher/impl/HashMapFeedInfoCacheTest.java
@@ -0,0 +1,42 @@
+package com.rometools.fetcher.impl;
+
+import java.net.URL;
+
+import junit.framework.TestCase;
+
+import com.rometools.fetcher.impl.HashMapFeedInfoCache;
+import com.rometools.fetcher.impl.SyndFeedInfo;
+
+public class HashMapFeedInfoCacheTest extends TestCase {
+
+ public void testRemove() throws Exception {
+ final HashMapFeedInfoCache cache = new HashMapFeedInfoCache();
+ assertNotNull(cache);
+
+ final URL url = new URL("http://foo.com");
+ final SyndFeedInfo syndFeedInfo = new SyndFeedInfo();
+ syndFeedInfo.setUrl(url);
+ cache.setFeedInfo(url, syndFeedInfo);
+
+ final SyndFeedInfo returned = cache.remove(url);
+ assertTrue(returned.equals(syndFeedInfo));
+ assertTrue(url.equals(returned.getUrl()));
+ }
+
+ public void testClear() throws Exception {
+ final HashMapFeedInfoCache cache = new HashMapFeedInfoCache();
+ assertNotNull(cache);
+
+ final URL url = new URL("http://foo.com");
+ final SyndFeedInfo syndFeedInfo = new SyndFeedInfo();
+ syndFeedInfo.setUrl(url);
+ cache.setFeedInfo(url, syndFeedInfo);
+
+ // clear it
+ cache.clear();
+
+ // we should not get a result back
+ final Object returned = cache.getFeedInfo(url);
+ assertTrue(returned == null);
+ }
+}
diff --git a/rome-fetcher/src/test/java/com/rometools/fetcher/impl/HttpClientFeedFetcherTest.java b/rome-fetcher/src/test/java/com/rometools/fetcher/impl/HttpClientFeedFetcherTest.java
new file mode 100644
index 0000000..c64339b
--- /dev/null
+++ b/rome-fetcher/src/test/java/com/rometools/fetcher/impl/HttpClientFeedFetcherTest.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2004 Sun Microsystems, Inc.
+ *
+ * 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 com.rometools.fetcher.impl;
+
+import org.apache.commons.httpclient.Credentials;
+import org.apache.commons.httpclient.UsernamePasswordCredentials;
+
+import com.rometools.fetcher.AbstractJettyTest;
+import com.rometools.fetcher.FeedFetcher;
+import com.rometools.fetcher.impl.FeedFetcherCache;
+import com.rometools.fetcher.impl.HttpClientFeedFetcher;
+
+/**
+ * @author Nick Lothian
+ */
+public class HttpClientFeedFetcherTest extends AbstractJettyTest {
+
+ public HttpClientFeedFetcherTest(final String s) {
+ super(s);
+ }
+
+ /**
+ * @see com.rometools.rome.fetcher.impl.AbstractJettyTest#getFeedFetcher()
+ */
+ @Override
+ protected FeedFetcher getFeedFetcher() {
+ return new HttpClientFeedFetcher();
+ }
+
+ @Override
+ protected FeedFetcher getFeedFetcher(final FeedFetcherCache cache) {
+ return new HttpClientFeedFetcher(cache);
+ }
+
+ /**
+ * @see com.rometools.rome.fetcher.impl.AbstractJettyTest#getAuthenticatedFeedFetcher()
+ */
+ @Override
+ public FeedFetcher getAuthenticatedFeedFetcher() {
+ return new HttpClientFeedFetcher(null, new HttpClientFeedFetcher.CredentialSupplier() {
+ @Override
+ public Credentials getCredentials(final String realm, final String host) {
+ if ("localhost".equals(host)) {
+ return new UsernamePasswordCredentials("username", "password");
+ } else {
+ return null;
+ }
+ }
+ });
+ }
+}
diff --git a/rome-fetcher/src/test/java/com/rometools/fetcher/impl/HttpURLFeedFetcherTest.java b/rome-fetcher/src/test/java/com/rometools/fetcher/impl/HttpURLFeedFetcherTest.java
new file mode 100644
index 0000000..c0ba1fe
--- /dev/null
+++ b/rome-fetcher/src/test/java/com/rometools/fetcher/impl/HttpURLFeedFetcherTest.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2004 Sun Microsystems, Inc.
+ *
+ * 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 com.rometools.fetcher.impl;
+
+import com.rometools.fetcher.AbstractJettyTest;
+import com.rometools.fetcher.FeedFetcher;
+import com.rometools.fetcher.TestBasicAuthenticator;
+import com.rometools.fetcher.impl.FeedFetcherCache;
+import com.rometools.fetcher.impl.HttpURLFeedFetcher;
+
+public class HttpURLFeedFetcherTest extends AbstractJettyTest {
+
+ public HttpURLFeedFetcherTest(final String s) {
+ super(s);
+ }
+
+ /**
+ * @see com.rometools.rome.fetcher.impl.AbstractJettyTest#getFeedFetcher()
+ */
+ @Override
+ protected FeedFetcher getFeedFetcher() {
+ return new HttpURLFeedFetcher();
+ }
+
+ @Override
+ protected FeedFetcher getFeedFetcher(final FeedFetcherCache cache) {
+ return new HttpURLFeedFetcher(cache);
+ }
+
+ /**
+ * @see com.rometools.rome.fetcher.impl.AbstractJettyTest#getAuthenticatedFeedFetcher()
+ */
+ @Override
+ public FeedFetcher getAuthenticatedFeedFetcher() {
+ // setup the authenticator
+ java.net.Authenticator.setDefault(new TestBasicAuthenticator());
+
+ final FeedFetcher feedFetcher = getFeedFetcher();
+
+ return feedFetcher;
+ }
+
+}
diff --git a/rome-fetcher/src/test/java/com/rometools/fetcher/impl/ResponseHandlerTest.java b/rome-fetcher/src/test/java/com/rometools/fetcher/impl/ResponseHandlerTest.java
new file mode 100644
index 0000000..71bfb4f
--- /dev/null
+++ b/rome-fetcher/src/test/java/com/rometools/fetcher/impl/ResponseHandlerTest.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2004 Sun Microsystems, Inc.
+ *
+ * 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 com.rometools.fetcher.impl;
+
+import junit.framework.TestCase;
+
+import com.rometools.fetcher.impl.ResponseHandler;
+
+public class ResponseHandlerTest extends TestCase {
+
+ /**
+ * Constructor for ResponseHandlerTest.
+ */
+ public ResponseHandlerTest(final String arg0) {
+ super(arg0);
+ }
+
+ public void testGetCharacterEncodingString() {
+ assertEquals(ResponseHandler.defaultCharacterEncoding, ResponseHandler.getCharacterEncoding((String) null));
+ assertEquals(ResponseHandler.defaultCharacterEncoding, ResponseHandler.getCharacterEncoding("text/xml"));
+ assertEquals(ResponseHandler.defaultCharacterEncoding, ResponseHandler.getCharacterEncoding("text/xml;"));
+ assertEquals("ISO-8859-4", ResponseHandler.getCharacterEncoding("text/xml; charset=ISO-8859-4"));
+ assertEquals("ISO-8859-4", ResponseHandler.getCharacterEncoding("text/xml;charset=ISO-8859-4"));
+ assertEquals("ISO-8859-4", ResponseHandler.getCharacterEncoding("text/xml;charset=ISO-8859-4;something"));
+ assertEquals(ResponseHandler.defaultCharacterEncoding, ResponseHandler.getCharacterEncoding("text/xml;something"));
+ }
+
+}
diff --git a/rome-fetcher/src/test/java/com/rometools/fetcher/samples/FeedAggregator.java b/rome-fetcher/src/test/java/com/rometools/fetcher/samples/FeedAggregator.java
new file mode 100644
index 0000000..32b7907
--- /dev/null
+++ b/rome-fetcher/src/test/java/com/rometools/fetcher/samples/FeedAggregator.java
@@ -0,0 +1,102 @@
+/*
+ * Copyright 2004 Sun Microsystems, Inc.
+ *
+ * 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 com.rometools.fetcher.samples;
+
+import java.io.PrintWriter;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+
+import com.rometools.fetcher.FeedFetcher;
+import com.rometools.fetcher.impl.FeedFetcherCache;
+import com.rometools.fetcher.impl.HashMapFeedInfoCache;
+import com.rometools.fetcher.impl.HttpURLFeedFetcher;
+import com.rometools.rome.feed.synd.SyndEntry;
+import com.rometools.rome.feed.synd.SyndFeed;
+import com.rometools.rome.feed.synd.SyndFeedImpl;
+import com.rometools.rome.io.SyndFeedOutput;
+
+/**
+ *
+ * It aggregates a list of RSS/Atom feeds (they can be of different types) into a single feed of the
+ * specified type.
+ *
+ *
+ *
+ * Converted from the original FeedAggregator sample
+ *
+ *
+ * @author Alejandro Abdelnur
+ * @author Nick Lothian
+ *
+ */
+public class FeedAggregator {
+
+ public static void main(final String[] args) {
+
+ boolean ok = false;
+
+ if (args.length >= 2) {
+
+ try {
+
+ final String outputType = args[0];
+
+ final SyndFeed feed = new SyndFeedImpl();
+ feed.setFeedType(outputType);
+
+ feed.setTitle("Aggregated Feed");
+ feed.setDescription("Anonymous Aggregated Feed");
+ feed.setAuthor("anonymous");
+ feed.setLink("http://www.anonymous.com");
+
+ final List entries = new ArrayList();
+ feed.setEntries(entries);
+
+ final FeedFetcherCache feedInfoCache = HashMapFeedInfoCache.getInstance();
+ final FeedFetcher feedFetcher = new HttpURLFeedFetcher(feedInfoCache);
+
+ for (int i = 1; i < args.length; i++) {
+ final URL inputUrl = new URL(args[i]);
+ final SyndFeed inFeed = feedFetcher.retrieveFeed(inputUrl);
+ entries.addAll(inFeed.getEntries());
+ }
+
+ final SyndFeedOutput output = new SyndFeedOutput();
+ output.output(feed, new PrintWriter(System.out));
+
+ ok = true;
+
+ } catch (final Exception ex) {
+ System.out.println("ERROR: " + ex.getMessage());
+ ex.printStackTrace();
+ }
+
+ }
+
+ if (!ok) {
+ System.out.println();
+ System.out.println("FeedAggregator aggregates different feeds into a single one.");
+ System.out.println("The first parameter must be the feed type for the aggregated feed.");
+ System.out.println(" [valid values are: rss_0.9, rss_0.91, rss_0.92, rss_0.93, ]");
+ System.out.println(" [ rss_0.94, rss_1.0, rss_2.0 & atom_0.3 ]");
+ System.out.println("The second to last parameters are the URLs of feeds to aggregate.");
+ System.out.println();
+ }
+ }
+
+}
diff --git a/rome-fetcher/src/test/java/com/rometools/fetcher/samples/FeedReader.java b/rome-fetcher/src/test/java/com/rometools/fetcher/samples/FeedReader.java
new file mode 100644
index 0000000..54d4be7
--- /dev/null
+++ b/rome-fetcher/src/test/java/com/rometools/fetcher/samples/FeedReader.java
@@ -0,0 +1,104 @@
+/*
+ * Copyright 2004 Sun Microsystems, Inc.
+ *
+ * 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 com.rometools.fetcher.samples;
+
+import java.net.URL;
+
+import com.rometools.fetcher.FeedFetcher;
+import com.rometools.fetcher.FetcherEvent;
+import com.rometools.fetcher.FetcherListener;
+import com.rometools.fetcher.impl.FeedFetcherCache;
+import com.rometools.fetcher.impl.HashMapFeedInfoCache;
+import com.rometools.fetcher.impl.HttpURLFeedFetcher;
+import com.rometools.rome.feed.synd.SyndFeed;
+
+/**
+ * Reads and prints any RSS/Atom feed type. Converted from the original Rome sample FeedReader
+ *
+ *
+ * @author Alejandro Abdelnur
+ * @author Nick Lothian
+ *
+ */
+public class FeedReader {
+
+ public static void main(final String[] args) {
+
+ boolean ok = false;
+
+ if (args.length == 1) {
+
+ try {
+ final URL feedUrl = new URL(args[0]);
+ final FeedFetcherCache feedInfoCache = HashMapFeedInfoCache.getInstance();
+ final FeedFetcher fetcher = new HttpURLFeedFetcher(feedInfoCache);
+
+ final FetcherEventListenerImpl listener = new FetcherEventListenerImpl();
+
+ fetcher.addFetcherEventListener(listener);
+
+ System.err.println("Retrieving feed " + feedUrl);
+ // Retrieve the feed.
+ // We will get a Feed Polled Event and then a
+ // Feed Retrieved event (assuming the feed is valid)
+ final SyndFeed feed = fetcher.retrieveFeed(feedUrl);
+
+ System.err.println(feedUrl + " retrieved");
+ System.err.println(feedUrl + " has a title: " + feed.getTitle() + " and contains " + feed.getEntries().size() + " entries.");
+ // We will now retrieve the feed again. If the feed is unmodified
+ // and the server supports conditional gets, we will get a "Feed
+ // Unchanged" event after the Feed Polled event
+ System.err.println("Polling " + feedUrl + " again to test conditional get support.");
+ fetcher.retrieveFeed(feedUrl);
+ System.err.println("If a \"Feed Unchanged\" event fired then the server supports conditional gets.");
+
+ ok = true;
+
+ } catch (final Exception ex) {
+ System.out.println("ERROR: " + ex.getMessage());
+ ex.printStackTrace();
+ }
+
+ }
+
+ if (!ok) {
+ System.out.println();
+ System.out.println("FeedReader reads and prints any RSS/Atom feed type.");
+ System.out.println("The first parameter must be the URL of the feed to read.");
+ System.out.println();
+ }
+
+ }
+
+ static class FetcherEventListenerImpl implements FetcherListener {
+ /**
+ * @see com.rometools.rome.fetcher.FetcherListener#fetcherEvent(com.rometools.rome.fetcher.FetcherEvent)
+ */
+ @Override
+ public void fetcherEvent(final FetcherEvent event) {
+ final String eventType = event.getEventType();
+ if (FetcherEvent.EVENT_TYPE_FEED_POLLED.equals(eventType)) {
+ System.err.println("\tEVENT: Feed Polled. URL = " + event.getUrlString());
+ } else if (FetcherEvent.EVENT_TYPE_FEED_RETRIEVED.equals(eventType)) {
+ System.err.println("\tEVENT: Feed Retrieved. URL = " + event.getUrlString());
+ } else if (FetcherEvent.EVENT_TYPE_FEED_UNCHANGED.equals(eventType)) {
+ System.err.println("\tEVENT: Feed Unchanged. URL = " + event.getUrlString());
+ }
+ }
+ }
+}
diff --git a/src/test/data/atom_1.0.xml b/rome-fetcher/src/test/resources/atom_1.0.xml
similarity index 100%
rename from src/test/data/atom_1.0.xml
rename to rome-fetcher/src/test/resources/atom_1.0.xml
diff --git a/rome-fetcher/src/test/resources/logback-test.xml b/rome-fetcher/src/test/resources/logback-test.xml
new file mode 100644
index 0000000..c34b099
--- /dev/null
+++ b/rome-fetcher/src/test/resources/logback-test.xml
@@ -0,0 +1,13 @@
+
+
+
+
+ %d{HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/rome-fetcher/src/test/resources/testuser.properties b/rome-fetcher/src/test/resources/testuser.properties
new file mode 100644
index 0000000..28bc8e6
--- /dev/null
+++ b/rome-fetcher/src/test/resources/testuser.properties
@@ -0,0 +1 @@
+username: password
diff --git a/rome-modules/.gitignore b/rome-modules/.gitignore
new file mode 100644
index 0000000..998692d
--- /dev/null
+++ b/rome-modules/.gitignore
@@ -0,0 +1,5 @@
+/.classpath
+/.project
+/.settings
+/target
+/.checkstyle
diff --git a/rome-modules/LICENSE b/rome-modules/LICENSE
new file mode 100644
index 0000000..7a4a3ea
--- /dev/null
+++ b/rome-modules/LICENSE
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ 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.
\ No newline at end of file
diff --git a/rome-modules/README.md b/rome-modules/README.md
new file mode 100644
index 0000000..8504b20
--- /dev/null
+++ b/rome-modules/README.md
@@ -0,0 +1,6 @@
+rome
+====
+
+ROME is a set of RSS and Atom Utilities for Java. It makes it easy to work in Java with most syndication formats: RSS 0.90, RSS 0.91 Netscape, RSS 0.91 Userland, RSS 0.92, RSS 0.93, RSS 0.94, RSS 1.0, RSS 2.0, Atom 0.3, Atom 1.0
+
+More Information: http://rometools.github.io/rome-modules/
diff --git a/rome-modules/pom.xml b/rome-modules/pom.xml
new file mode 100644
index 0000000..d49ed96
--- /dev/null
+++ b/rome-modules/pom.xml
@@ -0,0 +1,119 @@
+
+
+ 4.0.0
+
+
+ com.rometools
+ rome-parent
+ 1.6.0-SNAPSHOT
+
+
+ rome-modules
+ 1.6.0-SNAPSHOT
+ jar
+
+ rome-modules
+
+ Plugin collection for the ROME RSS and Atom Utilities
+
+ http://rometools.github.io/rome-modules/
+
+
+ scm:git:ssh://github.com/rometools/rome-modules.git
+ scm:git:ssh://git@github.com/rometools/rome-modules.git
+ https://github.com/rometools/rome-modules
+
+
+
+
+ kebernet
+ kebernet@gmail.com
+ Robert Cooper
+
+
+
+
+
+ sonatype-nexus-snapshots
+ https://oss.sonatype.org/content/repositories/snapshots
+
+ false
+
+
+ true
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-scm-publish-plugin
+
+ gh-pages
+ ${project.scm.developerConnection}
+ ${project.build.directory}/site
+
+
+
+ org.apache.felix
+ maven-bundle-plugin
+
+
+
+ !com.rometools.modules.*.io,
+ com.rometools.modules.*,
+
+
+ org.jdom2,
+ org.jdom2.filter,
+ org.jdom2.input,
+ org.jdom2.input.sax,
+ org.jdom2.output,
+ org.slf4j,
+ org.w3c.dom,
+ org.xml.sax
+
+ <_exportcontents>
+ com.rometools.rome.feed,
+ com.rometools.rome.feed.atom,
+ com.rometools.rome.feed.module,
+ com.rometools.rome.feed.rss,
+ com.rometools.rome.feed.synd,
+ com.rometools.rome.io,
+ com.rometools.utils
+
+ *;artifactId=rome|rome-utils
+ true
+
+
+
+
+
+
+
+
+ com.rometools
+ rome
+ 1.6.0-SNAPSHOT
+
+
+ ch.qos.logback
+ logback-classic
+ test
+
+
+ junit
+ junit
+ test
+
+
+ org.hamcrest
+ hamcrest-library
+ test
+
+
+
+
diff --git a/rome-modules/src/main/etc/header.txt b/rome-modules/src/main/etc/header.txt
new file mode 100644
index 0000000..09cdc51
--- /dev/null
+++ b/rome-modules/src/main/etc/header.txt
@@ -0,0 +1,17 @@
+/*
+ * Copyright (C) The ROME Team ${year}
+ *
+ *
+ * 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.
+ *
+ */
\ No newline at end of file
diff --git a/rome-modules/src/main/java/com/rometools/modules/activitystreams/ActivityStreamModule.java b/rome-modules/src/main/java/com/rometools/modules/activitystreams/ActivityStreamModule.java
new file mode 100644
index 0000000..e4b0f4c
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/activitystreams/ActivityStreamModule.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2011 robert.cooper.
+ *
+ * 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.
+ * under the License.
+ */
+
+package com.rometools.modules.activitystreams;
+
+import com.rometools.modules.activitystreams.types.ActivityObject;
+import com.rometools.modules.activitystreams.types.Mood;
+import com.rometools.modules.activitystreams.types.Verb;
+
+/**
+ *
+ * @author robert.cooper
+ */
+public interface ActivityStreamModule {
+
+ public Verb getVerb();
+
+ public void setVerb(Verb verb);
+
+ public ActivityObject getObject();
+
+ public void setObject(ActivityObject object);
+
+ public ActivityObject getTarget();
+
+ public void setTarget(ActivityObject object);
+
+ public Mood getMood();
+
+ public void setMood(Mood mood);
+
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/activitystreams/ActivityStreamModuleImpl.java b/rome-modules/src/main/java/com/rometools/modules/activitystreams/ActivityStreamModuleImpl.java
new file mode 100644
index 0000000..797ed63
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/activitystreams/ActivityStreamModuleImpl.java
@@ -0,0 +1,90 @@
+/*
+ * Copyright 2011 robert.cooper.
+ *
+ * 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.
+ * under the License.
+ */
+package com.rometools.modules.activitystreams;
+
+import com.rometools.modules.activitystreams.types.ActivityObject;
+import com.rometools.modules.activitystreams.types.Mood;
+import com.rometools.modules.activitystreams.types.Verb;
+
+/**
+ *
+ * @author robert.cooper
+ */
+public class ActivityStreamModuleImpl implements ActivityStreamModule {
+ private ActivityObject object;
+ private Verb verb;
+
+ /**
+ * Set the value of object
+ *
+ * @param newobject new value of object
+ */
+ @Override
+ public void setObject(final ActivityObject newobject) {
+ object = newobject;
+ }
+
+ /**
+ * Get the value of object
+ *
+ * @return the value of object
+ */
+ @Override
+ public ActivityObject getObject() {
+ return object;
+ }
+
+ /**
+ * Set the value of verb
+ *
+ * @param newverb new value of verb
+ */
+ @Override
+ public void setVerb(final Verb newverb) {
+ verb = newverb;
+ }
+
+ /**
+ * Get the value of verb
+ *
+ * @return the value of verb
+ */
+ @Override
+ public Verb getVerb() {
+ return verb;
+ }
+
+ @Override
+ public ActivityObject getTarget() {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setTarget(final ActivityObject object) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public Mood getMood() {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setMood(final Mood mood) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/activitystreams/types/ActivityObject.java b/rome-modules/src/main/java/com/rometools/modules/activitystreams/types/ActivityObject.java
new file mode 100644
index 0000000..513e359
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/activitystreams/types/ActivityObject.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2011 robert.cooper.
+ *
+ * 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.
+ * under the License.
+ */
+
+package com.rometools.modules.activitystreams.types;
+
+import com.rometools.modules.georss.GeoRSSModule;
+import com.rometools.modules.portablecontacts.ContactModule;
+import com.rometools.rome.feed.atom.Entry;
+
+/**
+ *
+ * @author robert.cooper
+ */
+public abstract class ActivityObject extends Entry implements HasLocation {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+ public abstract String getTypeIRI();
+
+ @Override
+ public GeoRSSModule getLocation() {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setLocation(final GeoRSSModule location) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public ContactModule getAddress() {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setAddress(final ContactModule address) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/activitystreams/types/Article.java b/rome-modules/src/main/java/com/rometools/modules/activitystreams/types/Article.java
new file mode 100644
index 0000000..62e139b
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/activitystreams/types/Article.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright 2011 robert.cooper.
+ *
+ * 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.
+ * under the License.
+ */
+package com.rometools.modules.activitystreams.types;
+
+/**
+ *
+ * The "article" Object type indicates that the Object is an article, such as a news article, a
+ * knowledge base entry, or other similar construct.
+ *
+ *
+ * Articles generally consist of paragraphs of text, in some cases incorporating embedded media such
+ * as photos and inline hyperlinks to other resources.
+ *
+ *
+ * The "Article" Object type is identified by the URL
+ * http://activitystrea.ms/schema/1.0/article.
+ *
+ *
+ * An article has the following additional components:
+ *
+ *
+ *
+ *
+ *
+ *
Name
+ *
The title of the article. Represented by the Name component of the base Object Construct.
+ *
Content
+ *
The main body content of the article. Represented in JSON as a property called
+ * content whose value is a JSON string containing a fragment of HTML that represents the
+ * content.
+ *
+ *
+ *
+ * @author robert.cooper
+ */
+public class Article extends ActivityObject {
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public String getTypeIRI() {
+ return "http://activitystrea.ms/schema/1.0/article";
+ }
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/activitystreams/types/Audio.java b/rome-modules/src/main/java/com/rometools/modules/activitystreams/types/Audio.java
new file mode 100644
index 0000000..2fa0a0d
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/activitystreams/types/Audio.java
@@ -0,0 +1,94 @@
+/*
+ * Copyright 2011 robert.cooper.
+ *
+ * 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.
+ * under the License.
+ */
+package com.rometools.modules.activitystreams.types;
+
+/**
+ *
+ * The "audio" Object type represents audio content.
+ *
+ *
+ * The "audio" Object type is identified by the URI
+ * http://activitystrea.ms/schema/1.0/audio.
+ *
+ *
+ * An audio has the following additional components:
+ *
+ *
+ *
+ *
+ *
+ *
Audio Stream Link
+ *
A Media Link Construct linking to the audio content itself. Represented in JSON as a property
+ * called stream whose value is a JSON object with properties as defined in [TODO: xref the
+ * JSON serialization of a Media Link Construct]
+ *
Embed Code
+ *
An HTML fragment that, when embedded in an HTML page, will provide an interactive player UI
+ * for the audio stream. Represented in JSON as a property called embedCode whose value is
+ * a JSON string containing the fragment of HTML.
+ *
+ *
+ * @author robert.cooper
+ */
+public class Audio extends ActivityObject {
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ private String embedCode;
+ private String streamLink;
+
+ /**
+ * Set the value of embedCode
+ *
+ * @param newembedCode new value of embedCode
+ */
+ public void setEmbedCode(final String newembedCode) {
+ embedCode = newembedCode;
+ }
+
+ /**
+ * Get the value of embedCode
+ *
+ * @return the value of embedCode
+ */
+ public String getEmbedCode() {
+ return embedCode;
+ }
+
+ /**
+ * Set the value of streamLink
+ *
+ * @param newstreamLink new value of streamLink
+ */
+ public void setStreamLink(final String newstreamLink) {
+ streamLink = newstreamLink;
+ }
+
+ /**
+ * Get the value of streamLink
+ *
+ * @return the value of streamLink
+ */
+ public String getStreamLink() {
+ return streamLink;
+ }
+
+ @Override
+ public String getTypeIRI() {
+ return "http://activitystrea.ms/schema/1.0/audio";
+ }
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/activitystreams/types/Bookmark.java b/rome-modules/src/main/java/com/rometools/modules/activitystreams/types/Bookmark.java
new file mode 100644
index 0000000..5a229cf
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/activitystreams/types/Bookmark.java
@@ -0,0 +1,117 @@
+/*
+ * Copyright 2011 robert.cooper.
+ *
+ * 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.
+ * under the License.
+ */
+
+package com.rometools.modules.activitystreams.types;
+
+import com.rometools.rome.feed.atom.Link;
+
+/**
+ *
+ * The "bookmark" Object type represents a pointer to some URL -- typically a web page. In most
+ * cases, a bookmark is specific to a given user and contains metadata chosen by that user. Bookmark
+ * Objects are similar in principle to the concept of bookmarks or favorites in a web browser. A
+ * bookmark represents a pointer to the URL, not the URL or the associated resource itself.
+ *
+ *
+ * When dealing with bookmarks it is important to note the distinction between the title,
+ * description, and URL of the bookmark itself and the title, content, and URL of the resource that
+ * is the target of the bookmark. In some implementations these MAY be the same, but bookmark
+ * managers often allow a user to edit the title and description of his or her own bookmarks to
+ * differ from the metadata on the target itself.
+ *
+ *
+ * Some implementations refer to this Object type as a "link". This specification uses the term
+ * "bookmark" to avoid confusion with the general concept of hyperlinks which apply to all Object
+ * types.
+ *
+ *
+ * Since bookmarks are often specific to a particular user, even though multiple users might have
+ * bookmarks pointing at the same resource, it is appropriate to use the "post" Verb to describe the
+ * publication of such a bookmark. The "mark as favorite" Verb SHOULD be used when a user flags
+ * another user's bookmark as being a favorite without creating his own bookmark, or when a user
+ * flags his own bookmark as being a favorite as a special classification within his own bookmark
+ * collection.
+ *
+ *
+ * The "bookmark" Object type is identified by the URI
+ * http://activitystrea.ms/schema/1.0/bookmark.
+ *
+ *
+ * A bookmark has the following additional components:
+ *
+ *
+ *
+ *
+ *
+ *
Title
+ *
The title of the bookmark, as entered by the user who created the bookmark. Represented by
+ * the Name component of the base Object Construct. Publishers MAY use the title of the target
+ * resource as a default for this property where a user hasn't entered a customized value.
+ *
Target URL
+ *
The URL of the item that is the target of the bookmark. Represented in JSON by a property
+ * called targetUrl whose value is a JSON string containing the target URL.
+ *
Thumbnail
+ *
The URL and metadata for a thumbnail version of the page. Represented by the Representative
+ * Image component of the base Object Construct. Processors MAY ignore thumbnails that are of an
+ * inappropriate size for their user interface.
+ *
+ *
+ *
+ * @author robert.cooper
+ */
+public class Bookmark extends ActivityObject {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public String getTypeIRI() {
+ return "http://activitystrea.ms/schema/1.0/bookmark";
+ }
+
+ /**
+ * Get the value of thumbnail
+ *
+ * @return the value of thumbnail
+ */
+ public Link getThumbnail() {
+ return findRelatedLink("thumbnail");
+ }
+
+ /**
+ * Set the value of thumbnail
+ *
+ * @param newthumbnail new value of thumbnail
+ */
+ public void setThumbnail(final Link newthumbnail) {
+ Link old = null;
+ for (final Link l : getOtherLinks()) {
+ if ("thumbnail".equals(l.getRel())) {
+ old = l;
+ break;
+ }
+ }
+ if (old != null) {
+ getOtherLinks().remove(old);
+ newthumbnail.setRel("thumbnail");
+ }
+ getOtherLinks().add(newthumbnail);
+ }
+
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/activitystreams/types/Comment.java b/rome-modules/src/main/java/com/rometools/modules/activitystreams/types/Comment.java
new file mode 100644
index 0000000..7de8614
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/activitystreams/types/Comment.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2011 robert.cooper.
+ *
+ * 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.
+ * under the License.
+ */
+
+package com.rometools.modules.activitystreams.types;
+
+/**
+ *
+ * The "comment" object type represents a textual response to another object.
+ *
+ *
+ * The comment object type MUST NOT be used for other kinds of replies, such as video replies or
+ * reviews.
+ *
+ *
+ * The "comment" object type is identified by the URI
+ * http://activitystrea.ms/schema/1.0/comment.
+ *
+ *
+ * A comment has the following additional components:
+ *
+ *
+ *
+ *
+ *
+ *
Subject
+ *
The subject of the comment. Represented by the Name component of the base Object Construct.
+ * Many systems do not have the concept of a title or subject for a comment; such systems MUST omit
+ * the Name component. Processors SHOULD refer to such comments as simply being "a comment", with
+ * appropriate localization, if they are to be described in a sentence.
+ *
Content
+ *
The content of the comment. Represented in JSON as a property called content whose
+ * value is a JSON string containing a fragment of HTML that represents the content. Publishers
+ * SHOULD include any markup necessary to achieve a similar presentation to that on the publisher's
+ * own HTML pages, including any links that the service automatically adds. Processors MAY remove
+ * all HTML markup and consider the comment to be plain text.
+ *
+ *
+ *
+ * @author robert.cooper
+ */
+public class Comment extends ActivityObject {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public String getTypeIRI() {
+ return "http://activitystrea.ms/schema/1.0/comment";
+ }
+
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/activitystreams/types/Event.java b/rome-modules/src/main/java/com/rometools/modules/activitystreams/types/Event.java
new file mode 100644
index 0000000..f2c1be1
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/activitystreams/types/Event.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2011 robert.cooper.
+ *
+ * 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.
+ * under the License.
+ */
+
+package com.rometools.modules.activitystreams.types;
+
+/**
+ *
+ * The "event" object type represents an event that occurs in a certain place during a particular
+ * interval of time.
+ *
+ *
+ * The object type URL for the "event" object type is
+ * http://activitystrea.ms/schema/1.0/event.
+ *
+ *
+ * An event has the following additional components:
+ *
+ *
+ *
+ *
+ *
+ *
Start Date and Time
+ *
The date and time that the event begins. Represented in JSON as a property called
+ * startTime whose value is JSON string containing a W3CDTF timestamp. [TODO: Reference
+ * W3CDTF spec.] [TODO: Include prose describing how to represent just a date vs. a date and time.]
+ *
End Date and Time
+ *
The date and time that the event ends. Represented in JSON as a property called
+ * endTime whose value is JSON string containing a W3CDTF timestamp. [TODO: Reference
+ * W3CDTF spec.] [TODO: Include prose describing how to represent just a date vs. a date and time.]
+ *
+ *
+ *
+ * @author robert.cooper
+ */
+public class Event extends ActivityObject {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public String getTypeIRI() {
+ return "http://activitystrea.ms/schema/1.0/event";
+ }
+
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/activitystreams/types/File.java b/rome-modules/src/main/java/com/rometools/modules/activitystreams/types/File.java
new file mode 100644
index 0000000..862c2dc
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/activitystreams/types/File.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2011 robert.cooper.
+ *
+ * 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.
+ * under the License.
+ */
+
+package com.rometools.modules.activitystreams.types;
+
+/**
+ *
+ * The "file" Object type represents some document or other file with no additional machine-readable
+ * semantics.
+ *
+ *
+ * It is intended that this type be used as a base type for other Objects that manifest as files, so
+ * that additional semantics can be added while providing a fallback ability for clients that do not
+ * support the more specific Object type.
+ *
+ *
+ * The "file" Object type is identified by the URI http://activitystrea.ms/schema/1.0/file.
+ *
+ *
+ * A file has the following additional components:
+ *
+ *
+ *
+ *
+ *
+ *
Associated File URL
+ *
The URL of the file described by this Object Construct. Represented in JSON by a property
+ * called fileUrl whose value is a JSON string containing the URL.
+ *
File MIME Type
+ *
The MIME type of the file described by this Object Construct. Represented in JSON by a
+ * property called mimeType whose value is a JSON string containing the MIME type.
+ *
+ *
+ *
+ * @author robert.cooper
+ */
+public class File extends ActivityObject {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public String getTypeIRI() {
+ return "http://activitystrea.ms/schema/1.0/file";
+ }
+
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/activitystreams/types/Folder.java b/rome-modules/src/main/java/com/rometools/modules/activitystreams/types/Folder.java
new file mode 100644
index 0000000..2694940
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/activitystreams/types/Folder.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2011 robert.cooper.
+ *
+ * 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.
+ * under the License.
+ */
+
+package com.rometools.modules.activitystreams.types;
+
+/**
+ *
+ * The "folder" object type represents a collection of files or media objects. This is similar to
+ * the "photo album" object type, but not specifically representing a collection of "photos."
+ *
+ *
+ * The "folder" object type is identified by the URI
+ * http://activitystrea.ms/schema/1.0/folder.
+ *
+ *
+ * A folder has the following additional components:
+ *
+ *
+ *
+ *
+ *
+ *
Preview Image Link
+ *
A Media Link Construct describing an image file that can be used as a preview image for the
+ * folder. Represented by the Representative Image component of the base Object Construct.
+ * Processors MAY ignore thumbnails that are of an inappropriate size for their user interface.
+ *
+ *
+ *
+ * @author robert.cooper
+ */
+public class Folder extends ActivityObject {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public String getTypeIRI() {
+ return "http://activitystrea.ms/schema/1.0/folder";
+ }
+
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/activitystreams/types/Group.java b/rome-modules/src/main/java/com/rometools/modules/activitystreams/types/Group.java
new file mode 100644
index 0000000..952e2f0
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/activitystreams/types/Group.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2011 robert.cooper.
+ *
+ * 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.
+ * under the License.
+ */
+
+package com.rometools.modules.activitystreams.types;
+
+/**
+ *
+ * The "group" Object type represents a social networking group. A group is a collection of people
+ * which people can join and leave.
+ *
+ *
+ * The "group" Object type is identified by the URI
+ * http://activitystrea.ms/schema/1.0/group.
+ *
+ *
+ * A group has no additional components.
+ *
+ * @author robert.cooper
+ */
+public class Group {
+
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/activitystreams/types/HasLocation.java b/rome-modules/src/main/java/com/rometools/modules/activitystreams/types/HasLocation.java
new file mode 100644
index 0000000..8b1705c
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/activitystreams/types/HasLocation.java
@@ -0,0 +1,104 @@
+/*
+ * Copyright 2011 robert.cooper.
+ *
+ * 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.
+ * under the License.
+ */
+
+package com.rometools.modules.activitystreams.types;
+
+import com.rometools.modules.georss.GeoRSSModule;
+import com.rometools.modules.portablecontacts.ContactModule;
+
+/**
+ *
+ * Location is a concept which can be used inside the atom:entry level, atom:author and
+ * activity:object. Location can be specified via geographic coordinates, a street address, a
+ * free-form location name or a combination of these. Geographic coordinates should be included as a
+ * geo:point element as described by the GeoRSS specification. Addresses should be included using a
+ * poco:address element defined at Portable Contacts specification. The entry level location
+ * represents the location of the author at the time the activity was performed. The author level
+ * location represents the primary location of the author. Finally, the location within other
+ * objects represents the physical location of those objects. All location fields are optional. For
+ * free form addresses use the poco:formatted field.
+ *
+ *
+ *
+ *
+ *
+ * @author robert.cooper
+ */
+public interface HasLocation {
+
+ public GeoRSSModule getLocation();
+
+ public void setLocation(GeoRSSModule location);
+
+ public ContactModule getAddress();
+
+ public void setAddress(ContactModule address);
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/activitystreams/types/List.java b/rome-modules/src/main/java/com/rometools/modules/activitystreams/types/List.java
new file mode 100644
index 0000000..d2a5010
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/activitystreams/types/List.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2011 robert.cooper.
+ *
+ * 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.
+ * under the License.
+ */
+
+package com.rometools.modules.activitystreams.types;
+
+/**
+ *
+ * The "list" object type represents a collection of related objects.
+ *
+ *
+ * The "list" object type is identified by the URI http://activitystrea.ms/schema/1.0/list.
+ *
+ *
+ * A list has no additional components.
+ *
+ *
+ * @author robert.cooper
+ */
+public class List extends ActivityObject {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public String getTypeIRI() {
+ return "http://activitystrea.ms/schema/1.0/list";
+ }
+
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/activitystreams/types/Mood.java b/rome-modules/src/main/java/com/rometools/modules/activitystreams/types/Mood.java
new file mode 100644
index 0000000..c215f67
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/activitystreams/types/Mood.java
@@ -0,0 +1,80 @@
+/*
+ * Copyright 2011 robert.cooper.
+ *
+ * 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.
+ * under the License.
+ */
+package com.rometools.modules.activitystreams.types;
+
+/**
+ *
+ *
+ * Mood describes the mood of the user when the activity was performed. This is usually collected
+ * via an extra field in the user interface used to perform the activity. For the purpose of this
+ * schema, a mood is a freeform, short mood keyword or phrase along with an optional mood icon
+ * image.
+ *
+ *
+ * Moods are included via a mood element in the namespace http://activitystrea.ms/context/.
+ *
+ *
+ * The content of the mood element is the mood keyword or phrase.
+ *
+ *
+ * The mood element may have an optional icon attribute which contains the URL of a mood
+ * icon image. The mood icon image SHOULD be small and appropriate to be displayed alongside the
+ * mood keyword at a normal text size.
+ *
+ *
+ * @author robert.cooper
+ */
+public class Mood {
+ private String iconUrl;
+ private String text;
+
+ /**
+ * Set the value of iconUrl
+ *
+ * @param newiconUrl new value of iconUrl
+ */
+ public void setIconUrl(final String newiconUrl) {
+ iconUrl = newiconUrl;
+ }
+
+ /**
+ * Get the value of iconUrl
+ *
+ * @return the value of iconUrl
+ */
+ public String getIconUrl() {
+ return iconUrl;
+ }
+
+ /**
+ * Set the value of text
+ *
+ * @param newtext new value of text
+ */
+ public void setText(final String newtext) {
+ text = newtext;
+ }
+
+ /**
+ * Get the value of text
+ *
+ * @return the value of text
+ */
+ public String getText() {
+ return text;
+ }
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/activitystreams/types/Note.java b/rome-modules/src/main/java/com/rometools/modules/activitystreams/types/Note.java
new file mode 100644
index 0000000..8dd0128
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/activitystreams/types/Note.java
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2011 robert.cooper.
+ *
+ * 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.
+ * under the License.
+ */
+
+package com.rometools.modules.activitystreams.types;
+
+/**
+ *
+ * The "note" Object type represents short-form text messages. This Object type is intended for use
+ * in "micro-blogging" and in systems where users are invited to publish short, often plain-text
+ * messages whose useful lifespan is generally shorter than that of an article or weblog entry.
+ *
+ *
+ * A note is similar in structure to an article, but it does not have a title and its body tends to
+ * be shorter. Applications will often display the entire content of a note in an activity stream
+ * UI, whereas they MAY display only the title or the title and summary for a weblog entry.
+ *
+ *
+ * The "note" Object type is identified by the URI http://activitystrea.ms/schema/1.0/note.
+ *
+ *
+ * A note has the following additional components:
+ *
+ *
+ *
+ *
+ *
+ *
Content
+ *
The content of the comment. Represented in JSON as a property called content whose
+ * value is a JSON string containing a fragment of HTML that represents the content. Publishers
+ * SHOULD include any markup necessary to achieve a similar presentation to that on the publisher's
+ * own HTML pages, including any links that the service automatically adds. Processors MAY remove
+ * all HTML markup and consider the comment to be plain text.
+ *
+ *
+ *
+ * @author robert.cooper
+ */
+public class Note extends ActivityObject {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public String getTypeIRI() {
+ return "http://activitystrea.ms/schema/1.0/note";
+ }
+
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/activitystreams/types/Person.java b/rome-modules/src/main/java/com/rometools/modules/activitystreams/types/Person.java
new file mode 100644
index 0000000..6858773
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/activitystreams/types/Person.java
@@ -0,0 +1,89 @@
+/*
+ * Copyright 2011 robert.cooper.
+ *
+ * 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.
+ * under the License.
+ */
+
+package com.rometools.modules.activitystreams.types;
+
+import com.rometools.rome.feed.atom.Link;
+
+/**
+ *
+ * The "person" Object type represents a user account. This is often represents a person, but might
+ * also be a company or fictitious character that is being represented by a user account.
+ *
+ *
+ * The "person" Object type is identified by the URI
+ * http://activitystrea.ms/schema/1.0/person.
+ *
+ *
+ * A person has the following additional components:
+ *
+ *
+ *
+ *
+ *
+ *
Display Name
+ *
A name that can be used for the person in the user interface. This is often a name by which
+ * the individual is known in a given context; no restriction is placed on what kind of name may be
+ * used here. Represented by the Name component of the base Object Construct.
+ *
Avatar
+ *
A link to an "avatar" or "userpic" image for the user. Represented by the Representative
+ * Image component of the base Object Construct.
+ *
+ *
+ *
+ * @author robert.cooper
+ */
+public class Person extends ActivityObject {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public String getTypeIRI() {
+ return "http://activitystrea.ms/schema/1.0/person";
+ }
+
+ /**
+ * Get the value of avatar
+ *
+ * @return the value of avatar
+ */
+ public Link getAvatar() {
+ final Link result = findRelatedLink("avatar");
+ if (result != null) {
+ return result;
+ }
+ return findRelatedLink("userpic");
+ }
+
+ /**
+ * Set the value of avatar
+ *
+ * @param newavatar new value of avatar
+ */
+ public void setAvatar(final Link newavatar) {
+ final Link old = getAvatar();
+ if (old != null) {
+ getOtherLinks().remove(old);
+ }
+ newavatar.setRel("avatar");
+ getOtherLinks().add(newavatar);
+ }
+
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/activitystreams/types/Photo.java b/rome-modules/src/main/java/com/rometools/modules/activitystreams/types/Photo.java
new file mode 100644
index 0000000..d7ebe85
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/activitystreams/types/Photo.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2011 robert.cooper.
+ *
+ * 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.
+ * under the License.
+ */
+
+package com.rometools.modules.activitystreams.types;
+
+/**
+ *
+ * The "photo" object type represents a graphical still image.
+ *
+ *
+ * The "photo" Object type is identified by the URI
+ * http://activitystrea.ms/schema/1.0/photo.
+ *
+ *
+ * A photo has the following additional components:
+ *
+ *
+ *
+ *
+ *
+ *
Thumbnail
+ *
A link to a thumbnail version of the image. Represented by the Representative Image component
+ * of the base Object Construct. Processors MAY ignore thumbnails that are of an inappropriate size
+ * for their user interface.
+ *
Larger Image
+ *
A Media Link Construct linking to a larger -- ideally, full-size -- version of the photo
+ * intended for standalone viewing. Represented in JSON as a property named fullImage whose
+ * value is a JSON object with properties as defined in [TODO: xref the JSON serialization of a
+ * Media Link Construct].
+ *
+ *
+ *
+ * @author robert.cooper
+ */
+public class Photo extends ActivityObject {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public String getTypeIRI() {
+ return "http://activitystrea.ms/schema/1.0/photo";
+ }
+
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/activitystreams/types/PhotoAlbum.java b/rome-modules/src/main/java/com/rometools/modules/activitystreams/types/PhotoAlbum.java
new file mode 100644
index 0000000..b912057
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/activitystreams/types/PhotoAlbum.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2011 robert.cooper.
+ *
+ * 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.
+ * under the License.
+ */
+
+package com.rometools.modules.activitystreams.types;
+
+/**
+ *
+ * The "photo album" object type represents a collection of images.
+ *
+ *
+ * The "photo album" object type is identified by the URI
+ * http://activitystrea.ms/schema/1.0/photo-album.
+ *
+ *
+ * The photo album has the following additional components:
+ *
+ *
+ *
+ *
+ *
+ *
Preview Image Link
+ *
A Media Link Construct describing an image file that can be used as a preview image for the
+ * album. Represented by the Representative Image component of the base Object Construct. Processors
+ * MAY ignore thumbnails that are of an inappropriate size for their user interface.
+ *
+ *
+ *
+ * @author robert.cooper
+ */
+public class PhotoAlbum extends ActivityObject {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public String getTypeIRI() {
+ return "http://activitystrea.ms/schema/1.0/photo-album";
+ }
+
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/activitystreams/types/Place.java b/rome-modules/src/main/java/com/rometools/modules/activitystreams/types/Place.java
new file mode 100644
index 0000000..ec3b645
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/activitystreams/types/Place.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright 2011 robert.cooper.
+ *
+ * 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.
+ * under the License.
+ */
+
+package com.rometools.modules.activitystreams.types;
+
+/**
+ *
+ * The "place" object type represents a location on Earth.
+ *
+ *
+ * The "place" object type is identified by the URI
+ * http://activitystrea.ms/schema/1.0/place.
+ *
+ *
+ * A place has the following additional components:
+ *
+ *
+ *
+ *
+ *
+ *
Latitude
+ *
The latitude of the place as a point on Earth. Represented in JSON as a property named
+ * latitude whose value is a JSON number containing a decimal representation of the
+ * latitude in degrees.
+ *
Longitude
+ *
The longitude of the place as a point on Earth. Represented in JSON as a property named
+ * longitude whose value is a JSON number containing a decimal representation of the
+ * longitude in degrees.
+ *
+ *
+ *
+ * @author robert.cooper
+ */
+public class Place extends ActivityObject {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public String getTypeIRI() {
+ return "http://activitystrea.ms/schema/1.0/place";
+ }
+
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/activitystreams/types/Playlist.java b/rome-modules/src/main/java/com/rometools/modules/activitystreams/types/Playlist.java
new file mode 100644
index 0000000..e12a04f
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/activitystreams/types/Playlist.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2011 robert.cooper.
+ *
+ * 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.
+ * under the License.
+ */
+
+package com.rometools.modules.activitystreams.types;
+
+/**
+ *
+ *
+ * The "playlist" object type represents an ordered list of time-based media items, such as video
+ * and audio objects.
+ *
+ *
+ * The "playlist" object type is identified by the URI
+ * http://activitystrea.ms/schema/1.0/playlist.
+ *
+ *
+ * A playlist has no additional components.
+ *
+ *
+ * @author robert.cooper
+ */
+public class Playlist extends ActivityObject {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public String getTypeIRI() {
+ return "http://activitystrea.ms/schema/1.0/playlist";
+ }
+
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/activitystreams/types/Product.java b/rome-modules/src/main/java/com/rometools/modules/activitystreams/types/Product.java
new file mode 100644
index 0000000..f293283
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/activitystreams/types/Product.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2011 robert.cooper.
+ *
+ * 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.
+ * under the License.
+ */
+
+package com.rometools.modules.activitystreams.types;
+
+/**
+ *
+ * The "product" object type represents a commercial good or service.
+ *
+ *
+ * The "product" object type is identified by the URI
+ * http://activitystrea.ms/schema/1.0/product.
+ *
+ *
+ * A product has the following additional components:
+ *
+ *
+ *
+ *
+ *
+ *
Thumbnail
+ *
A link to a thumbnail-sized image that contains a photo of the product. Represented by the
+ * Representative Image component of the base Object Construct. Processors MAY ignore thumbnails
+ * that are of an inappropriate size for their user interface.
+ *
Larger Image
+ *
A Media Link Construct linking to a larger -- ideally, full-size -- version of the photo of
+ * the product. Represented in JSON as a property named fullImage whose value is a JSON
+ * object with properties as defined in [TODO: xref the JSON serialization of a Media Link
+ * Construct].
+ *
+ *
+ *
+ * @author robert.cooper
+ */
+public class Product extends ActivityObject {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public String getTypeIRI() {
+ return "http://activitystrea.ms/schema/1.0/product";
+ }
+
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/activitystreams/types/Review.java b/rome-modules/src/main/java/com/rometools/modules/activitystreams/types/Review.java
new file mode 100644
index 0000000..047211d
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/activitystreams/types/Review.java
@@ -0,0 +1,70 @@
+/*
+ * Copyright 2011 robert.cooper.
+ *
+ * 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.
+ * under the License.
+ */
+
+package com.rometools.modules.activitystreams.types;
+
+/**
+ *
+ * The "review" object type represents a primarily prose-based commentary on another object.
+ *
+ *
+ * The "review" object type is identified by the URI
+ * http://activitystrea.ms/schema/1.0/review.
+ *
+ *
+ * A review has the following additional components:
+ *
+ *
+ *
+ *
+ *
+ *
Title
+ *
The title of the review. Represented by the Name component of the base Object Construct. Many
+ * systems do not have the concept of a title for a review; such systems MUST omit the Name
+ * component. Processors SHOULD refer to such reviews as simply being "a review", with appropriate
+ * localization, if they are to be described in a sentence.
+ *
Content
+ *
The content of the comment. Represented in JSON as a property called content whose
+ * value is a JSON string containing a fragment of HTML that represents the content. Publishers
+ * SHOULD include any markup necessary to achieve a similar presentation to that on the publisher's
+ * own HTML pages, including any links that the service automatically adds. Processors MAY remove
+ * all HTML markup and consider the comment to be plain text.
+ *
Reviewed Object
+ *
The Object Construct representing the item that this review applies to. Represented as the In
+ * Reply To Object component of the base Object Construct.
+ *
Rating
+ *
A rating for the item, given as a number between 1.0 and 5.0 inclusive with one decimal place
+ * of precision. Represented in JSON as a property called rating whose value is a JSON
+ * number giving the rating.
+ *
+ *
+ *
+ * @author robert.cooper
+ */
+public class Review extends ActivityObject {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public String getTypeIRI() {
+ return "http://activitystrea.ms/schema/1.0/review";
+ }
+
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/activitystreams/types/Service.java b/rome-modules/src/main/java/com/rometools/modules/activitystreams/types/Service.java
new file mode 100644
index 0000000..a882d68
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/activitystreams/types/Service.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright 2011 robert.cooper.
+ *
+ * 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.
+ * under the License.
+ */
+
+package com.rometools.modules.activitystreams.types;
+
+/**
+ *
+ * The "service" Object type represents a website, personal website or blog, business, brand, or
+ * other entity that performs some kind of work for other entities, people, or services, or acts as
+ * kind of container for other objects.
+ *
+ *
+ * The "service" Object type is identified by the URI
+ * http://activitystrea.ms/schema/1.0/service.
+ *
+ *
+ * A service has the following additional components:
+ *
+ *
+ *
+ *
+ *
+ *
icon
+ *
A Media Link Construct representing a link to a small image representing the service.
+ * Represented in JSON as a property named icon whose value is a JSON object with
+ * properties as defined in [TODO: xref the JSON serialization of a Media Link Construct]. The
+ * linked image MUST have an aspect ratio of one (horizontal) to one (vertical) and SHOULD be
+ * suitable for presentation at a small size.
+ *
+ *
+ *
+ * @author robert.cooper
+ */
+public class Service extends ActivityObject {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public String getTypeIRI() {
+ return "http://activitystrea.ms/schema/1.0/service";
+ }
+
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/activitystreams/types/Song.java b/rome-modules/src/main/java/com/rometools/modules/activitystreams/types/Song.java
new file mode 100644
index 0000000..b651bbb
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/activitystreams/types/Song.java
@@ -0,0 +1,70 @@
+/*
+ * Copyright 2011 robert.cooper.
+ *
+ * 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.
+ * under the License.
+ */
+package com.rometools.modules.activitystreams.types;
+
+/**
+ *
+ * The "song" Object type represents a song or a recording of a song.
+ *
+ *
+ * Objects of type Song might contain information about the song or recording, or they might contain
+ * some representation of the recording itself. In the latter case, the song SHOULD also be
+ * annotated with the "audio" object type as described in Section 3.2.2 (Audio)
+ * and use its properties. This type should only be used when the publisher can guarantee that the
+ * object is a song rather than merely a generic audio stream.
+ *
+ *
+ * The Object type URL for the "song" Object type is
+ * http://activitystrea.ms/schema/1.0/song.
+ *
+ *
+ * A song has no additional components.
+ *
+ *
+ * @author robert.cooper
+ */
+public class Song extends ActivityObject {
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ private Audio audio;
+
+ /**
+ * Set the value of audio
+ *
+ * @param newaudio new value of audio
+ */
+ public void setAudio(final Audio newaudio) {
+ audio = newaudio;
+ }
+
+ /**
+ * Get the value of audio
+ *
+ * @return the value of audio
+ */
+ public Audio getAudio() {
+ return audio;
+ }
+
+ @Override
+ public String getTypeIRI() {
+ return "http://activitystrea.ms/schema/1.0/song";
+ }
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/activitystreams/types/Status.java b/rome-modules/src/main/java/com/rometools/modules/activitystreams/types/Status.java
new file mode 100644
index 0000000..8492684
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/activitystreams/types/Status.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2011 robert.cooper.
+ *
+ * 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.
+ * under the License.
+ */
+
+package com.rometools.modules.activitystreams.types;
+
+/**
+ *
+ * The "status" Object type represents a human-readable update of the author's situation, mood,
+ * location or other status.
+ *
+ *
+ * A status is similar in structure to a note, but carries the additional meaning that the content
+ * is primarily describing something its author is doing, feeling or experiencing.
+ *
+ *
+ * A consumers MAY consider the content of the most recent status object it encountered to be the
+ * user's current status, unless the most recent status update is old. When a status becomes too old
+ * is not defined by this specification.
+ *
+ *
+ * The "status" object type is identified by the URI
+ * http://activitystrea.ms/schema/1.0/status.
+ *
+ *
+ * A status has the same components as a note.
+ *
+ *
+ * @author robert.cooper
+ */
+public class Status extends ActivityObject {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public String getTypeIRI() {
+ return "http://activitystrea.ms/schema/1.0/status";
+ }
+
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/activitystreams/types/Verb.java b/rome-modules/src/main/java/com/rometools/modules/activitystreams/types/Verb.java
new file mode 100644
index 0000000..39aabaf
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/activitystreams/types/Verb.java
@@ -0,0 +1,214 @@
+/*
+ * Copyright 2011 robert.cooper.
+ *
+ * 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 icense for the specific language governing permissions and
+ * limitations under the License.
+ * under the License.
+ */
+package com.rometools.modules.activitystreams.types;
+
+/**
+ *
+ * @author robert.cooper
+ */
+public enum Verb {
+ /**
+ * The "mark as favorite" Verb indicates that the Subject marked the Object as an item of
+ * special interest. Objects so marked often appear in a collection of such Objects which MAY be
+ * published as a feed of entries annotated with this Verb. If a particular service uses
+ * favorites as a mechanism by which a user can recall items that were earlier marked, it MAY be
+ * appropriate to also mark activities of this type with the "save" Verb as described in Section
+ * 3.1.8. The verb URI for the "mark as favorite" Verb is
+ * http://activitystrea.ms/schema/1.0/favorite.
+ */
+ MARK_AS_FAVORITE("http://activitystrea.ms/schema/1.0/favorite"),
+ /**
+ * The "start following" Verb indicates that the Subject began following the activity of the
+ * Object. In most cases, the Object of this Verb will be a user, but it can potentially be of
+ * any type that can sensibly generate activity.
+ *
+ * The verb URI for the "start following" Verb is http://activitystrea.ms/schema/1.0/follow.
+ *
+ * Processors MAY ignore (silently drop) successive identical "start following" activities
+ * regardless of whether they maintain state sufficient to determine (A), (B), or (C) above.
+ */
+ START_FOLLOWING("http://activitystrea.ms/schema/1.0/follow"),
+ /**
+ * The "mark as liked" verb indicates that the actor indicated that it likes the object.
+ *
+ * The verb URI for the "mark as liked" Verb is http://activitystrea.ms/schema/1.0/like.
+ */
+ MARK_AS_LIKED("http://activitystrea.ms/schema/1.0/like"),
+ /**
+ * The "make friend" Verb indicates the creation of a friendship that is reciprocated by the
+ * object.
+ *
+ * Since this verb implies an activity on the part of its object, processors MUST NOT accept
+ * activities with this Verb unless they are able to verify through some external means that
+ * there is in fact a reciprocated connection. For example, a processor MAY have received a
+ * guarantee from a particular publisher that the publisher will only use this Verb in cases
+ * where a reciprocal relationship exists.
+ *
+ * The verb URI for the "make friend" Verb is http://activitystrea.ms/schema/1.0/make-friend.
+ */
+ MAKE_FRIEND("http://activitystrea.ms/schema/1.0/make-friend"),
+ /**
+ * The "join" Verb indicates that the actor has become a member of the Object. This
+ * specification only defines the meaning of this Verb when its Object is a Group, though
+ * implementors SHOULD be prepared to handle other Object types as meaning MAY be provided by
+ * extension specifications.
+ *
+ * Processors MAY ignore (silently drop) successive identical "join" activities regardless of
+ * whether they maintain state sufficient to determine (A) or (B) above.
+ *
+ * The "join" Verb is identified by the URI http://activitystrea.ms/schema/1.0/join.
+ */
+ JOIN("http://activitystrea.ms/schema/1.0/join"),
+ /**
+ * The "play" verb indicates that the subject spent some time enjoying the object. For example,
+ * if the object is a video this indicates that the subject watched all or part of the video.
+ *
+ * The "play" Verb is identified by the URI http://activitystrea.ms/schema/1.0/play.
+ */
+ PLAY("http://activitystrea.ms/schema/1.0/play"),
+ /**
+ * The "Post" Verb is described in section 8 of the AtomActivity specification. It is only
+ * referenced here for completeness.
+ *
+ * http://activitystrea.ms/schema/1.0/post
+ */
+ POST("http://activitystrea.ms/schema/1.0/post"),
+ /**
+ * The "save" Verb indicates that the Subject has called out the Object as being of interest
+ * primarily to him- or herself. Though this action MAY be shared publicly, the implication is
+ * that the Object has been saved primarily for the actor's own benefit rather than to show it
+ * to others as would be indicated by the "share" Verb (Section 3.1.9).
+ *
+ * The "save" Verb is identified by the URI http://activitystrea.ms/schema/1.0/save.
+ */
+ SAVE("http://activitystrea.ms/schema/1.0/save"),
+ /**
+ * The "share" Verb indicates that the Subject has called out the Object to readers. In most
+ * cases, the actor did not create the Object being shared, but is instead drawing attention to
+ * it.
+ *
+ * The "share" Verb is identified by the URI http://activitystrea.ms/schema/1.0/share.
+ */
+ SHARE("http://activitystrea.ms/schema/1.0/share"),
+ /**
+ * The "tag" verb indicates that the actor has identified the presence of a target inside
+ * another object. For example, the actor may have specified that a particular user appears in a
+ * photo.
+ *
+ * The "tag" verb is identified by the URI http://activitystrea.ms/schema/1.0/tag.
+ *
+ * The target of the "tag" verb gives the object in which the tag has been added. For example,
+ * if a user appears in a photo, the activity:object is the user and the activity:target is the
+ * photo.
+ */
+ TAG("http://activitystrea.ms/schema/1.0/tag"),
+ /**
+ * The "update" Verb indicates that the Subject has modified the referenced Object.
+ *
+ * Implementors SHOULD use verbs such as Section 3.1.7 where the Subject is adding new items to
+ * a Section 3.2.8 or similar. Update is reserved for modifications to existing Objects or data
+ * such as changing a user's profile information.
+ *
+ * The "update" Verb is identified by the URI http://activitystrea.ms/schema/1.0/update.
+ */
+ UPDATE("http://activitystrea.ms/schema/1.0/update"),
+ /**
+ *
+ *
+ * The "positive RSVP" verb indicates that the actor has made a positive RSVP for the object.
+ * This specification only defines the meaning of this verb when its object is an event (see Section 4.2.1 (Event)), though implementors SHOULD be prepared to
+ * handle other object types as meaning MAY be provided by extension specifications.
+ *
+ *
+ * The use of this Verb is only appropriate when the RSVP was created by an explicit action by
+ * the actor. It is not appropriate to use this verb when a user has been added as an attendee
+ * by an event organiser or administrator.
+ *
+ *
+ * The verb URI for the "positive RSVP" Verb is
+ * http://activitystrea.ms/schema/1.0/rsvp-yes.
+ *
+ * The "possible RSVP" verb indicates that the actor has made a possible RSVP for the object.
+ * This specification only defines the meaning of this verb when its object is an event (see Section 4.2.1 (Event)), though implementors SHOULD be prepared to
+ * handle other object types as meaning MAY be provided by extension specifications.
+ *
+ *
+ * The use of this Verb is only appropriate when the RSVP was created by an explicit action by
+ * the actor. It is not appropriate to use this verb when a user has been added as an attendee
+ * by an event organiser or administrator.
+ *
+ *
+ * The verb URI for the "possible RSVP" Verb is
+ * http://activitystrea.ms/schema/1.0/rsvp-maybe.
+ *
+ * The "negative RSVP" verb indicates that the actor has made a negative RSVP for the object.
+ * This specification only defines the meaning of this verb when its object is an event (see Section 4.2.1 (Event)), though implementors SHOULD be prepared to
+ * handle other object types as meaning MAY be provided by extension specifications.
+ *
+ *
+ * The use of this Verb is only appropriate when the RSVP was created by an explicit action by
+ * the actor. It is not appropriate to use this verb when a user has been added as an attendee
+ * by an event organiser or administrator.
+ *
+ *
+ * The verb URI for the "negative RSVP" Verb is
+ * http://activitystrea.ms/schema/1.0/rsvp-no.
+ *
+ */
+ RSVP_NO("http://activitystrea.ms/schema/1.0/rsvp-no");
+ private final String iri;
+
+ /**
+ * @param iri
+ */
+ Verb(final String iri) {
+ this.iri = iri;
+ }
+
+ @Override
+ public String toString() {
+ return iri;
+ }
+
+ /**
+ *
+ * @param iri
+ * @return
+ */
+ public static Verb fromIRI(final String iri) {
+ for (final Verb v : Verb.values()) {
+ if (v.toString().equals(iri)) {
+ return v;
+ }
+ }
+ return null;
+ }
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/activitystreams/types/Video.java b/rome-modules/src/main/java/com/rometools/modules/activitystreams/types/Video.java
new file mode 100644
index 0000000..8cc07fb
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/activitystreams/types/Video.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2011 robert.cooper.
+ *
+ * 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.
+ * under the License.
+ */
+
+package com.rometools.modules.activitystreams.types;
+
+/**
+ *
+ * The "video" Object type represents video content, which usually consists of a motion picture
+ * track and an audio track.
+ *
+ *
+ * The "video" Object type is identified by the URI
+ * http://activitystrea.ms/schema/1.0/video.
+ *
+ *
+ * A video has the following additional components:
+ *
+ *
+ *
+ *
+ *
+ *
Video Stream Link
+ *
A Media Link Construct linking to the video content itself. Represented in JSON as a property
+ * called stream whose value is a JSON object with properties as defined in [TODO: xref the
+ * JSON serialization of a Media Link Construct]
+ *
Embed Code
+ *
An HTML fragment that, when embedded in an HTML page, will provide an interactive player UI
+ * for the video stream. Represented in JSON as a property called embedCode whose value is
+ * a JSON string containing the fragment of HTML.
+ *
+ *
+ *
+ * @author robert.cooper
+ */
+public class Video {
+
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/atom/io/AtomLinkAttribute.java b/rome-modules/src/main/java/com/rometools/modules/atom/io/AtomLinkAttribute.java
new file mode 100644
index 0000000..1ccfbfb
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/atom/io/AtomLinkAttribute.java
@@ -0,0 +1,10 @@
+package com.rometools.modules.atom.io;
+
+public interface AtomLinkAttribute {
+ String REL = "rel";
+ String TYPE = "type";
+ String HREF = "href";
+ String TITLE = "title";
+ String HREF_LANG = "hreflang";
+ String LENGTH = "length";
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/atom/io/AtomModuleGenerator.java b/rome-modules/src/main/java/com/rometools/modules/atom/io/AtomModuleGenerator.java
new file mode 100644
index 0000000..a683a6c
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/atom/io/AtomModuleGenerator.java
@@ -0,0 +1,82 @@
+package com.rometools.modules.atom.io;
+
+import com.rometools.modules.atom.modules.AtomLinkModule;
+import com.rometools.rome.feed.atom.Link;
+import com.rometools.rome.feed.module.Module;
+import com.rometools.rome.io.ModuleGenerator;
+import org.jdom2.Attribute;
+import org.jdom2.Element;
+import org.jdom2.Namespace;
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+public class AtomModuleGenerator implements ModuleGenerator {
+
+ static final Namespace NS = Namespace.getNamespace("atom", AtomLinkModule.URI);
+ private static final Set NAMESPACES;
+
+ static {
+ final Set nss = new HashSet();
+ nss.add(NS);
+ NAMESPACES = Collections.unmodifiableSet(nss);
+ }
+
+ @Override
+ public final String getNamespaceUri() {
+ return AtomLinkModule.URI;
+ }
+
+ @Override
+ public final Set getNamespaces() {
+ return NAMESPACES;
+ }
+
+ @Override
+ public void generate(Module module, Element element) {
+ if (module instanceof AtomLinkModule) {
+ AtomLinkModule m = (AtomLinkModule) module;
+ generateLinc(m.getLink(), element);
+ }
+ }
+
+ private void generateLinc(Link link, Element element) {
+ if (link == null) {
+ return;
+ }
+
+ Element linkElement = new Element("link", NS);
+
+ if (link.getHref() != null) {
+ Attribute href = new Attribute(AtomLinkAttribute.HREF, link.getHref());
+ linkElement.setAttribute(href);
+ }
+ if (link.getType() != null) {
+ Attribute type = new Attribute(AtomLinkAttribute.TYPE, link.getType());
+ linkElement.setAttribute(type);
+ }
+ if (link.getRel() != null) {
+ Attribute rel = new Attribute(AtomLinkAttribute.REL, link.getRel());
+ linkElement.setAttribute(rel);
+ }
+
+ if (link.getHreflang() != null) {
+ final Attribute hreflangAttribute = new Attribute(AtomLinkAttribute.HREF_LANG, link.getHreflang());
+ linkElement.setAttribute(hreflangAttribute);
+ }
+
+ if (link.getTitle() != null) {
+ final Attribute title = new Attribute(AtomLinkAttribute.TITLE, link.getTitle());
+ linkElement.setAttribute(title);
+ }
+
+ if (link.getLength() != 0) {
+ final Attribute lenght = new Attribute(AtomLinkAttribute.LENGTH, Long.toString(link.getLength()));
+ linkElement.setAttribute(lenght);
+ }
+
+ element.addContent(linkElement);
+ }
+
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/atom/io/AtomModuleParser.java b/rome-modules/src/main/java/com/rometools/modules/atom/io/AtomModuleParser.java
new file mode 100644
index 0000000..36cdfba
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/atom/io/AtomModuleParser.java
@@ -0,0 +1,90 @@
+package com.rometools.modules.atom.io;
+
+import com.rometools.modules.atom.modules.AtomLinkModule;
+import com.rometools.modules.atom.modules.AtomLinkModuleImpl;
+import com.rometools.rome.feed.atom.Link;
+import com.rometools.rome.feed.module.Module;
+import com.rometools.rome.io.ModuleParser;
+import com.rometools.rome.io.impl.NumberParser;
+import org.jdom2.Attribute;
+import org.jdom2.Element;
+import org.jdom2.Namespace;
+
+import java.util.Locale;
+
+public class AtomModuleParser implements ModuleParser {
+
+ private static final Namespace NS = Namespace.getNamespace(AtomLinkModule.URI);
+
+ @Override
+ public String getNamespaceUri() {
+ return null;
+ }
+
+ @Override
+ public Module parse(Element element, Locale locale) {
+ AtomLinkModuleImpl mod = new AtomLinkModuleImpl();
+ if (element.getName().equals("channel") || element.getName().equals("item")) {
+ Element link = element.getChild("link", NS);
+ if (link != null) {
+ Link l = parseLink(link);
+ mod.setLink(l);
+ return mod;
+ }
+ }
+ return null;
+ }
+
+ private Link parseLink(final Element eLink) {
+
+ final Link link = new Link();
+
+ final String rel = getAttributeValue(eLink, AtomLinkAttribute.REL);
+ if (rel != null) {
+ link.setRel(rel);
+ }
+
+ final String type = getAttributeValue(eLink, AtomLinkAttribute.TYPE);
+ if (type != null) {
+ link.setType(type);
+ }
+
+ final String href = getAttributeValue(eLink, AtomLinkAttribute.HREF);
+ if (href != null) {
+ link.setHref(href);
+ }
+
+ final String title = getAttributeValue(eLink, AtomLinkAttribute.TITLE);
+ if (title != null) {
+ link.setTitle(title);
+ }
+
+ final String hrefLang = getAttributeValue(eLink, AtomLinkAttribute.HREF_LANG);
+ if (hrefLang != null) {
+ link.setHreflang(hrefLang);
+ }
+
+ final String length = getAttributeValue(eLink, AtomLinkAttribute.LENGTH);
+ if (length != null) {
+ final Long val = NumberParser.parseLong(length);
+ if (val != null) {
+ link.setLength(val.longValue());
+ }
+ }
+
+ return link;
+
+ }
+
+ protected String getAttributeValue(final Element e, final String attributeName) {
+ Attribute attr = e.getAttribute(attributeName);
+ if (attr == null) {
+ attr = e.getAttribute(attributeName, NS);
+ }
+ if (attr != null) {
+ return attr.getValue();
+ } else {
+ return null;
+ }
+ }
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/atom/modules/AtomLinkModule.java b/rome-modules/src/main/java/com/rometools/modules/atom/modules/AtomLinkModule.java
new file mode 100644
index 0000000..22e3f6d
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/atom/modules/AtomLinkModule.java
@@ -0,0 +1,13 @@
+package com.rometools.modules.atom.modules;
+
+import com.rometools.rome.feed.atom.Link;
+import com.rometools.rome.feed.module.Module;
+
+public interface AtomLinkModule extends Module {
+
+ public static final String URI = "http://www.w3.org/2005/Atom";
+
+ public Link getLink();
+
+ public void setLink(Link link);
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/atom/modules/AtomLinkModuleImpl.java b/rome-modules/src/main/java/com/rometools/modules/atom/modules/AtomLinkModuleImpl.java
new file mode 100644
index 0000000..ec5e9e2
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/atom/modules/AtomLinkModuleImpl.java
@@ -0,0 +1,83 @@
+package com.rometools.modules.atom.modules;
+
+import com.rometools.rome.feed.CopyFrom;
+import com.rometools.rome.feed.atom.Link;
+import com.rometools.rome.feed.impl.EqualsBean;
+import com.rometools.rome.feed.impl.ToStringBean;
+
+import java.io.Serializable;
+
+public class AtomLinkModuleImpl implements AtomLinkModule, Cloneable, Serializable {
+
+ private Link link;
+
+ @Override
+ public Link getLink() {
+ return link;
+ }
+
+ @Override
+ public void setLink(Link link) {
+ this.link = link;
+ }
+
+ @Override
+ public String getUri() {
+ return URI;
+ }
+
+ @Override
+ public Class extends CopyFrom> getInterface() {
+ return AtomLinkModule.class;
+ }
+
+ @Override
+ public void copyFrom(CopyFrom obj) {
+ AtomLinkModule other = (AtomLinkModule) obj;
+ Link link = other.getLink();
+ if (link != null) {
+ Link l = new Link();
+ l.setHref(link.getHref());
+ l.setType(link.getType());
+ l.setRel(link.getRel());
+ l.setHreflang(link.getHreflang());
+ l.setTitle(link.getTitle());
+ l.setLength(link.getLength());
+ setLink(l);
+ }
+ }
+
+ @Override
+ public Object clone() {
+ final AtomLinkModuleImpl m = new AtomLinkModuleImpl();
+ if (link != null) {
+ Link l = new Link();
+ l.setHref(link.getHref());
+ l.setType(link.getType());
+ l.setRel(link.getRel());
+ l.setHreflang(link.getHreflang());
+ l.setTitle(link.getTitle());
+ l.setLength(link.getLength());
+ m.setLink(l);
+ }
+ return m;
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ final EqualsBean eBean = new EqualsBean(AtomLinkModuleImpl.class, this);
+ return eBean.beanEquals(obj);
+ }
+
+ @Override
+ public int hashCode() {
+ final EqualsBean equals = new EqualsBean(AtomLinkModuleImpl.class, this);
+ return equals.beanHashCode();
+ }
+
+ @Override
+ public String toString() {
+ final ToStringBean tsBean = new ToStringBean(AtomLinkModuleImpl.class, this);
+ return tsBean.toString();
+ }
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/base/Article.java b/rome-modules/src/main/java/com/rometools/modules/base/Article.java
new file mode 100644
index 0000000..0f90578
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/base/Article.java
@@ -0,0 +1,380 @@
+/*
+ * Article.java
+ *
+ * Created on November 16, 2005, 1:01 PM
+ *
+ * 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.
+ */
+package com.rometools.modules.base;
+
+import java.util.Date;
+
+/**
+ * This is an interface for the GoogleBase plug in that exposes methods used for Article or News
+ * entry types.
+ *
+ * @author Robert "kebernet" Cooper
+ * @version $Revision: 1.2 $
+ */
+public interface Article extends GlobalInterface {
+ /**
+ * Array of Author Names. Limit 10.
+ *
+ *
+ * @return Array of author names.
+ */
+ public String[] getAuthors();
+
+ /**
+ * Source for this article.
+ *
+ *
+ *
+ *
+ *
+ *
+ *
news_source
+ *
+ *
+ *
Details
+ *
+ *
The source of news content.
+ *
+ *
+ *
+ *
Example
+ *
<g:news_source>Journal</g:news_source>
+ *
+ *
+ *
+ *
+ *
Attribute of
+ *
News and Articles
+ *
+ *
+ *
+ *
+ *
+ * Content type
+ *
string
+ *
+ *
+ *
+ *
+ * @param newsSource Source for this article
+ */
+ public void setNewsSource(String newsSource);
+
+ /**
+ * Source for this article.
+ *
+ *
+ *
+ *
+ *
+ *
news_source
+ *
+ *
+ *
Details
+ *
+ *
The source of news content.
+ *
+ *
+ *
+ *
Example
+ *
<g:news_source>Journal</g:news_source>
+ *
+ *
+ *
+ *
+ *
Attribute of
+ *
News and Articles
+ *
+ *
+ *
+ *
+ *
+ * Content type
+ *
string
+ *
+ *
+ *
+ *
+ * @return source for this article.
+ */
+ public String getNewsSource();
+
+ /**
+ * Number of pages in the article.
+ *
+ *
+ *
+ *
+ *
+ *
pages
+ *
+ *
+ *
+ *
Details
+ *
+ *
+ * The number of pages in the publication.
+ *
+ *
+ *
+ *
Example
+ *
<g:pages>18</g:pages>
+ *
+ *
+ *
+ *
+ *
Attribute of
+ *
Reference Items, News and Articles
+ *
+ *
+ *
+ *
+ *
+ * Content type
+ *
integer
+ *
+ *
+ *
+ *
+ * @param pages Number of pages in the article
+ */
+ public void setPages(Integer pages);
+
+ /**
+ * Number of pages in the article.
+ *
+ *
+ *
+ *
+ *
+ *
pages
+ *
+ *
+ *
+ *
Details
+ *
+ *
+ * The number of pages in the publication.
+ *
+ *
+ *
+ *
Example
+ *
<g:pages>18</g:pages>
+ *
+ *
+ *
+ *
+ *
Attribute of
+ *
Reference Items, News and Articles
+ *
+ *
+ *
+ *
+ *
+ * Content type
+ *
integer
+ *
+ *
+ *
+ *
+ * @return Number of pages in the article
+ */
+ public Integer getPages();
+
+ /**
+ * Date article was published.
+ *
+ *
+ *
+ *
+ *
publish_date
+ *
+ *
+ *
+ *
+ *
+ * Details
+ *
Date the item was published in ISO 8601
+ * format: YYYY-MM-DD
+ *
+ *
+ *
+ *
+ *
+ * Example
+ *
<g:publish_date>2005-12-20</g:publish_date>
+ *
+ *
+ *
+ *
Attribute of
+ *
+ *
Reference Items
+ *
+ *
+ *
+ *
+ * Content type
+ *
+ *
+ * date
+ *
+ *
+ *
+ *
+ * @param publishDate Date article was published
+ */
+ public void setPublishDate(Date publishDate);
+
+ /**
+ * Date article was published.
+ *
+ *
+ *
+ *
+ *
publish_date
+ *
+ *
+ *
+ *
+ *
+ * Details
+ *
Date the item was published in ISO 8601
+ * format: YYYY-MM-DD
+ *
+ *
+ *
+ *
+ *
+ * Example
+ *
<g:publish_date>2005-12-20</g:publish_date>
+ *
+ *
+ *
+ *
Attribute of
+ *
+ *
Reference Items
+ *
+ *
+ *
+ *
+ * Content type
+ *
+ *
+ * date
+ *
+ *
+ *
+ *
+ * @return Date article was published
+ */
+ public Date getPublishDate();
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/base/Course.java b/rome-modules/src/main/java/com/rometools/modules/base/Course.java
new file mode 100644
index 0000000..9b2a80d
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/base/Course.java
@@ -0,0 +1,565 @@
+/*
+ * CourseInformation.java
+ *
+ * Created on November 16, 2005, 11:12 AM
+ * 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.
+ */
+package com.rometools.modules.base;
+
+import com.rometools.modules.base.types.DateTimeRange;
+
+/**
+ * This is an interface for the GoogleBase plug in that exposes methods used for Class or Course
+ * information entry types.
+ *
+ * @author Robert "kebernet" Cooper
+ * @version $Revision: 1.2 $
+ */
+public interface Course extends GlobalInterface {
+ /**
+ * The timeframe a course is running.
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
course_date_range
+ *
+ *
+ *
Details
+ *
Date and time range a class is in session, in ISO 8601. Two
+ * sub-attributes are included in course_date_range attribute.
+ *
+ *
+ *
start = Start date and time of a trip in format YYYY-MM-DDThh:mm:ss
+ *
end = End date and time of a trip in format YYYY-MM-DDThh:mm:ss
+ *
+ * @return The timeframe a course is running
+ */
+ public DateTimeRange getCourseDateRange();
+
+ /**
+ * ID code associated with a course.
+ *
+ *
+ *
+ *
+ *
+ *
course_number
+ *
+ *
+ *
Details
+ *
+ *
ID code associated with a course
+ *
+ *
+ *
+ *
Example
+ *
<g:course_number>HIST-90A</g:course_number>
+ *
+ *
+ *
+ *
+ *
Attribute of
+ *
Course schedules
+ *
+ *
+ *
Content type
+ *
+ *
string
+ *
+ *
+ *
+ *
+ *
+ * @param courseNumber ID code associated with a course
+ */
+ public void setCourseNumber(String courseNumber);
+
+ /**
+ * ID code associated with a course.
+ *
+ *
+ *
+ *
+ *
+ *
+ *
course_number
+ *
+ *
+ *
Details
+ *
+ *
ID code associated with a course
+ *
+ *
+ *
+ *
Example
+ *
<g:course_number>HIST-90A</g:course_number>
+ *
+ *
+ *
+ *
+ *
Attribute of
+ *
Course schedules
+ *
+ *
+ *
Content type
+ *
+ *
string
+ *
+ *
+ *
+ *
+ *
+ * @return ID code associated with a course
+ */
+ public String getCourseNumber();
+
+ /**
+ * Time a class is in session.
+ *
+ *
+ *
+ *
+ * @param courseTimes Time a class is in session
+ */
+ public void setCourseTimes(String courseTimes);
+
+ /**
+ * Time a class is in session.
+ *
+ *
+ *
+ *
+ *
+ * @return Time a class is in session
+ */
+ public String getCourseTimes();
+
+ /**
+ * Salary for this position.
+ *
+ *
+ *
+ *
+ *
+ *
+ *
salary
+ *
+ *
+ *
+ *
+ *
Details
+ *
Salary for this position. Non-numeric values such as "$" symbols are not
+ * acceptable.
+ *
+ *
+ *
+ *
+ *
+ * Example
+ *
<g:salary>55000</g:salary>
+ *
+ *
+ *
+ *
+ * Attribute of
+ *
+ *
Jobs
+ *
+ *
+ *
Content type
+ *
+ *
+ *
+ * float
+ *
+ *
+ *
+ *
+ * @param salary Salary for this position
+ */
+ public void setSalary(Float salary);
+
+ /**
+ * Salary for this position.
+ *
+ *
+ *
+ *
+ *
+ *
salary
+ *
+ *
+ *
+ *
+ *
Details
+ *
Salary for this position. Non-numeric values such as "$" symbols are not
+ * acceptable.
+ *
+ *
+ *
+ *
+ *
+ * Example
+ *
<g:salary>55000</g:salary>
+ *
+ *
+ *
+ *
+ * Attribute of
+ *
+ *
Jobs
+ *
+ *
+ *
Content type
+ *
+ *
+ *
+ * float
+ *
+ *
+ *
+ *
+ * @return Salary for this position
+ */
+ public Float getSalary();
+
+ /**
+ * Topics of study for a course.
+ *
+ *
+ *
+ *
+ *
+ *
subject
+ *
+ *
+ *
+ *
+ *
+ * Details
+ *
Topic of study for a course.
+ *
+ *
+ *
Example
+ *
+ *
<g:subject>Trigonometry</g:subject>
+ *
+ *
+ *
Attribute of
+ *
+ *
+ * Course schedules
+ *
+ *
+ *
Content type
+ *
string
+ *
+ *
+ *
+ *
+ *
+ * @param subject Topics of study for a course
+ */
+ public void setSubjects(String[] subject);
+
+ /**
+ * Topics of study for a course.
+ *
+ *
+ *
+ *
+ *
+ *
subject
+ *
+ *
+ *
+ *
+ *
+ * Details
+ *
Topic of study for a course.
+ *
+ *
+ *
Example
+ *
+ *
<g:subject>Trigonometry</g:subject>
+ *
+ *
+ *
Attribute of
+ *
+ *
+ * Course schedules
+ *
+ *
+ *
Content type
+ *
string
+ *
+ *
+ *
+ *
+ *
+ * @return Topics of study for a course
+ */
+ public String[] getSubjects();
+
+ /**
+ * Name of the school at which a class is offered.
+ *
+ *
+ *
+ *
university
+ *
+ *
+ *
+ *
Details
+ *
Name of the school a class is offered at.
+ *
+ *
+ *
+ *
+ *
Example
+ *
<g:university>Stanford</g:university>
+ *
+ *
+ *
+ *
+ *
+ * Attribute of
+ *
Course schedules
+ *
+ *
+ *
Content type
+ *
+ *
+ *
+ * string
+ *
+ *
+ *
+ *
+ * @param university Name of the school at which a class is offered.
+ */
+ public void setUniversity(String university);
+
+ /**
+ * Name of the school at which a class is offered.
+ *
+ *
+ *
+ *
university
+ *
+ *
+ *
+ *
Details
+ *
Name of the school a class is offered at.
+ *
+ *
+ *
+ *
+ *
Example
+ *
<g:university>Stanford</g:university>
+ *
+ *
+ *
+ *
+ *
+ * Attribute of
+ *
Course schedules
+ *
+ *
+ *
Content type
+ *
+ *
+ *
+ * string
+ *
+ *
+ *
+ *
+ * @return Name of the school at which a class is offered.
+ */
+ public String getUniversity();
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/base/CustomTag.java b/rome-modules/src/main/java/com/rometools/modules/base/CustomTag.java
new file mode 100644
index 0000000..5ec4373
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/base/CustomTag.java
@@ -0,0 +1,149 @@
+/*
+ * CustomTag.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) 2006 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 com.rometools.modules.base;
+
+/**
+ * This class represents a custom tag name and value.
+ *
+ * @author Robert "kebernet" Cooper
+ * @version $Revision: 1.2 $
+ */
+public interface CustomTag {
+
+ /**
+ * Returns the tag name used.
+ *
+ * @return Returns the tag name used.
+ */
+ public String getName();
+
+ /**
+ * The value of the custom tag.
+ *
+ *
+ *
+ *
+ *
Type (JavaType)
+ *
+ *
Description
+ *
Examples
+ *
+ *
+ *
string (String)
+ *
Any string
+ *
Blue
+ *
+ *
+ *
+ *
int (Integer)
+ *
Whole number values
+ *
1000
+ *
+ *
+ *
+ *
float (Float)
+ *
Numbers with decimal digits
+ *
3.5
+ *
+ *
+ *
intUnit (IntUnit)
+ *
+ *
Whole number value and a string
+ *
+ *
10 km
+ *
+ *
+ *
floatUnit (FloatUnit)
+ *
Numbers with decimal digits and a string
+ *
+ *
1.5 km
+ *
+ *
+ *
+ *
date (ShortDate)
+ *
Date of an event, in format YYYY-MM-DD
+ *
2005-12-12
+ *
+ *
+ *
+ *
dateTime (java.util.Date)
+ *
+ *
Date and time for an event, in format YYYY-MM-DDThh:mm:ss
+ *
2005-12-12T12:00:00
+ *
+ *
+ *
dateTimeRange (DateTimeRange)
+ *
+ *
Start and end dates for an event. An attribute of this type will contain
+ * two sub-attributes, <start> and <end> in format YYYY-MM-DD
+ *
+ * @return The value of the tag. The objects class is determined by the "type" attribute on the
+ * tag.
+ */
+ public Object getValue();
+
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/base/CustomTagImpl.java b/rome-modules/src/main/java/com/rometools/modules/base/CustomTagImpl.java
new file mode 100644
index 0000000..45e5891
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/base/CustomTagImpl.java
@@ -0,0 +1,246 @@
+/*
+ * CustomTagImpl.java
+ *
+ * Created on February 6, 2006, 12:06 AM
+ *
+ * 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
+ */
+package com.rometools.modules.base;
+
+import java.net.URL;
+import java.util.Date;
+
+import com.rometools.modules.base.types.DateTimeRange;
+import com.rometools.modules.base.types.FloatUnit;
+import com.rometools.modules.base.types.IntUnit;
+import com.rometools.modules.base.types.ShortDate;
+
+/**
+ * @version $Revision: 1.1 $
+ * @author Robert "kebernet" Cooper
+ */
+public class CustomTagImpl implements CustomTag {
+ private Object value;
+ private final String name;
+
+ /** Creates a new instance of CustomTagImpl */
+ public CustomTagImpl(final String name, final String value) {
+ if (name == null || value == null) {
+ throw new NullPointerException("Name and Value cannont be null.");
+ }
+ this.name = name;
+ this.value = value;
+ }
+
+ public CustomTagImpl(final String name, final Integer value) {
+ if (name == null || value == null) {
+ throw new NullPointerException("Name and Value cannont be null.");
+ }
+ this.name = name;
+ this.value = value;
+ }
+
+ public CustomTagImpl(final String name, final Float value) {
+ if (name == null || value == null) {
+ throw new NullPointerException("Name and Value cannont be null.");
+ }
+ this.name = name;
+ this.value = value;
+ }
+
+ public CustomTagImpl(final String name, final IntUnit value) {
+ if (name == null || value == null) {
+ throw new NullPointerException("Name and Value cannont be null.");
+ }
+ this.name = name;
+ this.value = value;
+ }
+
+ public CustomTagImpl(final String name, final FloatUnit value) {
+ if (name == null || value == null) {
+ throw new NullPointerException("Name and Value cannont be null.");
+ }
+ this.name = name;
+ this.value = value;
+ }
+
+ public CustomTagImpl(final String name, final ShortDate value) {
+ if (name == null || value == null) {
+ throw new NullPointerException("Name and Value cannont be null.");
+ }
+ this.name = name;
+ this.value = value;
+ }
+
+ public CustomTagImpl(final String name, final Date value) {
+ if (name == null || value == null) {
+ throw new NullPointerException("Name and Value cannont be null.");
+ }
+ this.name = name;
+ this.value = value;
+ }
+
+ public CustomTagImpl(final String name, final DateTimeRange value) {
+ if (name == null || value == null) {
+ throw new NullPointerException("Name and Value cannont be null.");
+ }
+ this.name = name;
+ this.value = value;
+ }
+
+ public CustomTagImpl(final String name, final URL value) {
+ if (name == null || value == null) {
+ throw new NullPointerException("Name and Value cannont be null.");
+ }
+ this.name = name;
+ this.value = value;
+ }
+
+ public CustomTagImpl(final String name, final Boolean value) {
+ if (name == null || value == null) {
+ throw new NullPointerException("Name and Value cannont be null.");
+ }
+ this.name = name;
+ this.value = value;
+ }
+
+ public CustomTagImpl(final String name, final Location value) {
+ if (name == null || value == null) {
+ throw new NullPointerException("Name and Value cannont be null.");
+ }
+ this.name = name;
+ this.value = value;
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public Object getValue() {
+ return value;
+ }
+
+ @Override
+ public boolean equals(final Object o) {
+ if (o instanceof CustomTag) {
+ final CustomTag tag = (CustomTag) o;
+ if (name.equals(tag.getName()) && value.equals(tag.getValue())) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Creates and returns a copy of this object. The precise meaning of "copy" may depend on the
+ * class of the object. The general intent is that, for any object x, the expression:
+ *
+ *
+ *
+ * x.clone() != x
+ *
+ *
+ *
will be true, and that the expression:
+ *
+ *
+ * x.clone().getClass() == x.getClass()
+ *
+ *
+ *
will be true, but these are not absolute requirements. While it is
+ * typically the case that:
+ *
+ *
+ * x.clone().equals(x)
+ *
+ *
+ *
will be true, this is not an absolute requirement.
+ *
+ * By convention, the returned object should be obtained by calling super.clone. If a
+ * class and all of its superclasses (except Object) obey this convention, it will be
+ * the case that x.clone().getClass() == x.getClass().
+ *
+ * By convention, the object returned by this method should be independent of this object (which
+ * is being cloned). To achieve this independence, it may be necessary to modify one or more
+ * fields of the object returned by super.clone before returning it. Typically, this
+ * means copying any mutable objects that comprise the internal "deep structure" of the object
+ * being cloned and replacing the references to these objects with references to the copies. If
+ * a class contains only primitive fields or references to immutable objects, then it is usually
+ * the case that no fields in the object returned by super.clone need to be modified.
+ *
+ * The method clone for class Object performs a specific cloning operation.
+ * First, if the class of this object does not implement the interface Cloneable, then
+ * a CloneNotSupportedException is thrown. Note that all arrays are considered to
+ * implement the interface Cloneable. Otherwise, this method creates a new instance of
+ * the class of this object and initializes all its fields with exactly the contents of the
+ * corresponding fields of this object, as if by assignment; the contents of the fields are not
+ * themselves cloned. Thus, this method performs a "shallow copy" of this object, not a
+ * "deep copy" operation.
+ *
+ * The class Object does not itself implement the interface Cloneable, so
+ * calling the clone method on an object whose class is Object will result in
+ * throwing an exception at run time.
+ *
+ * @return a clone of this instance.
+ * @exception CloneNotSupportedException if the object's class does not support the
+ * Cloneable interface. Subclasses that override the
+ * clone method can also throw this exception to indicate that an
+ * instance cannot be cloned.
+ * @see java.lang.Cloneable
+ */
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ final CustomTagImpl cti = new CustomTagImpl(name, "");
+ cti.value = value;
+ return cti;
+ }
+
+ @Override
+ public String toString() {
+ return "[custom name=\"" + name + "\" value=\"" + value.toString() + "\"]";
+ }
+
+ public static class Location {
+ private final String value;
+
+ public Location(final String value) {
+ this.value = value;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ @Override
+ public Object clone() {
+ return new Location(value);
+ }
+
+ @Override
+ public String toString() {
+ return value;
+ }
+
+ @Override
+ public boolean equals(final Object o) {
+ if (o instanceof Location && ((Location) o).value.equals(value)) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+ }
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/base/CustomTags.java b/rome-modules/src/main/java/com/rometools/modules/base/CustomTags.java
new file mode 100644
index 0000000..8d5159a
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/base/CustomTags.java
@@ -0,0 +1,57 @@
+/*
+ * CustomTags.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) 2006 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 com.rometools.modules.base;
+
+import java.util.List;
+
+import com.rometools.rome.feed.module.Module;
+
+/**
+ * @version $Revision: 1.1 $
+ * @author Robert "kebernet" Cooper
+ */
+public interface CustomTags extends Module {
+
+ public static final String URI = "http://base.google.com/cns/1.0";
+
+ public List getValues();
+
+ public void setValues(List values);
+
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/base/CustomTagsImpl.java b/rome-modules/src/main/java/com/rometools/modules/base/CustomTagsImpl.java
new file mode 100644
index 0000000..595bdc5
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/base/CustomTagsImpl.java
@@ -0,0 +1,90 @@
+/*
+ * CustomTagsImpl.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) 2006 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 com.rometools.modules.base;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.rometools.rome.feed.CopyFrom;
+
+/**
+ * @version $Revision: 1.1 $
+ * @author Robert "kebernet" Cooper
+ */
+public class CustomTagsImpl implements CustomTags {
+
+ private static final long serialVersionUID = 1L;
+
+ private List values;
+
+ @Override
+ public List getValues() {
+ values = values == null ? new ArrayList() : values;
+ return values;
+ }
+
+ @Override
+ public void setValues(final List values) {
+ this.values = values;
+ }
+
+ @Override
+ public void copyFrom(final CopyFrom object) {
+ final CustomTags ct = (CustomTags) object;
+ values = new ArrayList(ct.getValues());
+ }
+
+ @Override
+ public Object clone() {
+ final CustomTagsImpl cti = new CustomTagsImpl();
+ cti.values = new ArrayList(values);
+ return cti;
+ }
+
+ @Override
+ public Class getInterface() {
+ return CustomTags.class;
+ }
+
+ @Override
+ public String getUri() {
+ return CustomTags.URI;
+ }
+
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/base/Event.java b/rome-modules/src/main/java/com/rometools/modules/base/Event.java
new file mode 100644
index 0000000..578ea16
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/base/Event.java
@@ -0,0 +1,1346 @@
+/*
+ * Event.java
+ *
+ * Created on November 16, 2005, 11:38 AM
+ *
+ * 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.
+ */
+package com.rometools.modules.base;
+
+import com.rometools.modules.base.types.CurrencyEnumeration;
+import com.rometools.modules.base.types.DateTimeRange;
+import com.rometools.modules.base.types.FloatUnit;
+import com.rometools.modules.base.types.PaymentTypeEnumeration;
+import com.rometools.modules.base.types.PriceTypeEnumeration;
+import com.rometools.modules.base.types.ShippingType;
+
+/**
+ * This is an interface for the GoogleBase plug in that exposes methods used for Event entry types.
+ *
+ * @author Robert "kebernet" Cooper
+ * @version $Revision: 1.1 $
+ */
+public interface Event extends GlobalInterface {
+ /**
+ * Currency of the price amount for an item.
+ *
+ *
+ *
+ *
+ *
currency
+ *
+ *
+ *
+ *
Details
+ *
+ *
Currency of the price amount for an item. Values must be in ISO 4217
+ * currency code format.
+ *
+ * @param value Currency of the price amount for an item.
+ */
+ public void setCurrency(CurrencyEnumeration value);
+
+ /**
+ * Currency of the price amount for an item.
+ *
+ *
+ *
+ *
+ *
currency
+ *
+ *
+ *
+ *
Details
+ *
+ *
Currency of the price amount for an item. Values must be in ISO 4217
+ * currency code format.
+ *
+ * @return Additional instructions to explain the item’s delivery process.
+ */
+ public String getDeliveryNotes();
+
+ /**
+ * The maximum distance you will deliver an item in any direction.
+ *
+ *
+ *
+ *
delivery_radius
+ *
+ *
+ *
+ *
Details
+ *
The maximum distance you will deliver an item in any direction.
+ *
+ * @param deliveryRadius The maximum distance you will deliver an item in any direction.
+ */
+ public void setDeliveryRadius(FloatUnit deliveryRadius);
+
+ /**
+ * The maximum distance you will deliver an item in any direction.
+ *
+ *
+ *
+ *
delivery_radius
+ *
+ *
+ *
+ *
Details
+ *
The maximum distance you will deliver an item in any direction.
+ *
+ * @return The maximum distance you will deliver an item in any direction.
+ */
+ public FloatUnit getDeliveryRadius();
+
+ /**
+ * The time during which this event takes place.
+ *
+ *
+ *
+ *
+ *
event_date_range
+ *
+ *
+ *
+ *
Details
+ *
+ *
+ * Information on the date and time an event will take place, in ISO 8601
+ * format. Two sub-attributes are included in the event_date_range attribute:
+ *
+ *
+ *
from = Date and time an event will begin in format YYYY-MM-DDThh:mm:ss
+ *
to = (Optional). Date and time an event will end, in format YYYY-MM-DDThh:mm:ss
+ *
+ * @param eventDateRange The time during which this event takes place.
+ */
+ public void setEventDateRange(DateTimeRange eventDateRange);
+
+ /**
+ * The time during which this event takes place.
+ *
+ *
+ *
+ *
+ *
event_date_range
+ *
+ *
+ *
+ *
Details
+ *
+ *
+ * Information on the date and time an event will take place, in ISO 8601
+ * format. Two sub-attributes are included in the event_date_range attribute:
+ *
+ *
+ *
from = Date and time an event will begin in format YYYY-MM-DDThh:mm:ss
+ *
to = (Optional). Date and time an event will end, in format YYYY-MM-DDThh:mm:ss
+ *
+ * @return The time during which this event takes place.
+ */
+ public DateTimeRange getEventDateRange();
+
+ /**
+ * Location where the event will be held.
+ *
+ *
+ *
+ *
+ *
location
+ *
+ *
+ *
+ *
Details
+ *
Location of a property. Should include street, city, state, postal code,
+ * and country, in that order.
+ *
+ *
+ *
+ *
Example
+ *
+ *
Acceptable:
+ * <g:location>123 Main St, Anytown,
+ * CA, 12345,
+ * USA</g:location>
+ *
+ * Not acceptable:
+ * <g:location>123 Main St,, CA,
+ * 12345,
+ * USA</g:location>
+ * <g:location> Anytown, CA,
+ * 12345,
+ * USA</g:location>
+ *
+ *
+ *
+ *
Attribute of
+ *
Reference Items, Events, Housing, Jobs, News and Articles, People
+ * profiles, Products, Reviews, Services, Travel, Vehicles, Wanted Ads.
+ *
+ *
+ *
+ *
+ *
Content type
+ *
locationType
+ *
+ *
+ *
+ *
+ * @param location Location where the event will be held.
+ */
+ public void setLocation(String location);
+
+ /**
+ * Location where the event will be held.
+ *
+ *
+ *
+ *
+ *
location
+ *
+ *
+ *
+ *
Details
+ *
Location of a property. Should include street, city, state, postal code,
+ * and country, in that order.
+ *
+ *
+ *
+ *
Example
+ *
+ *
Acceptable:
+ * <g:location>123 Main St, Anytown,
+ * CA, 12345,
+ * USA</g:location>
+ *
+ * Not acceptable:
+ * <g:location>123 Main St,, CA,
+ * 12345,
+ * USA</g:location>
+ * <g:location> Anytown, CA,
+ * 12345,
+ * USA</g:location>
+ *
+ *
+ *
+ *
Attribute of
+ *
Reference Items, Events, Housing, Jobs, News and Articles, People
+ * profiles, Products, Reviews, Services, Travel, Vehicles, Wanted Ads.
+ *
+ *
+ *
+ *
+ *
Content type
+ *
locationType
+ *
+ *
+ *
+ *
+ * @return Location where the event will be held.
+ */
+ public String getLocation();
+
+ /**
+ * Payment Methods acceptable for the event.
+ *
+ *
+ *
+ *
+ *
+ *
payment_accepted
+ *
+ *
+ *
Details
+ *
Acceptable payment methods for item purchases. Acceptable values are
+ * "Cash," "Check," "Traveler’s Check," "Visa," "MasterCard,"
+ *
+ * "American Express," "Discover," "Wire transfer" or "Paypal." If you accept more than one
+ * method, include multiple instances of the <payment_accepted> attribute for each
+ * acceptable method.
+ *
+ * @param paymentAccepted Payment Methods acceptable for the event.
+ */
+ public void setPaymentAccepted(PaymentTypeEnumeration[] paymentAccepted);
+
+ /**
+ * Payment Methods acceptable for the event.
+ *
+ *
+ *
+ *
+ *
+ *
payment_accepted
+ *
+ *
+ *
Details
+ *
Acceptable payment methods for item purchases. Acceptable values are
+ * "Cash," "Check," "Traveler’s Check," "Visa," "MasterCard,"
+ *
+ * "American Express," "Discover," "Wire transfer" or "Paypal." If you accept more than one
+ * method, include multiple instances of the <payment_accepted> attribute for each
+ * acceptable method.
+ *
+ *
+ * @return Additional information about payment.
+ */
+ public String getPaymentNotes();
+
+ /**
+ * Price of the event.
+ *
+ *
+ *
+ *
+ *
+ *
+ *
price
+ *
+ *
+ *
+ *
+ * Details
+ *
Prices can be a single price, 0 (free), or blank if not applicable.
+ * Numerice values only. When used as a sub-attribute of <shipping>, the value included
+ * reflects the price of shipping.
+ *
+ * @param price Price of the event.
+ */
+ public void setPrice(FloatUnit price);
+
+ /**
+ * Price of the event.
+ *
+ *
+ *
+ *
+ *
+ *
+ *
price
+ *
+ *
+ *
+ *
+ * Details
+ *
Prices can be a single price, 0 (free), or blank if not applicable.
+ * Numerice values only. When used as a sub-attribute of <shipping>, the value included
+ * reflects the price of shipping.
The number of units available for purchase. This attribute can be left
+ * blank if you have a large quantity or if it is not applicable.
+ *
+ *
+ *
+ *
+ *
Example
+ *
Acceptable:
+ * <g:quantity>18</g:quantity>
+ *
+ * <g:quantity>0</g:quantity>
+ *
+ * Not acceptable:
+ * <g:quantity>out of stock</g:quantity>
+ *
+ *
+ *
+ *
+ * Attribute of
+ *
+ *
Events, Products, Services, Travel, Vehicles
+ *
+ *
+ *
Content type
+ *
+ *
+ *
+ * integer
+ *
+ *
+ *
+ *
+ * @return Quantity available.
+ */
+ public Integer getQuantity();
+
+ /**
+ * Shipping information related to the event.
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ * shipping
+ *
+ *
+ *
Details
+ *
+ *
Shipping options available for an item. Up to 10 shipping options can be
+ * included for each item. Three sub-attributes are included in the shipping attribute:
+ *
+ *
+ *
service = The type of service used to ship an item. Acceptable values are 'FedEx', 'UPS',
+ * 'DHL', 'Mail', and 'Other'
+ *
country = The country an item will ship to. Only acceptable values areISO 3166
+ * country codes.
+ *
+ * @param shipping Shipping information related to the event.
+ */
+ public void setShipping(ShippingType[] shipping);
+
+ /**
+ * Shipping information related to the event.
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ * shipping
+ *
+ *
+ *
Details
+ *
+ *
Shipping options available for an item. Up to 10 shipping options can be
+ * included for each item. Three sub-attributes are included in the shipping attribute:
+ *
+ *
+ *
service = The type of service used to ship an item. Acceptable values are 'FedEx', 'UPS',
+ * 'DHL', 'Mail', and 'Other'
+ *
country = The country an item will ship to. Only acceptable values areISO 3166
+ * country codes.
+ *
+ * @return Shipping information related to the event.
+ */
+ public ShippingType[] getShipping();
+
+ /**
+ * Tax rate associated with the event.
+ *
+ *
+ *
+ *
+ *
tax_percent
+ *
+ *
+ *
+ *
+ *
+ * Details
+ *
Tax rate as a percentage.
+ *
+ *
+ *
+ *
Example
+ *
+ *
<g:tax_percent>8.2<g:/tax_percent>
+ *
+ *
+ *
+ *
+ * Attribute of
+ *
+ *
+ * Products, Events
+ *
+ *
+ *
Content type
+ *
+ *
percentType
+ *
+ *
+ *
+ *
+ *
+ * @param taxPercent Tax rate associated with the event.
+ */
+ public void setTaxPercent(Float taxPercent);
+
+ /**
+ * Tax rate associated with the event.
+ *
+ *
+ *
+ *
+ *
tax_percent
+ *
+ *
+ *
+ *
+ *
+ * Details
+ *
Tax rate as a percentage.
+ *
+ *
+ *
+ *
Example
+ *
+ *
<g:tax_percent>8.2<g:/tax_percent>
+ *
+ *
+ *
+ *
+ * Attribute of
+ *
+ *
+ * Products, Events
+ *
+ *
+ *
Content type
+ *
+ *
percentType
+ *
+ *
+ *
+ *
+ *
+ * @return Tax rate associated with the event.
+ */
+ public Float getTaxPercent();
+
+ /**
+ * Region where tax applies.
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ * tax_region
+ *
+ *
+ *
+ *
Details
+ *
Geographical region a tax rate applies to.
+ *
+ *
+ *
+ *
+ *
+ * Example
+ *
<g:tax_region>California</g:tax_region>
+ *
+ *
+ *
+ *
Attribute of
+ *
+ *
Product, Events,
+ *
+ *
+ *
+ *
Content type
+ *
string
+ *
+ *
+ *
+ *
+ *
+ * @param taxRegion Region where tax applies.
+ */
+ public void setTaxRegion(String taxRegion);
+
+ /**
+ * Region where tax applies.
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ * tax_region
+ *
+ *
+ *
+ *
Details
+ *
Geographical region a tax rate applies to.
+ *
+ *
+ *
+ *
+ *
+ * Example
+ *
<g:tax_region>California</g:tax_region>
+ *
+ *
+ *
+ *
Attribute of
+ *
+ *
Product, Events,
+ *
+ *
+ *
+ *
Content type
+ *
string
+ *
+ *
+ *
+ *
+ *
+ * @return Region where tax applies.
+ */
+ public String getTaxRegion();
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/base/GlobalInterface.java b/rome-modules/src/main/java/com/rometools/modules/base/GlobalInterface.java
new file mode 100644
index 0000000..1760248
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/base/GlobalInterface.java
@@ -0,0 +1,554 @@
+/*
+ * GlobalInterface.java
+ *
+ * Created on November 16, 2005, 5:27 PM
+ *
+ * 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.
+ */
+package com.rometools.modules.base;
+
+import java.io.Serializable;
+import java.net.URL;
+import java.util.Date;
+
+/**
+ * This is an interface representing the universals.
+ *
+ * @author Robert "kebernet" Cooper
+ * @version $Revision: 1.2 $
+ */
+public interface GlobalInterface extends Serializable {
+ /**
+ * Expiration Date for this item.
+ *
+ *
+ *
+ *
+ *
expiration_date
+ *
+ *
+ *
Details
+ *
+ *
Date that the item expires in ISO 8601
+ * format: YYYY-MM-DD
+ *
+ * @param expirationDate the date this entry will expire
+ */
+ public void setExpirationDate(Date expirationDate);
+
+ /**
+ * Expiration Date for this item.
+ *
+ *
+ *
+ *
+ *
expiration_date
+ *
+ *
+ *
Details
+ *
+ *
Date that the item expires in ISO 8601
+ * format: YYYY-MM-DD
+ *
+ * @param expirationDateTime Date and time that the item expires.
+ */
+ public void setExpirationDateTime(Date expirationDateTime);
+
+ /**
+ * Date and time that the item expires.
+ *
+ *
+ *
+ *
+ *
expiration_date_time
+ *
+ *
+ *
+ *
Details
+ *
Date and time that the item expires in ISO 8601
+ * format: YYYY-MM-DDThh:mm:ss
+ *
+ * @return Date and time that the item expires.
+ */
+ public Date getExpirationDateTime();
+
+ /**
+ * Unique id for this item.
+ *
+ *
+ *
+ *
id
+ *
+ *
+ *
Details
+ *
+ *
Unique alphanumeric identifier for each item - e.g., your internal ID
+ * code.
+ * IMPORTANT: Once you submit an item with a unique id, this identifier must not change when you
+ * send in a new bulk upload. Each item must retain the same id in subsequent bulk
+ * uploads.
+ *
+ *
+ *
Example
+ *
+ *
+ * <g:id>01flx</g:id>
+ *
+ *
+ *
Attribute of
+ *
Reference Items, Events, Housing, Jobs, News and Articles, People
+ * profiles, Products, Reviews, Services, Travel, Vehicles, Wanted Ads.
+ *
+ *
+ *
+ *
+ *
Content type
+ *
string
+ *
+ *
+ *
+ *
+ * @param id unique identifier for this entry
+ */
+ public void setId(String id);
+
+ /**
+ * Unique id for this item.
+ *
+ *
+ *
+ *
id
+ *
+ *
+ *
Details
+ *
+ *
Unique alphanumeric identifier for each item - e.g., your internal ID
+ * code.
+ * IMPORTANT: Once you submit an item with a unique id, this identifier must not change when you
+ * send in a new bulk upload. Each item must retain the same id in subsequent bulk
+ * uploads.
+ *
+ *
+ *
Example
+ *
+ *
+ * <g:id>01flx</g:id>
+ *
+ *
+ *
Attribute of
+ *
Reference Items, Events, Housing, Jobs, News and Articles, People
+ * profiles, Products, Reviews, Services, Travel, Vehicles, Wanted Ads.
+ *
+ *
+ *
+ *
+ *
Content type
+ *
string
+ *
+ *
+ *
+ *
+ * @return unique identifier for this entry
+ */
+ public String getId();
+
+ /**
+ * Images for this item.
+ *
+ *
+ *
+ *
+ *
image_link
+ *
+ *
+ *
+ *
Details
+ *
URL of an associated image if available online. Use your full-sized
+ * images; do not use thumbnail images. Up to ten image_links, all placed in between their own
+ * <image_link> and </image_link> attributes, can be included with each item. If you
+ * do not have an image available, do not include this attribute. Please do not include an image
+ * that says "Image not available." Relative URLs and logo images are not acceptable.
Reference Items, Events, Housing, Jobs, News and Articles, People
+ * profiles, Products, Reviews, Services, Travel, Vehicles, Wanted Ads.
+ *
+ *
+ *
Content type
+ *
+ *
url
+ *
+ *
+ *
+ *
+ *
+ * @param imageLinks URLs to images. Limit 10.
+ */
+ public void setImageLinks(URL[] imageLinks);
+
+ /**
+ * Images for this item.
+ *
+ *
+ *
+ *
+ *
image_link
+ *
+ *
+ *
+ *
Details
+ *
URL of an associated image if available online. Use your full-sized
+ * images; do not use thumbnail images. Up to ten image_links, all placed in between their own
+ * <image_link> and </image_link> attributes, can be included with each item. If you
+ * do not have an image available, do not include this attribute. Please do not include an image
+ * that says "Image not available." Relative URLs and logo images are not acceptable.
Reference Items, Events, Housing, Jobs, News and Articles, People
+ * profiles, Products, Reviews, Services, Travel, Vehicles, Wanted Ads.
+ *
+ *
+ *
Content type
+ *
+ *
url
+ *
+ *
+ *
+ *
+ *
+ * @return URLs to images
+ */
+ public URL[] getImageLinks();
+
+ /**
+ * Labels for this item.
+ *
+ *
+ *
+ *
+ *
+ *
+ * label
+ *
+ *
+ *
+ *
+ * Details
+ *
+ * A list of classifications the item may fall under. Up to ten user-selected
+ * label, each placed in between their own <label>
+ *
+ * and </label> tags, can be included with each item. These attributes will be used to
+ * match your items to search queries. Each attribute value will be checked for policy
+ * compliance.
+ *
+ *
+ *
+ *
+ * Example
+ *
+ *
+ * Acceptable:
+ * For an automobile in a Vehicles information type:
+ *
+ *
+ * <g:label>Leather</g:label>
+ * <g:label>Power locks</g:label>
+ *
+ * <g:label>sunroof</g:label>
+ *
+ * <g:label>ABS</g:label>
+ *
+ * For a concert in an Events information type:
+ *
+ * <g:label>VIP</g:label>
+ *
+ * <g:label>front row</g:label>
+ * <g:label>backstage</g:label>
+ *
+ *
+ *
+ * <g:label>KROCK 101.5</g:label>
+ * <g:label>parking passes</g:label>
+ *
+ * Not acceptable:
+ *
+ * <g:label> leater, power locks, sunroof, ABS
+ * </g:label>
+ *
+ * @param labels labels for this entry. Limit 10.
+ */
+ public void setLabels(String[] labels);
+
+ /**
+ * Labels for this item.
+ *
+ *
+ *
+ *
+ *
+ *
+ * label
+ *
+ *
+ *
+ *
+ * Details
+ *
+ * A list of classifications the item may fall under. Up to ten user-selected
+ * label, each placed in between their own <label>
+ *
+ * and </label> tags, can be included with each item. These attributes will be used to
+ * match your items to search queries. Each attribute value will be checked for policy
+ * compliance.
+ *
+ *
+ *
+ *
+ * Example
+ *
+ *
+ * Acceptable:
+ * For an automobile in a Vehicles information type:
+ *
+ *
+ * <g:label>Leather</g:label>
+ * <g:label>Power locks</g:label>
+ *
+ * <g:label>sunroof</g:label>
+ *
+ * <g:label>ABS</g:label>
+ *
+ * For a concert in an Events information type:
+ *
+ * <g:label>VIP</g:label>
+ *
+ * <g:label>front row</g:label>
+ * <g:label>backstage</g:label>
+ *
+ *
+ *
+ * <g:label>KROCK 101.5</g:label>
+ * <g:label>parking passes</g:label>
+ *
+ * Not acceptable:
+ *
+ * <g:label> leater, power locks, sunroof, ABS
+ * </g:label>
+ *
+ * @return labels for this entry
+ */
+ public String[] getLabels();
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/base/GoogleBase.java b/rome-modules/src/main/java/com/rometools/modules/base/GoogleBase.java
new file mode 100644
index 0000000..db9b121
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/base/GoogleBase.java
@@ -0,0 +1,60 @@
+/*
+ * GoogleBase.java
+ *
+ * Created on November 16, 2005, 4:37 PM
+ *
+ * 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.
+ */
+package com.rometools.modules.base;
+
+import com.rometools.rome.feed.module.Module;
+
+/**
+ * This is the root interface for the Google Base module.
+ *
+ *
+ * It supports all the individual data "types". If you want to work with, for instance, just the
+ * Article or Job datatype, you can cast it to the respective interface and see only methods related
+ * to a particular entry type.
+ *
+ *
+ * @author Robert "kebernet" Cooper
+ * @version $Revision: 1.1 $
+ */
+public interface GoogleBase extends Module, Article, Course, Event, Job, Person, Product, Review, ScholarlyArticle, Service, Travel, Unknown, Vehicle, Wanted,
+ Housing {
+ /** This is the URI for the Google Base Schema. */
+ public static final String URI = "http://base.google.com/ns/1.0";
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/base/GoogleBaseImpl.java b/rome-modules/src/main/java/com/rometools/modules/base/GoogleBaseImpl.java
new file mode 100644
index 0000000..73f0840
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/base/GoogleBaseImpl.java
@@ -0,0 +1,1444 @@
+/*
+ * GoogleBaseImpl.java
+ *
+ * Created on November 16, 2005, 2:06 PM
+ *
+ * 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.
+ */
+package com.rometools.modules.base;
+
+import java.lang.reflect.Array;
+import java.net.URL;
+import java.util.Date;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.rometools.modules.base.types.CloneableType;
+import com.rometools.modules.base.types.CurrencyEnumeration;
+import com.rometools.modules.base.types.DateTimeRange;
+import com.rometools.modules.base.types.FloatUnit;
+import com.rometools.modules.base.types.GenderEnumeration;
+import com.rometools.modules.base.types.IntUnit;
+import com.rometools.modules.base.types.PaymentTypeEnumeration;
+import com.rometools.modules.base.types.PriceTypeEnumeration;
+import com.rometools.modules.base.types.ShippingType;
+import com.rometools.modules.base.types.ShortDate;
+import com.rometools.modules.base.types.Size;
+import com.rometools.modules.base.types.YearType;
+import com.rometools.rome.feed.CopyFrom;
+import com.rometools.rome.feed.impl.EqualsBean;
+
+/**
+ * This is the implementation class for the GoogleBase module interface.
+ *
+ * @author Robert "kebernet" Cooper
+ * @version $Revision: 1.2 $
+ */
+public class GoogleBaseImpl implements GoogleBase {
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+ private static final Logger LOG = LoggerFactory.getLogger(GoogleBaseImpl.class);
+
+ /** boolean:listing_type */
+ private Boolean listingType;
+
+ /** Can this item be picked up. */
+ private Boolean pickup;
+
+ /** currencyCodeEnumeration:currency */
+ private CurrencyEnumeration currency;
+
+ /** dateTime:expiration_date_time */
+ private Date expirationDateTime;
+
+ /** dateTimeRange:course_date_range */
+ private DateTimeRange courseDateRange;
+
+ /** dateTimeRange:event_date_range */
+ private DateTimeRange eventDateRange;
+
+ /** dateTimeRange:travel_date_range */
+ private DateTimeRange travelDateRange;
+
+ /** float:bathrooms */
+ private Float bathrooms;
+
+ /** float:hoa_dues */
+ private Float hoaDues;
+
+ /** string:rating thoug this a value from 1 to 5 */
+ private Float rating;
+
+ /** float:salary */
+ private Float salary;
+
+ /** percentType:tax_percent */
+ private Float taxPercent;
+
+ /** floatUnit:delivery_radius */
+ private FloatUnit deliveryRadius;
+
+ /** floatUnit:megapixels */
+ private FloatUnit megapixels;
+
+ /** floatUnit:memory */
+ private FloatUnit memory;
+
+ /** floatUnit:price */
+ private FloatUnit price;
+
+ /** floatUnit:processor_speed */
+ private FloatUnit processorSpeed;
+
+ /** floatUnit:weight */
+ private FloatUnit weight;
+
+ /** genderEnumeration:gender */
+ private GenderEnumeration gender;
+
+ /** intUnit:area */
+ private IntUnit area;
+
+ /** integer:age */
+ private Integer age;
+
+ /** integer:bedrooms */
+ private Integer bedrooms;
+
+ /** integer:mileage */
+ private Integer mileage;
+
+ /** integer:pages */
+ private Integer pages;
+
+ /** integer:quantity */
+ private Integer quantity;
+
+ /** locationType:from_location */
+ private String fromLocation;
+
+ /** locationType:location */
+ private String location;
+
+ /** locationType:to_location */
+ private String toLocation;
+
+ /** priceTypeEnumeration:price_type */
+ private PriceTypeEnumeration priceType;
+
+ /** starting/neg:salary_type */
+ private PriceTypeEnumeration salaryType;
+
+ /** date:expiration_date */
+ private ShortDate expirationDate;
+
+ /** date:publishedDate */
+ private ShortDate publishDate;
+
+ /** string:size */
+ private Size size;
+
+ /** string:sexual_orientation */
+ private String SexualOrientation;
+
+ /** string apparel_type */
+ private String apparelType;
+
+ /** string:brand */
+ private String brand;
+
+ /** string:condition */
+ private String condition;
+
+ /** string:course_number */
+ private String courseNumber;
+
+ /** string:course_times */
+ private String courseTimes;
+
+ /** string:delivery_notes */
+ private String deliveryNotes;
+
+ /** string:education */
+ private String education;
+
+ /** string:employer */
+ private String employer;
+
+ /** string:id */
+ private String id;
+
+ /** string:immigration_status */
+ private String immigrationStatus;
+
+ /** stirng:isbn */
+ private String isbn;
+
+ /** string:make */
+ private String make;
+
+ /** string:manufacturer */
+ private String manufacturer;
+
+ /** string:manufacturer_id */
+ private String manufacturerId;
+
+ /** string:marital_status */
+ private String maritalStatus;
+
+ /** string:model */
+ private String model;
+
+ /** string:model_number */
+ private String modelNumber;
+
+ /** string:name_of_item_being_reviewed */
+ private String nameOfItemBeingReviewed;
+
+ /** string:news_source */
+ private String newsSource;
+
+ /** string:occupation */
+ private String occupation;
+
+ /** string:operating_systems */
+ private String operatingSystems;
+
+ /** string:payment_notes */
+ private String paymentNotes;
+
+ /** string:publication_name */
+ private String publicationName;
+
+ /** string:publication_volume */
+ private String publicationVolume;
+
+ /** string:review_type */
+ private String reviewType;
+
+ /** string:reviewer_type */
+ private String reviewerType;
+
+ /** string:school_district */
+ private String schoolDistrict;
+
+ /** string:service_type */
+ private String serviceType;
+
+ /** string:taxRegion */
+ private String taxRegion;
+
+ /** string:university */
+ private String university;
+
+ /** string:upc */
+ private String upc;
+
+ /** string:vehicle_type */
+ private String vehicleType;
+
+ /** string:vin */
+ private String vin;
+
+ /** string:url_of_item_being_reviewed */
+ private URL urlOfItemBeingReviewed;
+
+ /** string:year */
+ private YearType year;
+
+ /** string:actor */
+ private String[] actors;
+
+ /** string:agent */
+ private String[] agents;
+
+ /** string:artist */
+ private String[] artists;
+
+ /** string:author */
+ private String[] authors;
+
+ /** string:color */
+ private String[] color;
+
+ /** string:ethnicities */
+ private String[] ethnicities;
+
+ /** string:format */
+ private String[] format;
+
+ /** url:image_links */
+ private URL[] imageLinks;
+
+ /** string:interested_in */
+ private String[] interestedIn;
+
+ /** string:job_function */
+ private String[] jobFunctions;
+
+ /** string:job_industry */
+ private String[] jobIndustries;
+
+ /** string:job_type */
+ private String[] jobTypes;
+
+ /** string:label */
+ private String[] labels;
+
+ /** string:license */
+ private String[] licenses;
+
+ /** paymentTypeEnumeration:payment_accepted */
+ private PaymentTypeEnumeration[] paymentAccepted;
+
+ /** string:product_type */
+ private String[] productTypes;
+
+ /** string:programming_language */
+ private String[] programmingLanguages;
+
+ /** string:property_type */
+ private String[] propertyTypes;
+
+ /** url:related_link */
+ private URL[] relatedLinks;
+
+ /** shippingType:shipping */
+ private ShippingType[] shipping;
+
+ /** intUnitType:square_footage */
+ private IntUnit[] squareFootages;
+
+ /** string:subject_area */
+ private String[] subjectAreas;
+
+ /** string:subject */
+ private String[] subjects;
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param actors
+ */
+ @Override
+ public void setActors(final String[] actors) {
+ this.actors = actors;
+ }
+
+ @Override
+ public String[] getActors() {
+ return actors == null ? new String[0] : actors;
+ }
+
+ @Override
+ public void setAge(final Integer age) {
+ this.age = age;
+ }
+
+ @Override
+ public Integer getAge() {
+ return age;
+ }
+
+ @Override
+ public void setAgents(final String[] agents) {
+ this.agents = agents == null ? new String[0] : agents;
+ }
+
+ @Override
+ public String[] getAgents() {
+ return agents;
+ }
+
+ @Override
+ public void setApparelType(final String apparelType) {
+ this.apparelType = apparelType;
+ }
+
+ @Override
+ public String getApparelType() {
+ return apparelType;
+ }
+
+ @Override
+ public void setArea(final IntUnit area) {
+ this.area = area;
+ }
+
+ @Override
+ public IntUnit getArea() {
+ return area;
+ }
+
+ @Override
+ public void setArtists(final String[] artists) {
+ this.artists = artists;
+ }
+
+ @Override
+ public String[] getArtists() {
+ return artists == null ? new String[0] : artists;
+ }
+
+ @Override
+ public void setAuthors(final String[] authors) {
+ this.authors = authors;
+ }
+
+ @Override
+ public String[] getAuthors() {
+ return authors == null ? new String[0] : authors;
+ }
+
+ @Override
+ public void setBathrooms(final Float bathrooms) {
+ this.bathrooms = bathrooms;
+ }
+
+ @Override
+ public Float getBathrooms() {
+ return bathrooms;
+ }
+
+ @Override
+ public void setBedrooms(final Integer bedrooms) {
+ this.bedrooms = bedrooms;
+ }
+
+ @Override
+ public Integer getBedrooms() {
+ return bedrooms;
+ }
+
+ @Override
+ public void setBrand(final String brand) {
+ this.brand = brand;
+ }
+
+ @Override
+ public String getBrand() {
+ return brand;
+ }
+
+ @Override
+ public void setColors(final String[] color) {
+ this.color = color;
+ }
+
+ @Override
+ public String[] getColors() {
+ return color == null ? new String[0] : color;
+ }
+
+ @Override
+ public void setCondition(final String condition) {
+ this.condition = condition;
+ }
+
+ @Override
+ public String getCondition() {
+ return condition;
+ }
+
+ @Override
+ public void setCourseDateRange(final DateTimeRange courseDateRange) {
+ this.courseDateRange = courseDateRange;
+ }
+
+ @Override
+ public DateTimeRange getCourseDateRange() {
+ return courseDateRange;
+ }
+
+ @Override
+ public void setCourseNumber(final String courseNumber) {
+ this.courseNumber = courseNumber;
+ }
+
+ @Override
+ public String getCourseNumber() {
+ return courseNumber;
+ }
+
+ @Override
+ public void setCourseTimes(final String courseTimes) {
+ this.courseTimes = courseTimes;
+ }
+
+ @Override
+ public String getCourseTimes() {
+ return courseTimes;
+ }
+
+ @Override
+ public void setCurrency(final CurrencyEnumeration currency) {
+ this.currency = currency;
+ }
+
+ @Override
+ public CurrencyEnumeration getCurrency() {
+ return currency;
+ }
+
+ @Override
+ public void setDeliveryNotes(final String deliveryNotes) {
+ this.deliveryNotes = deliveryNotes;
+ }
+
+ @Override
+ public String getDeliveryNotes() {
+ return deliveryNotes;
+ }
+
+ @Override
+ public void setDeliveryRadius(final FloatUnit deliveryRadius) {
+ this.deliveryRadius = deliveryRadius;
+ }
+
+ @Override
+ public FloatUnit getDeliveryRadius() {
+ return deliveryRadius;
+ }
+
+ @Override
+ public void setEducation(final String education) {
+ this.education = education;
+ }
+
+ @Override
+ public String getEducation() {
+ return education;
+ }
+
+ @Override
+ public void setEmployer(final String employer) {
+ this.employer = employer;
+ }
+
+ @Override
+ public String getEmployer() {
+ return employer;
+ }
+
+ @Override
+ public void setEthnicities(final String[] ethnicities) {
+ this.ethnicities = ethnicities;
+ }
+
+ @Override
+ public String[] getEthnicities() {
+ return ethnicities == null ? new String[0] : ethnicities;
+ }
+
+ @Override
+ public void setEventDateRange(final DateTimeRange eventDateRange) {
+ this.eventDateRange = eventDateRange;
+ }
+
+ @Override
+ public DateTimeRange getEventDateRange() {
+ return eventDateRange;
+ }
+
+ @Override
+ public void setExpirationDate(final Date expirationDate) {
+ if (expirationDate != null && !(expirationDate instanceof ShortDate)) {
+ this.expirationDate = new ShortDate(expirationDate);
+ } else {
+ this.expirationDate = null;
+ }
+ }
+
+ @Override
+ public Date getExpirationDate() {
+ return expirationDate;
+ }
+
+ @Override
+ public void setExpirationDateTime(final Date expirationDateTime) {
+ this.expirationDateTime = expirationDateTime;
+ }
+
+ @Override
+ public Date getExpirationDateTime() {
+ return expirationDateTime;
+ }
+
+ @Override
+ public void setFormat(final String[] format) {
+ this.format = format;
+ }
+
+ @Override
+ public String[] getFormat() {
+ return format == null ? new String[0] : format;
+ }
+
+ @Override
+ public void setFromLocation(final String fromLocation) {
+ this.fromLocation = fromLocation;
+ }
+
+ @Override
+ public String getFromLocation() {
+ return fromLocation;
+ }
+
+ @Override
+ public void setGender(final GenderEnumeration gender) {
+ this.gender = gender;
+ }
+
+ @Override
+ public GenderEnumeration getGender() {
+ return gender;
+ }
+
+ @Override
+ public void setHoaDues(final Float hoaDues) {
+ this.hoaDues = hoaDues;
+ }
+
+ @Override
+ public Float getHoaDues() {
+ return hoaDues;
+ }
+
+ @Override
+ public void setId(final String id) {
+ this.id = id;
+ }
+
+ @Override
+ public String getId() {
+ return id;
+ }
+
+ @Override
+ public void setImageLinks(final URL[] imageLinks) {
+ this.imageLinks = imageLinks;
+ }
+
+ @Override
+ public URL[] getImageLinks() {
+ return imageLinks == null ? new URL[0] : imageLinks;
+ }
+
+ @Override
+ public void setImmigrationStatus(final String immigrationStatus) {
+ this.immigrationStatus = immigrationStatus;
+ }
+
+ @Override
+ public String getImmigrationStatus() {
+ return immigrationStatus;
+ }
+
+ @Override
+ public void setInterestedIn(final String[] interestedIn) {
+ this.interestedIn = interestedIn;
+ }
+
+ @Override
+ public String[] getInterestedIn() {
+ return interestedIn == null ? new String[0] : interestedIn;
+ }
+
+ @Override
+ public Class getInterface() {
+ return GoogleBase.class;
+ }
+
+ @Override
+ public void setIsbn(final String isbn) {
+ this.isbn = isbn;
+ }
+
+ @Override
+ public String getIsbn() {
+ return isbn;
+ }
+
+ @Override
+ public void setJobFunctions(final String[] jobFunctions) {
+ this.jobFunctions = jobFunctions;
+ }
+
+ @Override
+ public String[] getJobFunctions() {
+ return jobFunctions == null ? new String[0] : jobFunctions;
+ }
+
+ @Override
+ public void setJobIndustries(final String[] jobIndustries) {
+ this.jobIndustries = jobIndustries;
+ }
+
+ @Override
+ public String[] getJobIndustries() {
+ return jobIndustries == null ? new String[0] : jobIndustries;
+ }
+
+ @Override
+ public void setJobTypes(final String[] jobTypes) {
+ this.jobTypes = jobTypes;
+ }
+
+ @Override
+ public String[] getJobTypes() {
+ return jobTypes == null ? new String[0] : jobTypes;
+ }
+
+ @Override
+ public void setLabels(final String[] labels) {
+ this.labels = labels;
+ }
+
+ @Override
+ public String[] getLabels() {
+ return labels == null ? new String[0] : labels;
+ }
+
+ @Override
+ public void setLicenses(final String[] licenses) {
+ this.licenses = licenses;
+ }
+
+ @Override
+ public String[] getLicenses() {
+ return licenses == null ? new String[0] : licenses;
+ }
+
+ @Override
+ public void setListingType(final Boolean listingType) {
+ this.listingType = listingType;
+ }
+
+ @Override
+ public Boolean getListingType() {
+ return listingType;
+ }
+
+ @Override
+ public void setLocation(final String location) {
+ this.location = location;
+ }
+
+ @Override
+ public String getLocation() {
+ return location;
+ }
+
+ @Override
+ public void setMake(final String make) {
+ this.make = make;
+ }
+
+ @Override
+ public String getMake() {
+ return make;
+ }
+
+ @Override
+ public void setManufacturer(final String manufacturer) {
+ this.manufacturer = manufacturer;
+ }
+
+ @Override
+ public String getManufacturer() {
+ return manufacturer;
+ }
+
+ @Override
+ public void setManufacturerId(final String manufacturerId) {
+ this.manufacturerId = manufacturerId;
+ }
+
+ @Override
+ public String getManufacturerId() {
+ return manufacturerId;
+ }
+
+ @Override
+ public void setMaritalStatus(final String maritalStatus) {
+ this.maritalStatus = maritalStatus;
+ }
+
+ @Override
+ public String getMaritalStatus() {
+ return maritalStatus;
+ }
+
+ @Override
+ public void setMegapixels(final FloatUnit megapixels) {
+ this.megapixels = megapixels;
+ }
+
+ @Override
+ public FloatUnit getMegapixels() {
+ return megapixels;
+ }
+
+ @Override
+ public void setMemory(final FloatUnit memory) {
+ this.memory = memory;
+ }
+
+ @Override
+ public FloatUnit getMemory() {
+ return memory;
+ }
+
+ @Override
+ public void setMileage(final Integer mileage) {
+ this.mileage = mileage;
+ }
+
+ @Override
+ public Integer getMileage() {
+ return mileage;
+ }
+
+ @Override
+ public void setModel(final String model) {
+ this.model = model;
+ }
+
+ @Override
+ public String getModel() {
+ return model;
+ }
+
+ @Override
+ public void setModelNumber(final String modelNumber) {
+ this.modelNumber = modelNumber;
+ }
+
+ @Override
+ public String getModelNumber() {
+ return modelNumber;
+ }
+
+ @Override
+ public void setNameOfItemBeingReviewed(final String nameOfItemBeingReviewed) {
+ this.nameOfItemBeingReviewed = nameOfItemBeingReviewed;
+ }
+
+ @Override
+ public String getNameOfItemBeingReviewed() {
+ return nameOfItemBeingReviewed;
+ }
+
+ @Override
+ public void setNewsSource(final String newsSource) {
+ this.newsSource = newsSource;
+ }
+
+ @Override
+ public String getNewsSource() {
+ return newsSource;
+ }
+
+ @Override
+ public void setOccupation(final String occupation) {
+ this.occupation = occupation;
+ }
+
+ @Override
+ public String getOccupation() {
+ return occupation;
+ }
+
+ @Override
+ public void setOperatingSystems(final String operatingSystems) {
+ this.operatingSystems = operatingSystems;
+ }
+
+ @Override
+ public String getOperatingSystems() {
+ return operatingSystems;
+ }
+
+ @Override
+ public void setPages(final Integer pages) {
+ this.pages = pages;
+ }
+
+ @Override
+ public Integer getPages() {
+ return pages;
+ }
+
+ @Override
+ public void setPaymentAccepted(final PaymentTypeEnumeration[] paymentAccepted) {
+ this.paymentAccepted = paymentAccepted;
+ }
+
+ @Override
+ public PaymentTypeEnumeration[] getPaymentAccepted() {
+ return paymentAccepted == null ? new PaymentTypeEnumeration[0] : paymentAccepted;
+ }
+
+ @Override
+ public void setPaymentNotes(final String paymentNotes) {
+ this.paymentNotes = paymentNotes;
+ }
+
+ @Override
+ public String getPaymentNotes() {
+ return paymentNotes;
+ }
+
+ @Override
+ public void setPickup(final Boolean pickup) {
+ this.pickup = pickup;
+ }
+
+ @Override
+ public Boolean getPickup() {
+ return pickup;
+ }
+
+ @Override
+ public void setPrice(final FloatUnit price) {
+ this.price = price;
+ }
+
+ @Override
+ public FloatUnit getPrice() {
+ return price;
+ }
+
+ @Override
+ public void setPriceType(final PriceTypeEnumeration priceType) {
+ this.priceType = priceType;
+ }
+
+ @Override
+ public PriceTypeEnumeration getPriceType() {
+ return priceType;
+ }
+
+ @Override
+ public void setProcessorSpeed(final FloatUnit processorSpeed) {
+ this.processorSpeed = processorSpeed;
+ }
+
+ @Override
+ public FloatUnit getProcessorSpeed() {
+ return processorSpeed;
+ }
+
+ @Override
+ public void setProductTypes(final String[] productTypes) {
+ this.productTypes = productTypes;
+ }
+
+ @Override
+ public String[] getProductTypes() {
+ return productTypes == null ? new String[0] : productTypes;
+ }
+
+ @Override
+ public void setProgrammingLanguages(final String[] programmingLanguages) {
+ this.programmingLanguages = programmingLanguages;
+ }
+
+ @Override
+ public String[] getProgrammingLanguages() {
+ return programmingLanguages == null ? new String[0] : programmingLanguages;
+ }
+
+ @Override
+ public void setPropertyTypes(final String[] propertyTypes) {
+ this.propertyTypes = propertyTypes;
+ }
+
+ @Override
+ public String[] getPropertyTypes() {
+ return propertyTypes == null ? new String[0] : propertyTypes;
+ }
+
+ @Override
+ public void setPublicationName(final String publicationName) {
+ this.publicationName = publicationName;
+ }
+
+ @Override
+ public String getPublicationName() {
+ return publicationName;
+ }
+
+ @Override
+ public void setPublicationVolume(final String publicationVolume) {
+ this.publicationVolume = publicationVolume;
+ }
+
+ @Override
+ public String getPublicationVolume() {
+ return publicationVolume;
+ }
+
+ @Override
+ public void setPublishDate(final Date publishDate) {
+ if (publishDate != null && !(publishDate instanceof ShortDate)) {
+ this.publishDate = new ShortDate(publishDate);
+ } else {
+ this.publishDate = null;
+ }
+ }
+
+ @Override
+ public Date getPublishDate() {
+ return publishDate;
+ }
+
+ @Override
+ public void setQuantity(final Integer quantity) {
+ this.quantity = quantity;
+ }
+
+ @Override
+ public Integer getQuantity() {
+ return quantity;
+ }
+
+ @Override
+ public void setRating(final Float rating) {
+ this.rating = rating;
+ }
+
+ @Override
+ public Float getRating() {
+ return rating;
+ }
+
+ @Override
+ public void setRelatedLinks(final URL[] relatedLinks) {
+ this.relatedLinks = relatedLinks;
+ }
+
+ @Override
+ public URL[] getRelatedLinks() {
+ return relatedLinks == null ? new URL[0] : relatedLinks;
+ }
+
+ @Override
+ public void setReviewType(final String reviewType) {
+ this.reviewType = reviewType;
+ }
+
+ @Override
+ public String getReviewType() {
+ return reviewType;
+ }
+
+ @Override
+ public void setReviewerType(final String reviewerType) {
+ this.reviewerType = reviewerType;
+ }
+
+ @Override
+ public String getReviewerType() {
+ return reviewerType;
+ }
+
+ @Override
+ public void setSalary(final Float salary) {
+ this.salary = salary;
+ }
+
+ @Override
+ public Float getSalary() {
+ return salary;
+ }
+
+ @Override
+ public void setSalaryType(final PriceTypeEnumeration salaryType) {
+ this.salaryType = salaryType;
+ }
+
+ @Override
+ public PriceTypeEnumeration getSalaryType() {
+ return salaryType;
+ }
+
+ @Override
+ public void setSchoolDistrict(final String schoolDistrict) {
+ this.schoolDistrict = schoolDistrict;
+ }
+
+ @Override
+ public String getSchoolDistrict() {
+ return schoolDistrict;
+ }
+
+ @Override
+ public void setServiceType(final String serviceType) {
+ this.serviceType = serviceType;
+ }
+
+ @Override
+ public String getServiceType() {
+ return serviceType;
+ }
+
+ @Override
+ public void setSexualOrientation(final String SexualOrientation) {
+ this.SexualOrientation = SexualOrientation;
+ }
+
+ @Override
+ public String getSexualOrientation() {
+ return SexualOrientation;
+ }
+
+ @Override
+ public void setShipping(final ShippingType[] shipping) {
+ this.shipping = shipping;
+ }
+
+ @Override
+ public ShippingType[] getShipping() {
+ return shipping == null ? new ShippingType[0] : shipping;
+ }
+
+ @Override
+ public void setSize(final Size size) {
+ this.size = size;
+ }
+
+ @Override
+ public Size getSize() {
+ return size;
+ }
+
+ @Override
+ public void setSquareFootages(final IntUnit[] squareFootages) {
+ this.squareFootages = squareFootages;
+ }
+
+ @Override
+ public IntUnit[] getSquareFootages() {
+ return squareFootages == null ? new IntUnit[0] : squareFootages;
+ }
+
+ @Override
+ public void setSubjectAreas(final String[] subjectAreas) {
+ this.subjectAreas = subjectAreas;
+ }
+
+ @Override
+ public String[] getSubjectAreas() {
+ return subjectAreas == null ? new String[0] : subjectAreas;
+ }
+
+ @Override
+ public void setSubjects(final String[] subjects) {
+ this.subjects = subjects;
+ }
+
+ @Override
+ public String[] getSubjects() {
+ return subjects == null ? new String[0] : subjects;
+ }
+
+ @Override
+ public void setTaxPercent(final Float taxPercent) {
+ this.taxPercent = taxPercent;
+ }
+
+ @Override
+ public Float getTaxPercent() {
+ return taxPercent;
+ }
+
+ @Override
+ public void setTaxRegion(final String taxRegion) {
+ this.taxRegion = taxRegion;
+ }
+
+ @Override
+ public String getTaxRegion() {
+ return taxRegion;
+ }
+
+ @Override
+ public void setToLocation(final String toLocation) {
+ this.toLocation = toLocation;
+ }
+
+ @Override
+ public String getToLocation() {
+ return toLocation;
+ }
+
+ @Override
+ public void setTravelDateRange(final DateTimeRange travelDateRange) {
+ this.travelDateRange = travelDateRange;
+ }
+
+ @Override
+ public DateTimeRange getTravelDateRange() {
+ return travelDateRange;
+ }
+
+ @Override
+ public void setUniversity(final String university) {
+ this.university = university;
+ }
+
+ @Override
+ public String getUniversity() {
+ return university;
+ }
+
+ @Override
+ public void setUpc(final String upc) {
+ this.upc = upc;
+ }
+
+ @Override
+ public String getUpc() {
+ return upc;
+ }
+
+ @Override
+ public String getUri() {
+ return GoogleBase.URI;
+ }
+
+ @Override
+ public void setUrlOfItemBeingReviewed(final URL urlOfItemBeingReviewed) {
+ this.urlOfItemBeingReviewed = urlOfItemBeingReviewed;
+ }
+
+ @Override
+ public URL getUrlOfItemBeingReviewed() {
+ return urlOfItemBeingReviewed;
+ }
+
+ @Override
+ public void setVehicleType(final String vehicleType) {
+ this.vehicleType = vehicleType;
+ }
+
+ @Override
+ public String getVehicleType() {
+ return vehicleType;
+ }
+
+ @Override
+ public void setVin(final String vin) {
+ this.vin = vin;
+ }
+
+ @Override
+ public String getVin() {
+ return vin;
+ }
+
+ @Override
+ public void setWeight(final FloatUnit weight) {
+ this.weight = weight;
+ }
+
+ @Override
+ public FloatUnit getWeight() {
+ return weight;
+ }
+
+ @Override
+ public void setYear(final YearType year) {
+ this.year = year;
+ }
+
+ @Override
+ public YearType getYear() {
+ return year;
+ }
+
+ // TODO: Finish
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ try {
+ final GoogleBaseImpl gbi = new GoogleBaseImpl();
+ gbi.copyFrom(this);
+
+ return gbi;
+ } catch (final Exception e) {
+ LOG.error("Error", e);
+ throw new CloneNotSupportedException();
+ }
+ }
+
+ @Override
+ public void copyFrom(final CopyFrom obj) {
+ if (!(obj instanceof GoogleBase)) {
+ return;
+ }
+
+ final GoogleBase source = (GoogleBase) obj;
+
+ setActors((String[]) arrayCopy(source.getActors()));
+ setAge(source.getAge());
+ setAgents((String[]) arrayCopy(source.getAgents()));
+ setApparelType(source.getApparelType());
+ setArea(source.getArea());
+ setArtists((String[]) arrayCopy(source.getArtists()));
+ setAuthors((String[]) arrayCopy(source.getAuthors()));
+ setBathrooms(source.getBathrooms());
+ setBedrooms(source.getBedrooms());
+ setBrand(source.getBrand());
+ setColors((String[]) arrayCopy(source.getColors()));
+ setCondition(source.getCondition());
+ setCourseDateRange((DateTimeRange) cloneOrNull(source.getCourseDateRange()));
+ setCourseNumber(source.getCourseNumber());
+ setCourseTimes(source.getCourseTimes());
+ setDeliveryNotes(source.getDeliveryNotes());
+ setDeliveryRadius(source.getDeliveryRadius());
+ setEducation(source.getEducation());
+ setEmployer(source.getEmployer());
+ setEthnicities((String[]) arrayCopy(source.getEthnicities()));
+ setEventDateRange((DateTimeRange) cloneOrNull(source.getEventDateRange()));
+ setExpirationDate(dateOrNull(source.getExpirationDate()));
+ setExpirationDateTime(dateOrNull(source.getExpirationDateTime()));
+ setFormat(source.getFormat());
+ setFromLocation(source.getFromLocation());
+ setGender(source.getGender());
+ setHoaDues(source.getHoaDues());
+ setId(source.getId());
+ setImageLinks((URL[]) arrayCopy(source.getImageLinks()));
+ setImmigrationStatus(source.getImmigrationStatus());
+ setInterestedIn(source.getInterestedIn());
+ setIsbn(source.getIsbn());
+ setJobFunctions((String[]) arrayCopy(source.getJobFunctions()));
+ setJobIndustries((String[]) arrayCopy(source.getJobIndustries()));
+ setJobTypes((String[]) arrayCopy(source.getJobTypes()));
+ setLabels((String[]) arrayCopy(source.getLabels()));
+ setListingType(source.getListingType());
+ setLocation(source.getLocation());
+ setMake(source.getMake());
+ setManufacturer(source.getManufacturer());
+ setManufacturerId(source.getManufacturerId());
+ setMaritalStatus(source.getMaritalStatus());
+ setMegapixels(source.getMegapixels());
+ setMemory(source.getMemory());
+ setMileage(source.getMileage());
+ setModel(source.getModel());
+ setModelNumber(source.getModelNumber());
+ setNameOfItemBeingReviewed(source.getNameOfItemBeingReviewed());
+ setNewsSource(source.getNewsSource());
+ setOccupation(source.getOccupation());
+ setPages(source.getPages());
+ setPaymentAccepted((PaymentTypeEnumeration[]) arrayCopy(source.getPaymentAccepted()));
+ setPaymentNotes(source.getPaymentNotes());
+ setPickup(source.getPickup());
+ setPrice(source.getPrice());
+ setPriceType(source.getPriceType());
+ setProcessorSpeed(source.getProcessorSpeed());
+ setProductTypes((String[]) arrayCopy(source.getProductTypes()));
+ setPropertyTypes((String[]) arrayCopy(source.getPropertyTypes()));
+ setPublicationName(source.getPublicationName());
+ setPublicationVolume(source.getPublicationVolume());
+ setPublishDate(dateOrNull(source.getPublishDate()));
+ setQuantity(source.getQuantity());
+ setRating(source.getRating());
+ setReviewType(source.getReviewType());
+ setReviewerType(source.getReviewerType());
+ setSalary(source.getSalary());
+ setSalaryType(source.getSalaryType());
+ setServiceType(source.getServiceType());
+ setSexualOrientation(source.getSexualOrientation());
+ setShipping((ShippingType[]) arrayCopy(source.getShipping()));
+ setSize(source.getSize());
+ setSubjects((String[]) arrayCopy(source.getSubjects()));
+ setTaxPercent(source.getTaxPercent());
+ setTaxRegion(source.getTaxRegion());
+ setToLocation(source.getToLocation());
+ setTravelDateRange((DateTimeRange) cloneOrNull(source.getTravelDateRange()));
+ setUpc(source.getUpc());
+ setUrlOfItemBeingReviewed(source.getUrlOfItemBeingReviewed());
+ setVehicleType(source.getVehicleType());
+ setVin(source.getVin());
+ setYear(source.getYear());
+ setLicenses((String[]) arrayCopy(source.getLicenses()));
+ setRelatedLinks((URL[]) arrayCopy(source.getRelatedLinks()));
+ setSubjectAreas((String[]) arrayCopy(source.getSubjectAreas()));
+ setProgrammingLanguages((String[]) arrayCopy(source.getProgrammingLanguages()));
+ setSquareFootages((IntUnit[]) arrayCopy(source.getSquareFootages()));
+ setCurrency(source.getCurrency());
+ setSchoolDistrict(source.getSchoolDistrict());
+ setUniversity(source.getUniversity());
+ setWeight(source.getWeight());
+ setOperatingSystems(source.getOperatingSystems());
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ final EqualsBean eBean = new EqualsBean(this.getClass(), this);
+
+ return eBean.beanEquals(obj);
+ }
+
+ private Object arrayCopy(final Object[] source) {
+ if (source == null) {
+ return null;
+ }
+
+ final Object[] array = (Object[]) Array.newInstance(source.getClass().getComponentType(), source.length);
+
+ for (int i = 0; i < source.length; i++) {
+ array[i] = source[i];
+ }
+
+ return array;
+ }
+
+ private Object cloneOrNull(final CloneableType o) {
+ if (o == null) {
+ return null;
+ } else {
+ return o.clone();
+ }
+ }
+
+ private Date dateOrNull(final Date date) {
+ if (date == null) {
+ return null;
+ } else {
+ return new Date(date.getTime());
+ }
+ }
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/base/Housing.java b/rome-modules/src/main/java/com/rometools/modules/base/Housing.java
new file mode 100644
index 0000000..f5b56d4
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/base/Housing.java
@@ -0,0 +1,1541 @@
+/*
+ * Housing.java
+ *
+ * Created on November 16, 2005, 12:48 PM
+ *
+ * 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.
+ */
+package com.rometools.modules.base;
+
+import com.rometools.modules.base.types.CurrencyEnumeration;
+import com.rometools.modules.base.types.FloatUnit;
+import com.rometools.modules.base.types.IntUnit;
+import com.rometools.modules.base.types.PaymentTypeEnumeration;
+import com.rometools.modules.base.types.PriceTypeEnumeration;
+import com.rometools.modules.base.types.YearType;
+
+/**
+ * This is an interface for the GoogleBase plug in that exposes methods used for Housing entry
+ * types.
+ *
+ * @author Robert "kebernet" Cooper
+ * @version $Revision: 1.1 $
+ */
+public interface Housing extends GlobalInterface {
+ /**
+ * An array of agent name Strings, not to exceed 10 in lenght.
+ *
+ *
+ *
+ *
agent
+ *
+ *
+ *
+ *
Details
+ *
Individual who is negotiating and arranging the real estate sale.
+ *
+ *
+ *
+ *
Example
+ *
+ *
<g:agent>Sue Smith</g:agent>
+ *
+ *
+ *
+ *
Attribute of
+ *
Housing
+ *
+ *
+ *
+ *
Content type
+ *
string
+ *
+ *
+ *
+ *
+ *
+ * @param agents An array of agent name Strings, not to exceed 10 in lenght.
+ */
+ public void setAgents(String[] agents);
+
+ /**
+ * An array of agent name Strings, not to exceed 10 in lenght.
+ *
+ *
+ *
+ *
agent
+ *
+ *
+ *
+ *
Details
+ *
Individual who is negotiating and arranging the real estate sale.
+ *
+ *
+ *
+ *
Example
+ *
+ *
<g:agent>Sue Smith</g:agent>
+ *
+ *
+ *
+ *
Attribute of
+ *
Housing
+ *
+ *
+ *
+ *
Content type
+ *
string
+ *
+ *
+ *
+ *
+ *
+ * @return An array of agent name Strings, not to exceed 10 in lenght.
+ */
+ public String[] getAgents();
+
+ /**
+ * The area of the real estate.
+ *
+ *
+ *
+ *
+ *
+ *
area
+ *
+ *
+ *
+ *
Details
+ *
The size of an area of real estate.
+ *
+ *
+ *
+ *
Example
+ *
<g:area>1000</g:area>
+ *
+ *
+ *
+ *
Attribute of
+ *
+ *
Housing
+ *
+ *
+ *
Content type
+ *
+ *
intUnit
+ *
+ *
+ *
+ *
+ * @param area The area of the real estate
+ */
+ public void setArea(IntUnit area);
+
+ /**
+ * The area of the real estate.
+ *
+ *
+ *
+ *
+ *
+ *
area
+ *
+ *
+ *
+ *
Details
+ *
The size of an area of real estate.
+ *
+ *
+ *
+ *
Example
+ *
<g:area>1000</g:area>
+ *
+ *
+ *
+ *
Attribute of
+ *
+ *
Housing
+ *
+ *
+ *
Content type
+ *
+ *
intUnit
+ *
+ *
+ *
+ *
+ * @return The area of the real estate
+ */
+ public IntUnit getArea();
+
+ /**
+ * The number of bathrooms.
+ *
+ *
+ * @param value Currency of the price amount for an item.
+ */
+ public void setCurrency(CurrencyEnumeration value);
+
+ /**
+ * Currency of the price amount for an item.
+ *
+ *
+ *
+ *
+ *
currency
+ *
+ *
+ *
+ *
Details
+ *
+ *
Currency of the price amount for an item. Values must be in ISO 4217
+ * currency code format.
+ *
+ * @return Currency of the price amount for an item.
+ */
+ public CurrencyEnumeration getCurrency();
+
+ /**
+ * Homeowners association dues on the property.
+ *
+ *
+ *
+ *
+ *
hoa_dues
+ *
+ *
+ *
Details
+ *
+ *
Monthly dues paid to a homeowners association.
+ *
+ *
+ *
+ *
Example
+ *
<g:hoa_dues>100</g:hoa_dues>
+ *
+ *
+ *
+ *
Attribute of
+ *
+ *
Housing
+ *
+ *
+ *
Content type
+ *
+ *
float
+ *
+ *
+ *
+ *
+ *
+ * @param hoaDues Homeowners association dues on the property.
+ */
+ public void setHoaDues(Float hoaDues);
+
+ /**
+ * Homeowners association dues on the property.
+ *
+ *
+ *
+ *
+ *
hoa_dues
+ *
+ *
+ *
Details
+ *
+ *
Monthly dues paid to a homeowners association.
+ *
+ *
+ *
+ *
Example
+ *
<g:hoa_dues>100</g:hoa_dues>
+ *
+ *
+ *
+ *
Attribute of
+ *
+ *
Housing
+ *
+ *
+ *
Content type
+ *
+ *
float
+ *
+ *
+ *
+ *
+ *
+ * @return Homeowners association dues on the property.
+ */
+ public Float getHoaDues();
+
+ /**
+ * Indicates whether this property is for sale or not.
+ *
+ *
+ *
+ *
+ *
+ *
+ *
listing_type
+ *
+ *
+ *
+ *
Details
+ *
+ *
Information about whether or not a property is for sale or not.
+ * Acceptable values are "True" or "False".
+ *
+ * @param forSale Indicates whether this property is for sale or not.
+ */
+ public void setListingType(Boolean forSale);
+
+ /**
+ * Indicates whether this property is for sale or not.
+ *
+ *
+ *
+ *
+ *
+ *
+ *
listing_type
+ *
+ *
+ *
+ *
Details
+ *
+ *
Information about whether or not a property is for sale or not.
+ * Acceptable values are "True" or "False".
+ *
+ * @return Indicates whether this property is for sale or not.
+ */
+ public Boolean getListingType();
+
+ /**
+ * Location of the property.
+ *
+ *
+ *
+ *
+ *
location
+ *
+ *
+ *
+ *
Details
+ *
Location of a property. Should include street, city, state, postal code,
+ * and country, in that order.
+ *
+ *
+ *
+ *
Example
+ *
+ *
Acceptable:
+ * <g:location>123 Main St, Anytown,
+ * CA, 12345,
+ * USA</g:location>
+ *
+ * Not acceptable:
+ * <g:location>123 Main St,, CA,
+ * 12345,
+ * USA</g:location>
+ * <g:location> Anytown, CA,
+ * 12345,
+ * USA</g:location>
+ *
+ *
+ *
+ *
Attribute of
+ *
Reference Items, Events, Housing, Jobs, News and Articles, People
+ * profiles, Products, Reviews, Services, Travel, Vehicles, Wanted Ads.
+ *
+ *
+ *
+ *
+ *
Content type
+ *
locationType
+ *
+ *
+ *
+ *
+ * @param location Location of the property.
+ */
+ public void setLocation(String location);
+
+ /**
+ * Location of the property.
+ *
+ *
+ *
+ *
+ *
location
+ *
+ *
+ *
+ *
Details
+ *
Location of a property. Should include street, city, state, postal code,
+ * and country, in that order.
+ *
+ *
+ *
+ *
Example
+ *
+ *
Acceptable:
+ * <g:location>123 Main St, Anytown,
+ * CA, 12345,
+ * USA</g:location>
+ *
+ * Not acceptable:
+ * <g:location>123 Main St,, CA,
+ * 12345,
+ * USA</g:location>
+ * <g:location> Anytown, CA,
+ * 12345,
+ * USA</g:location>
+ *
+ *
+ *
+ *
Attribute of
+ *
Reference Items, Events, Housing, Jobs, News and Articles, People
+ * profiles, Products, Reviews, Services, Travel, Vehicles, Wanted Ads.
+ *
+ *
+ *
+ *
+ *
Content type
+ *
locationType
+ *
+ *
+ *
+ *
+ * @return Location of the property.
+ */
+ public String getLocation();
+
+ /**
+ * Payment Methods acceptable for the property.
+ *
+ *
+ *
+ *
+ *
+ *
payment_accepted
+ *
+ *
+ *
Details
+ *
Acceptable payment methods for item purchases. Acceptable values are
+ * "Cash," "Check," "Traveler’s Check," "Visa," "MasterCard,"
+ *
+ * "American Express," "Discover," "Wire transfer" or "Paypal." If you accept more than one
+ * method, include multiple instances of the <payment_accepted> attribute for each
+ * acceptable method.
+ *
+ * @param paymentAccepted Payment Methods acceptable for the property.
+ */
+ public void setPaymentAccepted(PaymentTypeEnumeration[] paymentAccepted);
+
+ /**
+ * Payment Methods acceptable for the property.
+ *
+ *
+ *
+ *
+ *
+ *
payment_accepted
+ *
+ *
+ *
Details
+ *
Acceptable payment methods for item purchases. Acceptable values are
+ * "Cash," "Check," "Traveler’s Check," "Visa," "MasterCard,"
+ *
+ * "American Express," "Discover," "Wire transfer" or "Paypal." If you accept more than one
+ * method, include multiple instances of the <payment_accepted> attribute for each
+ * acceptable method.
+ *
+ * @return Additional payment information.
+ */
+ public String getPaymentNotes();
+
+ /**
+ * Price for the property.
+ *
+ *
+ *
+ *
+ *
+ *
+ *
price
+ *
+ *
+ *
Details
+ *
Prices can be a single price, 0 (free), or blank if not applicable.
+ * Numerice values only. When used as a sub-attribute of <shipping>, the value included
+ * reflects the price of shipping.
+ *
+ * @param price Price for the property.
+ */
+ public void setPrice(FloatUnit price);
+
+ /**
+ * Price for the property.
+ *
+ *
+ *
+ *
+ *
+ *
+ *
price
+ *
+ *
+ *
Details
+ *
Prices can be a single price, 0 (free), or blank if not applicable.
+ * Numerice values only. When used as a sub-attribute of <shipping>, the value included
+ * reflects the price of shipping.
+ *
+ * Type of property: house, apartment, condominium, etc.
+ *
+ *
+ *
Example
+ *
+ *
<g:property_type>house</g:property_type>
+ *
+ *
+ *
+ *
Attribute of
+ *
+ *
+ * Housing
+ *
+ *
+ *
+ *
Content type
+ *
string
+ *
+ *
+ *
+ *
+ *
+ * @return Types of property represented here. Limit 10.
+ */
+ public String[] getPropertyTypes();
+
+ /**
+ * School district a property is in.
+ *
+ *
+ *
+ *
+ *
+ *
school_district
+ *
+ *
+ *
+ *
Details
+ *
The school district the property is in.
+ *
+ *
+ *
+ *
+ *
Example
+ *
<g:school_district>Union
+ * School District</g:school_district>
+ *
+ *
+ *
+ *
+ *
Attribute of
+ *
Housing
+ *
+ *
+ *
+ *
+ *
+ * Content type
+ *
string
+ *
+ *
+ *
+ *
+ * @param schoolDistrict School district a property is in.
+ */
+ public void setSchoolDistrict(String schoolDistrict);
+
+ /**
+ * School district a property is in.
+ *
+ *
+ *
+ *
+ *
+ *
school_district
+ *
+ *
+ *
+ *
Details
+ *
The school district the property is in.
+ *
+ *
+ *
+ *
+ *
Example
+ *
<g:school_district>Union
+ * School District</g:school_district>
+ *
+ *
+ *
+ *
+ *
Attribute of
+ *
Housing
+ *
+ *
+ *
+ *
+ *
+ * Content type
+ *
string
+ *
+ *
+ *
+ *
+ * @return School district a property is in.
+ */
+ public String getSchoolDistrict();
+
+ /**
+ * Percentage tax rate.
+ *
+ *
+ * @return Percentage tax rate.
+ */
+ public Float getTaxPercent();
+
+ /**
+ * Geographical region a tax rate applies to.
+ *
+ *
+ *
+ *
+ *
+ *
+ * tax_region
+ *
+ *
+ *
+ *
Details
+ *
Geographical region a tax rate applies to.
+ *
+ *
+ *
+ *
+ *
+ * Example
+ *
<g:tax_region>California</g:tax_region>
+ *
+ *
+ *
+ *
Attribute of
+ *
+ *
Product, Events,
+ *
+ *
+ *
+ *
Content type
+ *
string
+ *
+ *
+ *
+ *
+ *
+ * @param taxRegion Geographical region a tax rate applies to.
+ */
+ public void setTaxRegion(String taxRegion);
+
+ /**
+ * Geographical region a tax rate applies to.
+ *
+ *
+ *
+ *
+ *
+ *
+ * tax_region
+ *
+ *
+ *
+ *
Details
+ *
Geographical region a tax rate applies to.
+ *
+ *
+ *
+ *
+ *
+ * Example
+ *
<g:tax_region>California</g:tax_region>
+ *
+ *
+ *
+ *
Attribute of
+ *
+ *
Product, Events,
+ *
+ *
+ *
+ *
Content type
+ *
string
+ *
+ *
+ *
+ *
+ *
+ * @return Geographical region a tax rate applies to.
+ */
+ public String getTaxRegion();
+
+ /**
+ * The four digit model year or year built.
+ *
+ *
+ *
+ *
+ *
year
+ *
+ *
+ *
+ *
Details
+ *
+ *
The four digit model year or year built. Format YYYY
+ *
+ * @param year The four digit model year or year built.
+ */
+ public void setYear(YearType year);
+
+ /**
+ * The four digit model year or year built.
+ *
+ *
+ *
+ *
+ *
year
+ *
+ *
+ *
+ *
Details
+ *
+ *
The four digit model year or year built. Format YYYY
+ *
+ * @return The four digit model year or year built.
+ */
+ public YearType getYear();
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/base/Job.java b/rome-modules/src/main/java/com/rometools/modules/base/Job.java
new file mode 100644
index 0000000..342867e
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/base/Job.java
@@ -0,0 +1,870 @@
+/*
+ * Job.java
+ *
+ * Created on November 16, 2005, 12:39 PM
+ *
+ * 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.
+ */
+package com.rometools.modules.base;
+
+import com.rometools.modules.base.types.CurrencyEnumeration;
+import com.rometools.modules.base.types.PriceTypeEnumeration;
+
+/**
+ * This is an interface for the GoogleBase plug in that exposes methods used for Job listing entry
+ * types.
+ *
+ * @author Robert "kebernet" Cooper
+ * @version $Revision: 1.1 $
+ */
+public interface Job extends GlobalInterface {
+ /**
+ * Level of education required for an employment position.
+ *
+ *
+ *
+ *
education
+ *
+ *
+ *
Details
+ *
+ *
Level of education required for an employment position.
+ *
+ *
+ *
Example
+ *
<g:education>PhD</g:education>
+ *
+ *
+ *
+ *
Attribute of
+ *
Jobs
+ *
+ *
+ *
Content type
+ *
+ *
string
+ *
+ *
+ *
+ *
+ * @param education Level of education required for an employment position.
+ */
+ public void setEducation(String education);
+
+ /**
+ * Level of education required for an employment position.
+ *
+ *
+ *
+ *
education
+ *
+ *
+ *
Details
+ *
+ *
Level of education required for an employment position.
+ *
+ *
+ *
Example
+ *
<g:education>PhD</g:education>
+ *
+ *
+ *
+ *
Attribute of
+ *
Jobs
+ *
+ *
+ *
Content type
+ *
+ *
string
+ *
+ *
+ *
+ *
+ * @return Level of education required for an employment position.
+ */
+ public String getEducation();
+
+ /**
+ * Company providing employment.
+ *
+ *
+ *
+ *
employer
+ *
+ *
+ *
+ *
Details
+ *
Company providing employment.
+ *
+ *
+ *
Example
+ *
+ *
<g:employer>Google, Inc</g:employer>
+ *
+ *
+ *
Attribute of
+ *
Jobs
+ *
+ *
+ *
+ *
Content type
+ *
string
+ *
+ *
+ *
+ *
+ * @param employer Company providing employment.
+ */
+ public void setEmployer(String employer);
+
+ /**
+ * Company providing employment.
+ *
+ *
+ *
+ *
employer
+ *
+ *
+ *
+ *
Details
+ *
Company providing employment.
+ *
+ *
+ *
Example
+ *
+ *
<g:employer>Google, Inc</g:employer>
+ *
+ *
+ *
Attribute of
+ *
Jobs
+ *
+ *
+ *
+ *
Content type
+ *
string
+ *
+ *
+ *
+ *
+ * @return Company providing employment.
+ */
+ public String getEmployer();
+
+ /**
+ * Legal residency requirements for an employment position.
+ *
+ *
+ *
+ *
+ *
immigration_status
+ *
+ *
+ *
+ *
Details
+ *
+ *
Legal residency requirements for an employment position.
+ *
+ * @return Legal residency requirements for an employment position.
+ */
+ public String getImmigrationStatus();
+
+ /**
+ * The functions of an employment position.
+ *
+ *
+ *
+ *
+ *
+ *
job_function
+ *
+ *
+ *
+ *
Details
+ *
The function of an employment position.
+ *
+ *
+ *
+ *
+ *
Example
+ *
<g:job_function>Product Manager</g:job_function>
+ *
+ *
+ *
+ *
+ *
+ * Attribute of
+ *
Jobs
+ *
+ *
+ *
+ *
+ * Content type
+ *
+ *
string
+ *
+ *
+ *
+ *
+ * @param function The functions of an employment position.
+ */
+ public void setJobFunctions(String[] function);
+
+ /**
+ * The functions of an employment position.
+ *
+ *
+ *
+ *
+ *
+ *
job_function
+ *
+ *
+ *
+ *
Details
+ *
The function of an employment position.
+ *
+ *
+ *
+ *
+ *
Example
+ *
<g:job_function>Product Manager</g:job_function>
+ *
+ *
+ *
+ *
+ *
+ * Attribute of
+ *
Jobs
+ *
+ *
+ *
+ *
+ * Content type
+ *
+ *
string
+ *
+ *
+ *
+ *
+ * @return The functions of an employment position.
+ */
+ public String[] getJobFunctions();
+
+ /**
+ * The industry of an employment position.
+ *
+ *
+ *
+ *
+ *
+ *
+ * job_industry
+ *
+ *
+ *
Details
+ *
The industry of an employment position.
+ *
+ *
+ *
+ *
Example
+ *
<g:job_industry>Government</g:job_industry>
+ *
+ *
+ *
+ *
Attribute of
+ *
Jobs
+ *
+ *
+ *
+ *
+ *
+ * Content type
+ *
string
+ *
+ *
+ *
+ *
+ * @param jobIndustries The industry of an employment position.
+ */
+ public void setJobIndustries(String[] jobIndustries);
+
+ /**
+ * The industry of an employment position.
+ *
+ *
+ *
+ *
+ *
+ *
+ * job_industry
+ *
+ *
+ *
Details
+ *
The industry of an employment position.
+ *
+ *
+ *
+ *
Example
+ *
<g:job_industry>Government</g:job_industry>
+ *
+ *
+ *
+ *
Attribute of
+ *
Jobs
+ *
+ *
+ *
+ *
+ *
+ * Content type
+ *
string
+ *
+ *
+ *
+ *
+ * @return The industry of an employment position.
+ */
+ public String[] getJobIndustries();
+
+ /**
+ * Type of employment position. Example: Full-time, part-time, contractor, etc.
+ *
+ *
+ *
+ *
+ *
job_type
+ *
+ *
+ *
Details
+ *
+ *
Type of employment position. Example: Full-time, part-time, contractor,
+ * etc.
+ *
+ *
+ *
+ *
Example
+ *
<g:job_type>contractor</g:job_type>
+ *
+ *
+ *
+ *
+ *
Attribute of
+ *
Jobs
+ *
+ *
+ *
+ *
+ *
+ * Content type
+ *
string
+ *
+ *
+ *
+ *
+ * @param jobTypes Type of employment position. Example: Full-time, part-time, contractor, etc.
+ */
+ public void setJobTypes(String[] jobTypes);
+
+ /**
+ * Type of employment position. Example: Full-time, part-time, contractor, etc.
+ *
+ *
+ *
+ *
+ *
job_type
+ *
+ *
+ *
Details
+ *
+ *
Type of employment position. Example: Full-time, part-time, contractor,
+ * etc.
+ *
+ *
+ *
+ *
Example
+ *
<g:job_type>contractor</g:job_type>
+ *
+ *
+ *
+ *
+ *
Attribute of
+ *
Jobs
+ *
+ *
+ *
+ *
+ *
+ * Content type
+ *
string
+ *
+ *
+ *
+ *
+ * @return Type of employment position. Example: Full-time, part-time, contractor, etc.
+ */
+ public String[] getJobTypes();
+
+ /**
+ * Location of the position.
+ *
+ *
+ *
+ *
+ *
location
+ *
+ *
+ *
+ *
Details
+ *
Location of a property. Should include street, city, state, postal code,
+ * and country, in that order.
+ *
+ *
+ *
+ *
Example
+ *
+ *
Acceptable:
+ * <g:location>123 Main St, Anytown,
+ * CA, 12345,
+ * USA</g:location>
+ *
+ * Not acceptable:
+ * <g:location>123 Main St,, CA,
+ * 12345,
+ * USA</g:location>
+ * <g:location> Anytown, CA,
+ * 12345,
+ * USA</g:location>
+ *
+ *
+ *
+ *
Attribute of
+ *
Reference Items, Events, Housing, Jobs, News and Articles, People
+ * profiles, Products, Reviews, Services, Travel, Vehicles, Wanted Ads.
+ *
+ *
+ *
+ *
+ *
Content type
+ *
locationType
+ *
+ *
+ *
+ *
+ * @param location Location of the position.
+ */
+ public void setLocation(String location);
+
+ /**
+ * Location of the position.
+ *
+ *
+ *
+ *
+ *
location
+ *
+ *
+ *
+ *
Details
+ *
Location of a property. Should include street, city, state, postal code,
+ * and country, in that order.
+ *
+ *
+ *
+ *
Example
+ *
+ *
Acceptable:
+ * <g:location>123 Main St, Anytown,
+ * CA, 12345,
+ * USA</g:location>
+ *
+ * Not acceptable:
+ * <g:location>123 Main St,, CA,
+ * 12345,
+ * USA</g:location>
+ * <g:location> Anytown, CA,
+ * 12345,
+ * USA</g:location>
+ *
+ *
+ *
+ *
Attribute of
+ *
Reference Items, Events, Housing, Jobs, News and Articles, People
+ * profiles, Products, Reviews, Services, Travel, Vehicles, Wanted Ads.
+ *
+ *
+ *
+ *
+ *
Content type
+ *
locationType
+ *
+ *
+ *
+ *
+ * @return Location of the position.
+ */
+ public String getLocation();
+
+ /**
+ * Salary for this position. Non-numeric values such as "$" symbols are not acceptable.
+ *
+ *
+ *
+ *
salary
+ *
+ *
+ *
+ *
+ *
Details
+ *
Salary for this position. Non-numeric values such as "$" symbols are not
+ * acceptable.
+ *
+ *
+ *
+ *
+ *
+ * Example
+ *
<g:salary>55000</g:salary>
+ *
+ *
+ *
+ *
+ * Attribute of
+ *
+ *
Jobs
+ *
+ *
+ *
Content type
+ *
+ *
+ *
+ * float
+ *
+ *
+ *
+ *
+ * @param salary Salary for this position. Non-numeric values such as "$" symbols are not
+ * acceptable.
+ */
+ public void setSalary(Float salary);
+
+ /**
+ * Salary for this position. Non-numeric values such as "$" symbols are not acceptable.
+ *
+ *
+ *
+ *
salary
+ *
+ *
+ *
+ *
+ *
Details
+ *
Salary for this position. Non-numeric values such as "$" symbols are not
+ * acceptable.
+ *
+ *
+ *
+ *
+ *
+ * Example
+ *
<g:salary>55000</g:salary>
+ *
+ *
+ *
+ *
+ * Attribute of
+ *
+ *
Jobs
+ *
+ *
+ *
Content type
+ *
+ *
+ *
+ * float
+ *
+ *
+ *
+ *
+ * @return Salary for this position. Non-numeric values such as "$" symbols are not acceptable.
+ */
+ public Float getSalary();
+
+ /**
+ * The type of salary included.
+ *
+ *
+ *
+ *
salary_type
+ *
+ *
+ *
+ *
+ *
Details
+ *
The type of salary included. Accepted values are �starting� or
+ * �negotiable;� The default is �starting at.�
+ *
+ *
+ *
+ *
+ *
+ * Example
+ *
<g:salary_type>negotiable</g:salary_type>
+ *
+ *
+ *
+ *
Attribute of
+ *
+ *
Jobs
+ *
+ *
+ *
+ *
+ * Content type
+ *
+ *
+ * "starting" or "negotiable"
+ *
+ *
+ *
+ *
+ * @param salaryType The type of salary included.
+ */
+ public void setSalaryType(PriceTypeEnumeration salaryType);
+
+ /**
+ * The type of salary included.
+ *
+ *
+ *
+ *
salary_type
+ *
+ *
+ *
+ *
+ *
Details
+ *
The type of salary included. Accepted values are �starting� or
+ * �negotiable;� The default is �starting at.�
+ *
+ *
+ *
+ *
+ *
+ * Example
+ *
<g:salary_type>negotiable</g:salary_type>
+ *
+ *
+ *
+ *
Attribute of
+ *
+ *
Jobs
+ *
+ *
+ *
+ *
+ * Content type
+ *
+ *
+ * "starting" or "negotiable"
+ *
+ *
+ *
+ *
+ * @return The type of salary included.
+ */
+ public PriceTypeEnumeration getSalaryType();
+
+ /**
+ * Currency of the price amount for an item.
+ *
+ *
+ *
+ *
+ *
currency
+ *
+ *
+ *
+ *
Details
+ *
+ *
Currency of the price amount for an item. Values must be in ISO 4217
+ * currency code format.
+ *
+ * @param value Currency of the price amount for an item.
+ */
+ public void setCurrency(CurrencyEnumeration value);
+
+ /**
+ * Currency of the price amount for an item.
+ *
+ *
+ *
+ *
+ *
currency
+ *
+ *
+ *
+ *
Details
+ *
+ *
Currency of the price amount for an item. Values must be in ISO 4217
+ * currency code format.
+ *
+ * @return Currency of the price amount for an item.
+ */
+ public CurrencyEnumeration getCurrency();
+
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/base/Person.java b/rome-modules/src/main/java/com/rometools/modules/base/Person.java
new file mode 100644
index 0000000..8d9038d
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/base/Person.java
@@ -0,0 +1,865 @@
+/*
+ * Person.java
+ *
+ * Created on November 16, 2005, 1:26 PM
+ *
+ * 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.
+ */
+package com.rometools.modules.base;
+
+import com.rometools.modules.base.types.GenderEnumeration;
+
+/**
+ * This is an interface for the GoogleBase plug in that exposes methods used for Person (personal
+ * ad, resume, profile) entry types.
+ *
+ * @author Robert "kebernet" Cooper
+ * @version $Revision: 1.2 $
+ */
+public interface Person extends GlobalInterface {
+ /**
+ * Age of the individual.
+ *
+ *
+ *
+ *
age
+ *
+ *
+ *
+ *
Details
+ *
Minimum age requirement for the event or the age of the individual in a
+ * People profiles bulk upload entry.
+ *
+ *
+ *
+ *
Example
+ *
Acceptable:
+ * < g:age>18</g:age>
+ * Not acceptable:
+ *
+ * < g:age>18 and over</g:age>
+ *
+ *
+ *
Attribute of
+ *
Events, People profiles
+ *
+ *
+ *
+ *
+ *
Content type
+ *
integer
+ *
+ *
+ *
+ *
+ * @param age Age of the individual.
+ */
+ public void setAge(Integer age);
+
+ /**
+ * Age of the individual.
+ *
+ *
+ *
+ *
age
+ *
+ *
+ *
+ *
Details
+ *
Minimum age requirement for the event or the age of the individual in a
+ * People profiles bulk upload entry.
+ *
+ *
+ *
+ *
Example
+ *
Acceptable:
+ * < g:age>18</g:age>
+ * Not acceptable:
+ *
+ * < g:age>18 and over</g:age>
+ *
+ *
+ *
Attribute of
+ *
Events, People profiles
+ *
+ *
+ *
+ *
+ *
Content type
+ *
integer
+ *
+ *
+ *
+ *
+ * @return Age of the individual.
+ */
+ public Integer getAge();
+
+ /**
+ * Education of the individual.
+ *
+ *
+ *
+ *
education
+ *
+ *
+ *
Details
+ *
+ *
Level of education required for an employment position.
+ *
+ *
+ *
Example
+ *
<g:education>PhD</g:education>
+ *
+ *
+ *
+ *
Attribute of
+ *
Jobs
+ *
+ *
+ *
Content type
+ *
+ *
string
+ *
+ *
+ *
+ *
+ * @param education Education of the individual.
+ */
+ public void setEducation(String education);
+
+ /**
+ * Education of the individual.
+ *
+ *
+ *
+ *
education
+ *
+ *
+ *
Details
+ *
+ *
Level of education required for an employment position.
+ *
+ *
+ *
Example
+ *
<g:education>PhD</g:education>
+ *
+ *
+ *
+ *
Attribute of
+ *
Jobs
+ *
+ *
+ *
Content type
+ *
+ *
string
+ *
+ *
+ *
+ *
+ * @return Education of the individual.
+ */
+ public String getEducation();
+
+ /**
+ * Individuals employer.
+ *
+ *
+ *
+ * @return Individuals employer.
+ */
+ public String getEmployer();
+
+ /**
+ * Ethnicity of the individual in the People profiles bulk upload entry.
+ *
+ *
+ *
+ *
+ *
ethnicity
+ *
+ *
+ *
Details
+ *
+ *
Ethnicity of the individual in the People profiles bulk upload
+ * entry.
+ *
+ *
+ *
+ *
Example
+ *
<g:ethnicity>Latino</g:ethnicity>
+ *
+ *
+ *
+ *
Attribute of
+ *
+ *
People profiles
+ *
+ *
+ *
Content type
+ *
+ *
string
+ *
+ *
+ *
+ *
+ *
+ * @param ethnicities Ethnicity of the individual in the People profiles bulk upload entry.
+ */
+ public void setEthnicities(String[] ethnicities);
+
+ /**
+ * Ethnicity of the individual in the People profiles bulk upload entry.
+ *
+ *
+ *
+ *
+ *
ethnicity
+ *
+ *
+ *
Details
+ *
+ *
Ethnicity of the individual in the People profiles bulk upload
+ * entry.
+ *
+ *
+ *
+ *
Example
+ *
<g:ethnicity>Latino</g:ethnicity>
+ *
+ *
+ *
+ *
Attribute of
+ *
+ *
People profiles
+ *
+ *
+ *
Content type
+ *
+ *
string
+ *
+ *
+ *
+ *
+ *
+ * @return Ethnicity of the individual in the People profiles bulk upload entry.
+ */
+ public String[] getEthnicities();
+
+ /**
+ * Gender of an individual in a People profiles bulk upload.
+ *
+ *
+ *
+ *
+ *
gender
+ *
+ *
+ *
+ *
Details
+ *
+ *
Gender of an individual in a People profiles bulk upload item.
+ * Acceptable values are �Male�, �M�, �Female�, or �F�.
+ *
+ *
+ *
Example
+ *
+ *
<gender>Female</gender>
+ *
+ *
+ *
Attribute of
+ *
People profiles
+ *
+ *
+ *
+ *
Content type
+ *
genderEnumeration
+ *
+ *
+ *
+ *
+ * @param gender Gender of an individual in a People profiles bulk upload.
+ */
+ public void setGender(GenderEnumeration gender);
+
+ /**
+ * Gender of an individual in a People profiles bulk upload.
+ *
+ *
+ *
+ *
+ *
gender
+ *
+ *
+ *
+ *
Details
+ *
+ *
Gender of an individual in a People profiles bulk upload item.
+ * Acceptable values are �Male�, �M�, �Female�, or �F�.
+ *
+ *
+ *
Example
+ *
+ *
<gender>Female</gender>
+ *
+ *
+ *
Attribute of
+ *
People profiles
+ *
+ *
+ *
+ *
Content type
+ *
genderEnumeration
+ *
+ *
+ *
+ *
+ * @return Gender of an individual in a People profiles bulk upload.
+ */
+ public GenderEnumeration getGender();
+
+ /**
+ * Interest of a person being profiled.
+ *
+ *
+ *
+ *
+ *
interested_in
+ *
+ *
+ *
+ *
Details
+ *
Interest of a person being profiled.
+ *
+ *
+ *
+ *
Example
+ *
+ *
<g:interested_in>Long walks on the
+ * beach.</g:interested_in>
+ *
+ *
+ *
Attribute of
+ *
+ *
People profiles
+ *
+ *
+ *
+ *
Content type
+ *
string
+ *
+ *
+ *
+ *
+ *
+ * @param interestedIn Interest of a person being profiled.
+ */
+ public void setInterestedIn(String[] interestedIn);
+
+ /**
+ * Interest of a person being profiled.
+ *
+ *
+ *
+ *
+ *
interested_in
+ *
+ *
+ *
+ *
Details
+ *
Interest of a person being profiled.
+ *
+ *
+ *
+ *
Example
+ *
+ *
<g:interested_in>Long walks on the
+ * beach.</g:interested_in>
+ *
+ *
+ *
Attribute of
+ *
+ *
People profiles
+ *
+ *
+ *
+ *
Content type
+ *
string
+ *
+ *
+ *
+ *
+ *
+ * @return Interest of a person being profiled.
+ */
+ public String[] getInterestedIn();
+
+ /**
+ * Location of a person.
+ *
+ *
+ *
+ *
+ *
location
+ *
+ *
+ *
+ *
Details
+ *
Location of a property. Should include street, city, state, postal code,
+ * and country, in that order.
+ *
+ *
+ *
+ *
Example
+ *
+ *
Acceptable:
+ * <g:location>123 Main St, Anytown,
+ * CA, 12345,
+ * USA</g:location>
+ *
+ * Not acceptable:
+ * <g:location>123 Main St,, CA,
+ * 12345,
+ * USA</g:location>
+ * <g:location> Anytown, CA,
+ * 12345,
+ * USA</g:location>
+ *
+ *
+ *
+ *
Attribute of
+ *
Reference Items, Events, Housing, Jobs, News and Articles, People
+ * profiles, Products, Reviews, Services, Travel, Vehicles, Wanted Ads.
+ *
+ *
+ *
+ *
+ *
Content type
+ *
locationType
+ *
+ *
+ *
+ *
+ * @param location Location of a person.
+ */
+ public void setLocation(String location);
+
+ /**
+ * Location of a person.
+ *
+ *
+ *
+ *
+ *
location
+ *
+ *
+ *
+ *
Details
+ *
Location of a property. Should include street, city, state, postal code,
+ * and country, in that order.
+ *
+ *
+ *
+ *
Example
+ *
+ *
Acceptable:
+ * <g:location>123 Main St, Anytown,
+ * CA, 12345,
+ * USA</g:location>
+ *
+ * Not acceptable:
+ * <g:location>123 Main St,, CA,
+ * 12345,
+ * USA</g:location>
+ * <g:location> Anytown, CA,
+ * 12345,
+ * USA</g:location>
+ *
+ *
+ *
+ *
Attribute of
+ *
Reference Items, Events, Housing, Jobs, News and Articles, People
+ * profiles, Products, Reviews, Services, Travel, Vehicles, Wanted Ads.
+ *
+ *
+ *
+ *
+ *
Content type
+ *
locationType
+ *
+ *
+ *
+ *
+ * @return Location of a person.
+ */
+ public String getLocation();
+
+ /**
+ * Marital status of an individual.
+ *
+ *
+ *
+ *
+ *
+ *
marital_status
+ *
+ *
+ *
+ *
+ * Details
+ *
Marital status of an individual in a People profiles bulk upload entry.
+ * For example -single, divorced, separated, widowed, married, and �in relationship.�
+ *
+ * @param maritalStatus Marital status of an individual.
+ */
+ public void setMaritalStatus(String maritalStatus);
+
+ /**
+ * Marital status of an individual.
+ *
+ *
+ *
+ *
+ *
+ *
marital_status
+ *
+ *
+ *
+ *
+ * Details
+ *
Marital status of an individual in a People profiles bulk upload entry.
+ * For example -single, divorced, separated, widowed, married, and �in relationship.�
+ *
+ * @return Individual's sexual orientation.
+ */
+ public String getSexualOrientation();
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/base/Product.java b/rome-modules/src/main/java/com/rometools/modules/base/Product.java
new file mode 100644
index 0000000..0764e6a
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/base/Product.java
@@ -0,0 +1,2742 @@
+/*
+ * Product.java
+ *
+ * Created on November 16, 2005, 1:39 PM
+ *
+ * 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.
+ */
+package com.rometools.modules.base;
+
+import com.rometools.modules.base.types.CurrencyEnumeration;
+import com.rometools.modules.base.types.FloatUnit;
+import com.rometools.modules.base.types.PaymentTypeEnumeration;
+import com.rometools.modules.base.types.PriceTypeEnumeration;
+import com.rometools.modules.base.types.ShippingType;
+import com.rometools.modules.base.types.Size;
+
+/**
+ * This is an interface for the GoogleBase plug in that exposes methods used for Products.
+ *
+ * @author Robert "kebernet" Cooper
+ * @version $Revision: 1.1 $
+ */
+public interface Product extends GlobalInterface {
+ /**
+ * Actor featured in the video.
+ *
+ *
+ *
+ *
+ *
+ *
actor
+ *
+ *
+ *
Details
+ *
Actor featured in the video.
+ *
+ *
+ *
+ *
+ *
Example
+ *
<g:actor>Charlie Chaplin</g:actor>
+ *
+ *
+ *
Attribute of
+ *
+ *
Products
+ *
+ *
+ *
+ *
Content type
+ *
string
+ *
+ *
+ *
+ *
+ * @param actors Actor featured in the video.
+ */
+ public void setActors(String[] actors);
+
+ /**
+ * Actor featured in the video.
+ *
+ *
+ *
+ *
+ *
+ *
actor
+ *
+ *
+ *
Details
+ *
Actor featured in the video.
+ *
+ *
+ *
+ *
+ *
Example
+ *
<g:actor>Charlie Chaplin</g:actor>
+ *
+ *
+ *
Attribute of
+ *
+ *
Products
+ *
+ *
+ *
+ *
Content type
+ *
string
+ *
+ *
+ *
+ *
+ * @return Actor featured in the video.
+ */
+ public String[] getActors();
+
+ /**
+ * The type of apparel being offered.
+ *
+ *
+ *
+ *
+ *
+ *
apparel_type
+ *
+ *
+ *
Details
+ *
+ *
The type of apparel being offered. Skirt, pants, sleepwear, etc.
+ *
+ *
+ *
+ *
Example
+ *
<g:apparel_type>sweater</g:apparel_type>
+ *
+ *
+ *
+ *
Attribute of
+ *
Products
+ *
+ *
+ *
+ *
Content type
+ *
+ *
string
+ *
+ *
+ *
+ *
+ * @param apparelType The type of apparel being offered.
+ */
+ public void setApparelType(String apparelType);
+
+ /**
+ * The type of apparel being offered.
+ *
+ *
+ *
+ *
+ *
+ *
apparel_type
+ *
+ *
+ *
Details
+ *
+ *
The type of apparel being offered. Skirt, pants, sleepwear, etc.
+ *
+ *
+ *
+ *
Example
+ *
<g:apparel_type>sweater</g:apparel_type>
+ *
+ *
+ *
+ *
Attribute of
+ *
Products
+ *
+ *
+ *
+ *
Content type
+ *
+ *
string
+ *
+ *
+ *
+ *
+ * @return The type of apparel being offered.
+ */
+ public String getApparelType();
+
+ /**
+ * Artist that created the work.
+ *
+ *
+ *
+ *
artist
+ *
+ *
+ *
+ *
Details
+ *
+ *
Artist that created the work.
+ *
+ *
+ *
+ *
Example
+ *
<g:artist>Vincent van Gogh</g:artist>
+ *
+ *
+ *
+ *
+ *
Attribute of
+ *
Products
+ *
+ *
+ *
+ *
+ *
+ * Content type
+ *
string
+ *
+ *
+ *
+ *
+ * @param artists Artist that created the work.
+ */
+ public void setArtists(String[] artists);
+
+ /**
+ * Artist that created the work.
+ *
+ *
+ *
+ *
artist
+ *
+ *
+ *
+ *
Details
+ *
+ *
Artist that created the work.
+ *
+ *
+ *
+ *
Example
+ *
<g:artist>Vincent van Gogh</g:artist>
+ *
+ *
+ *
+ *
+ *
Attribute of
+ *
Products
+ *
+ *
+ *
+ *
+ *
+ * Content type
+ *
string
+ *
+ *
+ *
+ *
+ * @return Artist that created the work.
+ */
+ public String[] getArtists();
+
+ /**
+ * Author of the item.
+ *
+ *
+ *
+ *
+ *
+ *
author
+ *
+ *
+ *
Details
+ *
+ *
Author of the item.
+ *
+ *
+ *
Example
+ *
<g:author>John Steinbeck</g:author>
+ *
+ *
+ *
+ *
Attribute of
+ *
Reference Items, News and Articles
+ *
+ *
+ *
+ *
+ *
Content type
+ *
string
+ *
+ *
+ *
+ *
+ * @param authors Author of the item.
+ */
+ public void setAuthors(String[] authors);
+
+ /**
+ * Author of the item.
+ *
+ *
+ *
+ *
+ *
+ *
author
+ *
+ *
+ *
Details
+ *
+ *
Author of the item.
+ *
+ *
+ *
Example
+ *
<g:author>John Steinbeck</g:author>
+ *
+ *
+ *
+ *
Attribute of
+ *
Reference Items, News and Articles
+ *
+ *
+ *
+ *
+ *
Content type
+ *
string
+ *
+ *
+ *
+ *
+ * @return Author of the item.
+ */
+ public String[] getAuthors();
+
+ /**
+ * The brand name of an item.
+ *
+ *
+ *
+ *
brand
+ *
+ *
+ *
Details
+ *
+ *
The brand name of an item.
+ *
+ *
+ *
Example
+ *
<g:brand>Acme</g:brand>
+ *
+ *
+ *
+ *
Attribute of
+ *
Products
+ *
+ *
+ *
+ *
Content type
+ *
+ *
string
+ *
+ *
+ *
+ *
+ * @param brand The brand name of an item.
+ */
+ public void setBrand(String brand);
+
+ /**
+ * The brand name of an item.
+ *
+ *
+ *
+ *
brand
+ *
+ *
+ *
Details
+ *
+ *
The brand name of an item.
+ *
+ *
+ *
Example
+ *
<g:brand>Acme</g:brand>
+ *
+ *
+ *
+ *
Attribute of
+ *
Products
+ *
+ *
+ *
+ *
Content type
+ *
+ *
string
+ *
+ *
+ *
+ *
+ * @return The brand name of an item.
+ */
+ public String getBrand();
+
+ /**
+ * Color of an item.
+ *
+ *
+ *
+ *
+ *
+ *
color
+ *
+ *
+ *
+ *
Details
+ *
+ *
Color of an item.
+ *
+ *
+ *
+ *
Example
+ *
<g:color>Black</g:color>
+ *
+ *
+ *
+ *
+ *
+ * Attribute of
+ *
Products, Vehicles
+ *
+ *
+ *
+ *
Content type
+ *
+ *
string
+ *
+ *
+ *
+ *
+ * @param color Color of an item.
+ */
+ public void setColors(String[] color);
+
+ /**
+ * Color of an item.
+ *
+ *
+ *
+ *
+ *
+ *
color
+ *
+ *
+ *
+ *
Details
+ *
+ *
Color of an item.
+ *
+ *
+ *
+ *
Example
+ *
<g:color>Black</g:color>
+ *
+ *
+ *
+ *
+ *
+ * Attribute of
+ *
Products, Vehicles
+ *
+ *
+ *
+ *
Content type
+ *
+ *
string
+ *
+ *
+ *
+ *
+ * @return Color of an item.
+ */
+ public String[] getColors();
+
+ /**
+ * Condition of the item. For example: new, used, or refurbished.
+ *
+ *
+ *
+ *
+ *
condition
+ *
+ *
+ *
+ *
Details
+ *
Condition of the item. For example: new, used, or refurbished.
+ *
+ *
+ *
+ *
Example
+ *
+ *
+ * <g:condition>refurbished</g:condition>
+ *
+ *
+ *
Attribute of
+ *
+ *
Products, Vehicles
+ *
+ *
+ *
+ *
Content type
+ *
string
+ *
+ *
+ *
+ *
+ *
+ * @param condition Condition of the item. For example: new, used, or refurbished.
+ */
+ public void setCondition(String condition);
+
+ /**
+ * Condition of the item. For example: new, used, or refurbished.
+ *
+ *
+ *
+ *
+ *
condition
+ *
+ *
+ *
+ *
Details
+ *
Condition of the item. For example: new, used, or refurbished.
+ *
+ *
+ *
+ *
Example
+ *
+ *
+ * <g:condition>refurbished</g:condition>
+ *
+ *
+ *
Attribute of
+ *
+ *
Products, Vehicles
+ *
+ *
+ *
+ *
Content type
+ *
string
+ *
+ *
+ *
+ *
+ *
+ * @return Condition of the item. For example: new, used, or refurbished.
+ */
+ public String getCondition();
+
+ /**
+ * Currency of the price amount for an item.
+ *
+ *
+ *
+ *
+ *
currency
+ *
+ *
+ *
+ *
Details
+ *
+ *
Currency of the price amount for an item. Values must be in ISO 4217
+ * currency code format.
+ *
+ * @param value Currency of the price amount for an item.
+ */
+ public void setCurrency(CurrencyEnumeration value);
+
+ /**
+ * Currency of the price amount for an item.
+ *
+ *
+ *
+ *
+ *
currency
+ *
+ *
+ *
+ *
Details
+ *
+ *
Currency of the price amount for an item. Values must be in ISO 4217
+ * currency code format.
+ *
+ * @return Additional instructions to explain the item�s delivery process.
+ */
+ public String getDeliveryNotes();
+
+ /**
+ * The maximum distance you will deliver an item in any direction.
+ *
+ *
+ *
+ *
delivery_radius
+ *
+ *
+ *
+ *
Details
+ *
The maximum distance you will deliver an item in any direction.
+ *
+ * @param deliveryRadius The maximum distance you will deliver an item in any direction.
+ */
+ public void setDeliveryRadius(FloatUnit deliveryRadius);
+
+ /**
+ * The maximum distance you will deliver an item in any direction.
+ *
+ *
+ *
+ *
delivery_radius
+ *
+ *
+ *
+ *
Details
+ *
The maximum distance you will deliver an item in any direction.
+ *
+ * @return The maximum distance you will deliver an item in any direction.
+ */
+ public FloatUnit getDeliveryRadius();
+
+ /**
+ * Format of the content.
+ *
+ *
+ * @return Format of the content.
+ */
+ public String[] getFormat();
+
+ /**
+ * A unique 10 or 13 digit number assigned to every printed book.
+ *
+ *
+ *
+ *
isbn
+ *
+ *
+ *
Details
+ *
+ *
A unique 10 or 13 digit number assigned to every printed book.
+ *
+ *
+ *
+ *
Example
+ *
<g:isbn>0451524233</g:isbn>
+ *
+ *
+ *
+ *
Attribute of
+ *
Products
+ *
+ *
+ *
+ *
Content type
+ *
string
+ *
+ *
+ *
+ *
+ *
+ * @param isbn A unique 10 or 13 digit number assigned to every printed book.
+ */
+ public void setIsbn(String isbn);
+
+ /**
+ * A unique 10 or 13 digit number assigned to every printed book.
+ *
+ *
+ *
+ *
isbn
+ *
+ *
+ *
Details
+ *
+ *
A unique 10 or 13 digit number assigned to every printed book.
+ *
+ *
+ *
+ *
Example
+ *
<g:isbn>0451524233</g:isbn>
+ *
+ *
+ *
+ *
Attribute of
+ *
Products
+ *
+ *
+ *
+ *
Content type
+ *
string
+ *
+ *
+ *
+ *
+ *
+ * @return A unique 10 or 13 digit number assigned to every printed book.
+ */
+ public String getIsbn();
+
+ /**
+ * Location of a property. Should include street, city, state, postal code, and country, in that
+ * order.
+ *
+ *
+ *
+ *
+ *
location
+ *
+ *
+ *
+ *
Details
+ *
Location of a property. Should include street, city, state, postal code,
+ * and country, in that order.
+ *
+ *
+ *
+ *
Example
+ *
+ *
Acceptable:
+ * <g:location>123 Main St, Anytown,
+ * CA, 12345,
+ * USA</g:location>
+ *
+ * Not acceptable:
+ * <g:location>123 Main St,, CA,
+ * 12345,
+ * USA</g:location>
+ * <g:location> Anytown, CA,
+ * 12345,
+ * USA</g:location>
+ *
+ *
+ *
+ *
Attribute of
+ *
Reference Items, Events, Housing, Jobs, News and Articles, People
+ * profiles, Products, Reviews, Services, Travel, Vehicles, Wanted Ads.
+ *
+ *
+ *
+ *
+ *
Content type
+ *
locationType
+ *
+ *
+ *
+ *
+ * @param location Location of a property. Should include street, city, state, postal code, and
+ * country, in that order.
+ */
+ public void setLocation(String location);
+
+ /**
+ * Location of a property. Should include street, city, state, postal code, and country, in that
+ * order.
+ *
+ *
+ *
+ *
+ *
location
+ *
+ *
+ *
+ *
Details
+ *
Location of a property. Should include street, city, state, postal code,
+ * and country, in that order.
+ *
+ *
+ *
+ *
Example
+ *
+ *
Acceptable:
+ * <g:location>123 Main St, Anytown,
+ * CA, 12345,
+ * USA</g:location>
+ *
+ * Not acceptable:
+ * <g:location>123 Main St,, CA,
+ * 12345,
+ * USA</g:location>
+ * <g:location> Anytown, CA,
+ * 12345,
+ * USA</g:location>
+ *
+ *
+ *
+ *
Attribute of
+ *
Reference Items, Events, Housing, Jobs, News and Articles, People
+ * profiles, Products, Reviews, Services, Travel, Vehicles, Wanted Ads.
+ *
+ *
+ *
+ *
+ *
Content type
+ *
locationType
+ *
+ *
+ *
+ *
+ * @return Location of a property. Should include street, city, state, postal code, and country,
+ * in that order.
+ */
+ public String getLocation();
+
+ /**
+ * Company that manufactures the item.
+ *
+ *
+ *
+ *
+ *
+ * manufacturer
+ *
+ *
+ *
+ *
+ * Details
+ *
+ *
+ * Company that manufactures the item.
+ *
+ *
+ *
+ *
+ * Example
+ *
+ * <g:manufacturer>Acme, Inc</g:manufacturer>
+ *
+ *
+ *
+ *
+ *
+ * Attribute of
+ *
+ * Products
+ *
+ *
+ *
+ *
+ *
+ * Content type
+ *
+ * string
+ *
+ *
+ *
+ *
+ * @param manufacturer Company that manufactures the item.
+ */
+ public void setManufacturer(String manufacturer);
+
+ /**
+ * Company that manufactures the item.
+ *
+ *
+ *
+ *
+ *
+ * manufacturer
+ *
+ *
+ *
+ *
+ * Details
+ *
+ *
+ * Company that manufactures the item.
+ *
+ *
+ *
+ *
+ * Example
+ *
+ * <g:manufacturer>Acme, Inc</g:manufacturer>
+ *
+ *
+ *
+ *
+ *
+ * Attribute of
+ *
+ * Products
+ *
+ *
+ *
+ *
+ *
+ * Content type
+ *
+ * string
+ *
+ *
+ *
+ *
+ * @return Company that manufactures the item.
+ */
+ public String getManufacturer();
+
+ /**
+ * Unique product ID code assigned by its manufacturer.
+ *
+ *
+ *
+ *
+ *
+ *
manufacturer_id
+ *
+ *
+ *
Details
+ *
+ *
+ * Unique product ID code assigned by its manufacturer.
+ *
+ *
+ *
Example
+ *
<g:manufacturer_id>030779A</g:manufacturer_id>
+ *
+ *
+ *
+ *
Attribute of
+ *
Products
+ *
+ *
+ *
+ *
+ *
Content type
+ *
string
+ *
+ *
+ *
+ *
+ * @param manufacturerId Unique product ID code assigned by its manufacturer.
+ */
+ public void setManufacturerId(String manufacturerId);
+
+ /**
+ * Unique product ID code assigned by its manufacturer.
+ *
+ *
+ *
+ *
+ *
+ *
manufacturer_id
+ *
+ *
+ *
Details
+ *
+ *
+ * Unique product ID code assigned by its manufacturer.
+ *
+ *
+ *
Example
+ *
<g:manufacturer_id>030779A</g:manufacturer_id>
+ *
+ *
+ *
+ *
Attribute of
+ *
Products
+ *
+ *
+ *
+ *
+ *
Content type
+ *
string
+ *
+ *
+ *
+ *
+ * @return Unique product ID code assigned by its manufacturer.
+ */
+ public String getManufacturerId();
+
+ /**
+ * Resolution of a digital imaging device.
+ *
+ *
+ *
+ *
+ *
+ * megapixels
+ *
+ *
+ *
+ *
Details
+ *
Resolution of a digital imaging device.
+ *
+ *
+ *
+ *
+ *
Example
+ *
<g:megapixels>5.2 MP</g:megapixels>
+ *
+ *
+ *
+ *
+ *
Attribute of
+ *
Products
+ *
+ *
+ *
+ *
+ * Content type
+ *
+ *
floatUnit
+ *
+ *
+ *
+ *
+ * @param megapixels Resolution of a digital imaging device.
+ */
+ public void setMegapixels(FloatUnit megapixels);
+
+ /**
+ * Resolution of a digital imaging device.
+ *
+ *
+ *
+ *
+ *
+ * megapixels
+ *
+ *
+ *
+ *
Details
+ *
Resolution of a digital imaging device.
+ *
+ *
+ *
+ *
+ *
Example
+ *
<g:megapixels>5.2 MP</g:megapixels>
+ *
+ *
+ *
+ *
+ *
Attribute of
+ *
Products
+ *
+ *
+ *
+ *
+ * Content type
+ *
+ *
floatUnit
+ *
+ *
+ *
+ *
+ * @return Resolution of a digital imaging device.
+ */
+ public FloatUnit getMegapixels();
+
+ /**
+ * The amount of memory included in an item.
+ *
+ *
+ *
+ *
memory
+ *
+ *
+ *
+ *
Details
+ *
The amount of memory included in an item.
+ *
+ *
+ *
+ *
+ *
Example
+ *
<g:memory>128 MB</g:memory>
+ *
+ *
+ *
+ *
+ *
+ * Attribute of
+ *
Products
+ *
+ *
+ *
+ *
+ * Content type
+ *
+ *
floatUnit
+ *
+ *
+ *
+ *
+ * @param memory The amount of memory included in an item.
+ */
+ public void setMemory(FloatUnit memory);
+
+ /**
+ * The amount of memory included in an item.
+ *
+ *
+ *
+ *
memory
+ *
+ *
+ *
+ *
Details
+ *
The amount of memory included in an item.
+ *
+ *
+ *
+ *
+ *
Example
+ *
<g:memory>128 MB</g:memory>
+ *
+ *
+ *
+ *
+ *
+ * Attribute of
+ *
Products
+ *
+ *
+ *
+ *
+ * Content type
+ *
+ *
floatUnit
+ *
+ *
+ *
+ *
+ * @return The amount of memory included in an item.
+ */
+ public FloatUnit getMemory();
+
+ /**
+ * Model number of the product.
+ *
+ *
+ *
+ *
+ *
+ *
+ *
model_number
+ *
+ *
+ *
Details
+ *
+ *
+ * Model number of the product.
+ *
+ *
+ *
Example
+ *
<g:model_number>1924863</g:model_number>
+ *
+ *
+ *
+ *
Attribute of
+ *
Products
+ *
+ *
+ *
+ *
+ *
Content type
+ *
string
+ *
+ *
+ *
+ *
+ * @param modelNumber Model number of the product.
+ */
+ public void setModelNumber(String modelNumber);
+
+ /**
+ * Model number of the product.
+ *
+ *
+ *
+ *
+ *
+ *
+ *
model_number
+ *
+ *
+ *
Details
+ *
+ *
+ * Model number of the product.
+ *
+ *
+ *
Example
+ *
<g:model_number>1924863</g:model_number>
+ *
+ *
+ *
+ *
Attribute of
+ *
Products
+ *
+ *
+ *
+ *
+ *
Content type
+ *
string
+ *
+ *
+ *
+ *
+ * @return Model number of the product.
+ */
+ public String getModelNumber();
+
+ /**
+ * Acceptable payment methods for item purchases.
+ *
+ *
+ *
+ *
+ *
+ *
payment_accepted
+ *
+ *
+ *
Details
+ *
Acceptable payment methods for item purchases. Acceptable values are
+ * “Cash,” “Check,” “Traveler’s Check,” “Visa,” “MasterCard,”
+ *
+ * “American Express,” “Discover,” or “Wire transfer.” If you accept more than one method,
+ * include multiple instances of the <payment_accepted> attribute for each acceptable
+ * method.
Acceptable payment methods for item purchases. Acceptable values are
+ * “Cash,” “Check,” “Traveler’s Check,” “Visa,” “MasterCard,”
+ *
+ * “American Express,” “Discover,” or “Wire transfer.” If you accept more than one method,
+ * include multiple instances of the <payment_accepted> attribute for each acceptable
+ * method.
+ *
+ * @return Additional instructions to explain a payment policy.
+ */
+ public String getPaymentNotes();
+
+ /**
+ * Whether or not an item is available for pick up.
+ *
+ *
+ *
+ *
+ *
+ *
pickup
+ *
+ *
+ *
+ *
Details
+ *
+ *
Information about whether or not an item is available for pick up.
+ * Acceptable values are "True and "False".
+ *
+ *
+ *
Example
+ *
+ *
+ *
+ * Acceptable:
+ * <g:pickup>True</g:pickup>
+ * Not acceptable:
+ * <g:pickup>Not on Tuesdays</g:pickup>
+ *
+ *
+ *
+ *
+ *
Attribute of
+ *
Products
+ *
+ *
+ *
+ *
+ * Content type
+ *
boolean
+ *
+ *
+ *
+ *
+ * @param pickup Whether or not an item is available for pick up.
+ */
+ public void setPickup(Boolean pickup);
+
+ /**
+ * Whether or not an item is available for pick up.
+ *
+ *
+ *
+ *
+ *
+ *
pickup
+ *
+ *
+ *
+ *
Details
+ *
+ *
Information about whether or not an item is available for pick up.
+ * Acceptable values are "True and "False".
+ *
+ *
+ *
Example
+ *
+ *
+ *
+ * Acceptable:
+ * <g:pickup>True</g:pickup>
+ * Not acceptable:
+ * <g:pickup>Not on Tuesdays</g:pickup>
+ *
+ *
+ *
+ *
+ *
Attribute of
+ *
Products
+ *
+ *
+ *
+ *
+ * Content type
+ *
boolean
+ *
+ *
+ *
+ *
+ * @return Whether or not an item is available for pick up.
+ */
+ public Boolean getPickup();
+
+ /**
+ * Price of the item.
+ *
+ *
+ *
+ *
+ *
+ *
+ *
price
+ *
+ *
+ *
Details
+ *
Prices can be a single price, 0 (free), or blank if not applicable.
+ * Numerice values only. When used as a sub-attribute of <shipping>, the value included
+ * reflects the price of shipping.
+ *
+ * @param price Price of the item.
+ */
+ public void setPrice(FloatUnit price);
+
+ /**
+ * Price of the item.
+ *
+ *
+ *
+ *
+ *
+ *
+ *
price
+ *
+ *
+ *
Details
+ *
Prices can be a single price, 0 (free), or blank if not applicable.
+ * Numerice values only. When used as a sub-attribute of <shipping>, the value included
+ * reflects the price of shipping.
+ *
+ * @param priceType The type of pricing for the item.
+ */
+ public void setPriceType(PriceTypeEnumeration priceType);
+
+ /**
+ * The type of pricing for the item.
+ *
+ *
+ *
+ *
+ *
price_type
+ *
+ *
+ *
+ *
+ *
Details
+ *
The type of pricing for the item. Acceptable values are “negotiable,” or
+ * “starting.” The default is “starting”
+ *
+ * @return The type of pricing for the item.
+ */
+ public PriceTypeEnumeration getPriceType();
+
+ /**
+ * The processor speed for the product.
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ * processor_speed
+ *
+ *
+ *
Details
+ *
+ *
The processor speed for the product.
+ *
+ *
+ *
+ *
Example
+ *
<g:processor_speed>2</g:processor_speed>
+ *
+ *
+ *
+ *
+ *
Attribute of
+ *
Products
+ *
+ *
+ *
+ *
Content type
+ *
floatUnit
+ *
+ *
+ *
+ *
+ * @param processorSpeed The processor speed for the product.
+ */
+ public void setProcessorSpeed(FloatUnit processorSpeed);
+
+ /**
+ * The processor speed for the product.
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ * processor_speed
+ *
+ *
+ *
Details
+ *
+ *
The processor speed for the product.
+ *
+ *
+ *
+ *
Example
+ *
<g:processor_speed>2</g:processor_speed>
+ *
+ *
+ *
+ *
+ *
Attribute of
+ *
Products
+ *
+ *
+ *
+ *
Content type
+ *
floatUnit
+ *
+ *
+ *
+ *
+ * @return The processor speed for the product.
+ */
+ public FloatUnit getProcessorSpeed();
+
+ /**
+ * The type of product being offered.
+ *
+ *
+ *
+ *
+ *
product_type
+ *
+ *
+ *
Details
+ *
+ *
+ *
+ * The type of product being offered. Toys, books, flowers, etc.
+ *
+ *
+ *
Example
+ *
<g:product_type>electronics</g:product_type>
+ *
+ *
+ *
+ *
Attribute of
+ *
Products
+ *
+ *
+ *
+ *
+ *
Content type
+ *
string
+ *
+ *
+ *
+ *
+ * @param productTypes The type of product being offered.
+ */
+ public void setProductTypes(String[] productTypes);
+
+ /**
+ * The type of product being offered.
+ *
+ *
+ *
+ *
+ *
product_type
+ *
+ *
+ *
Details
+ *
+ *
+ *
+ * The type of product being offered. Toys, books, flowers, etc.
+ *
+ *
+ *
Example
+ *
<g:product_type>electronics</g:product_type>
+ *
+ *
+ *
+ *
Attribute of
+ *
Products
+ *
+ *
+ *
+ *
+ *
Content type
+ *
string
+ *
+ *
+ *
+ *
+ * @return The type of product being offered.
+ */
+ public String[] getProductTypes();
+
+ /**
+ * Quantity available.
+ *
+ *
+ *
+ *
+ *
+ *
quantity
+ *
+ *
+ *
+ *
Details
+ *
The number of units available for purchase. This attribute can be left
+ * blank if you have a large quantity or if it is not applicable.
+ *
+ *
+ *
+ *
+ *
Example
+ *
Acceptable:
+ * <g:quantity>18</g:quantity>
+ *
+ * <g:quantity>0</g:quantity>
+ *
+ * Not acceptable:
+ * <g:quantity>out of stock</g:quantity>
The number of units available for purchase. This attribute can be left
+ * blank if you have a large quantity or if it is not applicable.
+ *
+ *
+ *
+ *
+ *
Example
+ *
Acceptable:
+ * <g:quantity>18</g:quantity>
+ *
+ * <g:quantity>0</g:quantity>
+ *
+ * Not acceptable:
+ * <g:quantity>out of stock</g:quantity>
+ *
+ *
+ *
+ *
+ * Attribute of
+ *
+ *
Events, Products, Services, Travel, Vehicles
+ *
+ *
+ *
Content type
+ *
+ *
+ *
+ * integer
+ *
+ *
+ *
+ *
+ * @return Quantity available.
+ */
+ public Integer getQuantity();
+
+ /**
+ * Shipping options available for an item.
+ *
+ *
+ *
+ *
+ *
+ *
+ * shipping
+ *
+ *
+ *
Details
+ *
+ *
Shipping options available for an item. Up to 10 shipping options can be
+ * included for each item. Three sub-attributes are included in the shipping attribute:
+ *
+ *
+ *
service = The type of service used to ship an item. Acceptable values are 'FedEx', 'UPS',
+ * 'DHL', 'Mail', and 'Other'
+ *
country = The country an item will ship to. Only acceptable values areISO 3166
+ * country codes.
+ *
+ * @param shipping Shipping options available for an item.
+ */
+ public void setShipping(ShippingType[] shipping);
+
+ /**
+ * Shipping options available for an item.
+ *
+ *
+ *
+ *
+ *
+ *
+ * shipping
+ *
+ *
+ *
Details
+ *
+ *
Shipping options available for an item. Up to 10 shipping options can be
+ * included for each item. Three sub-attributes are included in the shipping attribute:
+ *
+ *
+ *
service = The type of service used to ship an item. Acceptable values are 'FedEx', 'UPS',
+ * 'DHL', 'Mail', and 'Other'
+ *
country = The country an item will ship to. Only acceptable values areISO 3166
+ * country codes.
+ *
+ * @return Shipping options available for an item.
+ */
+ public ShippingType[] getShipping();
+
+ /**
+ * Dimensions of the item, expressed in either two or three dimensions.
+ *
+ *
+ *
+ *
+ *
+ *
size
+ *
+ *
+ *
+ *
Details
+ *
+ *
Dimensions of the item, expressed in either two or three
+ * dimensions.
+ *
+ *
+ *
+ *
Example
+ *
<g:size>12x10x4</g:size>
+ *
+ *
+ *
+ *
+ *
+ * Attribute of
+ *
Products
+ *
+ *
+ *
+ *
Content type
+ *
+ *
string
+ *
+ *
+ *
+ *
+ * @param size Dimensions of the item, expressed in either two or three dimensions.
+ */
+ public void setSize(Size size);
+
+ /**
+ * Dimensions of the item, expressed in either two or three dimensions.
+ *
+ *
+ *
+ *
+ *
+ *
size
+ *
+ *
+ *
+ *
Details
+ *
+ *
Dimensions of the item, expressed in either two or three
+ * dimensions.
+ *
+ *
+ *
+ *
Example
+ *
<g:size>12x10x4</g:size>
+ *
+ *
+ *
+ *
+ *
+ * Attribute of
+ *
Products
+ *
+ *
+ *
+ *
Content type
+ *
+ *
string
+ *
+ *
+ *
+ *
+ * @return Dimensions of the item, expressed in either two or three dimensions.
+ */
+ public Size getSize();
+
+ /**
+ * Tax rate associated with the event.
+ *
+ *
+ *
+ *
+ *
tax_percent
+ *
+ *
+ *
+ *
+ *
+ * Details
+ *
Tax rate as a percentage.
+ *
+ *
+ *
+ *
Example
+ *
+ *
<g:tax_percent>8.2<g:/tax_percent>
+ *
+ *
+ *
+ *
+ * Attribute of
+ *
+ *
+ * Products, Events
+ *
+ *
+ *
Content type
+ *
+ *
percentType
+ *
+ *
+ *
+ *
+ *
+ * @param taxPercent Tax rate associated with the event.
+ */
+ public void setTaxPercent(Float taxPercent);
+
+ /**
+ * Tax rate associated with the event.
+ *
+ *
+ *
+ *
+ *
tax_percent
+ *
+ *
+ *
+ *
+ *
+ * Details
+ *
Tax rate as a percentage.
+ *
+ *
+ *
+ *
Example
+ *
+ *
<g:tax_percent>8.2<g:/tax_percent>
+ *
+ *
+ *
+ *
+ * Attribute of
+ *
+ *
+ * Products, Events
+ *
+ *
+ *
Content type
+ *
+ *
percentType
+ *
+ *
+ *
+ *
+ *
+ * @return Tax rate associated with the event.
+ */
+ public Float getTaxPercent();
+
+ /**
+ * Region where tax applies.
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ * tax_region
+ *
+ *
+ *
+ *
Details
+ *
Geographical region a tax rate applies to.
+ *
+ *
+ *
+ *
+ *
+ * Example
+ *
<g:tax_region>California</g:tax_region>
+ *
+ *
+ *
+ *
Attribute of
+ *
+ *
Product, Events,
+ *
+ *
+ *
+ *
Content type
+ *
string
+ *
+ *
+ *
+ *
+ *
+ * @param taxRegion Region where tax applies.
+ */
+ public void setTaxRegion(String taxRegion);
+
+ /**
+ * Region where tax applies.
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ * tax_region
+ *
+ *
+ *
+ *
Details
+ *
Geographical region a tax rate applies to.
+ *
+ *
+ *
+ *
+ *
+ * Example
+ *
<g:tax_region>California</g:tax_region>
+ *
+ *
+ *
+ *
Attribute of
+ *
+ *
Product, Events,
+ *
+ *
+ *
+ *
Content type
+ *
string
+ *
+ *
+ *
+ *
+ *
+ * @return Region where tax applies.
+ */
+ public String getTaxRegion();
+
+ /**
+ * Product UPC code (Isn't that redundant?).
+ *
+ *
+ *
+ *
+ *
+ * @return Product UPC code (Isn't that redundant?).
+ */
+ public String getUpc();
+
+ /**
+ * Weight of the item.
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
weight
+ *
+ *
+ *
Details
+ *
+ *
Weight of the item.
+ *
+ *
+ *
+ *
Example
+ *
<g:weight>5</g:weight>
+ *
+ *
+ *
+ *
+ *
Attribute of
+ *
Products
+ *
+ *
+ *
+ *
+ *
+ * Content type
+ *
floatUnit
+ *
+ *
+ *
+ *
+ * @param weight Weight of the item.
+ */
+ public void setWeight(FloatUnit weight);
+
+ /**
+ * Weight of the item.
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
weight
+ *
+ *
+ *
Details
+ *
+ *
Weight of the item.
+ *
+ *
+ *
+ *
Example
+ *
<g:weight>5</g:weight>
+ *
+ *
+ *
+ *
+ *
Attribute of
+ *
Products
+ *
+ *
+ *
+ *
+ *
+ * Content type
+ *
floatUnit
+ *
+ *
+ *
+ *
+ * @return Weight of the item.
+ */
+ public FloatUnit getWeight();
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/base/Review.java b/rome-modules/src/main/java/com/rometools/modules/base/Review.java
new file mode 100644
index 0000000..dfdd8cf
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/base/Review.java
@@ -0,0 +1,798 @@
+/*
+ * Review.java
+ *
+ * Created on November 16, 2005, 1:58 PM
+ *
+ * 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.
+ */
+package com.rometools.modules.base;
+
+import java.net.URL;
+import java.util.Date;
+
+import com.rometools.modules.base.types.FloatUnit;
+
+/**
+ * This is an interface for the GoogleBase plug in that exposes methods used for critical reviews of
+ * other things.
+ *
+ * @author Robert "kebernet" Cooper
+ * @version $Revision: 1.1 $
+ */
+public interface Review extends GlobalInterface {
+ /**
+ * Author of the item.
+ *
+ *
+ *
+ *
+ *
+ *
+ *
author
+ *
+ *
+ *
Details
+ *
+ *
Author of the item.
+ *
+ *
+ *
Example
+ *
<g:author>John Steinbeck</g:author>
+ *
+ *
+ *
+ *
Attribute of
+ *
Reference Items, News and Articles
+ *
+ *
+ *
+ *
+ *
Content type
+ *
string
+ *
+ *
+ *
+ *
+ * @param authors Author of the item.
+ */
+ public void setAuthors(String[] authors);
+
+ /**
+ * Author of the item.
+ *
+ *
+ *
+ *
+ *
+ *
+ *
author
+ *
+ *
+ *
Details
+ *
+ *
Author of the item.
+ *
+ *
+ *
Example
+ *
<g:author>John Steinbeck</g:author>
+ *
+ *
+ *
+ *
Attribute of
+ *
Reference Items, News and Articles
+ *
+ *
+ *
+ *
+ *
Content type
+ *
string
+ *
+ *
+ *
+ *
+ * @return Author of the item.
+ */
+ public String[] getAuthors();
+
+ /**
+ * Additional instructions to explain the item’s delivery process.
+ *
+ *
+ *
+ *
+ *
delivery_notes
+ *
+ *
+ *
Details
+ *
+ *
Additional instructions to explain the item’s delivery process.
+ *
+ *
+ *
Example
+ *
+ * <g:delivery_notes>Items usually shipped within 24
+ * hours.<g:/delivery_notes>
+ *
+ *
+ *
+ * @return Additional instructions to explain the item’s delivery process.
+ */
+ public String getDeliveryNotes();
+
+ /**
+ * The maximum distance you will deliver an item in any direction.
+ *
+ *
+ *
+ *
delivery_radius
+ *
+ *
+ *
+ *
Details
+ *
The maximum distance you will deliver an item in any direction.
+ *
+ * @param deliveryRadius The maximum distance you will deliver an item in any direction.
+ */
+ public void setDeliveryRadius(FloatUnit deliveryRadius);
+
+ /**
+ * The maximum distance you will deliver an item in any direction.
+ *
+ *
+ *
+ *
delivery_radius
+ *
+ *
+ *
+ *
Details
+ *
The maximum distance you will deliver an item in any direction.
+ *
+ * @return The maximum distance you will deliver an item in any direction.
+ */
+ public FloatUnit getDeliveryRadius();
+
+ /**
+ * The name of an item being reviewed.
+ *
+ *
+ *
+ *
+ *
+ *
name_of_item_being_reviewed
+ *
+ *
+ *
Details
+ *
+ *
+ *
+ * The name of an item being reviewed.
+ *
+ *
+ *
Example
+ *
<g:name_of_item_being__reviewed>Fleur de lys
+ * Restaurant</g:name_of_item_being_reviewed>
+ *
+ *
+ *
+ *
Attribute of
+ *
Reviews
+ *
+ *
+ *
+ *
Content type
+ *
string
+ *
+ *
+ *
+ *
+ * @param nameOfItemBeingReviewed The name of an item being reviewed.
+ */
+ public void setNameOfItemBeingReviewed(String nameOfItemBeingReviewed);
+
+ /**
+ * The name of an item being reviewed.
+ *
+ *
+ *
+ *
+ *
+ *
name_of_item_being_reviewed
+ *
+ *
+ *
Details
+ *
+ *
+ *
+ * The name of an item being reviewed.
+ *
+ *
+ *
Example
+ *
<g:name_of_item_being__reviewed>Fleur de lys
+ * Restaurant</g:name_of_item_being_reviewed>
+ *
+ *
+ *
+ *
Attribute of
+ *
Reviews
+ *
+ *
+ *
+ *
Content type
+ *
string
+ *
+ *
+ *
+ *
+ * @return The name of an item being reviewed.
+ */
+ public String getNameOfItemBeingReviewed();
+
+ /**
+ * Date the item was published.
+ *
+ *
+ *
+ *
+ *
publish_date
+ *
+ *
+ *
+ *
Details
+ *
+ *
Date the item was published in ISO 8601
+ * format: YYYY-MM-DD
+ *
+ *
+ *
+ *
Example
+ *
+ *
<g:publish_date>2005-12-20</g:publish_date>
+ *
+ *
+ *
+ *
Attribute of
+ *
+ *
+ * Reference Items
+ *
+ *
+ *
+ *
+ * Content type
+ *
date
+ *
+ *
+ *
+ *
+ *
+ * @param publishDate Date the item was published.
+ */
+ public void setPublishDate(Date publishDate);
+
+ /**
+ * Date the item was published.
+ *
+ *
+ *
+ *
+ *
publish_date
+ *
+ *
+ *
+ *
Details
+ *
+ *
Date the item was published in ISO 8601
+ * format: YYYY-MM-DD
+ *
+ *
+ *
+ *
Example
+ *
+ *
<g:publish_date>2005-12-20</g:publish_date>
+ *
+ *
+ *
+ *
Attribute of
+ *
+ *
+ * Reference Items
+ *
+ *
+ *
+ *
+ * Content type
+ *
date
+ *
+ *
+ *
+ *
+ *
+ * @return Date the item was published.
+ */
+ public Date getPublishDate();
+
+ /**
+ * Rating of the product or service on a scale of 1-5, with 5 as the best.
+ *
+ *
+ *
+ *
rating
+ *
+ *
+ *
+ *
Details
+ *
Rating of the product or service on a scale of 1-5, with 5 as the best.
+ * Numeric values only.
+ *
+ * @param rating Rating of the product or service on a scale of 1-5, with 5 as the best.
+ */
+ public void setRating(Float rating);
+
+ /**
+ * Rating of the product or service on a scale of 1-5, with 5 as the best.
+ *
+ *
+ *
+ *
rating
+ *
+ *
+ *
+ *
Details
+ *
Rating of the product or service on a scale of 1-5, with 5 as the best.
+ * Numeric values only.
+ *
+ * @return Rating of the product or service on a scale of 1-5, with 5 as the best.
+ */
+ public Float getRating();
+
+ /**
+ * The category of the item being reviewed.
+ *
+ *
+ *
+ * @param reviewType The category of the item being reviewed.
+ */
+ public void setReviewType(String reviewType);
+
+ /**
+ * The category of the item being reviewed.
+ *
+ *
+ *
+ * @return The category of the item being reviewed.
+ */
+ public String getReviewType();
+
+ /**
+ * The type of rating being provided: editorial (a review written by a member of your staff) or
+ * “user” ( a review written by a user of your site).
+ *
+ *
+ *
+ *
reviewer_type
+ *
+ *
+ *
+ *
Details
+ *
+ *
The type of rating being provided: editorial (a review written by a
+ * member of your staff) or “user” ( a review written by a user of your site)
+ *
+ *
+ *
+ *
+ * Example
+ *
<g:reviewer_type>editorial</g:reviewer_type>
+ *
+ *
+ *
+ *
Attribute of
+ *
+ *
Reviews
+ *
+ *
+ *
+ *
Content type
+ *
string
+ *
+ *
+ *
+ *
+ *
+ * @param reviewerType The type of rating being provided: editorial (a review written by a
+ * member of your staff) or “user” ( a review written by a user of your site).
+ */
+ public void setReviewerType(String reviewerType);
+
+ /**
+ * The type of rating being provided: editorial (a review written by a member of your staff) or
+ * “user” ( a review written by a user of your site).
+ *
+ *
+ *
+ *
reviewer_type
+ *
+ *
+ *
+ *
Details
+ *
+ *
The type of rating being provided: editorial (a review written by a
+ * member of your staff) or “user” ( a review written by a user of your site)
+ *
+ *
+ *
+ *
+ * Example
+ *
<g:reviewer_type>editorial</g:reviewer_type>
+ *
+ *
+ *
+ *
Attribute of
+ *
+ *
Reviews
+ *
+ *
+ *
+ *
Content type
+ *
string
+ *
+ *
+ *
+ *
+ *
+ * @return The type of rating being provided: editorial (a review written by a member of your
+ * staff) or “user” ( a review written by a user of your site).
+ */
+ public String getReviewerType();
+
+ /**
+ * The web page of an item being reviewed.
+ *
+ *
+ *
+ * @param urlOfItemBeingReviewed The web page of an item being reviewed.
+ */
+ public void setUrlOfItemBeingReviewed(URL urlOfItemBeingReviewed);
+
+ /**
+ * The web page of an item being reviewed.
+ *
+ *
+ *
+ * @return The web page of an item being reviewed.
+ */
+ public URL getUrlOfItemBeingReviewed();
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/base/ScholarlyArticle.java b/rome-modules/src/main/java/com/rometools/modules/base/ScholarlyArticle.java
new file mode 100644
index 0000000..b0dc686
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/base/ScholarlyArticle.java
@@ -0,0 +1,463 @@
+/*
+ * ScholarlyArticle.java
+ *
+ * Created on November 16, 2005, 1:55 PM
+ *
+ * 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.
+ */
+package com.rometools.modules.base;
+
+import java.util.Date;
+
+/**
+ * This is an interface for the GoogleBase plug in that exposes methods used for Scholarly
+ * publication, research studies and reference materials.
+ *
+ * @author Robert "kebernet" Cooper
+ * @version $Revision: 1.2 $
+ */
+public interface ScholarlyArticle extends GlobalInterface {
+ /**
+ * Array of Author Names. Limit 10.
+ *
+ *
+ * @return Array of author names.
+ */
+ public String[] getAuthors();
+
+ /**
+ * Number of pages in the article.
+ *
+ *
+ *
+ *
+ *
+ *
pages
+ *
+ *
+ *
+ *
Details
+ *
+ *
+ * The number of pages in the publication.
+ *
+ *
+ *
+ *
Example
+ *
<g:pages>18</g:pages>
+ *
+ *
+ *
+ *
+ *
Attribute of
+ *
Reference Items, News and Articles
+ *
+ *
+ *
+ *
+ *
+ * Content type
+ *
integer
+ *
+ *
+ *
+ *
+ * @param pages Number of pages in the article
+ */
+ public void setPages(Integer pages);
+
+ /**
+ * Number of pages in the article.
+ *
+ *
+ *
+ *
+ *
+ *
pages
+ *
+ *
+ *
+ *
Details
+ *
+ *
+ * The number of pages in the publication.
+ *
+ *
+ *
+ *
Example
+ *
<g:pages>18</g:pages>
+ *
+ *
+ *
+ *
+ *
Attribute of
+ *
Reference Items, News and Articles
+ *
+ *
+ *
+ *
+ *
+ * Content type
+ *
integer
+ *
+ *
+ *
+ *
+ * @return Number of pages in the article
+ */
+ public Integer getPages();
+
+ /**
+ * Name of the publication.
+ *
+ *
+ *
+ *
+ *
+ *
publication_name
+ *
+ *
+ *
+ *
Details
+ *
+ *
+ * Name of the publication.
+ *
+ *
+ *
+ *
Example
+ *
<g:publication_name> Journal of Appropriate
+ * Technology</g:publication_name>
+ *
+ *
+ *
+ *
+ *
Attribute of
+ *
Research studies and publications
+ *
+ *
+ *
+ *
+ *
+ * Content type
+ *
string
+ *
+ *
+ *
+ *
+ * @param publicationName Name of the publication.
+ */
+ public void setPublicationName(String publicationName);
+
+ /**
+ * Name of the publication.
+ *
+ *
+ *
+ *
+ *
+ *
publication_name
+ *
+ *
+ *
+ *
Details
+ *
+ *
+ * Name of the publication.
+ *
+ *
+ *
+ *
Example
+ *
<g:publication_name> Journal of Appropriate
+ * Technology</g:publication_name>
+ *
+ *
+ *
+ *
+ *
Attribute of
+ *
Research studies and publications
+ *
+ *
+ *
+ *
+ *
+ * Content type
+ *
string
+ *
+ *
+ *
+ *
+ * @return Name of the publication.
+ */
+ public String getPublicationName();
+
+ /**
+ * Volume of the publication.
+ *
+ *
+ *
+ *
+ *
publication_volume
+ *
+ *
+ *
Details
+ *
+ *
+ * Volume of the publication.
+ *
+ *
+ *
+ *
Example
+ *
<g:publication_volume>VI</g:publication_volume>
+ *
+ *
+ *
+ *
+ *
Attribute of
+ *
Reference Items
+ *
+ *
+ *
+ *
Content type
+ *
+ *
string
+ *
+ *
+ *
+ *
+ * @param publicationVolume Volume of the publication.
+ */
+ public void setPublicationVolume(String publicationVolume);
+
+ /**
+ * Volume of the publication.
+ *
+ *
+ *
+ *
+ *
publication_volume
+ *
+ *
+ *
Details
+ *
+ *
+ * Volume of the publication.
+ *
+ *
+ *
+ *
Example
+ *
<g:publication_volume>VI</g:publication_volume>
+ *
+ *
+ *
+ *
+ *
Attribute of
+ *
Reference Items
+ *
+ *
+ *
+ *
Content type
+ *
+ *
string
+ *
+ *
+ *
+ *
+ * @return Volume of the publication.
+ */
+ public String getPublicationVolume();
+
+ /**
+ * Date article was published.
+ *
+ *
+ *
+ *
+ *
publish_date
+ *
+ *
+ *
+ *
+ *
+ * Details
+ *
Date the item was published in ISO 8601
+ * format: YYYY-MM-DD
+ *
+ *
+ *
+ *
+ *
+ * Example
+ *
<g:publish_date>2005-12-20</g:publish_date>
+ *
+ *
+ *
+ *
Attribute of
+ *
+ *
Reference Items
+ *
+ *
+ *
+ *
+ * Content type
+ *
+ *
+ * date
+ *
+ *
+ *
+ *
+ * @param publishDate Date article was published
+ */
+ public void setPublishDate(Date publishDate);
+
+ /**
+ * Date article was published.
+ *
+ *
+ *
+ *
+ *
publish_date
+ *
+ *
+ *
+ *
+ *
+ * Details
+ *
Date the item was published in ISO 8601
+ * format: YYYY-MM-DD
+ *
+ *
+ *
+ *
+ *
+ * Example
+ *
<g:publish_date>2005-12-20</g:publish_date>
+ *
+ *
+ *
+ *
Attribute of
+ *
+ *
Reference Items
+ *
+ *
+ *
+ *
+ * Content type
+ *
+ *
+ * date
+ *
+ *
+ *
+ *
+ * @return Date article was published
+ */
+ public Date getPublishDate();
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/base/Service.java b/rome-modules/src/main/java/com/rometools/modules/base/Service.java
new file mode 100644
index 0000000..cd5f142
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/base/Service.java
@@ -0,0 +1,1232 @@
+/*
+ * Service.java
+ *
+ * Created on November 16, 2005, 2:14 PM
+ *
+ * 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.
+ * ee the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.rometools.modules.base;
+
+import com.rometools.modules.base.types.CurrencyEnumeration;
+import com.rometools.modules.base.types.FloatUnit;
+import com.rometools.modules.base.types.PaymentTypeEnumeration;
+import com.rometools.modules.base.types.PriceTypeEnumeration;
+import com.rometools.modules.base.types.ShippingType;
+
+/**
+ * This is an interface for the GoogleBase plug in that exposes methods used for service offerings.
+ *
+ * @author Robert "kebernet" Cooper
+ * @version $Revision: 1.1 $
+ */
+public interface Service extends GlobalInterface {
+ /**
+ * Currency of the price amount for an item.
+ *
+ *
+ *
+ *
+ *
currency
+ *
+ *
+ *
+ *
Details
+ *
+ *
Currency of the price amount for an item. Values must be in ISO 4217
+ * currency code format.
+ *
+ * @param value Currency of the price amount for an item.
+ */
+ public void setCurrency(CurrencyEnumeration value);
+
+ /**
+ * Currency of the price amount for an item.
+ *
+ *
+ *
+ *
+ *
currency
+ *
+ *
+ *
+ *
Details
+ *
+ *
Currency of the price amount for an item. Values must be in ISO 4217
+ * currency code format.
+ *
+ * @return Additional instructions to explain the item’s delivery process.
+ */
+ public String getDeliveryNotes();
+
+ /**
+ * The maximum distance you will deliver an item in any direction.
+ *
+ *
+ *
+ *
delivery_radius
+ *
+ *
+ *
+ *
Details
+ *
The maximum distance you will deliver an item in any direction.
+ *
+ * @param deliveryRadius The maximum distance you will deliver an item in any direction.
+ */
+ public void setDeliveryRadius(FloatUnit deliveryRadius);
+
+ /**
+ * The maximum distance you will deliver an item in any direction.
+ *
+ *
+ *
+ *
delivery_radius
+ *
+ *
+ *
+ *
Details
+ *
The maximum distance you will deliver an item in any direction.
+ *
+ * @return The maximum distance you will deliver an item in any direction.
+ */
+ public FloatUnit getDeliveryRadius();
+
+ /**
+ * Location of the where the service is offered.
+ *
+ *
+ *
+ *
+ *
location
+ *
+ *
+ *
+ *
Details
+ *
Location of a property. Should include street, city, state, postal code,
+ * and country, in that order.
+ *
+ *
+ *
+ *
Example
+ *
+ *
Acceptable:
+ * <g:location>123 Main St, Anytown,
+ * CA, 12345,
+ * USA</g:location>
+ *
+ * Not acceptable:
+ * <g:location>123 Main St,, CA,
+ * 12345,
+ * USA</g:location>
+ * <g:location> Anytown, CA,
+ * 12345,
+ * USA</g:location>
+ *
+ *
+ *
+ *
Attribute of
+ *
Reference Items, Events, Housing, Jobs, News and Articles, People
+ * profiles, Products, Reviews, Services, Travel, Vehicles, Wanted Ads.
+ *
+ *
+ *
+ *
+ *
Content type
+ *
locationType
+ *
+ *
+ *
+ *
+ * @param location Location of the where the service is offered.
+ */
+ public void setLocation(String location);
+
+ /**
+ * Location of the where the service is offered.
+ *
+ *
+ *
+ *
+ *
location
+ *
+ *
+ *
+ *
Details
+ *
Location of a property. Should include street, city, state, postal code,
+ * and country, in that order.
+ *
+ *
+ *
+ *
Example
+ *
+ *
Acceptable:
+ * <g:location>123 Main St, Anytown,
+ * CA, 12345,
+ * USA</g:location>
+ *
+ * Not acceptable:
+ * <g:location>123 Main St,, CA,
+ * 12345,
+ * USA</g:location>
+ * <g:location> Anytown, CA,
+ * 12345,
+ * USA</g:location>
+ *
+ *
+ *
+ *
Attribute of
+ *
Reference Items, Events, Housing, Jobs, News and Articles, People
+ * profiles, Products, Reviews, Services, Travel, Vehicles, Wanted Ads.
+ *
+ *
+ *
+ *
+ *
Content type
+ *
locationType
+ *
+ *
+ *
+ *
+ * @return Location of the where the service is offered.
+ */
+ public String getLocation();
+
+ /**
+ * Payment Methods acceptable for the service.
+ *
+ *
+ *
+ *
+ *
+ *
payment_accepted
+ *
+ *
+ *
Details
+ *
Acceptable payment methods for item purchases. Acceptable values are
+ * "Cash," "Check," "Traveler’s Check," "Visa," "MasterCard,"
+ *
+ * "American Express," "Discover," "Wire transfer" or "Paypal." If you accept more than one
+ * method, include multiple instances of the <payment_accepted> attribute for each
+ * acceptable method.
+ *
+ * @param paymentAccepted Payment Methods acceptable for the service.
+ */
+ public void setPaymentAccepted(PaymentTypeEnumeration[] paymentAccepted);
+
+ /**
+ * Payment Methods acceptable for the service.
+ *
+ *
+ *
+ *
+ *
+ *
payment_accepted
+ *
+ *
+ *
Details
+ *
Acceptable payment methods for item purchases. Acceptable values are
+ * "Cash," "Check," "Traveler’s Check," "Visa," "MasterCard,"
+ *
+ * "American Express," "Discover," "Wire transfer" or "Paypal." If you accept more than one
+ * method, include multiple instances of the <payment_accepted> attribute for each
+ * acceptable method.
+ *
+ * @return Additional payment information.
+ */
+ public String getPaymentNotes();
+
+ /**
+ * Price for the service.
+ *
+ *
+ *
+ *
+ *
+ *
+ *
price
+ *
+ *
+ *
Details
+ *
Prices can be a single price, 0 (free), or blank if not applicable.
+ * Numerice values only. When used as a sub-attribute of <shipping>, the value included
+ * reflects the price of shipping.
+ *
+ * @param price Price for the service.
+ */
+ public void setPrice(FloatUnit price);
+
+ /**
+ * Price for the service.
+ *
+ *
+ *
+ *
+ *
+ *
+ *
price
+ *
+ *
+ *
Details
+ *
Prices can be a single price, 0 (free), or blank if not applicable.
+ * Numerice values only. When used as a sub-attribute of <shipping>, the value included
+ * reflects the price of shipping.
The number of units available for purchase. This attribute can be left
+ * blank if you have a large quantity or if it is not applicable.
+ *
+ *
+ *
+ *
+ *
Example
+ *
Acceptable:
+ * <g:quantity>18</g:quantity>
+ *
+ * <g:quantity>0</g:quantity>
+ *
+ * Not acceptable:
+ * <g:quantity>out of stock</g:quantity>
+ *
+ *
+ *
+ *
+ * Attribute of
+ *
+ *
Events, Products, Services, Travel, Vehicles
+ *
+ *
+ *
Content type
+ *
+ *
+ *
+ * integer
+ *
+ *
+ *
+ *
+ * @return Quantity available.
+ */
+ public Integer getQuantity();
+
+ /**
+ * The type of service being offered.
+ *
+ *
+ *
+ *
+ *
+ *
+ *
service_type
+ *
+ *
+ *
Details
+ *
+ *
The type of service being offered. Web hosting, legal, gardening,
+ * etc.
+ *
+ *
+ *
Example
+ *
<g:service_type>consulting</g:service_type>
+ *
+ *
+ *
+ *
Attribute of
+ *
Housing
+ *
+ *
+ *
+ *
+ *
Content type
+ *
string
+ *
+ *
+ *
+ *
+ * @param serviceType The type of service being offered.
+ */
+ public void setServiceType(String serviceType);
+
+ /**
+ * The type of service being offered.
+ *
+ *
+ *
+ *
+ *
+ *
+ *
service_type
+ *
+ *
+ *
Details
+ *
+ *
The type of service being offered. Web hosting, legal, gardening,
+ * etc.
+ *
+ *
+ *
Example
+ *
<g:service_type>consulting</g:service_type>
+ *
+ *
+ *
+ *
Attribute of
+ *
Housing
+ *
+ *
+ *
+ *
+ *
Content type
+ *
string
+ *
+ *
+ *
+ *
+ * @return The type of service being offered.
+ */
+ public String getServiceType();
+
+ /**
+ * Shipping options available for an item.
+ *
+ *
+ *
+ *
+ *
+ *
+ * shipping
+ *
+ *
+ *
Details
+ *
+ *
Shipping options available for an item. Up to 10 shipping options can be
+ * included for each item. Three sub-attributes are included in the shipping attribute:
+ *
+ *
+ *
service = The type of service used to ship an item. Acceptable values are 'FedEx', 'UPS',
+ * 'DHL', 'Mail', and 'Other'
+ *
country = The country an item will ship to. Only acceptable values areISO 3166
+ * country codes.
+ *
+ * @param shipping Shipping options available for an item.
+ */
+ public void setShipping(ShippingType[] shipping);
+
+ /**
+ * Shipping options available for an item.
+ *
+ *
+ *
+ *
+ *
+ *
+ * shipping
+ *
+ *
+ *
Details
+ *
+ *
Shipping options available for an item. Up to 10 shipping options can be
+ * included for each item. Three sub-attributes are included in the shipping attribute:
+ *
+ *
+ *
service = The type of service used to ship an item. Acceptable values are 'FedEx', 'UPS',
+ * 'DHL', 'Mail', and 'Other'
+ *
country = The country an item will ship to. Only acceptable values areISO 3166
+ * country codes.
+ *
+ * @return Shipping options available for an item.
+ */
+ public ShippingType[] getShipping();
+
+ /**
+ * Tax rate associated with the item.
+ *
+ *
+ *
+ *
+ *
tax_percent
+ *
+ *
+ *
+ *
+ *
+ * Details
+ *
Tax rate as a percentage.
+ *
+ *
+ *
+ *
Example
+ *
+ *
<g:tax_percent>8.2<g:/tax_percent>
+ *
+ *
+ *
+ *
+ * Attribute of
+ *
+ *
+ * Products, Events
+ *
+ *
+ *
Content type
+ *
+ *
percentType
+ *
+ *
+ *
+ *
+ *
+ * @param taxPercent Tax rate associated with the event.
+ */
+ public void setTaxPercent(Float taxPercent);
+
+ /**
+ * Tax rate associated with the service.
+ *
+ *
+ *
+ *
+ *
tax_percent
+ *
+ *
+ *
+ *
+ *
+ * Details
+ *
Tax rate as a percentage.
+ *
+ *
+ *
+ *
Example
+ *
+ *
<g:tax_percent>8.2<g:/tax_percent>
+ *
+ *
+ *
+ *
+ * Attribute of
+ *
+ *
+ * Products, Events
+ *
+ *
+ *
Content type
+ *
+ *
percentType
+ *
+ *
+ *
+ *
+ *
+ * @return Tax rate associated with the event.
+ */
+ public Float getTaxPercent();
+
+ /**
+ * Region where tax applies.
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ * tax_region
+ *
+ *
+ *
+ *
Details
+ *
Geographical region a tax rate applies to.
+ *
+ *
+ *
+ *
+ *
+ * Example
+ *
<g:tax_region>California</g:tax_region>
+ *
+ *
+ *
+ *
Attribute of
+ *
+ *
Product, Events,
+ *
+ *
+ *
+ *
Content type
+ *
string
+ *
+ *
+ *
+ *
+ *
+ * @param taxRegion Region where tax applies.
+ */
+ public void setTaxRegion(String taxRegion);
+
+ /**
+ * Region where tax applies.
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ * tax_region
+ *
+ *
+ *
+ *
Details
+ *
Geographical region a tax rate applies to.
+ *
+ *
+ *
+ *
+ *
+ * Example
+ *
<g:tax_region>California</g:tax_region>
+ *
+ *
+ *
+ *
Attribute of
+ *
+ *
Product, Events,
+ *
+ *
+ *
+ *
Content type
+ *
string
+ *
+ *
+ *
+ *
+ *
+ * @return Region where tax applies.
+ */
+ public String getTaxRegion();
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/base/Travel.java b/rome-modules/src/main/java/com/rometools/modules/base/Travel.java
new file mode 100644
index 0000000..bfd9ae9
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/base/Travel.java
@@ -0,0 +1,1352 @@
+/*
+ * Travel.java
+ *
+ * Created on November 16, 2005, 3:15 PM
+ *
+ * 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.
+ */
+package com.rometools.modules.base;
+
+import com.rometools.modules.base.types.CurrencyEnumeration;
+import com.rometools.modules.base.types.DateTimeRange;
+import com.rometools.modules.base.types.FloatUnit;
+import com.rometools.modules.base.types.PaymentTypeEnumeration;
+import com.rometools.modules.base.types.PriceTypeEnumeration;
+import com.rometools.modules.base.types.ShippingType;
+
+/**
+ * This is an interface for the GoogleBase plug in that exposes methods used for travel items.
+ *
+ * @author Robert "kebernet" Cooper
+ * @version $Revision: 1.1 $
+ */
+public interface Travel extends GlobalInterface {
+ /**
+ * Currency of the price amount for an item.
+ *
+ *
+ *
+ *
+ *
currency
+ *
+ *
+ *
+ *
Details
+ *
+ *
Currency of the price amount for an item. Values must be in ISO 4217
+ * currency code format.
+ *
+ * @param value Currency of the price amount for an item.
+ */
+ public void setCurrency(CurrencyEnumeration value);
+
+ /**
+ * Currency of the price amount for an item.
+ *
+ *
+ *
+ *
+ *
currency
+ *
+ *
+ *
+ *
Details
+ *
+ *
Currency of the price amount for an item. Values must be in ISO 4217
+ * currency code format.
+ *
+ * @return Additional instructions to explain the item’s delivery process.
+ */
+ public String getDeliveryNotes();
+
+ /**
+ * The maximum distance you will deliver an item in any direction.
+ *
+ *
+ *
+ *
delivery_radius
+ *
+ *
+ *
+ *
Details
+ *
The maximum distance you will deliver an item in any direction.
+ *
+ * @param deliveryRadius The maximum distance you will deliver an item in any direction.
+ */
+ public void setDeliveryRadius(FloatUnit deliveryRadius);
+
+ /**
+ * The maximum distance you will deliver an item in any direction.
+ *
+ *
+ *
+ *
delivery_radius
+ *
+ *
+ *
+ *
Details
+ *
The maximum distance you will deliver an item in any direction.
+ *
+ * @return The maximum distance you will deliver an item in any direction.
+ */
+ public FloatUnit getDeliveryRadius();
+
+ /**
+ * Starting city and state/country of the trip.
+ *
+ *
+ *
+ *
+ *
from_location
+ *
+ *
+ *
+ *
Details
+ *
+ *
Starting city and state/country of the trip.
+ *
+ *
+ *
Example
+ *
+ *
Acceptable:
+ * <g:from_location>San Francisco,
+ * CA</g:from_location>
+ *
+ * <g:from_location>Paris,
+ * France</g:from_location>
+ *
+ * Not acceptable:
+ * <g:from_location> San Francisco
+ * International
+ * Airport</g:from_location>
+ *
+ *
+ *
+ *
Attribute of
+ *
+ *
Travel
+ *
+ *
+ *
Content type
+ *
+ *
location
+ *
+ *
+ *
+ *
+ *
+ * @param fromLocation Starting city and state/country of the trip.
+ */
+ public void setFromLocation(String fromLocation);
+
+ /**
+ * Starting city and state/country of the trip.
+ *
+ *
+ *
+ *
+ *
from_location
+ *
+ *
+ *
+ *
Details
+ *
+ *
Starting city and state/country of the trip.
+ *
+ *
+ *
Example
+ *
+ *
Acceptable:
+ * <g:from_location>San Francisco,
+ * CA</g:from_location>
+ *
+ * <g:from_location>Paris,
+ * France</g:from_location>
+ *
+ * Not acceptable:
+ * <g:from_location> San Francisco
+ * International
+ * Airport</g:from_location>
+ *
+ *
+ *
+ *
Attribute of
+ *
+ *
Travel
+ *
+ *
+ *
Content type
+ *
+ *
location
+ *
+ *
+ *
+ *
+ *
+ * @return Starting city and state/country of the trip.
+ */
+ public String getFromLocation();
+
+ /**
+ * Acceptable payment methods for item purchases.
+ *
+ *
+ *
+ *
+ *
+ *
payment_accepted
+ *
+ *
+ *
Details
+ *
Acceptable payment methods for item purchases. Acceptable values are
+ * “Cash,” “Check,” “Traveler’s Check,” “Visa,” “MasterCard,”
+ *
+ * “American Express,” “Discover,” or “Wire transfer.” If you accept more than one method,
+ * include multiple instances of the <payment_accepted> attribute for each acceptable
+ * method.
Acceptable payment methods for item purchases. Acceptable values are
+ * “Cash,” “Check,” “Traveler’s Check,” “Visa,” “MasterCard,”
+ *
+ * “American Express,” “Discover,” or “Wire transfer.” If you accept more than one method,
+ * include multiple instances of the <payment_accepted> attribute for each acceptable
+ * method.
+ *
+ * @return Additional instructions to explain a payment policy.
+ */
+ public String getPaymentNotes();
+
+ /**
+ * Price of the item.
+ *
+ *
+ *
+ *
+ *
+ *
+ *
price
+ *
+ *
+ *
Details
+ *
Prices can be a single price, 0 (free), or blank if not applicable.
+ * Numerice values only. When used as a sub-attribute of <shipping>, the value included
+ * reflects the price of shipping.
+ *
+ * @param priceType The type of pricing for the item.
+ */
+ public void setPriceType(PriceTypeEnumeration priceType);
+
+ /**
+ * The type of pricing for the item.
+ *
+ *
+ *
+ *
+ *
price_type
+ *
+ *
+ *
+ *
+ *
Details
+ *
The type of pricing for the item. Acceptable values are “negotiable,” or
+ * “starting.” The default is “starting”
The number of units available for purchase. This attribute can be left
+ * blank if you have a large quantity or if it is not applicable.
+ *
+ *
+ *
+ *
+ *
Example
+ *
Acceptable:
+ * <g:quantity>18</g:quantity>
+ *
+ * <g:quantity>0</g:quantity>
+ *
+ * Not acceptable:
+ * <g:quantity>out of stock</g:quantity>
+ *
+ *
+ *
+ *
+ * Attribute of
+ *
+ *
Events, Products, Services, Travel, Vehicles
+ *
+ *
+ *
Content type
+ *
+ *
+ *
+ * integer
+ *
+ *
+ *
+ *
+ * @return Quantity available.
+ */
+ public Integer getQuantity();
+
+ /**
+ * Tax rate associated with the event.
+ *
+ *
+ *
+ *
+ *
tax_percent
+ *
+ *
+ *
+ *
+ *
+ * Details
+ *
Tax rate as a percentage.
+ *
+ *
+ *
+ *
Example
+ *
+ *
<g:tax_percent>8.2<g:/tax_percent>
+ *
+ *
+ *
+ *
+ * Attribute of
+ *
+ *
+ * Products, Events
+ *
+ *
+ *
Content type
+ *
+ *
percentType
+ *
+ *
+ *
+ *
+ *
+ * @param taxPercent Tax rate associated with the event.
+ */
+ public void setTaxPercent(Float taxPercent);
+
+ /**
+ * Tax rate associated with the service.
+ *
+ *
+ *
+ *
+ *
tax_percent
+ *
+ *
+ *
+ *
+ *
+ * Details
+ *
Tax rate as a percentage.
+ *
+ *
+ *
+ *
Example
+ *
+ *
<g:tax_percent>8.2<g:/tax_percent>
+ *
+ *
+ *
+ *
+ * Attribute of
+ *
+ *
+ * Products, Events
+ *
+ *
+ *
Content type
+ *
+ *
percentType
+ *
+ *
+ *
+ *
+ *
+ * @return Tax rate associated with the event.
+ */
+ public Float getTaxPercent();
+
+ /**
+ * Region where tax applies.
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ * tax_region
+ *
+ *
+ *
+ *
Details
+ *
Geographical region a tax rate applies to.
+ *
+ *
+ *
+ *
+ *
+ * Example
+ *
<g:tax_region>California</g:tax_region>
+ *
+ *
+ *
+ *
Attribute of
+ *
+ *
Product, Events,
+ *
+ *
+ *
+ *
Content type
+ *
string
+ *
+ *
+ *
+ *
+ *
+ * @param taxRegion Region where tax applies.
+ */
+ public void setTaxRegion(String taxRegion);
+
+ /**
+ * Region where tax applies.
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ * tax_region
+ *
+ *
+ *
+ *
Details
+ *
Geographical region a tax rate applies to.
+ *
+ *
+ *
+ *
+ *
+ * Example
+ *
<g:tax_region>California</g:tax_region>
+ *
+ *
+ *
+ *
Attribute of
+ *
+ *
Product, Events,
+ *
+ *
+ *
+ *
Content type
+ *
string
+ *
+ *
+ *
+ *
+ *
+ * @return Region where tax applies.
+ */
+ public String getTaxRegion();
+
+ /**
+ * Destination city and state/country of the trip.
+ *
+ *
+ *
+ *
+ *
+ *
to_location
+ *
+ *
+ *
+ *
+ *
+ * Details
+ *
Destination city and state/country of the trip.
+ *
+ *
+ *
+ *
+ * Example
+ *
+ *
Acceptable:
+ * <g:to_location>San Francisco,
+ * CA</g:to_location>
+ * <g:to_location>Paris,
+ * France</g:to_location>
+ *
+ * Not acceptable:
+ * <g:to_location>San Francisco
+ * International
+ * Airport</g:to_location>
+ *
+ *
+ *
+ *
+ * Attribute of
+ *
Travel
+ *
+ *
+ *
Content type
+ *
+ *
locationyTpe
+ *
+ *
+ *
+ *
+ * @param toLocation Destination city and state/country of the trip.
+ */
+ public void setToLocation(String toLocation);
+
+ /**
+ * Destination city and state/country of the trip.
+ *
+ *
+ *
+ *
+ *
+ *
to_location
+ *
+ *
+ *
+ *
+ *
+ * Details
+ *
Destination city and state/country of the trip.
+ *
+ *
+ *
+ *
+ * Example
+ *
+ *
Acceptable:
+ * <g:to_location>San Francisco,
+ * CA</g:to_location>
+ * <g:to_location>Paris,
+ * France</g:to_location>
+ *
+ * Not acceptable:
+ * <g:to_location>San Francisco
+ * International
+ * Airport</g:to_location>
+ *
+ *
+ *
+ *
+ * Attribute of
+ *
Travel
+ *
+ *
+ *
Content type
+ *
+ *
locationyTpe
+ *
+ *
+ *
+ *
+ * @return Destination city and state/country of the trip.
+ */
+ public String getToLocation();
+
+ /**
+ * Departure date and time of the trip.
+ *
+ *
+ *
+ *
+ *
travel_date_range
+ *
+ *
+ *
+ *
Details
+ *
Departure date and time of the trip in ISO 8601
+ * format: YYYY-MM-DD,hh:mmAM (12 hour clock) or YYYY-MM-DD,hh:mm (24 hour clock). Two
+ * sub-attributes are included in travel_date_range attribute.
+ *
+ *
+ *
start = Start date and time of a trip in format YYYY-MM-DDThh:mm:ss
+ *
end = End date and time of a trip in format YYYY-MM-DDThh:mm:ss
+ *
+ * @param travelDateRange Departure date and time of the trip.
+ */
+ public void setTravelDateRange(DateTimeRange travelDateRange);
+
+ /**
+ * Departure date and time of the trip.
+ *
+ *
+ *
+ *
+ *
travel_date_range
+ *
+ *
+ *
+ *
Details
+ *
Departure date and time of the trip in ISO 8601
+ * format: YYYY-MM-DD,hh:mmAM (12 hour clock) or YYYY-MM-DD,hh:mm (24 hour clock). Two
+ * sub-attributes are included in travel_date_range attribute.
+ *
+ *
+ *
start = Start date and time of a trip in format YYYY-MM-DDThh:mm:ss
+ *
end = End date and time of a trip in format YYYY-MM-DDThh:mm:ss
+ *
+ * @return Departure date and time of the trip.
+ */
+ public DateTimeRange getTravelDateRange();
+
+ /**
+ * Location of the property.
+ *
+ *
+ *
+ *
+ *
location
+ *
+ *
+ *
+ *
Details
+ *
Location of a property. Should include street, city, state, postal code,
+ * and country, in that order.
+ *
+ *
+ *
+ *
Example
+ *
+ *
Acceptable:
+ * <g:location>123 Main St, Anytown,
+ * CA, 12345,
+ * USA</g:location>
+ *
+ * Not acceptable:
+ * <g:location>123 Main St,, CA,
+ * 12345,
+ * USA</g:location>
+ * <g:location> Anytown, CA,
+ * 12345,
+ * USA</g:location>
+ *
+ *
+ *
+ *
Attribute of
+ *
Reference Items, Events, Housing, Jobs, News and Articles, People
+ * profiles, Products, Reviews, Services, Travel, Vehicles, Wanted Ads.
+ *
+ *
+ *
+ *
+ *
Content type
+ *
locationType
+ *
+ *
+ *
+ *
+ * @param location Location of the property.
+ */
+ public void setLocation(String location);
+
+ /**
+ * Location of the property.
+ *
+ *
+ *
+ *
+ *
location
+ *
+ *
+ *
+ *
Details
+ *
Location of a property. Should include street, city, state, postal code,
+ * and country, in that order.
+ *
+ *
+ *
+ *
Example
+ *
+ *
Acceptable:
+ * <g:location>123 Main St, Anytown,
+ * CA, 12345,
+ * USA</g:location>
+ *
+ * Not acceptable:
+ * <g:location>123 Main St,, CA,
+ * 12345,
+ * USA</g:location>
+ * <g:location> Anytown, CA,
+ * 12345,
+ * USA</g:location>
+ *
+ *
+ *
+ *
Attribute of
+ *
Reference Items, Events, Housing, Jobs, News and Articles, People
+ * profiles, Products, Reviews, Services, Travel, Vehicles, Wanted Ads.
+ *
+ *
+ *
+ *
+ *
Content type
+ *
locationType
+ *
+ *
+ *
+ *
+ * @return Location of the property.
+ */
+ public String getLocation();
+
+ /**
+ * Shipping options available for an item.
+ *
+ *
+ *
+ *
+ *
+ *
+ * shipping
+ *
+ *
+ *
Details
+ *
+ *
Shipping options available for an item. Up to 10 shipping options can be
+ * included for each item. Three sub-attributes are included in the shipping attribute:
+ *
+ *
+ *
service = The type of service used to ship an item. Acceptable values are 'FedEx', 'UPS',
+ * 'DHL', 'Mail', and 'Other'
+ *
country = The country an item will ship to. Only acceptable values areISO 3166
+ * country codes.
+ *
+ * @return Shipping options available for an item.
+ */
+ public ShippingType[] getShipping();
+
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/base/Unknown.java b/rome-modules/src/main/java/com/rometools/modules/base/Unknown.java
new file mode 100644
index 0000000..1e231a6
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/base/Unknown.java
@@ -0,0 +1,76 @@
+/*
+ * Unknown.java
+ *
+ * Created on November 18, 2005, 1:34 PM
+ *
+ * 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.
+ */
+package com.rometools.modules.base;
+
+import java.net.URL;
+
+import com.rometools.modules.base.types.IntUnit;
+
+/**
+ * This interface contains all the other schema elements that the document doesn't associate with a
+ * particular type.
+ *
+ * @author Robert "kebernet" Cooper
+ */
+public interface Unknown extends GlobalInterface {
+ public void setLicenses(String[] licenses);
+
+ public String[] getLicenses();
+
+ public void setOperatingSystems(String systems);
+
+ public String getOperatingSystems();
+
+ public void setProgrammingLanguages(String[] languages);
+
+ public String[] getProgrammingLanguages();
+
+ public void setRelatedLinks(URL[] links);
+
+ public URL[] getRelatedLinks();
+
+ public void setSquareFootages(IntUnit[] squareFootages);
+
+ public IntUnit[] getSquareFootages();
+
+ public void setSubjectAreas(String[] subjectAreas);
+
+ public String[] getSubjectAreas();
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/base/ValidationException.java b/rome-modules/src/main/java/com/rometools/modules/base/ValidationException.java
new file mode 100644
index 0000000..f7ec67b
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/base/ValidationException.java
@@ -0,0 +1,62 @@
+/*
+ * ValidationException.java
+ *
+ * Created on November 20, 2005, 3:14 PM
+ *
+ * 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.
+ */
+
+package com.rometools.modules.base;
+
+/**
+ * This is an unchecked exception that is thrown when a data value violates the Google Schema
+ * limits.
+ *
+ * @version $Revision: 1.1 $
+ * @author Robert "kebernet" Cooper
+ */
+public class ValidationException extends RuntimeException {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+ /** Creates a new instance of ValidationException */
+ public ValidationException(final String message) {
+ super(message);
+ }
+
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/base/Vehicle.java b/rome-modules/src/main/java/com/rometools/modules/base/Vehicle.java
new file mode 100644
index 0000000..3cb3286
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/base/Vehicle.java
@@ -0,0 +1,1827 @@
+/*
+ * Vehicle.java
+ *
+ * Created on November 16, 2005, 3:26 PM
+ *
+ * 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.
+ */
+package com.rometools.modules.base;
+
+import com.rometools.modules.base.types.CurrencyEnumeration;
+import com.rometools.modules.base.types.FloatUnit;
+import com.rometools.modules.base.types.PaymentTypeEnumeration;
+import com.rometools.modules.base.types.PriceTypeEnumeration;
+import com.rometools.modules.base.types.ShippingType;
+import com.rometools.modules.base.types.YearType;
+
+/**
+ * This is an interface for the GoogleBase plug in that exposes methods used for vehicles.
+ *
+ * @author Robert "kebernet" Cooper
+ * @version $Revision: 1.1 $
+ */
+public interface Vehicle extends GlobalInterface {
+ /**
+ * Color of an item.
+ *
+ *
+ *
+ *
+ *
+ *
color
+ *
+ *
+ *
+ *
Details
+ *
+ *
Color of an item.
+ *
+ *
+ *
+ *
Example
+ *
<g:color>Black</g:color>
+ *
+ *
+ *
+ *
+ *
+ * Attribute of
+ *
Products, Vehicles
+ *
+ *
+ *
+ *
Content type
+ *
+ *
string
+ *
+ *
+ *
+ *
+ * @param color Color of an item.
+ */
+ public void setColors(String[] color);
+
+ /**
+ * Color of an item.
+ *
+ *
+ *
+ *
+ *
+ *
color
+ *
+ *
+ *
+ *
Details
+ *
+ *
Color of an item.
+ *
+ *
+ *
+ *
Example
+ *
<g:color>Black</g:color>
+ *
+ *
+ *
+ *
+ *
+ * Attribute of
+ *
Products, Vehicles
+ *
+ *
+ *
+ *
Content type
+ *
+ *
string
+ *
+ *
+ *
+ *
+ * @return Color of an item.
+ */
+ public String[] getColors();
+
+ /**
+ * Condition of the item. For example: new, used, or refurbished.
+ *
+ *
+ *
+ *
+ *
condition
+ *
+ *
+ *
+ *
Details
+ *
Condition of the item. For example: new, used, or refurbished.
+ *
+ *
+ *
+ *
Example
+ *
+ *
+ * <g:condition>refurbished</g:condition>
+ *
+ *
+ *
Attribute of
+ *
+ *
Products, Vehicles
+ *
+ *
+ *
+ *
Content type
+ *
string
+ *
+ *
+ *
+ *
+ *
+ * @param condition Condition of the item. For example: new, used, or refurbished.
+ */
+ public void setCondition(String condition);
+
+ /**
+ * Condition of the item. For example: new, used, or refurbished.
+ *
+ *
+ *
+ *
+ *
condition
+ *
+ *
+ *
+ *
Details
+ *
Condition of the item. For example: new, used, or refurbished.
+ *
+ *
+ *
+ *
Example
+ *
+ *
+ * <g:condition>refurbished</g:condition>
+ *
+ *
+ *
Attribute of
+ *
+ *
Products, Vehicles
+ *
+ *
+ *
+ *
Content type
+ *
string
+ *
+ *
+ *
+ *
+ *
+ * @return Condition of the item. For example: new, used, or refurbished.
+ */
+ public String getCondition();
+
+ /**
+ * Currency of the price amount for an item.
+ *
+ *
+ *
+ *
+ *
currency
+ *
+ *
+ *
+ *
Details
+ *
+ *
Currency of the price amount for an item. Values must be in ISO 4217
+ * currency code format.
+ *
+ * @param value Currency of the price amount for an item.
+ */
+ public void setCurrency(CurrencyEnumeration value);
+
+ /**
+ * Currency of the price amount for an item.
+ *
+ *
+ *
+ *
+ *
currency
+ *
+ *
+ *
+ *
Details
+ *
+ *
Currency of the price amount for an item. Values must be in ISO 4217
+ * currency code format.
+ *
+ * @return Additional instructions to explain the item’s delivery process.
+ */
+ public String getDeliveryNotes();
+
+ /**
+ * The maximum distance you will deliver an item in any direction.
+ *
+ *
+ *
+ *
delivery_radius
+ *
+ *
+ *
+ *
Details
+ *
The maximum distance you will deliver an item in any direction.
+ *
+ * @param deliveryRadius The maximum distance you will deliver an item in any direction.
+ */
+ public void setDeliveryRadius(FloatUnit deliveryRadius);
+
+ /**
+ * The maximum distance you will deliver an item in any direction.
+ *
+ *
+ *
+ *
delivery_radius
+ *
+ *
+ *
+ *
Details
+ *
The maximum distance you will deliver an item in any direction.
+ *
+ * @return The maximum distance you will deliver an item in any direction.
+ */
+ public FloatUnit getDeliveryRadius();
+
+ /**
+ * Location of a property. Should include street, city, state, postal code, and country, in that
+ * order.
+ *
+ *
+ *
+ *
+ *
location
+ *
+ *
+ *
+ *
Details
+ *
Location of a property. Should include street, city, state, postal code,
+ * and country, in that order.
+ *
+ *
+ *
+ *
Example
+ *
+ *
Acceptable:
+ * <g:location>123 Main St, Anytown,
+ * CA, 12345,
+ * USA</g:location>
+ *
+ * Not acceptable:
+ * <g:location>123 Main St,, CA,
+ * 12345,
+ * USA</g:location>
+ * <g:location> Anytown, CA,
+ * 12345,
+ * USA</g:location>
+ *
+ *
+ *
+ *
Attribute of
+ *
Reference Items, Events, Housing, Jobs, News and Articles, People
+ * profiles, Products, Reviews, Services, Travel, Vehicles, Wanted Ads.
+ *
+ *
+ *
+ *
+ *
Content type
+ *
locationType
+ *
+ *
+ *
+ *
+ * @param location Location of a property. Should include street, city, state, postal code, and
+ * country, in that order.
+ */
+ public void setLocation(String location);
+
+ /**
+ * Location of a property. Should include street, city, state, postal code, and country, in that
+ * order.
+ *
+ *
+ *
+ *
+ *
location
+ *
+ *
+ *
+ *
Details
+ *
Location of a property. Should include street, city, state, postal code,
+ * and country, in that order.
+ *
+ *
+ *
+ *
Example
+ *
+ *
Acceptable:
+ * <g:location>123 Main St, Anytown,
+ * CA, 12345,
+ * USA</g:location>
+ *
+ * Not acceptable:
+ * <g:location>123 Main St,, CA,
+ * 12345,
+ * USA</g:location>
+ * <g:location> Anytown, CA,
+ * 12345,
+ * USA</g:location>
+ *
+ *
+ *
+ *
Attribute of
+ *
Reference Items, Events, Housing, Jobs, News and Articles, People
+ * profiles, Products, Reviews, Services, Travel, Vehicles, Wanted Ads.
+ *
+ *
+ *
+ *
+ *
Content type
+ *
locationType
+ *
+ *
+ *
+ *
+ * @return Location of a property. Should include street, city, state, postal code, and country,
+ * in that order.
+ */
+ public String getLocation();
+
+ /**
+ * The vehicle manufacturer.
+ *
+ *
+ *
+ *
+ *
+ *
make
+ *
+ *
+ *
+ *
+ * Details
+ *
+ *
+ * The vehicle manufacturer.
+ *
+ *
+ *
Example
+ *
+ *
<g:make>Honda</g:make>
+ *
+ *
+ *
+ *
Attribute of
+ *
+ *
+ * Vehicles
+ *
+ *
+ *
+ *
Content type
+ *
string
+ *
+ *
+ *
+ *
+ *
+ * @param make The vehicle manufacturer.
+ */
+ public void setMake(String make);
+
+ /**
+ * The vehicle manufacturer.
+ *
+ *
+ *
+ *
+ *
+ *
make
+ *
+ *
+ *
+ *
+ * Details
+ *
+ *
+ * The vehicle manufacturer.
+ *
+ *
+ *
Example
+ *
+ *
<g:make>Honda</g:make>
+ *
+ *
+ *
+ *
Attribute of
+ *
+ *
+ * Vehicles
+ *
+ *
+ *
+ *
Content type
+ *
string
+ *
+ *
+ *
+ *
+ *
+ * @return The vehicle manufacturer.
+ */
+ public String getMake();
+
+ /**
+ * Current mileage of the vehicle.
+ *
+ *
+ *
+ * @param mileage Current mileage of the vehicle.
+ */
+ public void setMileage(Integer mileage);
+
+ /**
+ * Current mileage of the vehicle.
+ *
+ *
+ *
+ * @return Current mileage of the vehicle.
+ */
+ public Integer getMileage();
+
+ /**
+ * The vehicle model.
+ *
+ *
+ *
+ *
model
+ *
+ *
+ *
+ *
Details
+ *
+ *
The vehicle model.
+ *
+ *
+ *
Example
+ *
+ *
<g:model>Camry</g:model>
+ *
+ *
+ *
+ *
Attribute of
+ *
Vehicles
+ *
+ *
+ *
+ *
+ *
Content type
+ *
string
+ *
+ *
+ *
+ *
+ * @param model The vehicle model.
+ */
+ public void setModel(String model);
+
+ /**
+ * The vehicle model.
+ *
+ *
+ *
+ *
model
+ *
+ *
+ *
+ *
Details
+ *
+ *
The vehicle model.
+ *
+ *
+ *
Example
+ *
+ *
<g:model>Camry</g:model>
+ *
+ *
+ *
+ *
Attribute of
+ *
Vehicles
+ *
+ *
+ *
+ *
+ *
Content type
+ *
string
+ *
+ *
+ *
+ *
+ * @return The vehicle model.
+ */
+ public String getModel();
+
+ /**
+ * Payment Methods acceptable for the service.
+ *
+ *
+ *
+ *
+ *
+ *
payment_accepted
+ *
+ *
+ *
Details
+ *
Acceptable payment methods for item purchases. Acceptable values are
+ * "Cash," "Check," "Traveler’s Check," "Visa," "MasterCard,"
+ *
+ * "American Express," "Discover," "Wire transfer" or "Paypal." If you accept more than one
+ * method, include multiple instances of the <payment_accepted> attribute for each
+ * acceptable method.
+ *
+ * @param paymentAccepted Payment Methods acceptable for the service.
+ */
+ public void setPaymentAccepted(PaymentTypeEnumeration[] paymentAccepted);
+
+ /**
+ * Payment Methods acceptable for the service.
+ *
+ *
+ *
+ *
+ *
+ *
payment_accepted
+ *
+ *
+ *
Details
+ *
Acceptable payment methods for item purchases. Acceptable values are
+ * "Cash," "Check," "Traveler’s Check," "Visa," "MasterCard,"
+ *
+ * "American Express," "Discover," "Wire transfer" or "Paypal." If you accept more than one
+ * method, include multiple instances of the <payment_accepted> attribute for each
+ * acceptable method.
+ *
+ * @return Additional payment information.
+ */
+ public String getPaymentNotes();
+
+ /**
+ * Price for the service.
+ *
+ *
+ *
+ *
+ *
+ *
+ *
price
+ *
+ *
+ *
Details
+ *
Prices can be a single price, 0 (free), or blank if not applicable.
+ * Numerice values only. When used as a sub-attribute of <shipping>, the value included
+ * reflects the price of shipping.
+ *
+ * @param price Price for the service.
+ */
+ public void setPrice(FloatUnit price);
+
+ /**
+ * Price for the service.
+ *
+ *
+ *
+ *
+ *
+ *
+ *
price
+ *
+ *
+ *
Details
+ *
Prices can be a single price, 0 (free), or blank if not applicable.
+ * Numerice values only. When used as a sub-attribute of <shipping>, the value included
+ * reflects the price of shipping.
The number of units available for purchase. This attribute can be left
+ * blank if you have a large quantity or if it is not applicable.
+ *
+ *
+ *
+ *
+ *
Example
+ *
Acceptable:
+ * <g:quantity>18</g:quantity>
+ *
+ * <g:quantity>0</g:quantity>
+ *
+ * Not acceptable:
+ * <g:quantity>out of stock</g:quantity>
+ *
+ *
+ *
+ *
+ * Attribute of
+ *
+ *
Events, Products, Services, Travel, Vehicles
+ *
+ *
+ *
Content type
+ *
+ *
+ *
+ * integer
+ *
+ *
+ *
+ *
+ * @return Quantity available.
+ */
+ public Integer getQuantity();
+
+ /**
+ * Shipping options available for an item.
+ *
+ *
+ *
+ *
+ *
+ *
+ * shipping
+ *
+ *
+ *
Details
+ *
+ *
Shipping options available for an item. Up to 10 shipping options can be
+ * included for each item. Three sub-attributes are included in the shipping attribute:
+ *
+ *
+ *
service = The type of service used to ship an item. Acceptable values are 'FedEx', 'UPS',
+ * 'DHL', 'Mail', and 'Other'
+ *
country = The country an item will ship to. Only acceptable values areISO 3166
+ * country codes.
+ *
+ * @param shipping Shipping options available for an item.
+ */
+ public void setShipping(ShippingType[] shipping);
+
+ /**
+ * Shipping options available for an item.
+ *
+ *
+ *
+ *
+ *
+ *
+ * shipping
+ *
+ *
+ *
Details
+ *
+ *
Shipping options available for an item. Up to 10 shipping options can be
+ * included for each item. Three sub-attributes are included in the shipping attribute:
+ *
+ *
+ *
service = The type of service used to ship an item. Acceptable values are 'FedEx', 'UPS',
+ * 'DHL', 'Mail', and 'Other'
+ *
country = The country an item will ship to. Only acceptable values areISO 3166
+ * country codes.
+ *
+ * @return Shipping options available for an item.
+ */
+ public ShippingType[] getShipping();
+
+ /**
+ * Tax rate associated with the item.
+ *
+ *
+ *
+ *
+ *
tax_percent
+ *
+ *
+ *
+ *
+ *
+ * Details
+ *
Tax rate as a percentage.
+ *
+ *
+ *
+ *
Example
+ *
+ *
<g:tax_percent>8.2<g:/tax_percent>
+ *
+ *
+ *
+ *
+ * Attribute of
+ *
+ *
+ * Products, Events
+ *
+ *
+ *
Content type
+ *
+ *
percentType
+ *
+ *
+ *
+ *
+ *
+ * @param taxPercent Tax rate associated with the event.
+ */
+ public void setTaxPercent(Float taxPercent);
+
+ /**
+ * Tax rate associated with the item.
+ *
+ *
+ *
+ *
+ *
tax_percent
+ *
+ *
+ *
+ *
+ *
+ * Details
+ *
Tax rate as a percentage.
+ *
+ *
+ *
+ *
Example
+ *
+ *
<g:tax_percent>8.2<g:/tax_percent>
+ *
+ *
+ *
+ *
+ * Attribute of
+ *
+ *
+ * Products, Events
+ *
+ *
+ *
Content type
+ *
+ *
percentType
+ *
+ *
+ *
+ *
+ *
+ * @return Tax rate associated with the event.
+ */
+ public Float getTaxPercent();
+
+ /**
+ * Region where tax applies.
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ * tax_region
+ *
+ *
+ *
+ *
Details
+ *
Geographical region a tax rate applies to.
+ *
+ *
+ *
+ *
+ *
+ * Example
+ *
<g:tax_region>California</g:tax_region>
+ *
+ *
+ *
+ *
Attribute of
+ *
+ *
Product, Events,
+ *
+ *
+ *
+ *
Content type
+ *
string
+ *
+ *
+ *
+ *
+ *
+ * @param taxRegion Region where tax applies.
+ */
+ public void setTaxRegion(String taxRegion);
+
+ /**
+ * Region where tax applies.
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ * tax_region
+ *
+ *
+ *
+ *
Details
+ *
Geographical region a tax rate applies to.
+ *
+ *
+ *
+ *
+ *
+ * Example
+ *
<g:tax_region>California</g:tax_region>
+ *
+ *
+ *
+ *
Attribute of
+ *
+ *
Product, Events,
+ *
+ *
+ *
+ *
Content type
+ *
string
+ *
+ *
+ *
+ *
+ *
+ * @return Region where tax applies.
+ */
+ public String getTaxRegion();
+
+ /**
+ * The type of vehicle: Car, motorcycle, scooter, etc.
+ *
+ *
+ *
+ *
+ *
+ *
+ * vehicle_type
+ *
+ *
+ *
+ *
Details
+ *
The type of vehicle: Car, motorcycle, scooter, etc.
+ *
+ *
+ *
+ *
+ *
+ * Example
+ *
<g:vehicle_type>truck</g:vehicle_type>
+ *
+ *
+ *
+ *
Attribute of
+ *
+ *
Products
+ *
+ *
+ *
+ *
+ * Content type
+ *
+ *
+ * string
+ *
+ *
+ *
+ *
+ * @param vehicleType The type of vehicle: Car, motorcycle, scooter, etc.
+ */
+ public void setVehicleType(String vehicleType);
+
+ /**
+ * The type of vehicle: Car, motorcycle, scooter, etc.
+ *
+ *
+ *
+ *
+ *
+ *
+ * vehicle_type
+ *
+ *
+ *
+ *
Details
+ *
The type of vehicle: Car, motorcycle, scooter, etc.
+ *
+ *
+ *
+ *
+ *
+ * Example
+ *
<g:vehicle_type>truck</g:vehicle_type>
+ *
+ *
+ *
+ *
Attribute of
+ *
+ *
Products
+ *
+ *
+ *
+ *
+ * Content type
+ *
+ *
+ * string
+ *
+ *
+ *
+ *
+ * @return The type of vehicle: Car, motorcycle, scooter, etc.
+ */
+ public String getVehicleType();
+
+ /**
+ * Vehicle Identification Number.
+ *
+ *
+ *
+ * @param year The four digit model year or year built.
+ */
+ public void setYear(YearType year);
+
+ /**
+ * The four digit model year or year built.
+ *
+ *
+ *
+ *
+ *
+ *
+ *
year
+ *
+ *
+ *
+ *
Details
+ *
+ *
The four digit model year or year built. Format YYYY
+ *
+ * @return The four digit model year or year built.
+ */
+ public YearType getYear();
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/base/Wanted.java b/rome-modules/src/main/java/com/rometools/modules/base/Wanted.java
new file mode 100644
index 0000000..7b7bdeb
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/base/Wanted.java
@@ -0,0 +1,309 @@
+/*
+ * Wanted.java
+ *
+ * Created on November 16, 2005, 3:32 PM
+ *
+ * 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.
+ */
+package com.rometools.modules.base;
+
+import com.rometools.modules.base.types.FloatUnit;
+
+/**
+ * This is an interface for the GoogleBase plug in that exposes methods used for wanted ads.
+ *
+ * @author Robert "kebernet" Cooper
+ * @version $Revision: 1.1 $
+ */
+public interface Wanted extends GlobalInterface {
+ /**
+ * Additional instructions to explain the item’s delivery process.
+ *
+ *
+ *
+ *
+ *
delivery_notes
+ *
+ *
+ *
Details
+ *
+ *
Additional instructions to explain the item’s delivery process.
+ *
+ *
+ *
Example
+ *
+ * <g:delivery_notes>Items usually shipped within 24
+ * hours.<g:/delivery_notes>
+ *
+ *
+ *
+ * @return Additional instructions to explain the item’s delivery process.
+ */
+ public String getDeliveryNotes();
+
+ /**
+ * The maximum distance you will deliver an item in any direction.
+ *
+ *
+ *
+ *
delivery_radius
+ *
+ *
+ *
+ *
Details
+ *
The maximum distance you will deliver an item in any direction.
+ *
+ * @param deliveryRadius The maximum distance you will deliver an item in any direction.
+ */
+ public void setDeliveryRadius(FloatUnit deliveryRadius);
+
+ /**
+ * The maximum distance you will deliver an item in any direction.
+ *
+ *
+ *
+ *
delivery_radius
+ *
+ *
+ *
+ *
Details
+ *
The maximum distance you will deliver an item in any direction.
+ *
+ * @return The maximum distance you will deliver an item in any direction.
+ */
+ public FloatUnit getDeliveryRadius();
+
+ /**
+ * Location of the property.
+ *
+ *
+ *
+ *
+ *
location
+ *
+ *
+ *
+ *
Details
+ *
Location of a property. Should include street, city, state, postal code,
+ * and country, in that order.
+ *
+ *
+ *
+ *
Example
+ *
+ *
Acceptable:
+ * <g:location>123 Main St, Anytown,
+ * CA, 12345,
+ * USA</g:location>
+ *
+ * Not acceptable:
+ * <g:location>123 Main St,, CA,
+ * 12345,
+ * USA</g:location>
+ * <g:location> Anytown, CA,
+ * 12345,
+ * USA</g:location>
+ *
+ *
+ *
+ *
Attribute of
+ *
Reference Items, Events, Housing, Jobs, News and Articles, People
+ * profiles, Products, Reviews, Services, Travel, Vehicles, Wanted Ads.
+ *
+ *
+ *
+ *
+ *
Content type
+ *
locationType
+ *
+ *
+ *
+ *
+ * @param location Location of the property.
+ */
+ public void setLocation(String location);
+
+ /**
+ * Location of the property.
+ *
+ *
+ *
+ *
+ *
location
+ *
+ *
+ *
+ *
Details
+ *
Location of a property. Should include street, city, state, postal code,
+ * and country, in that order.
+ *
+ *
+ *
+ *
Example
+ *
+ *
Acceptable:
+ * <g:location>123 Main St, Anytown,
+ * CA, 12345,
+ * USA</g:location>
+ *
+ * Not acceptable:
+ * <g:location>123 Main St,, CA,
+ * 12345,
+ * USA</g:location>
+ * <g:location> Anytown, CA,
+ * 12345,
+ * USA</g:location>
+ *
+ *
+ *
+ *
Attribute of
+ *
Reference Items, Events, Housing, Jobs, News and Articles, People
+ * profiles, Products, Reviews, Services, Travel, Vehicles, Wanted Ads.
+ *
+ *
+ *
+ *
+ *
Content type
+ *
locationType
+ *
+ *
+ *
+ *
+ * @return Location of the property.
+ */
+ public String getLocation();
+
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/base/io/CustomTagGenerator.java b/rome-modules/src/main/java/com/rometools/modules/base/io/CustomTagGenerator.java
new file mode 100644
index 0000000..bc2474a
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/base/io/CustomTagGenerator.java
@@ -0,0 +1,157 @@
+/*
+ * CustomTagGenerator.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) 2006 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 com.rometools.modules.base.io;
+
+import java.net.URL;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import org.jdom2.Element;
+import org.jdom2.Namespace;
+
+import com.rometools.modules.base.CustomTag;
+import com.rometools.modules.base.CustomTagImpl;
+import com.rometools.modules.base.CustomTags;
+import com.rometools.modules.base.types.DateTimeRange;
+import com.rometools.modules.base.types.FloatUnit;
+import com.rometools.modules.base.types.IntUnit;
+import com.rometools.modules.base.types.ShortDate;
+import com.rometools.rome.feed.module.Module;
+import com.rometools.rome.io.ModuleGenerator;
+
+/**
+ * @version $Revision: 1.1 $
+ * @author Robert "kebernet" Cooper
+ */
+public class CustomTagGenerator implements ModuleGenerator {
+
+ static final HashSet NAMESPACES = new HashSet();
+
+ static {
+ NAMESPACES.add(CustomTagParser.NS);
+ }
+
+ /** Creates a new instance of CustomTagGenerator */
+ public CustomTagGenerator() {
+ }
+
+ @Override
+ public String getNamespaceUri() {
+ return CustomTags.URI;
+ }
+
+ @Override
+ public Set getNamespaces() {
+ return NAMESPACES;
+ }
+
+ @Override
+ public void generate(final Module module, final Element element) {
+ if (!(module instanceof CustomTags)) {
+ return;
+ }
+
+ final List tags = ((CustomTags) module).getValues();
+ final Iterator it = tags.iterator();
+
+ while (it.hasNext()) {
+ final CustomTag tag = it.next();
+
+ if (tag.getValue() instanceof DateTimeRange) {
+ final DateTimeRange dtr = (DateTimeRange) tag.getValue();
+ final Element newTag = new Element(tag.getName(), CustomTagParser.NS);
+ newTag.setAttribute("type", "dateTimeRange");
+ newTag.addContent(generateSimpleElement("start", GoogleBaseParser.LONG_DT_FMT.format(dtr.getStart())));
+ newTag.addContent(generateSimpleElement("end", GoogleBaseParser.LONG_DT_FMT.format(dtr.getEnd())));
+ element.addContent(newTag);
+ } else if (tag.getValue() instanceof ShortDate) {
+ final ShortDate sd = (ShortDate) tag.getValue();
+ final Element newTag = generateSimpleElement(tag.getName(), GoogleBaseParser.SHORT_DT_FMT.format(sd));
+ newTag.setAttribute("type", "date");
+ element.addContent(newTag);
+ } else if (tag.getValue() instanceof Date) {
+ final Date d = (Date) tag.getValue();
+ final Element newTag = generateSimpleElement(tag.getName(), GoogleBaseParser.SHORT_DT_FMT.format(d));
+ newTag.setAttribute("type", "dateTime");
+ element.addContent(newTag);
+ } else if (tag.getValue() instanceof Integer) {
+ final Element newTag = generateSimpleElement(tag.getName(), tag.getValue().toString());
+ newTag.setAttribute("type", "int");
+ element.addContent(newTag);
+ } else if (tag.getValue() instanceof IntUnit) {
+ final Element newTag = generateSimpleElement(tag.getName(), tag.getValue().toString());
+ newTag.setAttribute("type", "intUnit");
+ element.addContent(newTag);
+ } else if (tag.getValue() instanceof Float) {
+ final Element newTag = generateSimpleElement(tag.getName(), tag.getValue().toString());
+ newTag.setAttribute("type", "float");
+ element.addContent(newTag);
+ } else if (tag.getValue() instanceof FloatUnit) {
+ final Element newTag = generateSimpleElement(tag.getName(), tag.getValue().toString());
+ newTag.setAttribute("type", "floatUnit");
+ element.addContent(newTag);
+ } else if (tag.getValue() instanceof String) {
+ final Element newTag = generateSimpleElement(tag.getName(), tag.getValue().toString());
+ newTag.setAttribute("type", "string");
+ element.addContent(newTag);
+ } else if (tag.getValue() instanceof URL) {
+ final Element newTag = generateSimpleElement(tag.getName(), tag.getValue().toString());
+ newTag.setAttribute("type", "url");
+ element.addContent(newTag);
+ } else if (tag.getValue() instanceof Boolean) {
+ final Element newTag = generateSimpleElement(tag.getName(), tag.getValue().toString());
+ newTag.setAttribute("type", "boolean");
+ element.addContent(newTag);
+ } else if (tag.getValue() instanceof CustomTagImpl.Location) {
+ final Element newTag = generateSimpleElement(tag.getName(), tag.getValue().toString());
+ newTag.setAttribute("type", "location");
+ element.addContent(newTag);
+ }
+ }
+ }
+
+ protected Element generateSimpleElement(final String name, final String value) {
+ final Element element = new Element(name, CustomTagParser.NS);
+ element.addContent(value);
+
+ return element;
+ }
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/base/io/CustomTagParser.java b/rome-modules/src/main/java/com/rometools/modules/base/io/CustomTagParser.java
new file mode 100644
index 0000000..15c72bd
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/base/io/CustomTagParser.java
@@ -0,0 +1,148 @@
+/*
+ * CustomTagParser.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) 2006 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 com.rometools.modules.base.io;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.text.ParseException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+
+import org.jdom2.Element;
+import org.jdom2.Namespace;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.rometools.modules.base.CustomTag;
+import com.rometools.modules.base.CustomTagImpl;
+import com.rometools.modules.base.CustomTags;
+import com.rometools.modules.base.CustomTagsImpl;
+import com.rometools.modules.base.types.DateTimeRange;
+import com.rometools.modules.base.types.FloatUnit;
+import com.rometools.modules.base.types.IntUnit;
+import com.rometools.modules.base.types.ShortDate;
+import com.rometools.rome.feed.module.Module;
+import com.rometools.rome.io.ModuleParser;
+
+/**
+ * @version $Revision: 1.4 $
+ * @author Robert "kebernet" Cooper
+ */
+public class CustomTagParser implements ModuleParser {
+
+ private static final Logger LOG = LoggerFactory.getLogger(CustomTagParser.class);
+
+ static final Namespace NS = Namespace.getNamespace("g-custom", CustomTags.URI);
+
+ /** Creates a new instance of CustomTagParser */
+ public CustomTagParser() {
+ }
+
+ @Override
+ public Module parse(final Element element, final Locale locale) {
+ final CustomTags module = new CustomTagsImpl();
+ final ArrayList tags = new ArrayList();
+ final List elements = element.getChildren();
+ final Iterator it = elements.iterator();
+ while (it.hasNext()) {
+ final Element child = it.next();
+ if (child.getNamespace().equals(NS)) {
+ final String type = child.getAttributeValue("type");
+ try {
+ if (type == null) {
+ continue;
+ } else if (type.equals("string")) {
+ tags.add(new CustomTagImpl(child.getName(), child.getText()));
+ } else if (type.equals("int")) {
+ tags.add(new CustomTagImpl(child.getName(), new Integer(child.getTextTrim())));
+ } else if (type.equals("float")) {
+ tags.add(new CustomTagImpl(child.getName(), new Float(child.getTextTrim())));
+ } else if (type.equals("intUnit")) {
+ tags.add(new CustomTagImpl(child.getName(), new IntUnit(child.getTextTrim())));
+ } else if (type.equals("floatUnit")) {
+ tags.add(new CustomTagImpl(child.getName(), new FloatUnit(child.getTextTrim())));
+ } else if (type.equals("date")) {
+ try {
+ tags.add(new CustomTagImpl(child.getName(), new ShortDate(GoogleBaseParser.SHORT_DT_FMT.parse(child.getTextTrim()))));
+ } catch (final ParseException e) {
+ LOG.warn("Unable to parse date type on " + child.getName(), e);
+ }
+ } else if (type.equals("dateTime")) {
+ try {
+ tags.add(new CustomTagImpl(child.getName(), GoogleBaseParser.LONG_DT_FMT.parse(child.getTextTrim())));
+ } catch (final ParseException e) {
+ LOG.warn("Unable to parse date type on " + child.getName(), e);
+ }
+ } else if (type.equals("dateTimeRange")) {
+ try {
+ tags.add(new CustomTagImpl(child.getName(), new DateTimeRange(GoogleBaseParser.LONG_DT_FMT.parse(child
+ .getChild("start", CustomTagParser.NS).getText().trim()), GoogleBaseParser.LONG_DT_FMT.parse(child
+ .getChild("end", CustomTagParser.NS).getText().trim()))));
+ } catch (final Exception e) {
+ LOG.warn("Unable to parse date type on " + child.getName(), e);
+ }
+ } else if (type.equals("url")) {
+ try {
+ tags.add(new CustomTagImpl(child.getName(), new URL(child.getTextTrim())));
+ } catch (final MalformedURLException e) {
+ LOG.warn("Unable to parse URL type on " + child.getName(), e);
+ }
+ } else if (type.equals("boolean")) {
+ tags.add(new CustomTagImpl(child.getName(), new Boolean(child.getTextTrim().toLowerCase())));
+ } else if (type.equals("location")) {
+ tags.add(new CustomTagImpl(child.getName(), new CustomTagImpl.Location(child.getText())));
+ } else {
+ throw new Exception("Unknown type: " + type);
+ }
+ } catch (final Exception e) {
+ LOG.warn("Unable to parse type on " + child.getName(), e);
+ }
+ }
+ }
+ module.setValues(tags);
+ return module;
+ }
+
+ @Override
+ public String getNamespaceUri() {
+ return CustomTags.URI;
+ }
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/base/io/GoogleBaseGenerator.java b/rome-modules/src/main/java/com/rometools/modules/base/io/GoogleBaseGenerator.java
new file mode 100644
index 0000000..36ed091
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/base/io/GoogleBaseGenerator.java
@@ -0,0 +1,163 @@
+/*
+ * GoogleBaseGenerator.java
+ *
+ * Created on November 17, 2005, 2:46 PM
+ *
+ * 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.
+ */
+package com.rometools.modules.base.io;
+
+import java.beans.PropertyDescriptor;
+import java.net.URL;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.jdom2.Element;
+import org.jdom2.Namespace;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.rometools.modules.base.GoogleBase;
+import com.rometools.modules.base.GoogleBaseImpl;
+import com.rometools.modules.base.types.CurrencyEnumeration;
+import com.rometools.modules.base.types.DateTimeRange;
+import com.rometools.modules.base.types.FloatUnit;
+import com.rometools.modules.base.types.GenderEnumeration;
+import com.rometools.modules.base.types.IntUnit;
+import com.rometools.modules.base.types.PaymentTypeEnumeration;
+import com.rometools.modules.base.types.PriceTypeEnumeration;
+import com.rometools.modules.base.types.ShippingType;
+import com.rometools.modules.base.types.ShortDate;
+import com.rometools.modules.base.types.Size;
+import com.rometools.modules.base.types.YearType;
+import com.rometools.rome.feed.module.Module;
+import com.rometools.rome.io.ModuleGenerator;
+
+/**
+ *
+ * @author Robert "kebernet" Cooper
+ * @version $Revision: 1.1 $
+ */
+public class GoogleBaseGenerator implements ModuleGenerator {
+ private static final Namespace NS = Namespace.getNamespace("g-core", GoogleBase.URI);
+
+ private static final Logger LOG = LoggerFactory.getLogger(GoogleBaseGenerator.class);
+
+ /** Creates a new instance of GoogleBaseGenerator */
+ public GoogleBaseGenerator() {
+ super();
+ }
+
+ @Override
+ public String getNamespaceUri() {
+ return GoogleBase.URI;
+ }
+
+ @Override
+ public Set getNamespaces() {
+ final HashSet set = new HashSet();
+ set.add(GoogleBaseGenerator.NS);
+ return set;
+ }
+
+ @Override
+ public void generate(final Module module, final Element element) {
+ final GoogleBaseImpl mod = (GoogleBaseImpl) module;
+ final HashMap
+
Google Base is a trademark of Google, Inc. The authors of this software
+ are not affiliated with Google, Inc. and Google does not endorse, support,
+ blah blah blah.
+
+
+ * 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.
+
+
+
diff --git a/rome-modules/src/main/java/com/rometools/modules/base/types/CloneableType.java b/rome-modules/src/main/java/com/rometools/modules/base/types/CloneableType.java
new file mode 100644
index 0000000..0f3ba6a
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/base/types/CloneableType.java
@@ -0,0 +1,50 @@
+/*
+ * CloneableType.java
+ *
+ * Created on November 18, 2005, 10:42 AM
+ *
+ * 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.
+ */
+package com.rometools.modules.base.types;
+
+/**
+ * This is just a holder interface for cloneable elements.
+ *
+ * @author Robert "kebernet" Cooper
+ * @version $Revision: 1.1 $
+ */
+public interface CloneableType extends Cloneable {
+ public Object clone();
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/base/types/CurrencyEnumeration.java b/rome-modules/src/main/java/com/rometools/modules/base/types/CurrencyEnumeration.java
new file mode 100644
index 0000000..6d4cdc6
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/base/types/CurrencyEnumeration.java
@@ -0,0 +1,601 @@
+/*
+ * CurrencyEnumeration.java
+ *
+ * Created on November 18, 2005, 11:33 AM
+ *
+ * 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.
+ */
+package com.rometools.modules.base.types;
+
+import java.util.HashMap;
+
+/**
+ * An Enumeration of valid currency types.
+ *
+ * @author Robert "kebernet" Cooper
+ * @version $Revision: 1.1 $
+ */
+public class CurrencyEnumeration {
+
+ private static final HashMap lookup = new HashMap();
+
+ //
+ //
+ public static final CurrencyEnumeration AED = new CurrencyEnumeration("AED");
+
+ //
+ public static final CurrencyEnumeration AFA = new CurrencyEnumeration("AFA");
+
+ //
+ public static final CurrencyEnumeration ALL = new CurrencyEnumeration("ALL");
+
+ //
+ public static final CurrencyEnumeration AMD = new CurrencyEnumeration("AMD");
+
+ //
+ public static final CurrencyEnumeration ANG = new CurrencyEnumeration("ANG");
+
+ //
+ public static final CurrencyEnumeration AOA = new CurrencyEnumeration("AOA");
+
+ //
+ public static final CurrencyEnumeration ARS = new CurrencyEnumeration("ARS");
+
+ //
+ public static final CurrencyEnumeration AUD = new CurrencyEnumeration("AUD");
+
+ //
+ public static final CurrencyEnumeration AWG = new CurrencyEnumeration("AWG");
+
+ //
+ public static final CurrencyEnumeration AZM = new CurrencyEnumeration("AZM");
+
+ //
+ public static final CurrencyEnumeration BAM = new CurrencyEnumeration("BAM");
+
+ //
+ public static final CurrencyEnumeration BBD = new CurrencyEnumeration("BBD");
+
+ //
+ public static final CurrencyEnumeration BDT = new CurrencyEnumeration("BDT");
+
+ //
+ public static final CurrencyEnumeration BGN = new CurrencyEnumeration("BGN");
+
+ //
+ public static final CurrencyEnumeration BHD = new CurrencyEnumeration("BHD");
+
+ //
+ public static final CurrencyEnumeration BIF = new CurrencyEnumeration("BIF");
+
+ //
+ public static final CurrencyEnumeration BMD = new CurrencyEnumeration("BMD");
+
+ //
+ public static final CurrencyEnumeration BND = new CurrencyEnumeration("BND");
+
+ //
+ public static final CurrencyEnumeration BOB = new CurrencyEnumeration("BOB");
+
+ //
+ public static final CurrencyEnumeration BRL = new CurrencyEnumeration("BRL");
+
+ //
+ public static final CurrencyEnumeration BSD = new CurrencyEnumeration("BSD");
+
+ //
+ public static final CurrencyEnumeration BTN = new CurrencyEnumeration("BTN");
+
+ //
+ public static final CurrencyEnumeration BWP = new CurrencyEnumeration("BWP");
+
+ //
+ public static final CurrencyEnumeration BYR = new CurrencyEnumeration("BYR");
+
+ //
+ public static final CurrencyEnumeration BZD = new CurrencyEnumeration("BZD");
+
+ //
+ public static final CurrencyEnumeration CAD = new CurrencyEnumeration("CAD");
+
+ //
+ public static final CurrencyEnumeration CDF = new CurrencyEnumeration("CDF");
+
+ //
+ public static final CurrencyEnumeration CHF = new CurrencyEnumeration("CHF");
+
+ //
+ public static final CurrencyEnumeration CLP = new CurrencyEnumeration("CLP");
+
+ //
+ public static final CurrencyEnumeration CNY = new CurrencyEnumeration("CNY");
+
+ //
+ public static final CurrencyEnumeration CRC = new CurrencyEnumeration("CRC");
+
+ //
+ public static final CurrencyEnumeration CSD = new CurrencyEnumeration("CSD");
+
+ //
+ public static final CurrencyEnumeration CUP = new CurrencyEnumeration("CUP");
+
+ //
+ public static final CurrencyEnumeration CVE = new CurrencyEnumeration("CVE");
+
+ //
+ public static final CurrencyEnumeration CYP = new CurrencyEnumeration("CYP");
+
+ //
+ public static final CurrencyEnumeration CZK = new CurrencyEnumeration("CZK");
+
+ //
+ public static final CurrencyEnumeration DJF = new CurrencyEnumeration("DJF");
+
+ //
+ public static final CurrencyEnumeration DKK = new CurrencyEnumeration("DKK");
+
+ //
+ public static final CurrencyEnumeration DOP = new CurrencyEnumeration("DOP");
+
+ //
+ public static final CurrencyEnumeration DZD = new CurrencyEnumeration("DZD");
+
+ //
+ public static final CurrencyEnumeration EEK = new CurrencyEnumeration("EEK");
+
+ //
+ public static final CurrencyEnumeration EGP = new CurrencyEnumeration("EGP");
+
+ //
+ public static final CurrencyEnumeration ERN = new CurrencyEnumeration("ERN");
+
+ //
+ public static final CurrencyEnumeration ETB = new CurrencyEnumeration("ETB");
+
+ //
+ public static final CurrencyEnumeration EUR = new CurrencyEnumeration("EUR");
+
+ //
+ public static final CurrencyEnumeration FJD = new CurrencyEnumeration("FJD");
+
+ //
+ public static final CurrencyEnumeration FKP = new CurrencyEnumeration("FKP");
+
+ //
+ public static final CurrencyEnumeration GBP = new CurrencyEnumeration("GBP");
+
+ //
+ public static final CurrencyEnumeration GEL = new CurrencyEnumeration("GEL");
+
+ //
+ public static final CurrencyEnumeration GGP = new CurrencyEnumeration("GGP");
+
+ //
+ public static final CurrencyEnumeration GHC = new CurrencyEnumeration("GHC");
+
+ //
+ public static final CurrencyEnumeration GIP = new CurrencyEnumeration("GIP");
+
+ //
+ public static final CurrencyEnumeration GMD = new CurrencyEnumeration("GMD");
+
+ //
+ public static final CurrencyEnumeration GNF = new CurrencyEnumeration("GNF");
+
+ //
+ public static final CurrencyEnumeration GTQ = new CurrencyEnumeration("GTQ");
+
+ //
+ public static final CurrencyEnumeration GYD = new CurrencyEnumeration("GYD");
+
+ //
+ public static final CurrencyEnumeration HKD = new CurrencyEnumeration("HKD");
+
+ //
+ public static final CurrencyEnumeration HNL = new CurrencyEnumeration("HNL");
+
+ //
+ public static final CurrencyEnumeration HRK = new CurrencyEnumeration("HRK");
+
+ //
+ public static final CurrencyEnumeration HTG = new CurrencyEnumeration("HTG");
+
+ //
+ public static final CurrencyEnumeration HUF = new CurrencyEnumeration("HUF");
+
+ //
+ public static final CurrencyEnumeration IDR = new CurrencyEnumeration("IDR");
+
+ //
+ public static final CurrencyEnumeration ILS = new CurrencyEnumeration("ILS");
+
+ //
+ public static final CurrencyEnumeration IMP = new CurrencyEnumeration("IMP");
+
+ //
+ public static final CurrencyEnumeration INR = new CurrencyEnumeration("INR");
+
+ //
+ public static final CurrencyEnumeration IQD = new CurrencyEnumeration("IQD");
+
+ //
+ public static final CurrencyEnumeration IRR = new CurrencyEnumeration("IRR");
+
+ //
+ public static final CurrencyEnumeration ISK = new CurrencyEnumeration("ISK");
+
+ //
+ public static final CurrencyEnumeration JEP = new CurrencyEnumeration("JEP");
+
+ //
+ public static final CurrencyEnumeration JMD = new CurrencyEnumeration("JMD");
+
+ //
+ public static final CurrencyEnumeration JOD = new CurrencyEnumeration("JOD");
+
+ //
+ public static final CurrencyEnumeration JPY = new CurrencyEnumeration("JPY");
+
+ //
+ public static final CurrencyEnumeration KES = new CurrencyEnumeration("KES");
+
+ //
+ public static final CurrencyEnumeration KGS = new CurrencyEnumeration("KGS");
+
+ //
+ public static final CurrencyEnumeration KHR = new CurrencyEnumeration("KHR");
+
+ //
+ public static final CurrencyEnumeration KMF = new CurrencyEnumeration("KMF");
+
+ //
+ public static final CurrencyEnumeration KPW = new CurrencyEnumeration("KPW");
+
+ //
+ public static final CurrencyEnumeration KRW = new CurrencyEnumeration("KRW");
+
+ //
+ public static final CurrencyEnumeration KWD = new CurrencyEnumeration("KWD");
+
+ //
+ public static final CurrencyEnumeration KYD = new CurrencyEnumeration("KYD");
+
+ //
+ public static final CurrencyEnumeration KZT = new CurrencyEnumeration("KZT");
+
+ //
+ public static final CurrencyEnumeration LAK = new CurrencyEnumeration("LAK");
+
+ //
+ public static final CurrencyEnumeration LBP = new CurrencyEnumeration("LBP");
+
+ //
+ public static final CurrencyEnumeration LKR = new CurrencyEnumeration("LKR");
+
+ //
+ public static final CurrencyEnumeration LRD = new CurrencyEnumeration("LRD");
+
+ //
+ public static final CurrencyEnumeration LSL = new CurrencyEnumeration("LSL");
+
+ //
+ public static final CurrencyEnumeration LTL = new CurrencyEnumeration("LTL");
+
+ //
+ public static final CurrencyEnumeration LVL = new CurrencyEnumeration("LVL");
+
+ //
+ public static final CurrencyEnumeration LYD = new CurrencyEnumeration("LYD");
+
+ //
+ public static final CurrencyEnumeration MAD = new CurrencyEnumeration("MAD");
+
+ //
+ public static final CurrencyEnumeration MDL = new CurrencyEnumeration("MDL");
+
+ //
+ public static final CurrencyEnumeration MGA = new CurrencyEnumeration("MGA");
+
+ //
+ public static final CurrencyEnumeration MKD = new CurrencyEnumeration("MKD");
+
+ //
+ public static final CurrencyEnumeration MMK = new CurrencyEnumeration("MMK");
+
+ //
+ public static final CurrencyEnumeration MNT = new CurrencyEnumeration("MNT");
+
+ //
+ public static final CurrencyEnumeration MOP = new CurrencyEnumeration("MOP");
+
+ //
+ public static final CurrencyEnumeration MRO = new CurrencyEnumeration("MRO");
+
+ //
+ public static final CurrencyEnumeration MTL = new CurrencyEnumeration("MTL");
+
+ //
+ public static final CurrencyEnumeration MUR = new CurrencyEnumeration("MUR");
+
+ //
+ public static final CurrencyEnumeration MVR = new CurrencyEnumeration("MVR");
+
+ //
+ public static final CurrencyEnumeration MWK = new CurrencyEnumeration("MWK");
+
+ //
+ public static final CurrencyEnumeration MXN = new CurrencyEnumeration("MXN");
+
+ //
+ public static final CurrencyEnumeration MYR = new CurrencyEnumeration("MYR");
+
+ //
+ public static final CurrencyEnumeration MZM = new CurrencyEnumeration("MZM");
+
+ //
+ public static final CurrencyEnumeration NAD = new CurrencyEnumeration("NAD");
+
+ //
+ public static final CurrencyEnumeration NGN = new CurrencyEnumeration("NGN");
+
+ //
+ public static final CurrencyEnumeration NIO = new CurrencyEnumeration("NIO");
+
+ //
+ public static final CurrencyEnumeration NOK = new CurrencyEnumeration("NOK");
+
+ //
+ public static final CurrencyEnumeration NPR = new CurrencyEnumeration("NPR");
+
+ //
+ public static final CurrencyEnumeration NZD = new CurrencyEnumeration("NZD");
+
+ //
+ public static final CurrencyEnumeration OMR = new CurrencyEnumeration("OMR");
+
+ //
+ public static final CurrencyEnumeration PAB = new CurrencyEnumeration("PAB");
+
+ //
+ public static final CurrencyEnumeration PEN = new CurrencyEnumeration("PEN");
+
+ //
+ public static final CurrencyEnumeration PGK = new CurrencyEnumeration("PGK");
+
+ //
+ public static final CurrencyEnumeration PHP = new CurrencyEnumeration("PHP");
+
+ //
+ public static final CurrencyEnumeration PKR = new CurrencyEnumeration("PKR");
+
+ //
+ public static final CurrencyEnumeration PLN = new CurrencyEnumeration("PLN");
+
+ //
+ public static final CurrencyEnumeration PYG = new CurrencyEnumeration("PYG");
+
+ //
+ public static final CurrencyEnumeration QAR = new CurrencyEnumeration("QAR");
+
+ //
+ public static final CurrencyEnumeration RON = new CurrencyEnumeration("RON");
+
+ //
+ public static final CurrencyEnumeration RUB = new CurrencyEnumeration("RUB");
+
+ //
+ public static final CurrencyEnumeration RWF = new CurrencyEnumeration("MOP");
+
+ //
+ public static final CurrencyEnumeration SAR = new CurrencyEnumeration("SAR");
+
+ //
+ public static final CurrencyEnumeration SBD = new CurrencyEnumeration("SBD");
+
+ //
+ public static final CurrencyEnumeration SCR = new CurrencyEnumeration("SCR");
+
+ //
+ public static final CurrencyEnumeration SDD = new CurrencyEnumeration("SDD");
+
+ //
+ public static final CurrencyEnumeration SEK = new CurrencyEnumeration("SEK");
+
+ //
+ public static final CurrencyEnumeration SGD = new CurrencyEnumeration("SGD");
+
+ //
+ public static final CurrencyEnumeration SHP = new CurrencyEnumeration("SHP");
+
+ //
+ public static final CurrencyEnumeration SIT = new CurrencyEnumeration("SIT");
+
+ //
+ public static final CurrencyEnumeration SKK = new CurrencyEnumeration("SKK");
+
+ //
+ public static final CurrencyEnumeration SLL = new CurrencyEnumeration("SLL");
+
+ //
+ public static final CurrencyEnumeration SOS = new CurrencyEnumeration("SOS");
+
+ //
+ public static final CurrencyEnumeration SPL = new CurrencyEnumeration("SPL");
+
+ //
+ public static final CurrencyEnumeration SRD = new CurrencyEnumeration("SRD");
+
+ //
+ public static final CurrencyEnumeration STD = new CurrencyEnumeration("STD");
+
+ //
+ public static final CurrencyEnumeration SVC = new CurrencyEnumeration("SVC");
+
+ //
+ public static final CurrencyEnumeration SYP = new CurrencyEnumeration("SYP");
+
+ //
+ public static final CurrencyEnumeration SZL = new CurrencyEnumeration("SZL");
+
+ //
+ public static final CurrencyEnumeration THB = new CurrencyEnumeration("THB");
+
+ //
+ public static final CurrencyEnumeration TJS = new CurrencyEnumeration("TJS");
+
+ //
+ public static final CurrencyEnumeration TMM = new CurrencyEnumeration("TMM");
+
+ //
+ public static final CurrencyEnumeration TND = new CurrencyEnumeration("TND");
+
+ //
+ public static final CurrencyEnumeration TOP = new CurrencyEnumeration("TOP");
+
+ //
+ public static final CurrencyEnumeration TRL = new CurrencyEnumeration("TRL");
+
+ //
+ public static final CurrencyEnumeration TRY = new CurrencyEnumeration("TRY");
+
+ //
+ public static final CurrencyEnumeration TTD = new CurrencyEnumeration("TTD");
+
+ //
+ public static final CurrencyEnumeration TVD = new CurrencyEnumeration("TVD");
+
+ //
+ public static final CurrencyEnumeration TWD = new CurrencyEnumeration("TWD");
+
+ //
+ public static final CurrencyEnumeration TZS = new CurrencyEnumeration("TZS");
+
+ //
+ public static final CurrencyEnumeration UAH = new CurrencyEnumeration("UAH");
+
+ //
+ public static final CurrencyEnumeration UGX = new CurrencyEnumeration("UGX");
+
+ //
+ public static final CurrencyEnumeration USD = new CurrencyEnumeration("USD");
+
+ //
+ public static final CurrencyEnumeration UYU = new CurrencyEnumeration("UYU");
+
+ //
+ public static final CurrencyEnumeration UZS = new CurrencyEnumeration("UZS");
+
+ //
+ public static final CurrencyEnumeration VEB = new CurrencyEnumeration("VEB");
+
+ //
+ public static final CurrencyEnumeration VND = new CurrencyEnumeration("VND");
+
+ //
+ public static final CurrencyEnumeration VUV = new CurrencyEnumeration("VUV");
+
+ //
+ public static final CurrencyEnumeration WST = new CurrencyEnumeration("WST");
+
+ //
+ public static final CurrencyEnumeration XAF = new CurrencyEnumeration("XAF");
+
+ //
+ public static final CurrencyEnumeration XAG = new CurrencyEnumeration("XAG");
+
+ //
+ public static final CurrencyEnumeration XAU = new CurrencyEnumeration("XAU");
+
+ //
+ public static final CurrencyEnumeration XCD = new CurrencyEnumeration("XCD");
+
+ //
+ public static final CurrencyEnumeration XDR = new CurrencyEnumeration("XDR");
+
+ //
+ public static final CurrencyEnumeration XOF = new CurrencyEnumeration("XOF");
+
+ //
+ public static final CurrencyEnumeration XPD = new CurrencyEnumeration("XPD");
+
+ //
+ public static final CurrencyEnumeration XPF = new CurrencyEnumeration("XPF");
+
+ //
+ public static final CurrencyEnumeration XPT = new CurrencyEnumeration("XPT");
+
+ //
+ public static final CurrencyEnumeration YER = new CurrencyEnumeration("YER");
+
+ //
+ public static final CurrencyEnumeration ZAR = new CurrencyEnumeration("ZAR");
+
+ //
+ public static final CurrencyEnumeration ZMK = new CurrencyEnumeration("ZMK");
+
+ //
+ public static final CurrencyEnumeration ZWD = new CurrencyEnumeration("ZWD");
+
+ //
+ private final String value;
+
+ /**
+ * Creates a new instance of CurrencyEnumeration
+ *
+ * @param value DOCUMENT ME!
+ */
+ private CurrencyEnumeration(final String value) {
+ this.value = value;
+ lookup.put(value, this);
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ @Override
+ public Object clone() {
+ return this;
+ }
+
+ public static CurrencyEnumeration findByValue(final String value) {
+ return lookup.get(value.trim().toUpperCase());
+ }
+
+ @Override
+ public String toString() {
+ return value;
+ }
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/base/types/DateTimeRange.java b/rome-modules/src/main/java/com/rometools/modules/base/types/DateTimeRange.java
new file mode 100644
index 0000000..6de93ca
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/base/types/DateTimeRange.java
@@ -0,0 +1,136 @@
+/*
+ * DateTimeRange.java
+ *
+ * Created on November 16, 2005, 11:14 AM
+ *
+ * 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.
+ */
+package com.rometools.modules.base.types;
+
+import java.util.Date;
+
+/**
+ * Represents a time range.
+ *
+ * @author Robert "kebernet" Cooper
+ * @version $Revision: 1.2 $
+ */
+public class DateTimeRange implements CloneableType {
+ /**
+ * end time
+ */
+ private Date end;
+ /**
+ * start time
+ */
+ private Date start;
+
+ /**
+ * Creates a new instance of DateTimeRange
+ *
+ * @param start Beginning of the timeframe.
+ * @param end End of the Timeframe.
+ */
+ public DateTimeRange(final Date start, final Date end) {
+ this.start = start;
+ this.end = end;
+ }
+
+ /**
+ * The end of the timeframe.
+ *
+ * @return The end of the timeframe.
+ */
+ public Date getEnd() {
+ return end;
+ }
+
+ /**
+ * The beginning of the timeframe.
+ *
+ * @return The beginning of the timeframe.
+ */
+ public Date getStart() {
+ return start;
+ }
+
+ /**
+ * Clones the object
+ *
+ * @return Duplicate of this object.
+ */
+ @Override
+ public Object clone() {
+ final DateTimeRange retValue = new DateTimeRange(null, null);
+
+ if (getStart() != null) {
+ retValue.start = (Date) getStart().clone();
+ }
+
+ if (getEnd() != null) {
+ retValue.end = (Date) getEnd().clone();
+ }
+
+ return retValue;
+ }
+
+ /**
+ * String representation of the object.
+ *
+ * @return String representation of the object.
+ */
+ @Override
+ public String toString() {
+ return "Start: " + start + " End: " + end;
+ }
+
+ @Override
+ public boolean equals(final Object o) {
+ if (!(o instanceof DateTimeRange) || o == null) {
+ return false;
+ }
+ final DateTimeRange d = (DateTimeRange) o;
+ if (start == d.getStart() && end == d.getEnd()) {
+ return true;
+ }
+ if (start != null && !start.equals(d.getStart())) {
+ return false;
+ }
+ if (end != null && !end.equals(d.getEnd())) {
+ return false;
+ }
+ return true;
+ }
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/base/types/FloatUnit.java b/rome-modules/src/main/java/com/rometools/modules/base/types/FloatUnit.java
new file mode 100644
index 0000000..6f36442
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/base/types/FloatUnit.java
@@ -0,0 +1,169 @@
+/*
+ * FloatUnit.java
+ *
+ * Created on November 16, 2005, 11:43 AM
+ *
+ * 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.
+ */
+package com.rometools.modules.base.types;
+
+import com.rometools.modules.base.io.GoogleBaseParser;
+
+/**
+ * This class represents a quantity consisting of a float value and an optional units specification.
+ *
+ * @author Robert "kebernet" Cooper
+ * @version $Revision: 1.1 $
+ */
+public class FloatUnit implements CloneableType {
+ /**
+ * Units
+ */
+ private String units;
+ /**
+ * Float value
+ */
+ private final float value;
+
+ /**
+ * Looks for a char in an array
+ *
+ * @param find char to search for
+ * @param array array to search
+ * @return boolean indicating presence.
+ */
+ private boolean inCharArray(final char find, final char[] array) {
+ for (final char element : array) {
+ if (find == element) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Creates a new float unit by parsing a String value
+ *
+ * @param source String value to parse
+ */
+ public FloatUnit(final String source) {
+ final String parse = source.trim();
+ int space = -1;
+ for (int i = 0; i < parse.length(); i++) {
+ if (!inCharArray(parse.charAt(i), GoogleBaseParser.FLOAT_CHARS)) {
+ space = i;
+ break;
+ }
+ }
+
+ if (space == -1) {
+ space = parse.length();
+ }
+
+ value = Float.parseFloat(GoogleBaseParser.stripNonValidCharacters(GoogleBaseParser.FLOAT_CHARS, parse.substring(0, space)));
+
+ if (space != parse.length()) {
+ units = parse.substring(space, parse.length()).trim();
+ }
+ }
+
+ /**
+ * Creates a new instance of FloatUnit
+ *
+ * @param value float value
+ * @param units Units represented, or null.
+ */
+ public FloatUnit(final float value, final String units) {
+ this.value = value;
+ this.units = units;
+ }
+
+ /**
+ * Returns the units.
+ *
+ * @return Returns the units.
+ */
+ public String getUnits() {
+ return units;
+ }
+
+ /**
+ * Returns the float value.
+ *
+ * @return Returns the float value.
+ */
+ public float getValue() {
+ return value;
+ }
+
+ /**
+ * Duplicates the object.
+ *
+ * @return Duplicate FloatUnit
+ */
+ @Override
+ public Object clone() {
+ return new FloatUnit(0 + value, units);
+ }
+
+ /**
+ * Returns a String representation of the object.
+ *
+ * @return Returns a String representation of the object.
+ */
+ @Override
+ public String toString() {
+ if (units != null && units.trim().length() > 0) {
+ return value + " " + units;
+ } else {
+ return Float.toString(value);
+ }
+ }
+
+ @Override
+ public boolean equals(final Object o) {
+ if (!(o instanceof FloatUnit)) {
+ return false;
+ }
+ final FloatUnit f = (FloatUnit) o;
+ if (f.getValue() != value) {
+ return false;
+ }
+ if (units == f.getUnits() || units != null && units.equals(f.getUnits())) {
+ return true;
+ }
+ return false;
+ }
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/base/types/GenderEnumeration.java b/rome-modules/src/main/java/com/rometools/modules/base/types/GenderEnumeration.java
new file mode 100644
index 0000000..a47bd8d
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/base/types/GenderEnumeration.java
@@ -0,0 +1,91 @@
+/*
+ * GenderEnumeration.java
+ *
+ * Created on November 16, 2005, 2:35 PM
+ *
+ * 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.
+ */
+package com.rometools.modules.base.types;
+
+/**
+ * Simple enumeration for Genders.
+ *
+ * @author Robert "kebernet" Cooper
+ * @version $Revision: 1.1 $
+ */
+public class GenderEnumeration implements CloneableType {
+ /** Men */
+ public static final GenderEnumeration MALE = new GenderEnumeration("Male");
+ /** Women */
+ public static final GenderEnumeration FEMALE = new GenderEnumeration("Female");
+ private final String value;
+
+ private GenderEnumeration(final String value) {
+ this.value = value;
+ }
+
+ /** Returns the proper instance based on the string value */
+ public static GenderEnumeration findByValue(final String value) {
+ if (value == null) {
+ return null;
+ }
+
+ final String gender = value.toUpperCase();
+
+ if (gender.charAt(0) == 'M') {
+ return GenderEnumeration.MALE;
+ } else if (gender.charAt(0) == 'F') {
+ return GenderEnumeration.FEMALE;
+ } else {
+ return null;
+ }
+ }
+
+ /** Returns the value of the instance */
+ public String getValue() {
+ return value;
+ }
+
+ /** Returns a reference to the same object. :P */
+ @Override
+ public Object clone() {
+ return this;
+ }
+
+ @Override
+ public String toString() {
+ return value;
+ }
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/base/types/IntUnit.java b/rome-modules/src/main/java/com/rometools/modules/base/types/IntUnit.java
new file mode 100644
index 0000000..eb00e10
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/base/types/IntUnit.java
@@ -0,0 +1,124 @@
+/*
+ * IntUnit.java
+ *
+ * Created on November 16, 2005, 12:49 PM
+ *
+ * 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.
+ */
+package com.rometools.modules.base.types;
+
+import com.rometools.modules.base.io.GoogleBaseParser;
+
+/**
+ *
+ * @author Robert "kebernet" Cooper
+ * @version $Revision: 1.1 $
+ */
+public class IntUnit implements CloneableType {
+ private String units;
+ private final int value;
+
+ private boolean inCharArray(final char find, final char[] array) {
+ for (final char element : array) {
+ if (find == element) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public IntUnit(final String source) {
+ final String parse = source.trim();
+ int space = -1;
+ for (int i = 0; i < parse.length(); i++) {
+ if (!inCharArray(parse.charAt(i), GoogleBaseParser.INTEGER_CHARS)) {
+ space = i;
+ break;
+ }
+ }
+ if (space == -1) {
+ space = parse.length();
+ }
+
+ value = Integer.parseInt(GoogleBaseParser.stripNonValidCharacters(GoogleBaseParser.INTEGER_CHARS, parse.substring(0, space)));
+
+ if (space != parse.length()) {
+ units = parse.substring(space, parse.length()).trim();
+ }
+ }
+
+ /** Creates a new instance of IntUnit */
+ public IntUnit(final int value, final String units) {
+ this.value = value;
+ this.units = units;
+ }
+
+ public String getUnits() {
+ return units;
+ }
+
+ public int getValue() {
+ return value;
+ }
+
+ @Override
+ public Object clone() {
+ return new IntUnit(value, units);
+ }
+
+ @Override
+ public String toString() {
+ if (units != null && units.trim().length() > 0) {
+ return value + " " + units;
+ } else {
+ return Integer.toString(value);
+ }
+ }
+
+ @Override
+ public boolean equals(final Object o) {
+ if (!(o instanceof IntUnit)) {
+ return false;
+ }
+ final IntUnit f = (IntUnit) o;
+ if (f.getValue() != value) {
+ return false;
+ }
+ if (units == f.getUnits() || units != null && units.equals(f.getUnits())) {
+ return true;
+ }
+ return false;
+ }
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/base/types/PaymentTypeEnumeration.java b/rome-modules/src/main/java/com/rometools/modules/base/types/PaymentTypeEnumeration.java
new file mode 100644
index 0000000..f367e0f
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/base/types/PaymentTypeEnumeration.java
@@ -0,0 +1,87 @@
+/*
+ * PaymentTypeEnumeration.java
+ *
+ * Created on November 16, 2005, 11:49 AM
+ *
+ * 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.
+ */
+package com.rometools.modules.base.types;
+
+import java.util.HashMap;
+
+/**
+ *
+ * @author Robert "kebernet" Cooper
+ * @version $Revision: 1.1 $
+ */
+public class PaymentTypeEnumeration {
+
+ private static final HashMap lookup = new HashMap();
+
+ public static final PaymentTypeEnumeration CASH = new PaymentTypeEnumeration("Cash");
+ public static final PaymentTypeEnumeration CHECK = new PaymentTypeEnumeration("Check");
+ public static final PaymentTypeEnumeration TRAVELERS_CHECK = new PaymentTypeEnumeration("Traveler�s Check");
+ public static final PaymentTypeEnumeration VISA = new PaymentTypeEnumeration("Visa");
+ public static final PaymentTypeEnumeration MASTERCARD = new PaymentTypeEnumeration("MasterCard");
+ public static final PaymentTypeEnumeration AMERICAN_EXPRESS = new PaymentTypeEnumeration("American Express");
+ public static final PaymentTypeEnumeration DISCOVER = new PaymentTypeEnumeration("Discover");
+ public static final PaymentTypeEnumeration WIRE_TRANSFER = new PaymentTypeEnumeration("Wire transfer");
+ public static final PaymentTypeEnumeration PAYPAL = new PaymentTypeEnumeration("Paypal");
+ private final String value;
+
+ /** Creates a new instance of PaymentTypeEnumeration */
+ private PaymentTypeEnumeration(final String value) {
+ this.value = value;
+ lookup.put(this.value.toUpperCase(), this);
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public static PaymentTypeEnumeration findByValue(final String value) {
+ return lookup.get(value.toUpperCase());
+ }
+
+ @Override
+ public Object clone() {
+ return this;
+ }
+
+ @Override
+ public String toString() {
+ return value;
+ }
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/base/types/PriceTypeEnumeration.java b/rome-modules/src/main/java/com/rometools/modules/base/types/PriceTypeEnumeration.java
new file mode 100644
index 0000000..c06c4a5
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/base/types/PriceTypeEnumeration.java
@@ -0,0 +1,113 @@
+/*
+ * PriceTypeEnumeration.java
+ *
+ * Created on November 16, 2005, 11:45 AM
+ *
+ * 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.
+ */
+package com.rometools.modules.base.types;
+
+/**
+ * Enumeration of values suitable for "price_type" or "salary_type".
+ *
+ * @author Robert "kebernet" Cooper
+ * @version $Revision: 1.1 $
+ */
+public class PriceTypeEnumeration implements CloneableType {
+ /**
+ * Indicates the value is a starting value.
+ */
+ public static final PriceTypeEnumeration STARTING = new PriceTypeEnumeration("starting");
+ /**
+ * Indicates the value is negotiable
+ */
+ public static final PriceTypeEnumeration NEGOTIABLE = new PriceTypeEnumeration("negotiable");
+ /**
+ * String value encapsulated
+ */
+ private final String value;
+
+ /**
+ * Creates a new instance of PriceTypeEnumeration
+ *
+ * @param value Value to encapsulate
+ */
+ private PriceTypeEnumeration(final String value) {
+ this.value = value;
+ }
+
+ /**
+ * Returns the string value of this instance.
+ *
+ * @return Returns the string value of this instance.
+ */
+ public String getValue() {
+ return value;
+ }
+
+ /**
+ * Returns a PriceTypeEnumeration based on the String value or null.
+ *
+ * @param value Value to search for.
+ * @return PriceTypeEnumeration or null.
+ */
+ public static PriceTypeEnumeration findByValue(final String value) {
+ if (value.equalsIgnoreCase("negotiable")) {
+ return PriceTypeEnumeration.NEGOTIABLE;
+ } else {
+ return PriceTypeEnumeration.STARTING;
+ }
+ }
+
+ /**
+ * Returns a duplicate of this instance
+ *
+ * @return The same instance.
+ */
+ @Override
+ public Object clone() {
+ return this;
+ }
+
+ /**
+ * Returns the string value of this instance.
+ *
+ * @return Returns the string value of this instance.
+ */
+ @Override
+ public String toString() {
+ return value;
+ }
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/base/types/ShippingType.java b/rome-modules/src/main/java/com/rometools/modules/base/types/ShippingType.java
new file mode 100644
index 0000000..daae24d
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/base/types/ShippingType.java
@@ -0,0 +1,200 @@
+/*
+ * ShippingType.java
+ *
+ * Created on November 16, 2005, 12:05 PM
+ *
+ * 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.
+ */
+package com.rometools.modules.base.types;
+
+import java.util.HashMap;
+
+/**
+ * This class represents a specific shipping option for an item.
+ *
+ * @author Robert "kebernet" Cooper
+ * @version $Revision: 1.1 $
+ */
+public class ShippingType implements CloneableType {
+ /**
+ * price of the shipping.
+ */
+ private final FloatUnit price;
+ /**
+ * Service used.
+ */
+ private final ServiceEnumeration service;
+ /**
+ * Country to ship to
+ */
+ private final String country;
+
+ /**
+ * Creates a new instance of ShippingType
+ *
+ * @param price The price of the shipping option
+ * @param service Shipping service used.
+ * @param country Country shipped to.
+ */
+ public ShippingType(final FloatUnit price, final ServiceEnumeration service, final String country) {
+ this.price = price;
+ this.service = service;
+ this.country = country;
+ }
+
+ /**
+ * Returns the destination country.
+ *
+ * @return Returns the destination country.
+ */
+ public String getCountry() {
+ return country;
+ }
+
+ /**
+ * Returns the price of this shipping option.
+ *
+ * @return Returns the price of this shipping option.
+ */
+ public FloatUnit getPrice() {
+ return price;
+ }
+
+ /**
+ * Returns the ServiceEnumeration instance for the shipping service used.
+ *
+ * @return Returns the ServiceEnumeration instance for the shipping service used.
+ */
+ public ServiceEnumeration getService() {
+ return service;
+ }
+
+ /**
+ * Clones this object.
+ *
+ * @return Duplicate ShippingType object.
+ */
+ @Override
+ public Object clone() {
+ return new ShippingType(price, service, country);
+ }
+
+ /**
+ * Returns a String representation of this object.
+ *
+ * @return String representation of this object.
+ */
+ @Override
+ public String toString() {
+ return country + " " + price + " " + service;
+ }
+
+ @Override
+ public boolean equals(final Object o) {
+ if (!(o instanceof ShippingType)) {
+ return false;
+ }
+ if (toString().equals(o.toString())) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Enumeration class of valid options for ServiceType.
+ */
+ public static class ServiceEnumeration {
+ /**
+ * Looks up a ServiceEnumeration based on the string value.
+ */
+ private static final HashMap lookup = new HashMap();
+ /**
+ * Standard
+ */
+ public static final ServiceEnumeration STANDARD = new ServiceEnumeration("Standard");
+ /**
+ * Freight
+ */
+ public static final ServiceEnumeration FREIGHT = new ServiceEnumeration("Freight");
+ /**
+ * Overnight
+ */
+ public static final ServiceEnumeration OVERNIGHT = new ServiceEnumeration("Overnight");
+
+ /**
+ * String value
+ */
+ private final String value;
+
+ /**
+ * Creates a new instance of ServiceEnumeration.
+ *
+ * @param value String value to encapsulate.
+ */
+ private ServiceEnumeration(final String value) {
+ this.value = value;
+ lookup.put(this.value.toUpperCase(), this);
+ }
+
+ /**
+ * String value of this Service.
+ *
+ * @return String value of this Service.
+ */
+ public String getValue() {
+ return value;
+ }
+
+ /**
+ * Looks up a ServiceEnumeration based on the string value.
+ *
+ * @param value String value to search for.
+ * @return ServiceEnumeration or null.
+ */
+ public static ServiceEnumeration findByValue(final String value) {
+ return lookup.get(value.toUpperCase());
+ }
+
+ /**
+ * String value of this Service.
+ *
+ * @return String value of this Service.
+ */
+ @Override
+ public String toString() {
+ return value;
+ }
+ }
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/base/types/ShortDate.java b/rome-modules/src/main/java/com/rometools/modules/base/types/ShortDate.java
new file mode 100644
index 0000000..952ee67
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/base/types/ShortDate.java
@@ -0,0 +1,91 @@
+/*
+ * ShortDate.java
+ *
+ * Created on November 17, 2005, 1:04 PM
+ *
+ * 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.
+ */
+package com.rometools.modules.base.types;
+
+import java.util.Date;
+
+/**
+ * This is a simple wrapper for java.util.Date that indicates it should be formatted without time of
+ * day for Google Base. It should be transparent to module developers.
+ *
+ * Move along. Nothing to see here.
+ *
+ * @author Robert "kebernet" Cooper
+ * @version $Revision: 1.1 $
+ */
+public class ShortDate extends Date implements CloneableType {
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+ /** Creates a new instance of ShortDate */
+ public ShortDate() {
+ super();
+ }
+
+ /**
+ * Creates a new Short Date based on a Date value.
+ *
+ * @param date Date value to read from.
+ */
+ public ShortDate(final Date date) {
+ super(date.getTime());
+ }
+
+ /**
+ * Creates a new ShortDate based on a millisecond time.
+ *
+ * @param time Millisecond time to start with.
+ */
+ public ShortDate(final long time) {
+ super(time);
+ }
+
+ /**
+ * Returns a duplicate of this object.
+ *
+ * @return Duplicate of the object.
+ */
+ @Override
+ public Object clone() {
+ return new ShortDate(getTime());
+ }
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/base/types/Size.java b/rome-modules/src/main/java/com/rometools/modules/base/types/Size.java
new file mode 100644
index 0000000..a913368
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/base/types/Size.java
@@ -0,0 +1,168 @@
+/*
+ * Size.java
+ *
+ * Created on November 16, 2005, 1:51 PM
+ *
+ * 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.
+ */
+package com.rometools.modules.base.types;
+
+import java.util.StringTokenizer;
+
+/**
+ * Represents the size on an item in 2 or 3 dimensions.
+ *
+ * @author Robert "kebernet" Cooper
+ * @version $Revision: 1.2 $
+ */
+public class Size implements CloneableType {
+ /**
+ * height
+ */
+ private FloatUnit height;
+ /**
+ * length
+ */
+ private final FloatUnit length;
+ /**
+ * width
+ */
+ private final FloatUnit width;
+
+ /**
+ * Creates a new Size object parsing a string value.
+ *
+ * @param source String value to parse
+ */
+ public Size(final String source) {
+ final StringTokenizer tok = new StringTokenizer(source, "Xx");
+ length = new FloatUnit(tok.nextToken());
+ width = new FloatUnit(tok.nextToken());
+
+ if (tok.hasMoreTokens()) {
+ height = new FloatUnit(tok.nextToken());
+ }
+ }
+
+ /**
+ * Creates a new instance of Size
+ *
+ * @param length lenght value
+ * @param width width value
+ */
+ public Size(final FloatUnit length, final FloatUnit width) {
+ this.length = length;
+ this.width = width;
+ }
+
+ /**
+ * Creates a new instance of Size.
+ *
+ * @param length Length value.
+ * @param width Width value.
+ * @param height Height value.
+ */
+ public Size(final FloatUnit length, final FloatUnit width, final FloatUnit height) {
+ this.length = length;
+ this.width = width;
+ this.height = height;
+ }
+
+ /**
+ * Height value.
+ *
+ * @return Height value.
+ */
+ public FloatUnit getHeight() {
+ return height;
+ }
+
+ /**
+ * Length value.
+ *
+ * @return Length value.
+ */
+ public FloatUnit getLength() {
+ return length;
+ }
+
+ /**
+ * Width value.
+ *
+ * @return Width value.
+ */
+ public FloatUnit getWidth() {
+ return width;
+ }
+
+ /**
+ * Duplicates this object.
+ *
+ * @return A duplicate Size object.
+ */
+ @Override
+ public Object clone() {
+ if (height != null) {
+ return new Size(length, width, height);
+ } else {
+ return new Size(length, width);
+ }
+ }
+
+ /**
+ * Returns a string representation of this object.
+ *
+ * @return A string representation of this object.
+ */
+ @Override
+ public String toString() {
+ if (height != null) {
+ return length + "x" + width + "x" + height;
+ } else {
+ return length + "x" + width;
+ }
+ }
+
+ @Override
+ public boolean equals(final Object o) {
+ if (!(o instanceof Size)) {
+ return false;
+ }
+ if (toString().equals(o.toString())) {
+ return true;
+ }
+ return false;
+ }
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/base/types/YearType.java b/rome-modules/src/main/java/com/rometools/modules/base/types/YearType.java
new file mode 100644
index 0000000..e4887b7
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/base/types/YearType.java
@@ -0,0 +1,107 @@
+/*
+ * YearType.java
+ *
+ * Created on November 17, 2005, 11:42 PM
+ *
+ * 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.
+ */
+package com.rometools.modules.base.types;
+
+import java.util.Calendar;
+import java.util.Date;
+
+/**
+ * This class represents a simple 4 digit year.
+ *
+ * @author Robert "kebernet" Cooper
+ * @version $Revision: 1.1 $
+ */
+public class YearType implements CloneableType {
+ /**
+ * year value
+ */
+ int year;
+
+ /**
+ * Creates a new year from a string value.
+ *
+ * @param year String to parse.
+ */
+ public YearType(final String year) {
+ this.year = Integer.parseInt(year.trim());
+ }
+
+ /**
+ * Creates a new instance of YearType
+ *
+ * @param date Date to get the year from.
+ */
+ public YearType(final Date date) {
+ final Calendar cal = Calendar.getInstance();
+ cal.setTime(date);
+ year = cal.get(Calendar.YEAR);
+ }
+
+ /**
+ * Duplicates this object.
+ *
+ * @return Cloned Year.
+ */
+ @Override
+ public Object clone() {
+ return new YearType(Integer.toString(year));
+ }
+
+ /**
+ * Returns a String representation of this object.
+ *
+ * @return Returns a String representation of this object.
+ */
+ @Override
+ public String toString() {
+ return Integer.toString(year);
+ }
+
+ @Override
+ public boolean equals(final Object o) {
+ if (!(o instanceof YearType)) {
+ return false;
+ }
+ if (toString().equals(o.toString())) {
+ return true;
+ }
+ return false;
+ }
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/base/types/package.html b/rome-modules/src/main/java/com/rometools/modules/base/types/package.html
new file mode 100644
index 0000000..618ff0c
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/base/types/package.html
@@ -0,0 +1,45 @@
+
+
+
+
+
+
+
+ This package contains complex and utility datatypes for use with Google Base.
+
+ * 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.
+
+
+
diff --git a/rome-modules/src/main/java/com/rometools/modules/cc/CreativeCommons.java b/rome-modules/src/main/java/com/rometools/modules/cc/CreativeCommons.java
new file mode 100644
index 0000000..24d3345
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/cc/CreativeCommons.java
@@ -0,0 +1,61 @@
+/*
+ * CreativeCommons.java
+ *
+ * Created on November 20, 2005, 5:05 PM
+ *
+ * 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.
+ */
+
+package com.rometools.modules.cc;
+
+import com.rometools.modules.cc.types.License;
+import com.rometools.rome.feed.module.Module;
+
+/**
+ *
+ * @author Robert "kebernet" Cooper
+ */
+public interface CreativeCommons extends Module {
+
+ public static final String URI = "rome:CreativeCommons";
+
+ public License[] getAllLicenses();
+
+ public void setAllLicenses(License[] licenses);
+
+ public License[] getLicenses();
+
+ public void setLicenses(License[] license);
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/cc/CreativeCommonsImpl.java b/rome-modules/src/main/java/com/rometools/modules/cc/CreativeCommonsImpl.java
new file mode 100644
index 0000000..1ea754a
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/cc/CreativeCommonsImpl.java
@@ -0,0 +1,136 @@
+/*
+ * AbstractCreativeCommons.java
+ *
+ * Created on November 20, 2005, 5:12 PM
+ *
+ * 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.
+ */
+
+package com.rometools.modules.cc;
+
+import java.lang.reflect.Array;
+
+import com.rometools.modules.cc.types.License;
+import com.rometools.rome.feed.CopyFrom;
+import com.rometools.rome.feed.impl.EqualsBean;
+import com.rometools.rome.feed.impl.ToStringBean;
+
+/**
+ * @version $Revision: 1.1 $
+ * @author Robert "kebernet" Cooper
+ */
+public class CreativeCommonsImpl implements CreativeCommons {
+
+ private static final long serialVersionUID = 1L;
+
+ public static final String RDF_URI = "http://www.w3.org/1999/02/22-rdf-syntax-ns#";
+ public static final String RSS2_URI = "http://backend.userland.com/creativeCommonsRssModule";
+ public static final String RSS1_URI = "http://web.resource.org/cc/";
+
+ private License[] allLicenses;
+ private License[] licenses;
+
+ protected Object arrayCopy(final Object[] source) {
+ if (source == null) {
+ return null;
+ }
+
+ final Object[] array = (Object[]) Array.newInstance(source.getClass().getComponentType(), source.length);
+
+ for (int i = 0; i < source.length; i++) {
+ array[i] = source[i];
+ }
+
+ return array;
+ }
+
+ @Override
+ public License[] getAllLicenses() {
+ return allLicenses;
+ }
+
+ @Override
+ public void setAllLicenses(final License[] allLicenses) {
+ this.allLicenses = allLicenses;
+ }
+
+ @Override
+ public Class getInterface() {
+ return CreativeCommons.class;
+ }
+
+ @Override
+ public String getUri() {
+ return CreativeCommons.URI;
+ }
+
+ @Override
+ public Object clone() {
+ final CreativeCommonsImpl clone = new CreativeCommonsImpl();
+ clone.copyFrom(this);
+ return clone;
+ }
+
+ @Override
+ public void copyFrom(final CopyFrom object) {
+ final CreativeCommons source = (CreativeCommons) object;
+ setAllLicenses((License[]) arrayCopy(source.getAllLicenses()));
+ setLicenses(source.getLicenses());
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ final EqualsBean eBean = new EqualsBean(this.getClass(), this);
+
+ return eBean.beanEquals(obj);
+ }
+
+ @Override
+ public License[] getLicenses() {
+ return licenses;
+ }
+
+ @Override
+ public void setLicenses(final License[] licenses) {
+ this.licenses = licenses;
+ }
+
+ @Override
+ public String toString() {
+ final ToStringBean tsb = new ToStringBean(CreativeCommonsImpl.class, this);
+ return tsb.toString();
+ }
+
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/cc/io/CCModuleGenerator.java b/rome-modules/src/main/java/com/rometools/modules/cc/io/CCModuleGenerator.java
new file mode 100644
index 0000000..de0e065
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/cc/io/CCModuleGenerator.java
@@ -0,0 +1,151 @@
+/*
+ * CCModuleGenerator.java
+ *
+ * Created on November 20, 2005, 5:23 PM
+ *
+ * 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.
+ */
+
+package com.rometools.modules.cc.io;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.jdom2.Element;
+import org.jdom2.Namespace;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.rometools.modules.cc.CreativeCommons;
+import com.rometools.modules.cc.CreativeCommonsImpl;
+import com.rometools.modules.cc.types.License;
+import com.rometools.rome.feed.module.Module;
+import com.rometools.rome.io.ModuleGenerator;
+
+/**
+ * @version $Revision: 1.1 $
+ * @author Robert "kebernet" Cooper
+ */
+public class CCModuleGenerator implements ModuleGenerator {
+
+ private static final Logger LOG = LoggerFactory.getLogger(CCModuleGenerator.class);
+
+ private static final Namespace RSS1 = Namespace.getNamespace("cc", CreativeCommonsImpl.RSS1_URI);
+ private static final Namespace RSS2 = Namespace.getNamespace("creativeCommons", CreativeCommonsImpl.RSS2_URI);
+ private static final Namespace RSS = Namespace.getNamespace("http://purl.org/rss/1.0/");
+ private static final Namespace RDF = Namespace.getNamespace("rdf", "http://www.w3.org/1999/02/22-rdf-syntax-ns#");
+ private static final HashSet NAMESPACES = new HashSet();
+ static {
+ NAMESPACES.add(RSS1);
+ NAMESPACES.add(RSS2);
+ NAMESPACES.add(RDF);
+ }
+
+ /**
+ * Creates a new instance of CCModuleGenerator
+ */
+ public CCModuleGenerator() {
+ super();
+ }
+
+ @Override
+ public void generate(final Module module, final Element element) {
+ Element root = element;
+ while (root.getParentElement() != null) {
+ root = root.getParentElement();
+ }
+ if (root.getNamespace().equals(RDF) || root.getNamespace().equals(RSS)) {
+ generateRSS1((CreativeCommons) module, element);
+ } else {
+ generateRSS2((CreativeCommons) module, element);
+ }
+ }
+
+ @Override
+ public Set getNamespaces() {
+ return NAMESPACES;
+ }
+
+ @Override
+ public String getNamespaceUri() {
+ return CreativeCommons.URI;
+ }
+
+ private void generateRSS1(final CreativeCommons module, final Element element) {
+ // throw new RuntimeException( "Generating RSS1 Feeds not currently Supported.");
+
+ LOG.debug(element.getName());
+ if (element.getName().equals("channel")) {
+ // Do all licenses list.
+ final License[] all = module.getAllLicenses();
+ for (final License element2 : all) {
+ final Element license = new Element("License", RSS1);
+ license.setAttribute("about", element2.getValue(), RDF);
+ final License.Behaviour[] permits = element2.getPermits();
+ for (int j = 0; permits != null && j < permits.length; j++) {
+ final Element permit = new Element("permits", RSS1);
+ permit.setAttribute("resource", permits[j].toString(), RDF);
+ license.addContent(permit);
+ }
+ final License.Behaviour[] requires = element2.getPermits();
+ for (int j = 0; requires != null && j < requires.length; j++) {
+ final Element permit = new Element("requires", RSS1);
+ permit.setAttribute("resource", permits[j].toString(), RDF);
+ license.addContent(permit);
+ }
+ LOG.debug("Is Root? {}", element.getParentElement());
+ element.getParentElement().addContent(license);
+ }
+ }
+
+ // Do local licenses
+ final License[] licenses = module.getLicenses();
+ for (final License license2 : licenses) {
+ final Element license = new Element("license", RSS1);
+ license.setAttribute("resource", license2.getValue(), RDF);
+ element.addContent(license);
+ }
+
+ }
+
+ private void generateRSS2(final CreativeCommons module, final Element element) {
+ final License[] licenses = module.getLicenses();
+ for (int i = 0; licenses != null && i < licenses.length; i++) {
+ final Element license = new Element("license", RSS2);
+ license.setText(licenses[i].getValue());
+ element.addContent(license);
+ }
+ }
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/cc/io/ModuleParserRSS1.java b/rome-modules/src/main/java/com/rometools/modules/cc/io/ModuleParserRSS1.java
new file mode 100644
index 0000000..04ba046
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/cc/io/ModuleParserRSS1.java
@@ -0,0 +1,139 @@
+/*
+ * CCModuleParser.java
+ *
+ * Created on November 20, 2005, 5:23 PM
+ *
+ * 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.
+ */
+
+package com.rometools.modules.cc.io;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+
+import org.jdom2.Element;
+import org.jdom2.Namespace;
+
+import com.rometools.modules.cc.CreativeCommonsImpl;
+import com.rometools.modules.cc.types.License;
+import com.rometools.modules.cc.types.License.Behaviour;
+import com.rometools.rome.feed.module.Module;
+import com.rometools.rome.io.ModuleParser;
+
+/**
+ * @version $Revision: 1.3 $
+ * @author Robert "kebernet" Cooper
+ */
+public class ModuleParserRSS1 implements ModuleParser {
+
+ private static final Namespace NS = Namespace.getNamespace(CreativeCommonsImpl.RSS1_URI);
+ static final Namespace RDF = Namespace.getNamespace(CreativeCommonsImpl.RDF_URI);
+
+ /**
+ * Creates a new instance of ModuleParserRSS1
+ */
+ public ModuleParserRSS1() {
+ }
+
+ @Override
+ public Module parse(final Element element, final Locale locale) {
+ final CreativeCommonsImpl module = new CreativeCommonsImpl();
+ {
+ // Parsing Channel level.
+ Element root = element;
+ while (root.getParentElement() != null) {
+ root = root.getParentElement();
+ }
+ final List licenseList = root.getChildren("License", NS);
+ final ArrayList licenses = new ArrayList();
+ final Iterator it = licenseList.iterator();
+ while (it.hasNext()) {
+ final Element licenseTag = it.next();
+ final String licenseURI = licenseTag.getAttributeValue("about", RDF);
+ if (licenseURI == null) {
+ continue;
+ }
+ License license = License.findByValue(licenseURI);
+ {
+ final ArrayList permitsValues = new ArrayList();
+ final ArrayList requiresValues = new ArrayList();
+ final List permitsTags = licenseTag.getChildren("permits", NS);
+ Iterator sit = permitsTags.iterator();
+ while (sit.hasNext()) {
+ final Element permitTag = sit.next();
+ permitsValues.add(License.Behaviour.findByValue(permitTag.getAttributeValue("resource", RDF)));
+ }
+ final List requiresTags = licenseTag.getChildren("requires", NS);
+ sit = requiresTags.iterator();
+ while (sit.hasNext()) {
+ final Element requireTag = sit.next();
+ requiresValues.add(License.Behaviour.findByValue(requireTag.getAttributeValue("resource", RDF)));
+ }
+ license = new License(licenseURI, requiresValues.toArray(new License.Behaviour[requiresValues.size()]),
+ permitsValues.toArray(new License.Behaviour[permitsValues.size()]));
+
+ }
+
+ licenses.add(license);
+ }
+ module.setAllLicenses(licenses.toArray(new License[0]));
+ }
+ final ArrayList licenses = new ArrayList();
+ final List licenseTags = element.getChildren("license", NS);
+ final Iterator lit = licenseTags.iterator();
+ while (lit.hasNext()) {
+ final Element licenseTag = lit.next();
+ licenses.add(License.findByValue(licenseTag.getAttributeValue("resource", RDF)));
+ }
+
+ if (!licenses.isEmpty()) {
+ module.setLicenses(licenses.toArray(new License[licenses.size()]));
+ }
+
+ if (module.getLicenses() != null || module.getAllLicenses() != null) {
+ return module;
+ } else {
+ return null;
+ }
+ }
+
+ @Override
+ public String getNamespaceUri() {
+ return CreativeCommonsImpl.RSS1_URI;
+ }
+
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/cc/io/ModuleParserRSS2.java b/rome-modules/src/main/java/com/rometools/modules/cc/io/ModuleParserRSS2.java
new file mode 100644
index 0000000..8030c68
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/cc/io/ModuleParserRSS2.java
@@ -0,0 +1,127 @@
+/*
+ * ModuleParserRSS2.java
+ *
+ * Created on November 20, 2005, 6:15 PM
+ *
+ * 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.
+ */
+
+package com.rometools.modules.cc.io;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+
+import org.jdom2.Element;
+import org.jdom2.Namespace;
+
+import com.rometools.modules.cc.CreativeCommonsImpl;
+import com.rometools.modules.cc.types.License;
+import com.rometools.rome.feed.module.Module;
+import com.rometools.rome.io.ModuleParser;
+
+/**
+ *
+ * @version $Revision: 1.3 $
+ * @author Robert "kebernet" Cooper
+ */
+public class ModuleParserRSS2 implements ModuleParser {
+
+ private static final Namespace NS = Namespace.getNamespace(CreativeCommonsImpl.RSS2_URI);
+
+ /** Creates a new instance of ModuleParserRSS2 */
+ public ModuleParserRSS2() {
+ }
+
+ @Override
+ public Module parse(final Element element, final Locale locale) {
+ final CreativeCommonsImpl module = new CreativeCommonsImpl();
+ // Do channel global
+ {
+ Element root = element;
+ while (!root.getName().equals("channel") && !root.getName().equals("feed")) {
+ root = root.getParentElement();
+ }
+ final ArrayList licenses = new ArrayList();
+ List items = null;
+ if (root.getName().equals("channel")) {
+ items = root.getChildren("item");
+ } else {
+ items = root.getChildren("entry");
+ }
+
+ final Iterator iit = items.iterator();
+ while (iit.hasNext()) {
+ final Element item = iit.next();
+ final List licenseTags = item.getChildren("license", NS);
+ final Iterator lit = licenseTags.iterator();
+ while (lit.hasNext()) {
+ final Element licenseTag = lit.next();
+ final License license = License.findByValue(licenseTag.getTextTrim());
+ if (!licenses.contains(license)) {
+ ;
+ }
+ licenses.add(license);
+ }
+ }
+ if (!licenses.isEmpty()) {
+ module.setAllLicenses(licenses.toArray(new License[0]));
+ }
+ }
+ // do element local
+ final ArrayList licenses = new ArrayList();
+ final List licenseTags = element.getChildren("license", NS);
+ final Iterator it = licenseTags.iterator();
+ while (it.hasNext()) {
+ final Element licenseTag = it.next();
+ licenses.add(License.findByValue(licenseTag.getTextTrim()));
+ }
+ if (!licenses.isEmpty()) {
+ module.setLicenses(licenses.toArray(new License[0]));
+ }
+
+ if (module.getLicenses() != null && module.getAllLicenses() != null) {
+ return module;
+ } else {
+ return null;
+ }
+ }
+
+ @Override
+ public String getNamespaceUri() {
+ return CreativeCommonsImpl.RSS2_URI;
+ }
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/cc/package.html b/rome-modules/src/main/java/com/rometools/modules/cc/package.html
new file mode 100644
index 0000000..0a0fbb7
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/cc/package.html
@@ -0,0 +1,80 @@
+
+
+
+
+
+
+
+ This is a module for ROME that supports both the
+ "CC" RSS1 module and the
+ RSS 2 (and Atom)
+ module in a unified manner.
+
+
It does this by superimposing the "rome:creativecommon" namespace over both of them
+ for the purposes of the module, and synchronizes them into a unified structure. For RSS2
+ it attempts to correlate the license into a code-capable fashion. If the license link
+ goes to one of the standard licenses at creativecommons.org, it will populate the permissions
+ based on it's know set (See License.Behaviour).
+
+
The module has 2 fields on it. One is "allLicenses". This is simply an array of all licenses
+ in a feed. The second one "licenses" contains licenses that apply to a specific element (feed or
+ entry). Licenses then contain "permits" and "requires" behaviours. If a license is used that
+ the system can't determine anything about, these will be null. Zero-lenght means "known and
+ empty."
+
+
At this time, because of a ROME limitation, writing RSS1 feeds is not possible. However,
+ if you read an RSS1 feed, you can convert it to an RSS2 feed properly.
+
+
Sample Usage:
+
+
+ CreativeCommons commons = new CreativeCommonsImpl();
+ commons.setLicense( new License[]{ License.NONCOMMERCIAL } );
+ // Note, you do not have to setAllLicenses right now. When the RSS1 functionality is
+ // added, this will be required at the Feed level only.
+ ArrayList modules = new ArrayList()
+ modules.add( commons );
+ syndEntry.setModules( commons );
+
+ //Alternately, to get the module:
+ CreativeCommons commons = (CreativeCommons) syndFeed.getModule( CreativeCommons.URI );
+
+
+
+
+ * 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.
+
+
+
diff --git a/rome-modules/src/main/java/com/rometools/modules/cc/types/License.java b/rome-modules/src/main/java/com/rometools/modules/cc/types/License.java
new file mode 100644
index 0000000..29ec5eb
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/cc/types/License.java
@@ -0,0 +1,197 @@
+/*
+ * LicenseEnumeration.java
+ *
+ * Created on November 20, 2005, 3:20 PM
+ *
+ * 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.
+ */
+package com.rometools.modules.cc.types;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.StringTokenizer;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.rometools.rome.feed.impl.EqualsBean;
+import com.rometools.rome.feed.impl.ToStringBean;
+
+/**
+ * @version $Revision: 1.1 $
+ * @author Robert "kebernet" Cooper
+ */
+public class License {
+
+ private static final String CC_START = "http://creativecommons.org/licenses/";
+ private static final Map lookupLicense = new ConcurrentHashMap();
+ private static final Logger LOG = LoggerFactory.getLogger(License.class);
+ public static final License NO_DERIVS = new License("http://creativecommons.org/licenses/nd/1.0/", new Behaviour[0], new Behaviour[] {
+ Behaviour.DISTRIBUTION, Behaviour.REPRODUCTION});
+ public static final License NO_DERIVS_NONCOMMERCIAL = new License("http://creativecommons.org/licenses/nd-nc/1.0/",
+ new Behaviour[] {Behaviour.NONCOMMERCIAL}, new Behaviour[] {Behaviour.DISTRIBUTION, Behaviour.REPRODUCTION});
+ public static final License NONCOMMERCIAL = new License("http://creativecommons.org/licenses/nc/1.0/", new Behaviour[] {Behaviour.NONCOMMERCIAL},
+ new Behaviour[] {Behaviour.DERIVATIVE, Behaviour.DISTRIBUTION, Behaviour.REPRODUCTION});
+ public static final License SHARE_ALIKE = new License("http://creativecommons.org/licenses/sa/1.0/", new Behaviour[] {Behaviour.COPYLEFT}, new Behaviour[] {
+ Behaviour.DERIVATIVE, Behaviour.DISTRIBUTION, Behaviour.REPRODUCTION});
+ public static final License SHARE_ALIKE_NONCOMMERCIAL = new License("http://creativecommons.org/licenses/nc-sa/1.0/", new Behaviour[] {Behaviour.COPYLEFT,
+ Behaviour.NONCOMMERCIAL}, new Behaviour[] {Behaviour.DERIVATIVE, Behaviour.DISTRIBUTION, Behaviour.REPRODUCTION});
+ public static final License SHARE_ALIKE_ATTRIBUTION = new License("http://creativecommons.org/licenses/by-sa/2.5/", new Behaviour[] {Behaviour.COPYLEFT,
+ Behaviour.ATTRIBUTION}, new Behaviour[] {Behaviour.DERIVATIVE, Behaviour.DISTRIBUTION, Behaviour.REPRODUCTION});
+ public static final License SHARE_ALIKE_NONCOMMERCIAL_ATTRIBUTION = new License("http://creativecommons.org/licenses/by-nc-sa/2.5/", new Behaviour[] {
+ Behaviour.COPYLEFT, Behaviour.ATTRIBUTION, Behaviour.NONCOMMERCIAL}, new Behaviour[] {Behaviour.DERIVATIVE, Behaviour.DISTRIBUTION,
+ Behaviour.REPRODUCTION});
+ public static final License NONCOMMERCIAL_ATTRIBUTION = new License("http://creativecommons.org/licenses/by-nc/2.5/", new Behaviour[] {
+ Behaviour.ATTRIBUTION, Behaviour.NONCOMMERCIAL}, new Behaviour[] {Behaviour.DERIVATIVE, Behaviour.DISTRIBUTION, Behaviour.REPRODUCTION});
+ public static final License NONCOMMERCIAL_ATTRIBUTION_NO_DERIVS = new License("http://creativecommons.org/licenses/by-nc-nd/2.5/", new Behaviour[] {
+ Behaviour.ATTRIBUTION, Behaviour.NONCOMMERCIAL}, new Behaviour[] {Behaviour.DISTRIBUTION, Behaviour.REPRODUCTION});
+ public static final License ATTRIBUTION_NO_DERIVS = new License("http://creativecommons.org/licenses/by-nd/2.5/", new Behaviour[] {Behaviour.ATTRIBUTION},
+ new Behaviour[] {Behaviour.DISTRIBUTION, Behaviour.REPRODUCTION});
+ public static final License ATTRIBUTION = new License("http://creativecommons.org/licenses/by/2.5/", new Behaviour[] {Behaviour.ATTRIBUTION},
+ new Behaviour[] {Behaviour.DERIVATIVE, Behaviour.DISTRIBUTION, Behaviour.REPRODUCTION});
+ private final String uri;
+ private final Behaviour[] permits;
+ private final Behaviour[] requires;
+
+ /**
+ * Creates a new instance of License
+ */
+ public License(final String uri, final Behaviour[] requires, final Behaviour[] permits) {
+ this.requires = requires;
+ this.permits = permits;
+ this.uri = uri;
+ License.lookupLicense.put(uri, this);
+
+ if (this.uri.endsWith("/")) {
+ // LOG.debug(uri.substring(0,this.uri.lastIndexOf("/")));
+ License.lookupLicense.put(uri.substring(0, this.uri.lastIndexOf("/")), this);
+ }
+ }
+
+ public static License findByValue(final String uri) {
+ License found = License.lookupLicense.get(uri);
+
+ // No I am going to try an guess about unknown licenses
+ // This is try and match known CC licenses of other versions or various URLs to
+ // current licenses, then make a new one with the same permissions.
+ if (found == null && uri.startsWith("http://") && uri.toLowerCase().indexOf("creativecommons.org") != -1) {
+ final Iterator it = License.lookupLicense.keySet().iterator();
+ while (it.hasNext() && found == null) {
+ final String key = it.next();
+ try {
+ if (key.startsWith(CC_START)) {
+ final String licensePath = key.substring(CC_START.length(), key.length());
+ final StringTokenizer tok = new StringTokenizer(licensePath, "/");
+ final String license = tok.nextToken();
+ // final String version = tok.nextToken();
+ if (uri.toLowerCase().indexOf("creativecommons.org/licenses/" + license) != -1) {
+ final License current = lookupLicense.get(key);
+ found = new License(uri, current.getRequires(), current.getPermits());
+ }
+ }
+ } catch (final Exception e) {
+ LOG.error("Error", e);
+ }
+ }
+ }
+ // OK, we got here. If we haven't found a match, return a new License with unknown
+ // permissions.
+ if (found == null) {
+ found = new License(uri, null, null);
+ }
+ return found;
+ }
+
+ /**
+ * This is just useful for testing to allow clearing of the looked up licenses.
+ */
+ static void clear() {
+ lookupLicense.clear();
+ }
+
+ public Behaviour[] getPermits() {
+ return permits;
+ }
+
+ public Behaviour[] getRequires() {
+ return requires;
+ }
+
+ @Override
+ public String toString() {
+
+ final ToStringBean tsb = new ToStringBean(License.class, this);
+ return tsb.toString();
+ }
+
+ public String getValue() {
+ return uri;
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ final EqualsBean eBean = new EqualsBean(License.class, this);
+ return eBean.beanEquals(obj);
+ }
+
+ @Override
+ public int hashCode() {
+ final EqualsBean equals = new EqualsBean(License.class, this);
+ return equals.beanHashCode();
+ }
+
+ public static class Behaviour {
+ private static final Map lookup = new HashMap();
+ public static final Behaviour REPRODUCTION = new Behaviour("http://web.resource.org/cc/Reproduction");
+ public static final Behaviour DISTRIBUTION = new Behaviour("http://web.resource.org/cc/Distribution");
+ public static final Behaviour DERIVATIVE = new Behaviour("http://web.resource.org/cc/DerivativeWorks");
+ public static final Behaviour NOTICE = new Behaviour("http://web.resource.org/cc/Notice");
+ public static final Behaviour ATTRIBUTION = new Behaviour("http://web.resource.org/cc/Attribution");
+ public static final Behaviour COPYLEFT = new Behaviour("http://web.resource.org/cc/Copyleft");
+ public static final Behaviour NONCOMMERCIAL = new Behaviour("http://web.resource.org/cc/Noncommercial");
+ private final String uri;
+
+ private Behaviour(final String uri) {
+ this.uri = uri;
+ Behaviour.lookup.put(uri, this);
+ }
+
+ public static Behaviour findByValue(final String uri) {
+ return Behaviour.lookup.get(uri);
+ }
+
+ @Override
+ public String toString() {
+ return uri;
+ }
+ }
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/cc/types/package.html b/rome-modules/src/main/java/com/rometools/modules/cc/types/package.html
new file mode 100644
index 0000000..d1ef41e
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/cc/types/package.html
@@ -0,0 +1,45 @@
+
+
+
+
+
+
+
+This package contains datatypes for use with the plug in.
+
+ * 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.
+
+
+
diff --git a/rome-modules/src/main/java/com/rometools/modules/content/ContentItem.java b/rome-modules/src/main/java/com/rometools/modules/content/ContentItem.java
new file mode 100644
index 0000000..34f95e3
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/content/ContentItem.java
@@ -0,0 +1,211 @@
+/*
+ * ContentItem.java
+ *
+ * Created on January 12, 2005, 8:52 AM
+ *
+ * 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.
+ *
+ *
+ */
+package com.rometools.modules.content;
+
+import java.util.List;
+
+import org.jdom2.Content;
+import org.jdom2.Namespace;
+
+/**
+ * This class represents a content item per the "Original Syntax".
+ * http://purl.org/rss/1.0/modules/content/
+ *
+ * @version $Revision: 1.1 $
+ * @author Robert "kebernet" Cooper
+ */
+public class ContentItem implements Cloneable {
+
+ private String contentFormat;
+ private String contentEncoding;
+ private String contentValue;
+ private List contentValueDOM;
+ private String contentAbout;
+ private String contentValueParseType;
+ private List contentValueNamespace;
+ private String contentResource;
+
+ /** Creates a new instance of ContentItem */
+ public ContentItem() {
+ }
+
+ public String getContentFormat() {
+ return contentFormat;
+ }
+
+ public void setContentFormat(final String contentFormat) {
+ this.contentFormat = contentFormat;
+ }
+
+ public String getContentEncoding() {
+ return contentEncoding;
+ }
+
+ public void setContentEncoding(final String contentEncoding) {
+ this.contentEncoding = contentEncoding;
+ }
+
+ public String getContentValue() {
+ return contentValue;
+ }
+
+ public void setContentValue(final String contentValue) {
+ this.contentValue = contentValue;
+ }
+
+ public List getContentValueDOM() {
+ return contentValueDOM;
+ }
+
+ public void setContentValueDOM(final List contentValueDOM) {
+ this.contentValueDOM = contentValueDOM;
+ }
+
+ public String getContentAbout() {
+ return contentAbout;
+ }
+
+ public void setContentAbout(final String contentAbout) {
+ this.contentAbout = contentAbout;
+ }
+
+ public String getContentValueParseType() {
+ return contentValueParseType;
+ }
+
+ public void setContentValueParseType(final String contentValueParseType) {
+ this.contentValueParseType = contentValueParseType;
+ }
+
+ public List getContentValueNamespaces() {
+ return contentValueNamespace;
+ }
+
+ public void setContentValueNamespaces(final List contentValueNamespace) {
+ this.contentValueNamespace = contentValueNamespace;
+ }
+
+ public String getContentResource() {
+ return contentResource;
+ }
+
+ public void setContentResource(final String contentResource) {
+ this.contentResource = contentResource;
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ final ContentItem other = (ContentItem) obj;
+ if (contentFormat == null ? other.contentFormat != null : !contentFormat.equals(other.contentFormat)) {
+ // LOG.debug("format");
+ return false;
+ }
+ if (contentEncoding == null ? other.contentEncoding != null : !contentEncoding.equals(other.contentEncoding)) {
+ // LOG.debug("enc");
+ return false;
+ }
+ final String thisCV = contentValue.replaceAll(" xmlns=\"http://www.w3.org/1999/xhtml\"", "").trim();
+ ;
+ final String thatCV = other.contentValue.replaceAll(" xmlns=\"http://www.w3.org/1999/xhtml\"", "").trim();
+ if (contentValue == null ? other.contentValue != null : !thisCV.equals(thatCV)) {
+
+ return false;
+ }
+ if (contentValueDOM != other.contentValueDOM && (contentValueDOM == null || !contentValueDOM.equals(other.contentValueDOM))) {
+ // LOG.debug("vd");
+ return false;
+ }
+ if (contentAbout == null ? other.contentAbout != null : !contentAbout.equals(other.contentAbout)) {
+ // LOG.debug("abt");
+ return false;
+ }
+ if (contentValueParseType == null ? other.contentValueParseType != null : !contentValueParseType.equals(other.contentValueParseType)) {
+ // LOG.debug("pt");
+ return false;
+ }
+ if (contentValueNamespace != other.contentValueNamespace
+ && (contentValueNamespace == null || !contentValueNamespace.equals(other.contentValueNamespace))) {
+ // LOG.debug("ns");
+ return false;
+ }
+ if (contentResource == null ? other.contentResource != null : !contentResource.equals(other.contentResource)) {
+ // LOG.debug("res");
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int hash = 7;
+ hash = 97 * hash + (contentFormat != null ? contentFormat.hashCode() : 0);
+ hash = 97 * hash + (contentEncoding != null ? contentEncoding.hashCode() : 0);
+ hash = 97 * hash + (contentValue != null ? contentValue.hashCode() : 0);
+ hash = 97 * hash + (contentValueDOM != null ? contentValueDOM.hashCode() : 0);
+ hash = 97 * hash + (contentAbout != null ? contentAbout.hashCode() : 0);
+ hash = 97 * hash + (contentValueParseType != null ? contentValueParseType.hashCode() : 0);
+ hash = 97 * hash + (contentValueNamespace != null ? contentValueNamespace.hashCode() : 0);
+ hash = 97 * hash + (contentResource != null ? contentResource.hashCode() : 0);
+ return hash;
+ }
+
+ @Override
+ public Object clone() {
+ final ContentItem o = new ContentItem();
+ o.contentAbout = contentAbout;
+ o.contentEncoding = contentEncoding;
+ o.contentFormat = contentFormat;
+ o.contentResource = contentResource;
+ o.contentValue = contentValue;
+ o.contentValueDOM = contentValueDOM;
+ o.contentValueNamespace = contentValueNamespace;
+ o.contentValueParseType = contentValueParseType;
+
+ return o;
+ }
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/content/ContentModule.java b/rome-modules/src/main/java/com/rometools/modules/content/ContentModule.java
new file mode 100644
index 0000000..342701d
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/content/ContentModule.java
@@ -0,0 +1,106 @@
+/*
+ * ContentModule.java
+ *
+ * Created on January 11, 2005, 1:02 PM
+ *
+ *
+ * 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.
+ */
+package com.rometools.modules.content;
+
+import java.util.List;
+
+import com.rometools.rome.feed.module.Module;
+
+/**
+ * @version $Revision: 1.1 $
+ * @author Robert "kebernet" Cooper
+ */
+public interface ContentModule extends Module {
+
+ public static final String URI = "http://purl.org/rss/1.0/modules/content/";
+ public static final String RDF_URI = "http://www.w3.org/1999/02/22-rdf-syntax-ns#";
+
+ /**
+ * Returns a List of Strings containing the New Syntax Encoded values are in the element.
+ *
+ * @return List of content Strings
+ */
+ public List getEncodeds();
+
+ /**
+ * Sets a List of Strings containing the New Syntax Encoded values are in the element.
+ *
+ * @return List of content Strings
+ */
+ public void setEncodeds(List encodeds);
+
+ @Override
+ public String getUri();
+
+ public String toString(String str);
+
+ /**
+ * Contains a list of ContentItems that represent the "Original Syntax" set.
+ *
+ * @see com.totsp.xml.syndication.content.ContentItem
+ * @return List of ContentItems.
+ */
+ public List getContentItems();
+
+ /**
+ * Contains a list of ContentItems that represent the "Original Syntax" set.
+ *
+ * @see com.totsp.xml.syndication.content.ContentItem
+ * @param List of ContentItems.
+ */
+ public void setContentItems(List list);
+
+ /**
+ * Returns a List of Strings containing whatever new or original syntax items are in the
+ * element.
+ *
+ * @return List of content Strings
+ */
+ public List getContents();
+
+ /**
+ * Sets a List of Strings containing whatever new or original syntax items are in the element.
+ *
+ * @return List of content Strings
+ */
+ public void setContents(List contents);
+
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/content/ContentModuleImpl.java b/rome-modules/src/main/java/com/rometools/modules/content/ContentModuleImpl.java
new file mode 100644
index 0000000..e0e345d
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/content/ContentModuleImpl.java
@@ -0,0 +1,122 @@
+/*
+ * ContentModuleImpl.java
+ *
+ * Created on January 11, 2005, 1:07 PM
+ *
+ * Copyright (C) 2005 Robert Cooper, Temple of the Screaming Penguin
+ *
+ * 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.
+ *
+ *
+ */
+package com.rometools.modules.content;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.rometools.rome.feed.CopyFrom;
+import com.rometools.rome.feed.module.ModuleImpl;
+
+/**
+ * @version $Revision: 1.4 $
+ * @author Robert "kebernet" Cooper
+ */
+public class ContentModuleImpl extends ModuleImpl implements ContentModule {
+
+ private static final long serialVersionUID = 1L;
+
+ private List encodeds;
+ private List contents;
+ private List contentItems;
+
+ public ContentModuleImpl() {
+ super(ContentModuleImpl.class, URI);
+ }
+
+ protected ContentModuleImpl(final Class beanClass, final java.lang.String uri) {
+ super(beanClass, uri);
+ }
+
+ @Override
+ public List getEncodeds() {
+ encodeds = encodeds == null ? new ArrayList() : encodeds;
+ return encodeds;
+ }
+
+ @Override
+ public void setEncodeds(final List encodeds) {
+ this.encodeds = encodeds;
+ }
+
+ @Override
+ public void copyFrom(final CopyFrom obj) {
+ final ContentModule cm = (ContentModule) obj;
+ setEncodeds(cm.getEncodeds());
+ setContentItems(cm.getContentItems());
+ setContents(cm.getContents());
+ }
+
+ @Override
+ public Class getInterface() {
+ return ContentModule.class;
+ }
+
+ @Override
+ public List getContentItems() {
+ contentItems = contentItems == null ? new ArrayList() : contentItems;
+ return contentItems;
+ }
+
+ @Override
+ public void setContentItems(final List list) {
+ contentItems = list;
+ }
+
+ @Override
+ public List getContents() {
+ contents = contents == null ? new ArrayList() : contents;
+ return contents;
+ }
+
+ @Override
+ public void setContents(final List contents) {
+ this.contents = contents;
+ }
+
+ @Override
+ public String toString(final String str) {
+ return contentItems.toString();
+ }
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/content/io/ContentModuleGenerator.java b/rome-modules/src/main/java/com/rometools/modules/content/io/ContentModuleGenerator.java
new file mode 100644
index 0000000..3c9126c
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/content/io/ContentModuleGenerator.java
@@ -0,0 +1,201 @@
+/*
+ * ContentModuleGenerator.java
+ *
+ * Created on January 11, 2005, 1:41 PM
+ *
+ * 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.
+ *
+ *
+ */
+package com.rometools.modules.content.io;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.jdom2.Attribute;
+import org.jdom2.CDATA;
+import org.jdom2.Content;
+import org.jdom2.Element;
+import org.jdom2.Namespace;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.rometools.modules.content.ContentItem;
+import com.rometools.modules.content.ContentModule;
+
+/**
+ * @version $Revision: 1.2 $
+ * @author Robert "kebernet" Cooper
+ */
+public class ContentModuleGenerator implements com.rometools.rome.io.ModuleGenerator {
+
+ private static final Logger LOG = LoggerFactory.getLogger(ContentModuleGenerator.class);
+
+ private static final Namespace CONTENT_NS = Namespace.getNamespace("content", ContentModule.URI);
+ private static final Namespace RDF_NS = Namespace.getNamespace("rdf", ContentModule.RDF_URI);
+ private static final Set NAMESPACES;
+
+ static {
+ final Set nss = new HashSet();
+ nss.add(CONTENT_NS);
+ NAMESPACES = Collections.unmodifiableSet(nss);
+ }
+
+ /** Creates a new instance of ContentModuleGenerator */
+ public ContentModuleGenerator() {
+ }
+
+ @Override
+ public void generate(final com.rometools.rome.feed.module.Module module, final org.jdom2.Element element) {
+ // this is not necessary, it is done to avoid the namespace definition in every item.
+ Element root = element;
+
+ while (root.getParent() != null && root.getParent() instanceof Element) {
+ root = (Element) root.getParent();
+ }
+
+ root.addNamespaceDeclaration(CONTENT_NS);
+
+ if (!(module instanceof ContentModule)) {
+ return;
+ }
+
+ final ContentModule cm = (ContentModule) module;
+
+ final List encodeds = cm.getEncodeds();
+
+ if (encodeds != null) {
+ LOG.debug("{}", cm.getEncodeds().size());
+ for (int i = 0; i < encodeds.size(); i++) {
+ element.addContent(generateCDATAElement("encoded", encodeds.get(i).toString()));
+ }
+ }
+
+ final List contentItems = cm.getContentItems();
+
+ if (contentItems != null && !contentItems.isEmpty()) {
+ final Element items = new Element("items", CONTENT_NS);
+ final Element bag = new Element("Bag", RDF_NS);
+ items.addContent(bag);
+
+ for (int i = 0; i < contentItems.size(); i++) {
+ final ContentItem contentItem = contentItems.get(i);
+ final Element li = new Element("li", RDF_NS);
+ final Element item = new Element("item", CONTENT_NS);
+
+ if (contentItem.getContentAbout() != null) {
+ final Attribute about = new Attribute("about", contentItem.getContentAbout(), RDF_NS);
+ item.setAttribute(about);
+ }
+
+ if (contentItem.getContentFormat() != null) {
+ // LOG.debug( "Format");
+ final Element format = new Element("format", CONTENT_NS);
+ final Attribute formatResource = new Attribute("resource", contentItem.getContentFormat(), RDF_NS);
+ format.setAttribute(formatResource);
+
+ item.addContent(format);
+ }
+
+ if (contentItem.getContentEncoding() != null) {
+ // LOG.debug( "Encoding");
+ final Element encoding = new Element("encoding", CONTENT_NS);
+ final Attribute encodingResource = new Attribute("resource", contentItem.getContentEncoding(), RDF_NS);
+ encoding.setAttribute(encodingResource);
+ item.addContent(encoding);
+ }
+
+ if (contentItem.getContentValue() != null) {
+ final Element value = new Element("value", RDF_NS);
+
+ if (contentItem.getContentValueParseType() != null) {
+ final Attribute parseType = new Attribute("parseType", contentItem.getContentValueParseType(), RDF_NS);
+ value.setAttribute(parseType);
+ }
+
+ if (contentItem.getContentValueNamespaces() != null) {
+ final List namespaces = contentItem.getContentValueNamespaces();
+
+ for (int ni = 0; ni < namespaces.size(); ni++) {
+ value.addNamespaceDeclaration(namespaces.get(ni));
+ }
+ }
+
+ final List detached = new ArrayList();
+
+ for (int c = 0; c < contentItem.getContentValueDOM().size(); c++) {
+ detached.add(contentItem.getContentValueDOM().get(c).clone().detach());
+ }
+
+ value.setContent(detached);
+ item.addContent(value);
+ } // end value
+
+ li.addContent(item);
+ bag.addContent(li);
+ } // end contentItems loop
+
+ element.addContent(items);
+ }
+ }
+
+ protected Element generateSimpleElement(final String name, final String value) {
+ final Element element = new Element(name, CONTENT_NS);
+ element.addContent(value);
+
+ return element;
+ }
+
+ protected Element generateCDATAElement(final String name, final String value) {
+ final Element element = new Element(name, CONTENT_NS);
+ final CDATA cdata = new CDATA(value);
+ element.addContent(cdata);
+
+ return element;
+ }
+
+ @Override
+ public String getNamespaceUri() {
+ return ContentModule.URI;
+ }
+
+ @Override
+ public Set getNamespaces() {
+ return NAMESPACES;
+ }
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/content/io/ContentModuleParser.java b/rome-modules/src/main/java/com/rometools/modules/content/io/ContentModuleParser.java
new file mode 100644
index 0000000..61e4c92
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/content/io/ContentModuleParser.java
@@ -0,0 +1,163 @@
+/*
+ * ContentModuleParser.java
+ *
+ * Created on January 11, 2005, 1:23 PM
+ *
+ * Copyright (C) 2005 Robert Cooper, Temple of the Screaming Penguin
+ *
+ * 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.
+ *
+ *
+ */
+package com.rometools.modules.content.io;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Locale;
+
+import org.jdom2.Attribute;
+import org.jdom2.Content;
+import org.jdom2.Element;
+import org.jdom2.Namespace;
+import org.jdom2.output.XMLOutputter;
+
+import com.rometools.modules.content.ContentItem;
+import com.rometools.modules.content.ContentModule;
+import com.rometools.modules.content.ContentModuleImpl;
+
+/**
+ * @version $Revision: 1.3 $
+ * @author Robert "kebernet" Cooper
+ */
+public class ContentModuleParser implements com.rometools.rome.io.ModuleParser {
+ private static final Namespace CONTENT_NS = Namespace.getNamespace("content", ContentModule.URI);
+ private static final Namespace RDF_NS = Namespace.getNamespace("rdf", ContentModule.RDF_URI);
+
+ /** Creates a new instance of ContentModuleParser */
+ public ContentModuleParser() {
+ }
+
+ @Override
+ public String getNamespaceUri() {
+ return ContentModule.URI;
+ }
+
+ @Override
+ public com.rometools.rome.feed.module.Module parse(final Element element, final Locale locale) {
+ boolean foundSomething = false;
+ final ContentModule cm = new ContentModuleImpl();
+ final List encodeds = element.getChildren("encoded", CONTENT_NS);
+ final ArrayList contentStrings = new ArrayList();
+ final ArrayList encodedStrings = new ArrayList();
+
+ if (!encodeds.isEmpty()) {
+ foundSomething = true;
+
+ for (int i = 0; i < encodeds.size(); i++) {
+ final Element encodedElement = encodeds.get(i);
+ encodedStrings.add(encodedElement.getText());
+ contentStrings.add(encodedElement.getText());
+ }
+ }
+
+ final ArrayList contentItems = new ArrayList();
+ final List items = element.getChildren("items", CONTENT_NS);
+
+ for (int i = 0; i < items.size(); i++) {
+ foundSomething = true;
+
+ final List lis = items.get(i).getChild("Bag", RDF_NS).getChildren("li", RDF_NS);
+
+ for (int j = 0; j < lis.size(); j++) {
+ final ContentItem ci = new ContentItem();
+ final Element li = lis.get(j);
+ final Element item = li.getChild("item", CONTENT_NS);
+ final Element format = item.getChild("format", CONTENT_NS);
+ final Element encoding = item.getChild("encoding", CONTENT_NS);
+ final Element value = item.getChild("value", RDF_NS);
+
+ if (value != null) {
+ if (value.getAttributeValue("parseType", RDF_NS) != null) {
+ ci.setContentValueParseType(value.getAttributeValue("parseType", RDF_NS));
+ }
+
+ if (ci.getContentValueParseType() != null && ci.getContentValueParseType().equals("Literal")) {
+ ci.setContentValue(getXmlInnerText(value));
+ contentStrings.add(getXmlInnerText(value));
+ ci.setContentValueNamespaces(value.getAdditionalNamespaces());
+ } else {
+ ci.setContentValue(value.getText());
+ contentStrings.add(value.getText());
+ }
+
+ ci.setContentValueDOM(value.clone().getContent());
+ }
+
+ if (format != null) {
+ ci.setContentFormat(format.getAttribute("resource", RDF_NS).getValue());
+ }
+
+ if (encoding != null) {
+ ci.setContentEncoding(encoding.getAttribute("resource", RDF_NS).getValue());
+ }
+
+ if (item != null) {
+ final Attribute about = item.getAttribute("about", RDF_NS);
+
+ if (about != null) {
+ ci.setContentAbout(about.getValue());
+ }
+ }
+
+ contentItems.add(ci);
+ }
+ }
+
+ cm.setEncodeds(encodedStrings);
+ cm.setContentItems(contentItems);
+ cm.setContents(contentStrings);
+
+ return foundSomething ? cm : null;
+ }
+
+ protected String getXmlInnerText(final Element e) {
+ final StringBuffer sb = new StringBuffer();
+ final XMLOutputter xo = new XMLOutputter();
+ final List children = e.getContent();
+ sb.append(xo.outputString(children));
+
+ return sb.toString();
+ }
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/content/package.html b/rome-modules/src/main/java/com/rometools/modules/content/package.html
new file mode 100644
index 0000000..3d84caf
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/content/package.html
@@ -0,0 +1,66 @@
+
+
+
+
+
+
+
+
+ This is a ROME plug in that implements the Content RSS extension.
+ http://purl.org/rss/1.0/modules/content/
+
+ Note, this supports both the "Original" syntax via the ContentItem object
+ and the "New" Syntax via the ".getEncodeds()" method on the ContentModule.
+
+
+ * 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.
+
+
+
diff --git a/rome-modules/src/main/java/com/rometools/modules/feedburner/FeedBurner.java b/rome-modules/src/main/java/com/rometools/modules/feedburner/FeedBurner.java
new file mode 100644
index 0000000..d1619a4
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/feedburner/FeedBurner.java
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2011 robert.cooper.
+ *
+ * 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.
+ * under the License.
+ */
+
+package com.rometools.modules.feedburner;
+
+import java.io.Serializable;
+
+import com.rometools.rome.feed.module.Module;
+
+/**
+ * Interface for the FeedBurner RSS extension.
+ *
+ * @version 1.0
+ * @author Georg Schmidl
+ *
+ */
+public interface FeedBurner extends Module, Serializable, Cloneable {
+
+ public static final String URI = "http://rssnamespace.org/feedburner/ext/1.0";
+
+ public String getAwareness();
+
+ public void setAwareness(String awareness);
+
+ public String getOrigLink();
+
+ public void setOrigLink(String origLink);
+
+ public String getOrigEnclosureLink();
+
+ public void setOrigEnclosureLink(String origEnclosureLink);
+
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/feedburner/FeedBurnerImpl.java b/rome-modules/src/main/java/com/rometools/modules/feedburner/FeedBurnerImpl.java
new file mode 100644
index 0000000..cf74014
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/feedburner/FeedBurnerImpl.java
@@ -0,0 +1,91 @@
+/*
+ * Copyright 2010 Scandio GmbH.
+ *
+ * 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 com.rometools.modules.feedburner;
+
+import com.rometools.rome.feed.CopyFrom;
+
+/**
+ * Implementation of the FeedBurner RSS extension.
+ *
+ * @version 1.0
+ * @author Georg Schmidl
+ *
+ */
+public class FeedBurnerImpl implements FeedBurner {
+
+ private static final long serialVersionUID = 1L;
+
+ private String awareness;
+ private String origLink;
+ private String origEnclosureLink;
+
+ @Override
+ public String getAwareness() {
+ return awareness;
+ }
+
+ @Override
+ public void setAwareness(final String awareness) {
+ this.awareness = awareness;
+ }
+
+ @Override
+ public String getOrigLink() {
+ return origLink;
+ }
+
+ @Override
+ public void setOrigLink(final String origLink) {
+ this.origLink = origLink;
+ }
+
+ @Override
+ public String getOrigEnclosureLink() {
+ return origEnclosureLink;
+ }
+
+ @Override
+ public void setOrigEnclosureLink(final String origEnclosureLink) {
+ this.origEnclosureLink = origEnclosureLink;
+ }
+
+ @Override
+ public String getUri() {
+ return FeedBurner.URI;
+ }
+
+ @Override
+ public void copyFrom(final CopyFrom object) {
+ final FeedBurner source = (FeedBurner) object;
+ setAwareness(source.getAwareness());
+ setOrigLink(source.getOrigLink());
+ setOrigEnclosureLink(source.getOrigEnclosureLink());
+ }
+
+ @Override
+ public Class getInterface() {
+ return FeedBurner.class;
+ }
+
+ @Override
+ public Object clone() {
+ final FeedBurnerImpl fbi = new FeedBurnerImpl();
+ fbi.copyFrom(this);
+ return fbi;
+ }
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/feedburner/io/FeedBurnerModuleGenerator.java b/rome-modules/src/main/java/com/rometools/modules/feedburner/io/FeedBurnerModuleGenerator.java
new file mode 100644
index 0000000..9406f04
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/feedburner/io/FeedBurnerModuleGenerator.java
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2010 Scandio GmbH.
+ *
+ * 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 com.rometools.modules.feedburner.io;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.jdom2.Element;
+import org.jdom2.Namespace;
+
+import com.rometools.modules.feedburner.FeedBurner;
+import com.rometools.rome.feed.module.Module;
+import com.rometools.rome.io.ModuleGenerator;
+
+/**
+ * ModuleGenerator implementation for the FeedBurner RSS extension.
+ *
+ * @version 1.0
+ * @author Georg Schmidl
+ *
+ */
+public class FeedBurnerModuleGenerator implements ModuleGenerator {
+ private static final Namespace NS = Namespace.getNamespace("feedburner", FeedBurner.URI);
+
+ @Override
+ public String getNamespaceUri() {
+ return FeedBurner.URI;
+ }
+
+ @Override
+ public Set getNamespaces() {
+ final HashSet set = new HashSet();
+ set.add(FeedBurnerModuleGenerator.NS);
+ return set;
+ }
+
+ @Override
+ public void generate(final Module module, final Element element) {
+ if (!(module instanceof FeedBurner)) {
+ return;
+ }
+
+ final FeedBurner feedBurner = (FeedBurner) module;
+
+ if (feedBurner.getAwareness() != null) {
+ element.addContent(generateSimpleElement("awareness", feedBurner.getAwareness()));
+ }
+
+ if (feedBurner.getOrigLink() != null) {
+ element.addContent(generateSimpleElement("origLink", feedBurner.getOrigLink()));
+ }
+
+ if (feedBurner.getOrigEnclosureLink() != null) {
+ element.addContent(generateSimpleElement("origEnclosureLink", feedBurner.getOrigEnclosureLink()));
+ }
+ }
+
+ protected Element generateSimpleElement(final String name, final String value) {
+ final Element element = new Element(name, FeedBurnerModuleGenerator.NS);
+ element.addContent(value);
+
+ return element;
+ }
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/feedburner/io/FeedBurnerModuleParser.java b/rome-modules/src/main/java/com/rometools/modules/feedburner/io/FeedBurnerModuleParser.java
new file mode 100644
index 0000000..ad124ff
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/feedburner/io/FeedBurnerModuleParser.java
@@ -0,0 +1,75 @@
+/*
+ * Copyright 2010 Scandio GmbH.
+ *
+ * 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 com.rometools.modules.feedburner.io;
+
+import java.util.Locale;
+
+import org.jdom2.Element;
+import org.jdom2.Namespace;
+
+import com.rometools.modules.feedburner.FeedBurner;
+import com.rometools.modules.feedburner.FeedBurnerImpl;
+import com.rometools.rome.feed.module.Module;
+import com.rometools.rome.io.ModuleParser;
+
+/**
+ * ModuleParser implementation for the FeedBurner RSS extension.
+ *
+ * @version 1.0
+ * @author Georg Schmidl
+ *
+ */
+public class FeedBurnerModuleParser implements ModuleParser {
+ private static final Namespace NS = Namespace.getNamespace(FeedBurner.URI);
+
+ @Override
+ public String getNamespaceUri() {
+ return FeedBurner.URI;
+ }
+
+ @Override
+ public Module parse(final Element element, final Locale locale) {
+ final FeedBurnerImpl fbi = new FeedBurnerImpl();
+ boolean returnObj = false;
+ Element tag = element.getChild("awareness", FeedBurnerModuleParser.NS);
+
+ if (tag != null) {
+ fbi.setAwareness(tag.getText().trim());
+ returnObj = true;
+ }
+
+ tag = element.getChild("origLink", FeedBurnerModuleParser.NS);
+
+ if (tag != null) {
+ fbi.setOrigLink(tag.getText().trim());
+ returnObj = true;
+ }
+
+ tag = element.getChild("origEnclosureLink", FeedBurnerModuleParser.NS);
+
+ if (tag != null) {
+ fbi.setOrigEnclosureLink(tag.getText().trim());
+ returnObj = true;
+ }
+
+ if (returnObj) {
+ return fbi;
+ }
+
+ return null;
+ }
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/feedburner/package.html b/rome-modules/src/main/java/com/rometools/modules/feedburner/package.html
new file mode 100644
index 0000000..6591aaf
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/feedburner/package.html
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
+
+
+
+ * 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) 2011 The ROME Team
+ *
+ * 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.
+
+
+
\ No newline at end of file
diff --git a/rome-modules/src/main/java/com/rometools/modules/georss/GMLGenerator.java b/rome-modules/src/main/java/com/rometools/modules/georss/GMLGenerator.java
new file mode 100644
index 0000000..b83a0f7
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/georss/GMLGenerator.java
@@ -0,0 +1,173 @@
+/*
+ * Copyright 2006 Marc Wick, geonames.org
+ *
+ * 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 com.rometools.modules.georss;
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import org.jdom2.Element;
+import org.jdom2.Namespace;
+
+import com.rometools.modules.georss.geometries.AbstractGeometry;
+import com.rometools.modules.georss.geometries.AbstractRing;
+import com.rometools.modules.georss.geometries.Envelope;
+import com.rometools.modules.georss.geometries.LineString;
+import com.rometools.modules.georss.geometries.LinearRing;
+import com.rometools.modules.georss.geometries.Point;
+import com.rometools.modules.georss.geometries.Polygon;
+import com.rometools.modules.georss.geometries.Position;
+import com.rometools.modules.georss.geometries.PositionList;
+import com.rometools.rome.feed.module.Module;
+import com.rometools.rome.io.ModuleGenerator;
+
+/**
+ * GMLGenerator produces georss elements in georss GML format.
+ *
+ * @author Marc Wick
+ * @version $Id: GMLGenerator.java,v 1.1 2007/04/18 09:59:29 marcwick Exp $
+ *
+ */
+public class GMLGenerator implements ModuleGenerator {
+
+ private static final Set NAMESPACES;
+
+ static {
+ final Set nss = new HashSet();
+ nss.add(GeoRSSModule.GML_NS);
+ NAMESPACES = Collections.unmodifiableSet(nss);
+ }
+
+ private Element createPosListElement(final PositionList posList) {
+ final Element posElement = new Element("posList", GeoRSSModule.GML_NS);
+ final StringBuffer sb = new StringBuffer();
+ for (int i = 0; i < posList.size(); ++i) {
+ sb.append(posList.getLatitude(i)).append(" ").append(posList.getLongitude(i)).append(" ");
+ }
+
+ posElement.addContent(sb.toString());
+ return posElement;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.rometools.rome.io.ModuleGenerator#getNamespaceUri()
+ */
+ @Override
+ public String getNamespaceUri() {
+ return GeoRSSModule.GEORSS_GML_URI;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.rometools.rome.io.ModuleGenerator#getNamespaces()
+ */
+ @Override
+ public Set getNamespaces() {
+ return NAMESPACES;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.rometools.rome.io.ModuleGenerator#generate(com.rometools.rome.feed.module.Module,
+ * org.jdom2.Element)
+ */
+ @Override
+ public void generate(final Module module, final Element element) {
+ // this is not necessary, it is done to avoid the namespace definition
+ // in every item.
+ Element root = element;
+ while (root.getParent() != null && root.getParent() instanceof Element) {
+ root = (Element) element.getParent();
+ }
+ root.addNamespaceDeclaration(GeoRSSModule.SIMPLE_NS);
+ root.addNamespaceDeclaration(GeoRSSModule.GML_NS);
+
+ final Element whereElement = new Element("where", GeoRSSModule.SIMPLE_NS);
+ element.addContent(whereElement);
+
+ final GeoRSSModule geoRSSModule = (GeoRSSModule) module;
+ final AbstractGeometry geometry = geoRSSModule.getGeometry();
+
+ if (geometry instanceof Point) {
+ final Position pos = ((Point) geometry).getPosition();
+
+ final Element pointElement = new Element("Point", GeoRSSModule.GML_NS);
+ whereElement.addContent(pointElement);
+
+ final Element posElement = new Element("pos", GeoRSSModule.GML_NS);
+ posElement.addContent(String.valueOf(pos.getLatitude()) + " " + String.valueOf(pos.getLongitude()));
+ pointElement.addContent(posElement);
+ }
+
+ else if (geometry instanceof LineString) {
+ final PositionList posList = ((LineString) geometry).getPositionList();
+
+ final Element lineElement = new Element("LineString", GeoRSSModule.GML_NS);
+ lineElement.addContent(createPosListElement(posList));
+ whereElement.addContent(lineElement);
+ } else if (geometry instanceof Polygon) {
+ final Element polygonElement = new Element("Polygon", GeoRSSModule.GML_NS);
+ {
+ final AbstractRing ring = ((Polygon) geometry).getExterior();
+ if (ring instanceof LinearRing) {
+ final Element exteriorElement = new Element("exterior", GeoRSSModule.GML_NS);
+ polygonElement.addContent(exteriorElement);
+ final Element ringElement = new Element("LinearRing", GeoRSSModule.GML_NS);
+ exteriorElement.addContent(ringElement);
+ ringElement.addContent(createPosListElement(((LinearRing) ring).getPositionList()));
+
+ } else {
+ System.err.println("GeoRSS GML format can't handle rings of type: " + ring.getClass().getName());
+ }
+ }
+ final List interiorList = ((Polygon) geometry).getInterior();
+ final Iterator it = interiorList.iterator();
+ while (it.hasNext()) {
+ final AbstractRing ring = it.next();
+ if (ring instanceof LinearRing) {
+ final Element interiorElement = new Element("interior", GeoRSSModule.GML_NS);
+ polygonElement.addContent(interiorElement);
+ final Element ringElement = new Element("LinearRing", GeoRSSModule.GML_NS);
+ interiorElement.addContent(ringElement);
+ ringElement.addContent(createPosListElement(((LinearRing) ring).getPositionList()));
+
+ } else {
+ System.err.println("GeoRSS GML format can't handle rings of type: " + ring.getClass().getName());
+ }
+ }
+ whereElement.addContent(polygonElement);
+ } else if (geometry instanceof Envelope) {
+ final Envelope envelope = (Envelope) geometry;
+ final Element envelopeElement = new Element("Envelope", GeoRSSModule.GML_NS);
+ whereElement.addContent(envelopeElement);
+
+ final Element lowerElement = new Element("lowerCorner", GeoRSSModule.GML_NS);
+ lowerElement.addContent(String.valueOf(envelope.getMinLatitude()) + " " + String.valueOf(envelope.getMinLongitude()));
+ envelopeElement.addContent(lowerElement);
+
+ final Element upperElement = new Element("upperCorner", GeoRSSModule.GML_NS);
+ upperElement.addContent(String.valueOf(envelope.getMaxLatitude()) + " " + String.valueOf(envelope.getMaxLongitude()));
+ envelopeElement.addContent(upperElement);
+
+ } else {
+ System.err.println("GeoRSS GML format can't handle geometries of type: " + geometry.getClass().getName());
+ }
+ }
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/georss/GMLModuleImpl.java b/rome-modules/src/main/java/com/rometools/modules/georss/GMLModuleImpl.java
new file mode 100644
index 0000000..03c944d
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/georss/GMLModuleImpl.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2006 Marc Wick, geonames.org
+ *
+ * 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 com.rometools.modules.georss;
+
+/**
+ * GMLModuleImpl is the implementation of the {@link GeoRSSModule} Interface for the gml GeoRSS
+ * format.
+ *
+ * @author Marc Wick
+ * @version $Id: GMLModuleImpl.java,v 1.1 2007/04/18 09:59:29 marcwick Exp $
+ *
+ */
+public class GMLModuleImpl extends GeoRSSModule {
+
+ private static final long serialVersionUID = 1L;
+
+ public GMLModuleImpl() {
+ super(GeoRSSModule.class, GeoRSSModule.GEORSS_GML_URI);
+ }
+
+ @Override
+ public Class getInterface() {
+ return GeoRSSModule.class;
+ }
+
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/georss/GMLParser.java b/rome-modules/src/main/java/com/rometools/modules/georss/GMLParser.java
new file mode 100644
index 0000000..7312418
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/georss/GMLParser.java
@@ -0,0 +1,148 @@
+/*
+ * Copyright 2006 Marc Wick, geonames.org
+ *
+ * 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 com.rometools.modules.georss;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+
+import org.jdom2.Element;
+
+import com.rometools.modules.georss.geometries.Envelope;
+import com.rometools.modules.georss.geometries.LineString;
+import com.rometools.modules.georss.geometries.LinearRing;
+import com.rometools.modules.georss.geometries.Point;
+import com.rometools.modules.georss.geometries.Polygon;
+import com.rometools.modules.georss.geometries.Position;
+import com.rometools.modules.georss.geometries.PositionList;
+import com.rometools.rome.feed.module.Module;
+import com.rometools.rome.io.ModuleParser;
+import com.rometools.utils.Strings;
+
+/**
+ * GMLParser is a parser for the GML georss format.
+ *
+ * @author Marc Wick
+ * @version $Id: GMLParser.java,v 1.2 2007/06/05 20:44:53 marcwick Exp $
+ *
+ */
+public class GMLParser implements ModuleParser {
+
+ @Override
+ public String getNamespaceUri() {
+ return GeoRSSModule.GEORSS_GEORSS_URI;
+ }
+
+ @Override
+ public Module parse(final Element element, final Locale locale) {
+ final Module geoRssModule = parseGML(element);
+ return geoRssModule;
+ }
+
+ private static PositionList parsePosList(final Element element) {
+ final String coordinates = element.getText();
+ final String[] coord = Strings.trimToEmpty(coordinates).split(" ");
+ final PositionList posList = new PositionList();
+ for (int i = 0; i < coord.length; i += 2) {
+ posList.add(Double.parseDouble(coord[i]), Double.parseDouble(coord[i + 1]));
+ }
+ return posList;
+ }
+
+ static Module parseGML(final Element element) {
+ GeoRSSModule geoRSSModule = null;
+
+ final Element pointElement = element.getChild("Point", GeoRSSModule.GML_NS);
+ final Element lineStringElement = element.getChild("LineString", GeoRSSModule.GML_NS);
+ final Element polygonElement = element.getChild("Polygon", GeoRSSModule.GML_NS);
+ final Element envelopeElement = element.getChild("Envelope", GeoRSSModule.GML_NS);
+ if (pointElement != null) {
+ final Element posElement = pointElement.getChild("pos", GeoRSSModule.GML_NS);
+ if (posElement != null) {
+ geoRSSModule = new GMLModuleImpl();
+ final String coordinates = posElement.getText();
+ final String[] coord = Strings.trimToEmpty(coordinates).split(" ");
+ final Position pos = new Position(Double.parseDouble(coord[0]), Double.parseDouble(coord[1]));
+ geoRSSModule.setGeometry(new Point(pos));
+ }
+ } else if (lineStringElement != null) {
+ final Element posListElement = lineStringElement.getChild("posList", GeoRSSModule.GML_NS);
+ if (posListElement != null) {
+ geoRSSModule = new GMLModuleImpl();
+ geoRSSModule.setGeometry(new LineString(parsePosList(posListElement)));
+ }
+ } else if (polygonElement != null) {
+ Polygon poly = null;
+
+ // The external ring
+ final Element exteriorElement = polygonElement.getChild("exterior", GeoRSSModule.GML_NS);
+ if (exteriorElement != null) {
+ final Element linearRingElement = exteriorElement.getChild("LinearRing", GeoRSSModule.GML_NS);
+ if (linearRingElement != null) {
+ final Element posListElement = linearRingElement.getChild("posList", GeoRSSModule.GML_NS);
+ if (posListElement != null) {
+ if (poly == null) {
+ poly = new Polygon();
+ }
+ poly.setExterior(new LinearRing(parsePosList(posListElement)));
+ }
+ }
+ }
+
+ // The internal rings (holes)
+ final List interiorElementList = polygonElement.getChildren("interior", GeoRSSModule.GML_NS);
+ final Iterator it = interiorElementList.iterator();
+ while (it.hasNext()) {
+ final Element interiorElement = it.next();
+ if (interiorElement != null) {
+ final Element linearRingElement = interiorElement.getChild("LinearRing", GeoRSSModule.GML_NS);
+ if (linearRingElement != null) {
+ final Element posListElement = linearRingElement.getChild("posList", GeoRSSModule.GML_NS);
+ if (posListElement != null) {
+ if (poly == null) {
+ poly = new Polygon();
+ }
+ poly.getInterior().add(new LinearRing(parsePosList(posListElement)));
+ }
+ }
+ }
+
+ }
+
+ if (poly != null) {
+ geoRSSModule = new GMLModuleImpl();
+ geoRSSModule.setGeometry(poly);
+ }
+ } else if (envelopeElement != null) {
+ final Element lowerElement = envelopeElement.getChild("lowerCorner", GeoRSSModule.GML_NS);
+ final Element upperElement = envelopeElement.getChild("upperCorner", GeoRSSModule.GML_NS);
+ if (lowerElement != null && upperElement != null) {
+ geoRSSModule = new GMLModuleImpl();
+ final String lowerCoordinates = lowerElement.getText();
+ final String[] lowerCoord = Strings.trimToEmpty(lowerCoordinates).split(" ");
+ final String upperCoordinates = upperElement.getText();
+ final String[] upperCoord = Strings.trimToEmpty(upperCoordinates).split(" ");
+ final Envelope envelope = new Envelope(Double.parseDouble(lowerCoord[0]), Double.parseDouble(lowerCoord[1]), Double.parseDouble(upperCoord[0]),
+ Double.parseDouble(upperCoord[1]));
+ geoRSSModule.setGeometry(envelope);
+ }
+ }
+
+ return geoRSSModule;
+ }
+
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/georss/GeoRSSModule.java b/rome-modules/src/main/java/com/rometools/modules/georss/GeoRSSModule.java
new file mode 100644
index 0000000..2895c02
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/georss/GeoRSSModule.java
@@ -0,0 +1,150 @@
+/*
+ * Copyright 2006 Marc Wick, geonames.org
+ *
+ * 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 com.rometools.modules.georss;
+
+import org.jdom2.Namespace;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.rometools.modules.georss.geometries.AbstractGeometry;
+import com.rometools.modules.georss.geometries.Point;
+import com.rometools.modules.georss.geometries.Position;
+import com.rometools.rome.feed.CopyFrom;
+import com.rometools.rome.feed.module.ModuleImpl;
+
+/**
+ * GeoRSSModule is the main georss interface defining the methods to produce and consume georss
+ * elements.
+ *
+ * @author Marc Wick
+ * @version $Id: GeoRSSModule.java,v 1.8 2007/06/06 09:47:32 marcwick Exp $
+ */
+public abstract class GeoRSSModule extends ModuleImpl implements Cloneable {
+
+ private static final long serialVersionUID = 1L;
+
+ private static final Logger LOG = LoggerFactory.getLogger(GeoRSSModule.class);
+
+ protected AbstractGeometry geometry;
+
+ public static final String version = "0.9.8";
+
+ /**
+ * namespace URI for georss simple: "http://www.georss.org/georss"
+ */
+ public static final String GEORSS_GEORSS_URI = "http://www.georss.org/georss";
+
+ /**
+ * namespace URI for w3c georss : "http://www.w3.org/2003/01/geo/wgs84_pos#"
+ */
+ public static final String GEORSS_W3CGEO_URI = "http://www.w3.org/2003/01/geo/wgs84_pos#";
+
+ /**
+ * namespace URI for GML georss : "http://www.opengis.net/gml"
+ */
+ public static final String GEORSS_GML_URI = "http://www.opengis.net/gml";
+
+ /**
+ * Namespace for georss simple : xmlns:georss="http://www.georss.org/georss"
+ */
+ public static final Namespace SIMPLE_NS = Namespace.getNamespace("georss", GeoRSSModule.GEORSS_GEORSS_URI);
+
+ /**
+ *
+ * Namespace for w3c georss : xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#"
+ */
+ public static final Namespace W3CGEO_NS = Namespace.getNamespace("geo", GeoRSSModule.GEORSS_W3CGEO_URI);
+
+ /**
+ *
+ * Namespace for gml georss : xmlns:gml="http://www.opengis.net/gml"
+ */
+ public static final Namespace GML_NS = Namespace.getNamespace("gml", GeoRSSModule.GEORSS_GML_URI);
+
+ protected GeoRSSModule(final Class extends GeoRSSModule> beanClass, final java.lang.String uri) {
+ super(beanClass, uri);
+ }
+
+ /**
+ * Set geometry of georss element
+ *
+ * @param geometry geometry
+ */
+ public void setGeometry(final AbstractGeometry geometry) {
+ this.geometry = geometry;
+ }
+
+ /**
+ * returns the geometry
+ *
+ * @return geometry
+ */
+ public AbstractGeometry getGeometry() {
+ return geometry;
+ }
+
+ /**
+ * Convenience method to return point geometry. Returns null if the geometry is non-point.
+ *
+ * @return geometry
+ */
+ public Position getPosition() {
+ if (geometry instanceof Point) {
+ return ((Point) geometry).getPosition();
+ }
+ return null;
+ }
+
+ /**
+ * Convenience method to set point geometry.
+ *
+ * @return geometry
+ */
+ public void setPosition(final Position pos) {
+ if (pos != null) {
+ geometry = new Point(pos);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.rometools.rome.feed.CopyFrom#copyFrom(java.lang.Object)
+ */
+ @Override
+ public void copyFrom(final CopyFrom obj) {
+ final GeoRSSModule geoRSSModule = (GeoRSSModule) obj;
+ geometry = geoRSSModule.getGeometry();
+ try {
+ geometry = (AbstractGeometry) geometry.clone();
+ } catch (final CloneNotSupportedException ex) {
+ LOG.error("Error", ex);
+ }
+ }
+
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ try {
+ final GeoRSSModule retval = (GeoRSSModule) super.clone();
+ if (geometry != null) {
+ retval.geometry = (AbstractGeometry) geometry.clone();
+ }
+ return retval;
+ } catch (final Exception ex) {
+ LOG.error("Error", ex);
+ }
+ throw new CloneNotSupportedException();
+ }
+
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/georss/GeoRSSPoint.java b/rome-modules/src/main/java/com/rometools/modules/georss/GeoRSSPoint.java
new file mode 100644
index 0000000..ef7f1f6
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/georss/GeoRSSPoint.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2007 Marc Wick, geonames.org
+ *
+ * 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 com.rometools.modules.georss;
+
+/**
+ * @author marc
+ *
+ */
+public class GeoRSSPoint implements Cloneable {
+ private double latitude;
+
+ private double longitude;
+
+ /**
+ * @return the latitude
+ */
+ public double getLatitude() {
+ return latitude;
+ }
+
+ /**
+ * @param latitude the latitude to set
+ */
+ public void setLatitude(final double latitude) {
+ this.latitude = latitude;
+ }
+
+ /**
+ * @return the longitude
+ */
+ public double getLongitude() {
+ return longitude;
+ }
+
+ /**
+ * @param longitude the longitude to set
+ */
+ public void setLongitude(final double longitude) {
+ this.longitude = longitude;
+ }
+
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ return super.clone();
+ }
+
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/georss/GeoRSSUtils.java b/rome-modules/src/main/java/com/rometools/modules/georss/GeoRSSUtils.java
new file mode 100644
index 0000000..56c82cf
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/georss/GeoRSSUtils.java
@@ -0,0 +1,93 @@
+/*
+ * Copyright 2006 Marc Wick, geonames.org
+ *
+ * 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 com.rometools.modules.georss;
+
+import com.rometools.rome.feed.synd.SyndEntry;
+import com.rometools.rome.feed.synd.SyndFeed;
+
+/**
+ * static utility methods for georss.
+ *
+ * @author Marc Wick
+ * @version $Id: GeoRSSUtils.java,v 1.4 2007/04/18 09:59:29 marcwick Exp $
+ *
+ */
+public class GeoRSSUtils {
+
+ /**
+ * This convenience method checks whether there is any geoRss Element and will return it (georss
+ * simple or W3GGeo).
+ *
+ * @param entry the element in the feed which might have a georss element
+ * @return a georssmodule or null if none is present
+ */
+ public static GeoRSSModule getGeoRSS(final SyndEntry entry) {
+ final GeoRSSModule simple = (GeoRSSModule) entry.getModule(GeoRSSModule.GEORSS_GEORSS_URI);
+ final GeoRSSModule w3cGeo = (GeoRSSModule) entry.getModule(GeoRSSModule.GEORSS_W3CGEO_URI);
+ final GeoRSSModule gml = (GeoRSSModule) entry.getModule(GeoRSSModule.GEORSS_GML_URI);
+ if (gml != null) {
+ return gml;
+ }
+ if (simple != null) {
+ return simple;
+ }
+ if (w3cGeo != null) {
+ return w3cGeo;
+ }
+
+ return null;
+ /*
+ * if (geoRSSModule == null && w3cGeo != null) { geoRSSModule = w3cGeo; } else if
+ * (geoRSSModule == null && gml != null) { geoRSSModule = gml; } else if (geoRSSModule !=
+ * null && w3cGeo != null) { // sanity check if
+ * (!geoRSSModule.getGeometry().equals(w3cGeo.getGeometry())) { throw new
+ * Error("geometry of simple and w3c do not match"); } } return geoRSSModule;
+ */
+ }
+
+ /**
+ * This convenience method checks whether there is any geoRss Element and will return it (georss
+ * simple or W3GGeo).
+ *
+ * @param feed the element in the feed which might have a georss element
+ * @return a georssmodule or null if none is present
+ */
+ public static GeoRSSModule getGeoRSS(final SyndFeed feed) {
+ final GeoRSSModule simple = (GeoRSSModule) feed.getModule(GeoRSSModule.GEORSS_GEORSS_URI);
+ final GeoRSSModule w3cGeo = (GeoRSSModule) feed.getModule(GeoRSSModule.GEORSS_W3CGEO_URI);
+ final GeoRSSModule gml = (GeoRSSModule) feed.getModule(GeoRSSModule.GEORSS_GML_URI);
+
+ if (gml != null) {
+ return gml;
+ }
+ if (simple != null) {
+ return simple;
+ }
+ if (w3cGeo != null) {
+ return w3cGeo;
+ }
+
+ return null;
+ /*
+ * if (geoRSSModule == null && w3cGeo != null) { geoRSSModule = w3cGeo; } else if
+ * (geoRSSModule == null && gml != null) { geoRSSModule = gml; } else if (geoRSSModule !=
+ * null && w3cGeo != null) { // sanity check if
+ * (!geoRSSModule.getGeometry().equals(w3cGeo.getGeometry())) { throw new
+ * Error("geometry of simple and w3c do not match"); } } return geoRSSModule;
+ */
+ }
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/georss/SimpleGenerator.java b/rome-modules/src/main/java/com/rometools/modules/georss/SimpleGenerator.java
new file mode 100644
index 0000000..f30e11e
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/georss/SimpleGenerator.java
@@ -0,0 +1,143 @@
+/*
+ * Copyright 2006 Marc Wick, geonames.org
+ *
+ * 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 com.rometools.modules.georss;
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.jdom2.Element;
+import org.jdom2.Namespace;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.rometools.modules.georss.geometries.AbstractGeometry;
+import com.rometools.modules.georss.geometries.AbstractRing;
+import com.rometools.modules.georss.geometries.Envelope;
+import com.rometools.modules.georss.geometries.LineString;
+import com.rometools.modules.georss.geometries.LinearRing;
+import com.rometools.modules.georss.geometries.Point;
+import com.rometools.modules.georss.geometries.Polygon;
+import com.rometools.modules.georss.geometries.Position;
+import com.rometools.modules.georss.geometries.PositionList;
+import com.rometools.rome.feed.module.Module;
+import com.rometools.rome.io.ModuleGenerator;
+
+/**
+ * SimpleGenerator produces georss elements in georss simple format.
+ *
+ * @author Marc Wick
+ * @version $Id: SimpleGenerator.java,v 1.4 2007/04/18 09:59:29 marcwick Exp $
+ *
+ */
+public class SimpleGenerator implements ModuleGenerator {
+ private static final Logger LOG = LoggerFactory.getLogger(SimpleGenerator.class);
+
+ private static final Set NAMESPACES;
+ static {
+ final Set nss = new HashSet();
+ nss.add(GeoRSSModule.SIMPLE_NS);
+ NAMESPACES = Collections.unmodifiableSet(nss);
+ }
+
+ /**
+ * @param posList PositionList to convert
+ * @return String representation
+ */
+ private String posListToString(final PositionList posList) {
+ final StringBuffer sb = new StringBuffer();
+ for (int i = 0; i < posList.size(); ++i) {
+ sb.append(posList.getLatitude(i)).append(" ").append(posList.getLongitude(i)).append(" ");
+ }
+ return sb.toString();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.rometools.rome.io.ModuleGenerator#getNamespaceUri()
+ */
+ @Override
+ public String getNamespaceUri() {
+ return GeoRSSModule.GEORSS_GEORSS_URI;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.rometools.rome.io.ModuleGenerator#getNamespaces()
+ */
+ @Override
+ public Set getNamespaces() {
+ return NAMESPACES;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.rometools.rome.io.ModuleGenerator#generate(com.rometools.rome.feed.module.Module,
+ * org.jdom2.Element)
+ */
+ @Override
+ public void generate(final Module module, final Element element) {
+ // this is not necessary, it is done to avoid the namespace definition
+ // in every item.
+ Element root = element;
+ while (root.getParent() != null && root.getParent() instanceof Element) {
+ root = (Element) element.getParent();
+ }
+ root.addNamespaceDeclaration(GeoRSSModule.SIMPLE_NS);
+
+ final GeoRSSModule geoRSSModule = (GeoRSSModule) module;
+
+ final AbstractGeometry geometry = geoRSSModule.getGeometry();
+ if (geometry instanceof Point) {
+ final Position pos = ((Point) geometry).getPosition();
+
+ final Element pointElement = new Element("point", GeoRSSModule.SIMPLE_NS);
+ pointElement.addContent(pos.getLatitude() + " " + pos.getLongitude());
+ element.addContent(pointElement);
+ } else if (geometry instanceof LineString) {
+ final PositionList posList = ((LineString) geometry).getPositionList();
+
+ final Element lineElement = new Element("line", GeoRSSModule.SIMPLE_NS);
+
+ lineElement.addContent(posListToString(posList));
+ element.addContent(lineElement);
+ } else if (geometry instanceof Polygon) {
+ final AbstractRing ring = ((Polygon) geometry).getExterior();
+ if (ring instanceof LinearRing) {
+ final PositionList posList = ((LinearRing) ring).getPositionList();
+ final Element polygonElement = new Element("polygon", GeoRSSModule.SIMPLE_NS);
+
+ polygonElement.addContent(posListToString(posList));
+ element.addContent(polygonElement);
+ } else {
+ LOG.error("GeoRSS simple format can't handle rings of type: " + ring.getClass().getName());
+ }
+ if (((Polygon) geometry).getInterior() != null && !((Polygon) geometry).getInterior().isEmpty()) {
+ LOG.error("GeoRSS simple format can't handle interior rings (ignored)");
+ }
+ } else if (geometry instanceof Envelope) {
+ final Envelope envelope = (Envelope) geometry;
+ final Element boxElement = new Element("box", GeoRSSModule.SIMPLE_NS);
+ boxElement.addContent(envelope.getMinLatitude() + " " + envelope.getMinLongitude() + " " + envelope.getMaxLatitude() + " "
+ + envelope.getMaxLongitude());
+ element.addContent(boxElement);
+ } else {
+ LOG.error("GeoRSS simple format can't handle geometries of type: " + geometry.getClass().getName());
+ }
+ }
+
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/georss/SimpleModuleImpl.java b/rome-modules/src/main/java/com/rometools/modules/georss/SimpleModuleImpl.java
new file mode 100644
index 0000000..1e96d78
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/georss/SimpleModuleImpl.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2006 Marc Wick, geonames.org
+ *
+ * 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 com.rometools.modules.georss;
+
+/**
+ * SimpleModuleImpl is the implementation of the {@link GeoRSSModule} Interface for the GeoRSS
+ * Simple format.
+ *
+ * @author Marc Wick
+ * @version $Id: SimpleModuleImpl.java,v 1.4 2007/04/18 09:59:29 marcwick Exp $
+ *
+ */
+public class SimpleModuleImpl extends GeoRSSModule {
+
+ private static final long serialVersionUID = 1L;
+
+ public SimpleModuleImpl() {
+ super(GeoRSSModule.class, GeoRSSModule.GEORSS_GEORSS_URI);
+ }
+
+ @Override
+ public Class getInterface() {
+ return GeoRSSModule.class;
+ }
+
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/georss/SimpleParser.java b/rome-modules/src/main/java/com/rometools/modules/georss/SimpleParser.java
new file mode 100644
index 0000000..d407f47
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/georss/SimpleParser.java
@@ -0,0 +1,166 @@
+/*
+ * Copyright 2006 Marc Wick, geonames.org
+ *
+ * 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 com.rometools.modules.georss;
+
+import java.util.Locale;
+
+import org.jdom2.Element;
+
+import com.rometools.modules.georss.geometries.Envelope;
+import com.rometools.modules.georss.geometries.LineString;
+import com.rometools.modules.georss.geometries.LinearRing;
+import com.rometools.modules.georss.geometries.Point;
+import com.rometools.modules.georss.geometries.Polygon;
+import com.rometools.modules.georss.geometries.Position;
+import com.rometools.modules.georss.geometries.PositionList;
+import com.rometools.rome.feed.module.Module;
+import com.rometools.rome.io.ModuleParser;
+import com.rometools.utils.Doubles;
+import com.rometools.utils.Strings;
+
+/**
+ * SimpleParser is a parser for the GeoRSS Simple format.
+ *
+ * @author Marc Wick
+ * @version $Id: SimpleParser.java,v 1.4 2007/04/18 09:59:29 marcwick Exp $
+ *
+ */
+public class SimpleParser implements ModuleParser {
+
+ @Override
+ public String getNamespaceUri() {
+ return GeoRSSModule.GEORSS_GEORSS_URI;
+ }
+
+ private static PositionList parsePosList(final Element element) {
+
+ PositionList posList = null;
+
+ final String coordinates = Strings.trimToNull(element.getText());
+ if (coordinates != null) {
+
+ posList = new PositionList();
+ final String[] coord = coordinates.split(" ");
+ for (int i = 0; i < coord.length; i += 2) {
+ final double latitude = Double.parseDouble(coord[i]);
+ final double longitude = Double.parseDouble(coord[i + 1]);
+ posList.add(latitude, longitude);
+ }
+
+ }
+
+ return posList;
+
+ }
+
+ @Override
+ public Module parse(final Element element, final Locale locale) {
+ return parseSimple(element);
+ }
+
+ static Module parseSimple(final Element element) {
+
+ final Element pointElement = element.getChild("point", GeoRSSModule.SIMPLE_NS);
+ final Element lineElement = element.getChild("line", GeoRSSModule.SIMPLE_NS);
+ final Element polygonElement = element.getChild("polygon", GeoRSSModule.SIMPLE_NS);
+ final Element boxElement = element.getChild("box", GeoRSSModule.SIMPLE_NS);
+ final Element whereElement = element.getChild("where", GeoRSSModule.SIMPLE_NS);
+
+ GeoRSSModule geoRSSModule = null;
+
+ if (pointElement != null) {
+
+ final String coordinates = Strings.trimToNull(pointElement.getText());
+ if (coordinates != null) {
+
+ final String[] coord = coordinates.split(" ");
+
+ if (coord.length == 2) {
+
+ final Double latitude = Doubles.parse(coord[0]);
+ final Double longitude = Doubles.parse(coord[1]);
+
+ if (latitude != null && longitude != null) {
+
+ final Position pos = new Position(latitude, longitude);
+
+ final Point point = new Point(pos);
+
+ geoRSSModule = new SimpleModuleImpl();
+ geoRSSModule.setGeometry(point);
+
+ }
+
+ }
+
+ }
+
+ } else if (lineElement != null) {
+
+ final PositionList posList = parsePosList(lineElement);
+
+ if (posList != null) {
+
+ final LineString lineString = new LineString(posList);
+
+ geoRSSModule = new SimpleModuleImpl();
+ geoRSSModule.setGeometry(lineString);
+
+ }
+
+ } else if (polygonElement != null) {
+
+ final PositionList posList = parsePosList(polygonElement);
+ if (posList != null) {
+
+ final LinearRing linearRing = new LinearRing(posList);
+
+ final Polygon poly = new Polygon();
+ poly.setExterior(linearRing);
+
+ geoRSSModule = new SimpleModuleImpl();
+ geoRSSModule.setGeometry(poly);
+
+ }
+
+ } else if (boxElement != null) {
+
+ final String coordinates = Strings.trimToNull(boxElement.getText());
+ if (coordinates != null) {
+
+ final String[] coord = coordinates.split(" ");
+ final double bottom = Double.parseDouble(coord[0]);
+ final double left = Double.parseDouble(coord[1]);
+ final double top = Double.parseDouble(coord[2]);
+ final double right = Double.parseDouble(coord[3]);
+
+ final Envelope envelope = new Envelope(bottom, left, top, right);
+
+ geoRSSModule = new SimpleModuleImpl();
+ geoRSSModule.setGeometry(envelope);
+ }
+
+ } else if (whereElement != null) {
+
+ geoRSSModule = (GeoRSSModule) GMLParser.parseGML(whereElement);
+
+ }
+
+ return geoRSSModule;
+ }
+
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/georss/W3CGeoGenerator.java b/rome-modules/src/main/java/com/rometools/modules/georss/W3CGeoGenerator.java
new file mode 100644
index 0000000..06185ad
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/georss/W3CGeoGenerator.java
@@ -0,0 +1,110 @@
+/*
+ * Copyright 2006 Marc Wick, geonames.org
+ *
+ * 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 com.rometools.modules.georss;
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.jdom2.Element;
+import org.jdom2.Namespace;
+
+import com.rometools.modules.georss.geometries.AbstractGeometry;
+import com.rometools.modules.georss.geometries.Point;
+import com.rometools.modules.georss.geometries.Position;
+import com.rometools.rome.feed.module.Module;
+import com.rometools.rome.io.ModuleGenerator;
+
+/**
+ * W3CGeoGenerator produces georss elements in georss W3C geo format.
+ *
+ * @author Marc Wick
+ * @version $Id: W3CGeoGenerator.java,v 1.3 2007/04/18 09:59:30 marcwick Exp $
+ *
+ */
+public class W3CGeoGenerator implements ModuleGenerator {
+
+ private static boolean isShort = true;
+
+ private static final Set NAMESPACES;
+
+ static {
+ final Set nss = new HashSet();
+ nss.add(GeoRSSModule.W3CGEO_NS);
+ NAMESPACES = Collections.unmodifiableSet(nss);
+ }
+
+ public static void enableDefaultPointElement() {
+ isShort = false;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.rometools.rome.io.ModuleGenerator#getNamespaceUri()
+ */
+ @Override
+ public String getNamespaceUri() {
+ return GeoRSSModule.GEORSS_W3CGEO_URI;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.rometools.rome.io.ModuleGenerator#getNamespaces()
+ */
+ @Override
+ public Set getNamespaces() {
+ return NAMESPACES;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.rometools.rome.io.ModuleGenerator#generate(com.rometools.rome.feed.module.Module,
+ * org.jdom2.Element)
+ */
+ @Override
+ public void generate(final Module module, final Element element) {
+ // this is not necessary, it is done to avoid the namespace definition
+ // in every item.
+ Element root = element;
+ while (root.getParent() != null && root.getParent() instanceof Element) {
+ root = (Element) element.getParent();
+ }
+ root.addNamespaceDeclaration(GeoRSSModule.W3CGEO_NS);
+
+ Element pointElement = element;
+ if (!isShort) {
+ pointElement = new Element("Point", GeoRSSModule.W3CGEO_NS);
+ element.addContent(pointElement);
+ }
+
+ final GeoRSSModule geoRSSModule = (GeoRSSModule) module;
+ final AbstractGeometry geometry = geoRSSModule.getGeometry();
+
+ if (geometry instanceof Point) {
+ final Position pos = ((Point) geometry).getPosition();
+
+ final Element latElement = new Element("lat", GeoRSSModule.W3CGEO_NS);
+ latElement.addContent(String.valueOf(pos.getLatitude()));
+ pointElement.addContent(latElement);
+ final Element lngElement = new Element("long", GeoRSSModule.W3CGEO_NS);
+ lngElement.addContent(String.valueOf(pos.getLongitude()));
+ pointElement.addContent(lngElement);
+ } else {
+ System.err.println("W3C Geo format can't handle geometries of type: " + geometry.getClass().getName());
+ }
+ }
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/georss/W3CGeoModuleImpl.java b/rome-modules/src/main/java/com/rometools/modules/georss/W3CGeoModuleImpl.java
new file mode 100644
index 0000000..a4ff886
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/georss/W3CGeoModuleImpl.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2006 Marc Wick, geonames.org
+ *
+ * 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 com.rometools.modules.georss;
+
+/**
+ * W3CGeoModuleImpl is the implementation of the {@link GeoRSSModule} Interface for the W3C geo
+ * format.
+ *
+ * @author Marc Wick
+ * @version $Id: W3CGeoModuleImpl.java,v 1.2 2007/04/18 09:59:29 marcwick Exp $
+ *
+ */
+public class W3CGeoModuleImpl extends GeoRSSModule {
+
+ private static final long serialVersionUID = 1L;
+
+ public W3CGeoModuleImpl() {
+ super(GeoRSSModule.class, GeoRSSModule.GEORSS_W3CGEO_URI);
+ }
+
+ @Override
+ public Class getInterface() {
+ return GeoRSSModule.class;
+ }
+
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/georss/W3CGeoParser.java b/rome-modules/src/main/java/com/rometools/modules/georss/W3CGeoParser.java
new file mode 100644
index 0000000..c887fbf
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/georss/W3CGeoParser.java
@@ -0,0 +1,90 @@
+/*
+ * Copyright 2006 Marc Wick, geonames.org
+ *
+ * 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 com.rometools.modules.georss;
+
+import java.util.Locale;
+
+import org.jdom2.Element;
+
+import com.rometools.modules.georss.geometries.Point;
+import com.rometools.modules.georss.geometries.Position;
+import com.rometools.rome.feed.module.Module;
+import com.rometools.rome.io.ModuleParser;
+import com.rometools.utils.Strings;
+
+/**
+ * W3CGeoParser is a parser for the W3C geo format.
+ *
+ * @author Marc Wick
+ * @version $Id: W3CGeoParser.java,v 1.4 2007/04/18 09:59:29 marcwick Exp $
+ *
+ */
+public class W3CGeoParser implements ModuleParser {
+
+ @Override
+ public String getNamespaceUri() {
+ return GeoRSSModule.GEORSS_W3CGEO_URI;
+ }
+
+ static Module parseW3C(final Element element) {
+
+ GeoRSSModule geoRSSModule = null;
+
+ // do we have an optional "Point" element ?
+ Element pointElement = element.getChild("Point", GeoRSSModule.W3CGEO_NS);
+
+ // we don't have an optional "Point" element
+ if (pointElement == null) {
+ pointElement = element;
+ }
+
+ final Element lat = pointElement.getChild("lat", GeoRSSModule.W3CGEO_NS);
+ Element lng = pointElement.getChild("long", GeoRSSModule.W3CGEO_NS);
+ if (lng == null) {
+ lng = pointElement.getChild("lon", GeoRSSModule.W3CGEO_NS);
+ }
+
+ if (lat != null && lng != null) {
+
+ geoRSSModule = new W3CGeoModuleImpl();
+
+ final String latTxt = Strings.trimToNull(lat.getText());
+ final String lngTxt = Strings.trimToNull(lng.getText());
+
+ if (latTxt != null && lngTxt != null) {
+
+ final double latitude = Double.parseDouble(lat.getText());
+ final double longitude = Double.parseDouble(lng.getText());
+
+ final Position position = new Position(latitude, longitude);
+
+ final Point point = new Point(position);
+
+ geoRSSModule.setGeometry(point);
+ }
+
+ }
+
+ return geoRSSModule;
+ }
+
+ @Override
+ public Module parse(final Element element, final Locale locale) {
+ return parseW3C(element);
+ }
+
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/georss/geometries/AbstractCurve.java b/rome-modules/src/main/java/com/rometools/modules/georss/geometries/AbstractCurve.java
new file mode 100644
index 0000000..12c8324
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/georss/geometries/AbstractCurve.java
@@ -0,0 +1,33 @@
+/*
+ * 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 com.rometools.modules.georss.geometries;
+
+/**
+ * Abstract base class for Curves (linear objects)
+ *
+ * @author runaas
+ */
+public abstract class AbstractCurve extends AbstractGeometricPrimitive {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+ /** Creates a new instance of Curve */
+ public AbstractCurve() {
+ }
+
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/georss/geometries/AbstractGeometricPrimitive.java b/rome-modules/src/main/java/com/rometools/modules/georss/geometries/AbstractGeometricPrimitive.java
new file mode 100644
index 0000000..7d4d431
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/georss/geometries/AbstractGeometricPrimitive.java
@@ -0,0 +1,35 @@
+/*
+ * 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 com.rometools.modules.georss.geometries;
+
+/**
+ * Abstract base class for geometric primitives (non-composite geometric objects)
+ *
+ * @author runaas
+ */
+public abstract class AbstractGeometricPrimitive extends AbstractGeometry {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+ /** Creates a new instance of GeometricPrimitive */
+ public AbstractGeometricPrimitive() {
+
+ }
+
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/georss/geometries/AbstractGeometry.java b/rome-modules/src/main/java/com/rometools/modules/georss/geometries/AbstractGeometry.java
new file mode 100644
index 0000000..40775fe
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/georss/geometries/AbstractGeometry.java
@@ -0,0 +1,50 @@
+/*
+ * 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 com.rometools.modules.georss.geometries;
+
+import java.io.Serializable;
+
+/**
+ * Abstract base class for geometries.
+ *
+ * @author runaas
+ */
+public abstract class AbstractGeometry implements Cloneable, Serializable {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+ /** Creates a new instance of Geometry */
+ public AbstractGeometry() {
+ }
+
+ /**
+ * Make a deep copy of the geometric object
+ *
+ * @return A copy of the object
+ */
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ return super.clone();
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ return obj != null && obj.getClass() == getClass();
+ }
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/georss/geometries/AbstractRing.java b/rome-modules/src/main/java/com/rometools/modules/georss/geometries/AbstractRing.java
new file mode 100644
index 0000000..610a2fa
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/georss/geometries/AbstractRing.java
@@ -0,0 +1,40 @@
+/*
+ * 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 com.rometools.modules.georss.geometries;
+
+import java.io.Serializable;
+
+/**
+ * Abstract base class for rings (closed linear objects used for polygon borders)
+ *
+ * @author runaas
+ */
+public abstract class AbstractRing implements Cloneable, Serializable {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+ /** Creates a new instance of AbstractRing */
+ public AbstractRing() {
+ }
+
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ return super.clone();
+ }
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/georss/geometries/AbstractSurface.java b/rome-modules/src/main/java/com/rometools/modules/georss/geometries/AbstractSurface.java
new file mode 100644
index 0000000..3776530
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/georss/geometries/AbstractSurface.java
@@ -0,0 +1,34 @@
+/*
+ * 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 com.rometools.modules.georss.geometries;
+
+/**
+ * Abstract base class for surface (area) objects
+ *
+ * @author runaas
+ */
+public abstract class AbstractSurface extends AbstractGeometricPrimitive {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+ /** Creates a new instance of Surface */
+ public AbstractSurface() {
+ }
+
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/georss/geometries/Envelope.java b/rome-modules/src/main/java/com/rometools/modules/georss/geometries/Envelope.java
new file mode 100644
index 0000000..a80e6b8
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/georss/geometries/Envelope.java
@@ -0,0 +1,107 @@
+/*
+ * 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 com.rometools.modules.georss.geometries;
+
+/**
+ * Envelope, a bounding box spanned by an upper right and lower left corner point. Note that if the
+ * box spans the -180 180 degree meridian the numerical value of the minLongitude may be greater
+ * than the maxLongitude.
+ *
+ * @author runaas
+ */
+public class Envelope extends AbstractGeometry {
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ protected double minLatitude, minLongitude, maxLatitude, maxLongitude;
+
+ /** Creates a new instance of Envelope */
+ public Envelope() {
+ minLatitude = minLongitude = maxLatitude = maxLongitude = Double.NaN;
+ }
+
+ /**
+ * Construct object from coordinate values
+ *
+ * @param minLatitude
+ * @param minLongitude
+ * @param maxLatitude
+ * @param maxLongitude
+ */
+ public Envelope(final double minLatitude, final double minLongitude, final double maxLatitude, final double maxLongitude) {
+ this.minLatitude = minLatitude;
+ this.minLongitude = minLongitude;
+ this.maxLatitude = maxLatitude;
+ this.maxLongitude = maxLongitude;
+ }
+
+ /**
+ * @return the minimum longitude
+ */
+ public double getMinLongitude() {
+ return minLongitude;
+ }
+
+ /**
+ * @return the minimum latitude
+ */
+ public double getMinLatitude() {
+ return minLatitude;
+ }
+
+ /**
+ * @return the maximum longitude
+ */
+ public double getMaxLongitude() {
+ return maxLongitude;
+ }
+
+ /**
+ * @return the maximum latitude
+ */
+ public double getMaxLatitude() {
+ return maxLatitude;
+ }
+
+ /**
+ * @param v minimum longitude
+ */
+ public void setMinLongitude(final double v) {
+ minLongitude = v;
+ }
+
+ /**
+ * @param v minimum latitude
+ */
+ public void setMinLatitude(final double v) {
+ minLatitude = v;
+ }
+
+ /**
+ * @param v maximum longitude
+ */
+ public void setMaxLongitude(final double v) {
+ maxLongitude = v;
+ }
+
+ /**
+ * @param v maximum latitude
+ */
+ public void setMaxLatitude(final double v) {
+ maxLatitude = v;
+ }
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/georss/geometries/LineString.java b/rome-modules/src/main/java/com/rometools/modules/georss/geometries/LineString.java
new file mode 100644
index 0000000..0f31d6a
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/georss/geometries/LineString.java
@@ -0,0 +1,82 @@
+/*
+ * 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 com.rometools.modules.georss.geometries;
+
+/**
+ * Linear object constructed by linear interpolation between points
+ *
+ * @author runaas
+ */
+public final class LineString extends AbstractCurve {
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ private PositionList posList;
+
+ /** Creates a new instance of LineString */
+ public LineString() {
+
+ }
+
+ /**
+ * Construct object from a position list
+ */
+ public LineString(final PositionList posList) {
+ this.posList = posList;
+ }
+
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ final LineString retval = (LineString) super.clone();
+ if (posList != null) {
+ retval.posList = (PositionList) posList.clone();
+ }
+ return retval;
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (!super.equals(obj)) {
+ return false;
+ }
+ return getPositionList().equals(((LineString) obj).getPositionList());
+ }
+
+ /**
+ * Get the position list
+ *
+ * @return the positionlist
+ */
+ public PositionList getPositionList() {
+ if (posList == null) {
+ posList = new PositionList();
+ }
+ return posList;
+ }
+
+ /**
+ * Set the position list
+ *
+ * @param posList the new position list
+ */
+ public void setPositionList(final PositionList posList) {
+ this.posList = posList;
+ }
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/georss/geometries/LinearRing.java b/rome-modules/src/main/java/com/rometools/modules/georss/geometries/LinearRing.java
new file mode 100644
index 0000000..fe3ec59
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/georss/geometries/LinearRing.java
@@ -0,0 +1,79 @@
+/*
+ * 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 com.rometools.modules.georss.geometries;
+
+/**
+ * Linear boundary object constructed by linear interpolation between points. Start and end point
+ * should be identical.
+ *
+ * @author runaas
+ */
+public final class LinearRing extends AbstractRing {
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ private PositionList posList;
+
+ /** Creates a new instance of LinearLing */
+ public LinearRing() {
+ }
+
+ public LinearRing(final PositionList posList) {
+ this.posList = posList;
+ }
+
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ final LinearRing retval = (LinearRing) super.clone();
+ if (posList != null) {
+ retval.posList = (PositionList) posList.clone();
+ }
+ return retval;
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (!super.equals(obj)) {
+ return false;
+ }
+ return getPositionList().equals(((LinearRing) obj).getPositionList());
+ }
+
+ /**
+ * Get the position list
+ *
+ * @return the positionlist
+ */
+ public PositionList getPositionList() {
+ if (posList == null) {
+ posList = new PositionList();
+ }
+ return posList;
+ }
+
+ /**
+ * Set the position list
+ *
+ * @param posList the new position list
+ */
+ public void setPositionList(final PositionList posList) {
+ this.posList = posList;
+ }
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/georss/geometries/Point.java b/rome-modules/src/main/java/com/rometools/modules/georss/geometries/Point.java
new file mode 100644
index 0000000..8df1f99
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/georss/geometries/Point.java
@@ -0,0 +1,79 @@
+/*
+ * 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 com.rometools.modules.georss.geometries;
+
+/**
+ * Point object, contains a position
+ *
+ * @author runaas
+ */
+public final class Point extends AbstractGeometricPrimitive {
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ private Position pos;
+
+ /** Creates a new instance of Point */
+ public Point() {
+
+ }
+
+ public Point(final Position pos) {
+ this.pos = pos;
+ }
+
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ final Point retval = (Point) super.clone();
+ if (pos != null) {
+ retval.pos = (Position) pos.clone();
+ }
+ return retval;
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (!super.equals(obj)) {
+ return false;
+ }
+ return getPosition().equals(((Point) obj).getPosition());
+ }
+
+ /**
+ * Get the position
+ *
+ * @return the position
+ */
+ public Position getPosition() {
+ if (pos == null) {
+ pos = new Position();
+ }
+ return pos;
+ }
+
+ /**
+ * Set the position
+ *
+ * @param pos the new position
+ */
+ public void setPosition(final Position pos) {
+ this.pos = pos;
+ }
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/georss/geometries/Polygon.java b/rome-modules/src/main/java/com/rometools/modules/georss/geometries/Polygon.java
new file mode 100644
index 0000000..35db7c5
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/georss/geometries/Polygon.java
@@ -0,0 +1,128 @@
+/*
+ * 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 com.rometools.modules.georss.geometries;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * Polygon, a surface object bounded by one external ring and zero or more internal rings
+ *
+ * @author runaas
+ */
+public final class Polygon extends AbstractSurface implements Cloneable {
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ private AbstractRing exterior;
+ private List interior;
+
+ /** Creates a new instance of Polygon */
+ public Polygon() {
+
+ }
+
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ final Polygon retval = (Polygon) super.clone();
+ if (exterior != null) {
+ retval.exterior = (AbstractRing) exterior.clone();
+ }
+ if (interior != null) {
+ retval.interior = new ArrayList();
+ final Iterator it = interior.iterator();
+ while (it.hasNext()) {
+ final AbstractRing r = it.next();
+ retval.interior.add((AbstractRing) r.clone());
+ }
+ }
+ return retval;
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (!super.equals(obj)) {
+ return false;
+ }
+ final Polygon pol = (Polygon) obj;
+ if (exterior == null && pol.exterior == null) {
+ ;
+ } else if (exterior == null || pol.exterior == null) {
+ return false;
+ } else if (!exterior.equals(pol.exterior)) {
+ return false;
+ }
+
+ // Not efficient.... (but the number of internal ringr is usually small).
+ Iterator it = interior.iterator();
+ while (it.hasNext()) {
+ if (!pol.interior.contains(it.next())) {
+ return false;
+ }
+ }
+ it = pol.interior.iterator();
+ while (it.hasNext()) {
+ if (!interior.contains(it.next())) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Retrieve the outer border
+ *
+ * @return the border ring
+ */
+ public AbstractRing getExterior() {
+ return exterior;
+ }
+
+ /**
+ * Retrieve the inner border
+ *
+ * @return the list of border rings
+ */
+ public List getInterior() {
+ if (interior == null) {
+ interior = new ArrayList();
+ }
+ return interior;
+ }
+
+ /**
+ * Set the outer border
+ *
+ * @param exterior the outer ring
+ */
+ public void setExterior(final AbstractRing exterior) {
+ this.exterior = exterior;
+ }
+
+ /**
+ * Set the list of inner borders (holes)
+ *
+ * @param interior the list of inner rings
+ */
+ public void setInterior(final List interior) {
+ this.interior = interior;
+ }
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/georss/geometries/Position.java b/rome-modules/src/main/java/com/rometools/modules/georss/geometries/Position.java
new file mode 100644
index 0000000..7d4904b
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/georss/geometries/Position.java
@@ -0,0 +1,99 @@
+/*
+ * 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 com.rometools.modules.georss.geometries;
+
+import java.io.Serializable;
+
+/**
+ * A two dimensional position represented by latitude and longitude decimal degrees in WGS84
+ *
+ * @author runaas
+ */
+public class Position implements Cloneable, Serializable {
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ private double latitude;
+ private double longitude;
+
+ /** Creates a new instance of Position */
+ public Position() {
+ latitude = Double.NaN;
+ longitude = Double.NaN;
+ }
+
+ /**
+ * Create Position from a pair of coordinate values
+ *
+ * @param latitude
+ * @param longitude
+ */
+ public Position(final double latitude, final double longitude) {
+ this.latitude = latitude;
+ this.longitude = longitude;
+ }
+
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ return super.clone();
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (!super.equals(obj)) {
+ return false;
+ }
+
+ final Position p = (Position) obj;
+ return p.latitude == latitude && p.longitude == longitude;
+ }
+
+ /**
+ * @return latitude
+ */
+ public double getLatitude() {
+ return latitude;
+ }
+
+ /**
+ * Set the latitude
+ *
+ * @param latitude the new latitude
+ */
+ public void setLatitude(final double latitude) {
+ this.latitude = latitude;
+ }
+
+ /**
+ * @return longitude
+ */
+ public double getLongitude() {
+ return longitude;
+ }
+
+ /**
+ * Set the longitude
+ *
+ * @param longitude the new longitude
+ */
+ public void setLongitude(final double longitude) {
+ this.longitude = longitude;
+ }
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/georss/geometries/PositionList.java b/rome-modules/src/main/java/com/rometools/modules/georss/geometries/PositionList.java
new file mode 100644
index 0000000..509008d
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/georss/geometries/PositionList.java
@@ -0,0 +1,169 @@
+/*
+ * 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 com.rometools.modules.georss.geometries;
+
+import java.io.Serializable;
+
+/**
+ * A list of geographic positions, latitude, longitude decimal degrees WGS84
+ *
+ * @author runaas
+ */
+public class PositionList implements Cloneable, Serializable {
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ private double[] latitude;
+ private double[] longitude;
+ private int size;
+
+ /** Creates a new empty instance of PositionList */
+ public PositionList() {
+ size = 0;
+ }
+
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ final PositionList retval = (PositionList) super.clone();
+ if (latitude != null) {
+ retval.latitude = latitude.clone();
+ }
+ if (longitude != null) {
+ retval.longitude = longitude.clone();
+ }
+ retval.size = size;
+ return retval;
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (!super.equals(obj)) {
+ return false;
+ }
+
+ final PositionList p = (PositionList) obj;
+ if (p.size != size) {
+ return false;
+ }
+ for (int i = 0; i < size; ++i) {
+ if (p.latitude[i] != latitude[i] || p.longitude[i] != longitude[i]) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ private void ensureCapacity(int new_size) {
+ if (longitude != null && longitude.length >= new_size) {
+ return;
+ }
+ if (new_size < 4) {
+ new_size = 4;
+ } else {
+ new_size = (int) Math.ceil(Math.pow(2, Math.ceil(Math.log(new_size) / Math.log(2))));
+ }
+ double[] tmp = new double[new_size];
+ if (longitude != null) {
+ System.arraycopy(longitude, 0, tmp, 0, size);
+ }
+ longitude = tmp;
+ tmp = new double[new_size];
+ if (latitude != null) {
+ System.arraycopy(latitude, 0, tmp, 0, size);
+ }
+ latitude = tmp;
+ }
+
+ /**
+ * @return the number of positions in the list
+ */
+ public int size() {
+ return size;
+ }
+
+ /**
+ * @param pos position index
+ * @return longitude for position
+ */
+ public double getLongitude(final int pos) {
+ return longitude[pos];
+ }
+
+ /**
+ * @param pos position index
+ * @return latitude for position
+ */
+ public double getLatitude(final int pos) {
+ return latitude[pos];
+ }
+
+ /**
+ * Add a position at the end of the list
+ *
+ * @param latitude
+ * @param longitude
+ */
+ public void add(final double latitude, final double longitude) {
+ ensureCapacity(size + 1);
+ this.longitude[size] = longitude;
+ this.latitude[size] = latitude;
+ ++size;
+ }
+
+ /**
+ * Add a position at a given index in the list. The rest of the list is shifted one place to the
+ * "right"
+ *
+ * @param pos position index
+ * @param latitude
+ * @param longitude
+ */
+ public void insert(final int pos, final double latitude, final double longitude) {
+ ensureCapacity(size + 1);
+ System.arraycopy(this.longitude, pos, this.longitude, pos + 1, size - pos);
+ System.arraycopy(this.latitude, pos, this.latitude, pos + 1, size - pos);
+ this.longitude[pos] = longitude;
+ this.latitude[pos] = latitude;
+ ++size;
+ }
+
+ /**
+ * Replace the position at the index with new values
+ *
+ * @param pos position index
+ * @param latitude
+ * @param longitude
+ */
+ public void replace(final int pos, final double latitude, final double longitude) {
+ this.longitude[pos] = longitude;
+ this.latitude[pos] = latitude;
+ }
+
+ /**
+ * Remove the position at the index, the rest of the list is shifted one place to the "left"
+ *
+ * @param pos position index
+ */
+ public void remove(final int pos) {
+ System.arraycopy(longitude, pos + 1, longitude, pos, size - pos - 1);
+ System.arraycopy(latitude, pos + 1, latitude, pos, size - pos - 1);
+ --size;
+ }
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/georss/geometries/package.html b/rome-modules/src/main/java/com/rometools/modules/georss/geometries/package.html
new file mode 100644
index 0000000..2d7654a
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/georss/geometries/package.html
@@ -0,0 +1,14 @@
+
+
+
+
+ Geometry package documetation
+
+
+ This package contains classes for handling of geometric objects in a
+ geographical context, mainly for
+ use with the GeoRSS library. The geometry objects closely mimics the model
+ used for the geometry part of GML
+ 3.1.1 "simple features", and supports the whole GeoRSS GML profile.
+
+
diff --git a/rome-modules/src/main/java/com/rometools/modules/georss/package.html b/rome-modules/src/main/java/com/rometools/modules/georss/package.html
new file mode 100644
index 0000000..bf84f47
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/georss/package.html
@@ -0,0 +1,46 @@
+
+
+
+
+ GeoRSS package documentation
+
+
+
+
+
+This package contains classes to enable the rome rss library with georss support.
+GeoRSS describes a number of ways to encoding location in RSS feeds
+
+
+
GeoRSSModule geoRSSModule = new W3CGeoModuleImpl();
+ //GeoRSSModule geoRSSModule = new SimpleModuleImpl();
+ geoRSSModule.setPosition(new Position(47.0, 9.0));
+ entry.getModules().add(geoRSSModule);
+
+
+
+
diff --git a/rome-modules/src/main/java/com/rometools/modules/itunes/AbstractITunesObject.java b/rome-modules/src/main/java/com/rometools/modules/itunes/AbstractITunesObject.java
new file mode 100644
index 0000000..948d47e
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/itunes/AbstractITunesObject.java
@@ -0,0 +1,273 @@
+/*
+ * AbstractITunesObject.java
+ *
+ * Created on August 1, 2005, 7:37 PM
+ *
+ * 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.
+ *
+ */
+package com.rometools.modules.itunes;
+
+import java.net.URL;
+
+/**
+ * This is an abstract object that implements the attributes common across Feeds or Items in an
+ * iTunes compatible RSS feed.
+ *
+ * @version $Revision: 1.4 $
+ * @author Robert "kebernet" Cooper
+ */
+public abstract class AbstractITunesObject implements ITunes, java.lang.Cloneable {
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * The URI that iTunes used for its custom tags.
+ *
+ * What is up with using a versioned DTD anyway?
+ *
+ * \
+ */
+ public static final String URI = "http://www.itunes.com/dtds/podcast-1.0.dtd";
+
+ /**
+ * The RDF namespace URI.
+ */
+ public static final String RDF_URI = "http://www.w3.org/1999/02/22-rdf-syntax-ns#";
+
+ /**
+ * A default prefix to use for itunes tags.
+ */
+ public static final String PREFIX = "itunes";
+ private String author;
+ private boolean block;
+ private boolean explicit;
+ private URL image;
+ private String[] keywords;
+ private String subtitle;
+ private String summary;
+
+ /**
+ * Defined by the ROME API
+ *
+ * @return Class of the Interface for this module.
+ */
+ @Override
+ public Class extends AbstractITunesObject> getInterface() {
+ return getClass();
+ }
+
+ /**
+ * The URI this module implements
+ *
+ * @return "http://www.itunes.com/dtds/podcast-1.0.dtd"
+ */
+ @Override
+ public String getUri() {
+ return AbstractITunesObject.URI;
+ }
+
+ /**
+ * Required by the ROME API
+ *
+ * @return A clone of this module object
+ */
+ @Override
+ public abstract Object clone();
+
+ /**
+ * Returns the author string for this feed or entry
+ *
+ * @return Returns the author string for this feed or entry
+ */
+ @Override
+ public String getAuthor() {
+ return author;
+ }
+
+ /**
+ * Sets the author string for this feed or entry
+ *
+ * @param author Sets the author string for this feed or entry
+ */
+ @Override
+ public void setAuthor(final String author) {
+ this.author = author;
+ }
+
+ /**
+ * Boolean as to whether to block this feed or entry
+ *
+ * @return Boolean as to whether to block this feed or entry
+ */
+ @Override
+ public boolean getBlock() {
+ return block;
+ }
+
+ /**
+ * Boolean as to whether to block this feed or entry
+ *
+ * @param block Boolean as to whether to block this feed or entry
+ */
+ @Override
+ public void setBlock(final boolean block) {
+ this.block = block;
+ }
+
+ /**
+ * Boolean as to whether this feed or entry contains adult content
+ *
+ * @return Boolean as to whether this feed or entry contains adult content
+ */
+ @Override
+ public boolean getExplicit() {
+ return explicit;
+ }
+
+ /**
+ * Boolean as to whether this feed or entry contains adult content
+ *
+ * @param explicit Boolean as to whether this feed or entry contains adult content
+ */
+ @Override
+ public void setExplicit(final boolean explicit) {
+ this.explicit = explicit;
+ }
+
+ @Override
+ public URL getImage() {
+ return image;
+ }
+
+ @Override
+ public void setImage(final URL image) {
+ this.image = image;
+ }
+
+ /**
+ * A list of keywords for this feed or entry
+ *
+ * Must not contain spaces
+ *
+ * @return A list of keywords for this feed or entry
+ */
+ @Override
+ public String[] getKeywords() {
+ return keywords == null ? new String[0] : keywords;
+ }
+
+ /**
+ * A list of keywords for this feed or entry
+ *
+ * Must not contain spaces
+ *
+ * @param keywords A list of keywords for this feed or enty
+ */
+ @Override
+ public void setKeywords(final String[] keywords) {
+ this.keywords = keywords;
+ }
+
+ /**
+ * A subtitle for this feed or entry
+ *
+ * @return A subtitle for this feed or entry
+ */
+ @Override
+ public String getSubtitle() {
+ return subtitle;
+ }
+
+ /**
+ * A subtitle for this feed or entry
+ *
+ * @param subtitle A subtitle for this feed or entry
+ */
+ @Override
+ public void setSubtitle(final String subtitle) {
+ this.subtitle = subtitle;
+ }
+
+ /**
+ * A subtitle for this feed or entry
+ *
+ * @return A subtitle for this feed or entry
+ */
+ @Override
+ public String getSummary() {
+ return summary;
+ }
+
+ /**
+ * A subtitle for this feed or entry
+ *
+ * @param summary A subtitle for this feed or entry
+ */
+ @Override
+ public void setSummary(final String summary) {
+ this.summary = summary;
+ }
+
+ @Override
+ public String toString() {
+ final StringBuffer sb = new StringBuffer("[");
+ sb.append(" Author: ");
+ sb.append(getAuthor());
+ sb.append(" Block: ");
+ sb.append(getBlock());
+ sb.append(" Explicit: ");
+ sb.append(getExplicit());
+ sb.append(" Image: ");
+ sb.append(getImage());
+ sb.append(" Keywords: ");
+
+ if (getKeywords() != null) {
+ for (int i = 0; i < keywords.length; i++) {
+ sb.append("'" + getKeywords()[i] + "'");
+ }
+ }
+
+ sb.append(" Subtitle: ");
+ sb.append(getSubtitle());
+ sb.append(" Summary: ");
+ sb.append(getSummary());
+ sb.append("]");
+
+ return sb.toString();
+ }
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/itunes/EntryInformation.java b/rome-modules/src/main/java/com/rometools/modules/itunes/EntryInformation.java
new file mode 100644
index 0000000..4710a1e
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/itunes/EntryInformation.java
@@ -0,0 +1,76 @@
+/*
+ * EntryInformation.java
+ *
+ * Created on November 19, 2005, 10:56 PM
+ *
+ * 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.
+ *
+ */
+
+package com.rometools.modules.itunes;
+
+import com.rometools.modules.itunes.types.Duration;
+
+/**
+ * This class contains information for iTunes podcast feeds that exist at the Item level.
+ *
+ * @author Robert "kebernet" Cooper
+ * @version $Revision: 1.2 $
+ *
+ */
+public interface EntryInformation extends ITunes {
+
+ /**
+ * Returns the Duration object for this Item
+ *
+ * @return Returns the Duration object for this Item
+ */
+ public Duration getDuration();
+
+ /**
+ * Sets the Duration object for this Item
+ *
+ * @param duration Sets the Duration object for this Item
+ */
+ public void setDuration(Duration duration);
+
+ public boolean getClosedCaptioned();
+
+ public void setClosedCaptioned(boolean closedCaptioned);
+
+ public Integer getOrder();
+
+ public void setOrder(Integer order);
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/itunes/EntryInformationImpl.java b/rome-modules/src/main/java/com/rometools/modules/itunes/EntryInformationImpl.java
new file mode 100644
index 0000000..b85449b
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/itunes/EntryInformationImpl.java
@@ -0,0 +1,178 @@
+/*
+ * EntryInformation.java
+ *
+ * Created on August 1, 2005, 7:37 PM
+ *
+ * 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.
+ *
+ */
+package com.rometools.modules.itunes;
+
+import com.rometools.modules.itunes.types.Duration;
+import com.rometools.rome.feed.CopyFrom;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+
+/**
+ * This class contains information for iTunes podcast feeds that exist at the Item level.
+ *
+ * @version $Revision: 1.2 $
+ * @author Robert "kebernet" Cooper
+ */
+public class EntryInformationImpl extends AbstractITunesObject implements EntryInformation {
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+ private static final Logger LOG = LoggerFactory.getLogger(EntryInformationImpl.class);
+
+ private Duration duration;
+ private boolean closedCaptioned;
+ private Integer order;
+
+ /**
+ * Creates a new instance of EntryInformationImpl
+ */
+ public EntryInformationImpl() {
+ }
+
+ /**
+ * Returns the Duration object for this Item
+ *
+ * @return Returns the Duration object for this Item
+ */
+ @Override
+ public Duration getDuration() {
+ return duration;
+ }
+
+ /**
+ * Sets the Duration object for this Item
+ *
+ * @param duration Sets the Duration object for this Item
+ */
+ @Override
+ public void setDuration(final Duration duration) {
+ this.duration = duration;
+ }
+
+ @Override
+ public boolean getClosedCaptioned() {
+ return closedCaptioned;
+ }
+
+ @Override
+ public void setClosedCaptioned(boolean closedCaptioned) {
+ this.closedCaptioned = closedCaptioned;
+ }
+
+ @Override
+ public Integer getOrder() {
+ return order;
+ }
+
+ @Override
+ public void setOrder(Integer order) {
+ this.order = order;
+ }
+
+ /**
+ * Defined by the ROME module API
+ *
+ * @param obj Object to copy from
+ */
+ @Override
+ public void copyFrom(final CopyFrom obj) {
+ final EntryInformationImpl info = (EntryInformationImpl) obj;
+ setAuthor(info.getAuthor());
+ setBlock(info.getBlock());
+
+ if (info.getDuration() != null) {
+ setDuration(new Duration(info.getDuration().getMilliseconds()));
+ }
+
+ setExplicit(info.getExplicit());
+
+ try {
+ if (info.getImage() != null) {
+ setImage(new URL(info.getImage().toExternalForm()));
+ }
+ } catch (final MalformedURLException e) {
+ LOG.debug("Error copying URL:" + info.getImage(), e);
+ }
+
+ if (info.getKeywords() != null) {
+ setKeywords(info.getKeywords().clone());
+ }
+
+ setSubtitle(info.getSubtitle());
+ setSummary(info.getSummary());
+ setClosedCaptioned(info.getClosedCaptioned());
+ setOrder(info.getOrder());
+ }
+
+ /**
+ * Required by the ROME API
+ *
+ * @return A clone of this module object
+ */
+ @Override
+ public Object clone() {
+ final EntryInformationImpl info = new EntryInformationImpl();
+ info.copyFrom(this);
+
+ return info;
+ }
+
+ @Override
+ public String toString() {
+ final StringBuffer sb = new StringBuffer("[");
+ sb.append(" duration: ");
+ sb.append(getDuration());
+ sb.append(" closedCaptioned: ");
+ sb.append(getClosedCaptioned());
+ sb.append(" order: ");
+ sb.append(getOrder());
+ sb.append("]");
+ sb.append(super.toString());
+
+ return sb.toString();
+ }
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/itunes/FeedInformation.java b/rome-modules/src/main/java/com/rometools/modules/itunes/FeedInformation.java
new file mode 100644
index 0000000..9f2965d
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/itunes/FeedInformation.java
@@ -0,0 +1,105 @@
+/*
+ * FeedInformation.java
+ *
+ * Created on November 19, 2005, 10:57 PM
+ *
+ * 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.
+ *
+ */
+package com.rometools.modules.itunes;
+
+import java.net.URL;
+import java.util.List;
+
+import com.rometools.modules.itunes.types.Category;
+
+/**
+ * This class contains information for iTunes podcast feeds that exist at the Channel level.
+ *
+ * @author Robert "kebernet" Cooper
+ * @version $Revision: 1.2 $
+ */
+public interface FeedInformation extends ITunes {
+
+ /**
+ * The parent categories for this feed
+ *
+ * @return The parent categories for this feed
+ */
+ public List getCategories();
+
+ /**
+ * The parent categories for this feed
+ *
+ * @param categories The parent categories for this feed
+ */
+ public void setCategories(List categories);
+
+ public boolean getComplete();
+
+ public void setComplete(boolean complete);
+
+ public String getNewFeedUrl();
+
+ public void setNewFeedUrl(String newFeedUrl);
+
+ /**
+ * Sets the owner email address for the feed.
+ *
+ * @param ownerEmailAddress Sets the owner email address for the feed.
+ */
+ public void setOwnerEmailAddress(String ownerEmailAddress);
+
+ /**
+ * Returns the owner email address for the feed.
+ *
+ * @return Returns the owner email address for the feed.
+ */
+ public String getOwnerEmailAddress();
+
+ /**
+ * Sets the owner name for the feed
+ *
+ * @param ownerName Sets the owner name for the feed
+ */
+ public void setOwnerName(String ownerName);
+
+ /**
+ * Returns the owner name for the feed
+ *
+ * @return Returns the owner name for the feed
+ */
+ public String getOwnerName();
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/itunes/FeedInformationImpl.java b/rome-modules/src/main/java/com/rometools/modules/itunes/FeedInformationImpl.java
new file mode 100644
index 0000000..07f584f
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/itunes/FeedInformationImpl.java
@@ -0,0 +1,228 @@
+/*
+ * FeedInformation.java
+ *
+ * Created on August 1, 2005, 7:11 PM
+ *
+ *
+ * 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.
+ *
+ */
+package com.rometools.modules.itunes;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.rometools.modules.itunes.types.Category;
+import com.rometools.rome.feed.CopyFrom;
+
+/**
+ * This class contains information for iTunes podcast feeds that exist at the Channel level.
+ *
+ * @version $Revision: 1.2 $
+ * @author Robert "kebernet" Cooper
+ */
+public class FeedInformationImpl extends AbstractITunesObject implements FeedInformation {
+
+ private static final long serialVersionUID = 1L;
+
+ private static final Logger LOG = LoggerFactory.getLogger(FeedInformationImpl.class);
+
+ private String ownerName;
+ private String ownerEmailAddress;
+ private List categories;
+ private boolean complete;
+ private String newFeedUrl;
+
+ /**
+ * Creates a new instance of FeedInformationImpl
+ */
+ public FeedInformationImpl() {
+ }
+
+ /**
+ * The parent categories for this feed
+ *
+ * @return The parent categories for this feed
+ */
+ @Override
+ public List getCategories() {
+ return categories == null ? (categories = new ArrayList()) : categories;
+ }
+
+ /**
+ * The parent categories for this feed
+ *
+ * @param categories The parent categories for this feed
+ */
+ @Override
+ public void setCategories(final List categories) {
+ this.categories = categories;
+ }
+
+ @Override
+ public boolean getComplete() {
+ return complete;
+ }
+
+ @Override
+ public void setComplete(boolean complete) {
+ this.complete = complete;
+ }
+
+ @Override
+ public String getNewFeedUrl() {
+ return newFeedUrl;
+ }
+
+ @Override
+ public void setNewFeedUrl(String newFeedUrl) {
+ this.newFeedUrl = newFeedUrl;
+ }
+
+ /**
+ * Returns the owner name for the feed
+ *
+ * @return Returns the owner name for the feed
+ */
+ @Override
+ public String getOwnerName() {
+ return ownerName;
+ }
+
+ /**
+ * Sets the owner name for the feed
+ *
+ * @param ownerName Sets the owner name for the feed
+ */
+ @Override
+ public void setOwnerName(final String ownerName) {
+ this.ownerName = ownerName;
+ }
+
+ /**
+ * Returns the owner email address for the feed.
+ *
+ * @return Returns the owner email address for the feed.
+ */
+ @Override
+ public String getOwnerEmailAddress() {
+ return ownerEmailAddress;
+ }
+
+ /**
+ * Sets the owner email address for the feed.
+ *
+ * @param ownerEmailAddress Sets the owner email address for the feed.
+ */
+ @Override
+ public void setOwnerEmailAddress(final String ownerEmailAddress) {
+ this.ownerEmailAddress = ownerEmailAddress;
+ }
+
+ /**
+ * Required by the ROME API
+ *
+ * @param obj object to copy property values from
+ */
+ @Override
+ public void copyFrom(final CopyFrom obj) {
+ final FeedInformationImpl info = (FeedInformationImpl) obj;
+ setAuthor(info.getAuthor());
+ setBlock(info.getBlock());
+
+ getCategories().clear();
+ if (info.getCategories() != null) {
+ getCategories().addAll(info.getCategories());
+ }
+
+ setComplete(info.getComplete());
+ setNewFeedUrl(info.getNewFeedUrl());
+ setExplicit(info.getExplicit());
+
+ try {
+ if (info.getImage() != null) {
+ setImage(new URL(info.getImage().toExternalForm()));
+ }
+ } catch (final MalformedURLException e) {
+ LOG.debug("Error copying URL:" + info.getImage(), e);
+ }
+
+ if (info.getKeywords() != null) {
+ setKeywords(info.getKeywords().clone());
+ }
+
+ setOwnerEmailAddress(info.getOwnerEmailAddress());
+ setOwnerName(info.getOwnerName());
+ setSubtitle(info.getSubtitle());
+ setSummary(info.getSummary());
+ }
+
+ /**
+ * Returns a copy of this FeedInformationImpl object
+ *
+ * @return Returns a copy of this FeedInformationImpl object
+ */
+ @Override
+ public Object clone() {
+ final FeedInformationImpl info = new FeedInformationImpl();
+ info.copyFrom(this);
+
+ return info;
+ }
+
+ @Override
+ public String toString() {
+ final StringBuffer sb = new StringBuffer("[");
+ sb.append(" email: ");
+ sb.append(getOwnerEmailAddress());
+ sb.append(" name: ");
+ sb.append(getOwnerName());
+ sb.append(" categories: ");
+ sb.append(getCategories());
+ sb.append(" complete: ");
+ sb.append(getComplete());
+ sb.append(" newFeedUrl: ");
+ sb.append(getNewFeedUrl());
+ sb.append("]");
+ sb.append(super.toString());
+
+ return sb.toString();
+ }
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/itunes/ITunes.java b/rome-modules/src/main/java/com/rometools/modules/itunes/ITunes.java
new file mode 100644
index 0000000..1451f95
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/itunes/ITunes.java
@@ -0,0 +1,149 @@
+/*
+ * ITunes.java
+ *
+ * Created on November 19, 2005, 10:58 PM
+ *
+ * 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.
+ */
+
+package com.rometools.modules.itunes;
+
+import com.rometools.rome.feed.module.Module;
+
+import java.net.URL;
+
+/**
+ * This interface contains the methods common to all iTunes module points.
+ *
+ * @author Robert "kebernet" Cooper
+ * @version $Revision: 1.3 $
+ */
+public interface ITunes extends Module {
+
+ public static final String URI = AbstractITunesObject.URI;
+
+ /**
+ * Returns the author string for this feed or entry
+ *
+ * @return Returns the author string for this feed or entry
+ */
+ public String getAuthor();
+
+ /**
+ * Sets the author string for this feed or entry
+ *
+ * @param author Sets the author string for this feed or entry
+ */
+ public void setAuthor(String author);
+
+ /**
+ * Boolean as to whether to block this feed or entry
+ *
+ * @return Boolean as to whether to block this feed or entry
+ */
+ public boolean getBlock();
+
+ /**
+ * Boolean as to whether to block this feed or entry
+ *
+ * @param block Boolean as to whether to block this feed or entry
+ */
+ public void setBlock(boolean block);
+
+ /**
+ * Boolean as to whether this feed or entry contains adult content
+ *
+ * @return Boolean as to whether this feed or entry contains adult content
+ */
+ public boolean getExplicit();
+
+ /**
+ * Boolean as to whether this feed or entry contains adult content
+ *
+ * @param explicit Boolean as to whether this feed or entry contains adult content
+ */
+ public void setExplicit(boolean explicit);
+
+ public URL getImage();
+
+ public void setImage(URL image);
+
+ /**
+ * A list of keywords for this feed or entry
+ *
+ * Must not contain spaces
+ *
+ * @return A list of keywords for this feed or entry
+ */
+ public String[] getKeywords();
+
+ /**
+ * A list of keywords for this feed or entry
+ *
+ * Must not contain spaces
+ *
+ * @param keywords A list of keywords for this feed or enty
+ */
+ public void setKeywords(String[] keywords);
+
+ /**
+ * A subtitle for this feed or entry
+ *
+ * @return A subtitle for this feed or entry
+ */
+ public String getSubtitle();
+
+ /**
+ * A subtitle for this feed or entry
+ *
+ * @param subtitle A subtitle for this feed or entry
+ */
+ public void setSubtitle(String subtitle);
+
+ /**
+ * A subtitle for this feed or entry
+ *
+ * @return A subtitle for this feed or entry
+ */
+ public String getSummary();
+
+ /**
+ * A subtitle for this feed or entry
+ *
+ * @param summary A subtitle for this feed or entry
+ */
+ public void setSummary(String summary);
+
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/itunes/io/ITunesGenerator.java b/rome-modules/src/main/java/com/rometools/modules/itunes/io/ITunesGenerator.java
new file mode 100644
index 0000000..e4fc68a
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/itunes/io/ITunesGenerator.java
@@ -0,0 +1,207 @@
+/*
+ * ITunesGenerator.java
+ *
+ * Created on August 1, 2005, 10:44 PM
+ *
+ * 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.
+ *
+ */
+package com.rometools.modules.itunes.io;
+
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.jdom2.Element;
+import org.jdom2.Namespace;
+
+import com.rometools.modules.itunes.AbstractITunesObject;
+import com.rometools.modules.itunes.EntryInformationImpl;
+import com.rometools.modules.itunes.FeedInformationImpl;
+import com.rometools.modules.itunes.types.Category;
+import com.rometools.rome.feed.module.Module;
+import com.rometools.rome.io.ModuleGenerator;
+
+/**
+ * @version $Revision: 1.3 $
+ * @author Robert "kebernet" Cooper
+ */
+public class ITunesGenerator implements ModuleGenerator {
+
+ private static final HashSet NAMESPACES = new HashSet();
+ private static final Namespace NAMESPACE = Namespace.getNamespace(AbstractITunesObject.PREFIX, AbstractITunesObject.URI);
+
+ static {
+ NAMESPACES.add(NAMESPACE);
+ }
+
+ /** Creates a new instance of ITunesGenerator */
+ public ITunesGenerator() {
+ }
+
+ @Override
+ public void generate(final Module module, final Element element) {
+ Element root = element;
+
+ while (root.getParent() != null && root.getParent() instanceof Element) {
+ root = (Element) root.getParent();
+ }
+
+ root.addNamespaceDeclaration(NAMESPACE);
+
+ if (!(module instanceof AbstractITunesObject)) {
+ return;
+ }
+
+ final AbstractITunesObject itunes = (AbstractITunesObject) module;
+
+ if (itunes instanceof FeedInformationImpl) {
+ // Do Channel Specific Stuff.
+ final FeedInformationImpl info = (FeedInformationImpl) itunes;
+ final Element owner = generateSimpleElement("owner", "");
+ final Element email = generateSimpleElement("email", info.getOwnerEmailAddress());
+ owner.addContent(email);
+
+ final Element name = generateSimpleElement("name", info.getOwnerName());
+ owner.addContent(name);
+ element.addContent(owner);
+
+ final List categories = info.getCategories();
+ for (final Category cat : categories) {
+
+ final Element category = generateSimpleElement("category", "");
+ category.setAttribute("text", cat.getName());
+
+ if (cat.getSubcategory() != null) {
+ final Element subcat = generateSimpleElement("category", "");
+ subcat.setAttribute("text", cat.getSubcategory().getName());
+ category.addContent(subcat);
+ }
+
+ element.addContent(category);
+ }
+
+ if (info.getComplete()) {
+ element.addContent(generateSimpleElement("complete", "yes"));
+ }
+
+ if (info.getNewFeedUrl() != null) {
+ element.addContent(generateSimpleElement("new-feed-url", info.getNewFeedUrl()));
+ }
+
+ } else if (itunes instanceof EntryInformationImpl) {
+ final EntryInformationImpl info = (EntryInformationImpl) itunes;
+
+ if (info.getDuration() != null) {
+ element.addContent(generateSimpleElement("duration", info.getDuration().toString()));
+ }
+ if (info.getClosedCaptioned()) {
+ element.addContent(generateSimpleElement("isClosedCaptioned", "yes"));
+ }
+ if (info.getOrder() != null) {
+ element.addContent(generateSimpleElement("order", info.getOrder().toString()));
+ }
+ }
+
+ if (itunes.getAuthor() != null) {
+ element.addContent(generateSimpleElement("author", itunes.getAuthor()));
+ }
+
+ if (itunes.getBlock()) {
+ element.addContent(generateSimpleElement("block", ""));
+ }
+
+ if (itunes.getExplicit()) {
+ element.addContent(generateSimpleElement("explicit", "yes"));
+ } else {
+ element.addContent(generateSimpleElement("explicit", "no"));
+ }
+
+ if (itunes.getImage() != null) {
+ final Element image = generateSimpleElement("image", "");
+ image.setAttribute("href", itunes.getImage().toExternalForm());
+ element.addContent(image);
+ }
+
+ if (itunes.getKeywords() != null) {
+ final StringBuffer sb = new StringBuffer();
+
+ for (int i = 0; i < itunes.getKeywords().length; i++) {
+ if (i != 0) {
+ sb.append(", ");
+ }
+
+ sb.append(itunes.getKeywords()[i]);
+ }
+
+ element.addContent(generateSimpleElement("keywords", sb.toString()));
+ }
+
+ if (itunes.getSubtitle() != null) {
+ element.addContent(generateSimpleElement("subtitle", itunes.getSubtitle()));
+ }
+
+ if (itunes.getSummary() != null) {
+ element.addContent(generateSimpleElement("summary", itunes.getSummary()));
+ }
+ }
+
+ /**
+ * Returns the list of namespaces this module uses.
+ *
+ * @return set of Namespace objects.
+ */
+ @Override
+ public Set getNamespaces() {
+ return NAMESPACES;
+ }
+
+ /**
+ * Returns the namespace URI this module handles.
+ *
+ * @return Returns the namespace URI this module handles.
+ */
+ @Override
+ public String getNamespaceUri() {
+ return AbstractITunesObject.URI;
+ }
+
+ protected Element generateSimpleElement(final String name, final String value) {
+ final Element element = new Element(name, NAMESPACE);
+ element.addContent(value);
+
+ return element;
+ }
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/itunes/io/ITunesParser.java b/rome-modules/src/main/java/com/rometools/modules/itunes/io/ITunesParser.java
new file mode 100644
index 0000000..1986df7
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/itunes/io/ITunesParser.java
@@ -0,0 +1,234 @@
+/*
+ * ITunesParser.java
+ *
+ * Created on August 1, 2005, 8:29 PM
+ *
+ * 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.
+
+ */
+package com.rometools.modules.itunes.io;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.List;
+import java.util.Locale;
+import java.util.StringTokenizer;
+
+import org.jdom2.Content;
+import org.jdom2.Element;
+import org.jdom2.Namespace;
+import org.jdom2.output.XMLOutputter;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.rometools.modules.itunes.AbstractITunesObject;
+import com.rometools.modules.itunes.EntryInformationImpl;
+import com.rometools.modules.itunes.FeedInformationImpl;
+import com.rometools.modules.itunes.types.Category;
+import com.rometools.modules.itunes.types.Duration;
+import com.rometools.modules.itunes.types.Subcategory;
+import com.rometools.rome.io.ModuleParser;
+import com.rometools.rome.io.WireFeedParser;
+
+/**
+ * @version $Revision: 1.10 $
+ * @author Robert "kebernet" Cooper
+ */
+public class ITunesParser implements ModuleParser {
+
+ private static final Logger LOG = LoggerFactory.getLogger(ITunesParser.class);
+
+ Namespace ns = Namespace.getNamespace(AbstractITunesObject.URI);
+
+ /** Creates a new instance of ITunesParser */
+ public ITunesParser() {
+ }
+
+ public void setParser(final WireFeedParser feedParser) {
+ }
+
+ @Override
+ public String getNamespaceUri() {
+ return AbstractITunesObject.URI;
+ }
+
+ @Override
+ public com.rometools.rome.feed.module.Module parse(final Element element, final Locale locale) {
+ AbstractITunesObject module = null;
+
+ if (element.getName().equals("channel")) {
+ final FeedInformationImpl feedInfo = new FeedInformationImpl();
+ module = feedInfo;
+
+ // Now I am going to get the channel specific tags
+ final Element owner = element.getChild("owner", ns);
+
+ if (owner != null) {
+ final Element name = owner.getChild("name", ns);
+
+ if (name != null) {
+ feedInfo.setOwnerName(name.getValue().trim());
+ }
+
+ final Element email = owner.getChild("email", ns);
+
+ if (email != null) {
+ feedInfo.setOwnerEmailAddress(email.getValue().trim());
+ }
+ }
+
+ final List categories = element.getChildren("category", ns);
+ for (final Element element2 : categories) {
+ final Element category = element2;
+ if (category != null && category.getAttribute("text") != null) {
+ final Category cat = new Category();
+ cat.setName(category.getAttribute("text").getValue().trim());
+
+ final Element subcategory = category.getChild("category", ns);
+
+ if (subcategory != null && subcategory.getAttribute("text") != null) {
+ final Subcategory subcat = new Subcategory();
+ subcat.setName(subcategory.getAttribute("text").getValue().trim());
+ cat.setSubcategory(subcat);
+ }
+
+ feedInfo.getCategories().add(cat);
+ }
+ }
+
+ final Element complete = element.getChild("complete", ns);
+ if (complete != null) {
+ feedInfo.setComplete("yes".equals(complete.getTextTrim().toLowerCase()));
+ }
+
+ final Element newFeedUrl = element.getChild("new-feed-url", ns);
+ if (newFeedUrl != null) {
+ feedInfo.setNewFeedUrl(newFeedUrl.getTextTrim());
+ }
+
+ } else if (element.getName().equals("item")) {
+ final EntryInformationImpl entryInfo = new EntryInformationImpl();
+ module = entryInfo;
+
+ // Now I am going to get the item specific tags
+
+ final Element duration = element.getChild("duration", ns);
+
+ if (duration != null && duration.getValue() != null) {
+ final Duration dur = new Duration(duration.getValue().trim());
+ entryInfo.setDuration(dur);
+ }
+
+ final Element closedCaptioned = element.getChild("isClosedCaptioned", ns);
+
+ if (closedCaptioned != null && closedCaptioned.getValue() != null && closedCaptioned.getValue().trim().equalsIgnoreCase("yes")) {
+ entryInfo.setClosedCaptioned(true);
+ }
+
+ final Element order = element.getChild("order", ns);
+
+ if (order != null && order.getValue() != null) {
+ final Integer o = Integer.valueOf(order.getValue().trim());
+ entryInfo.setOrder(o);
+ }
+ }
+ if (module != null) {
+ // All these are common to both Channel and Item
+ final Element author = element.getChild("author", ns);
+
+ if (author != null && author.getText() != null) {
+ module.setAuthor(author.getText());
+ }
+
+ final Element block = element.getChild("block", ns);
+
+ if (block != null) {
+ module.setBlock(true);
+ }
+
+ final Element explicit = element.getChild("explicit", ns);
+
+ if (explicit != null && explicit.getValue() != null && explicit.getValue().trim().equalsIgnoreCase("yes")) {
+ module.setExplicit(true);
+ }
+
+ final Element keywords = element.getChild("keywords", ns);
+
+ if (keywords != null) {
+ final StringTokenizer tok = new StringTokenizer(getXmlInnerText(keywords).trim(), ",");
+ final String[] keywordsArray = new String[tok.countTokens()];
+
+ for (int i = 0; tok.hasMoreTokens(); i++) {
+ keywordsArray[i] = tok.nextToken();
+ }
+
+ module.setKeywords(keywordsArray);
+ }
+
+ final Element subtitle = element.getChild("subtitle", ns);
+
+ if (subtitle != null) {
+ module.setSubtitle(subtitle.getTextTrim());
+ }
+
+ final Element summary = element.getChild("summary", ns);
+
+ if (summary != null) {
+ module.setSummary(summary.getTextTrim());
+ }
+
+ final Element image = element.getChild("image", ns);
+
+ if (image != null && image.getAttributeValue("href") != null) {
+ try {
+ final URL imageURL = new URL(image.getAttributeValue("href").trim());
+ module.setImage(imageURL);
+ } catch (final MalformedURLException e) {
+ LOG.debug("Malformed URL Exception reading itunes:image tag: {}", image.getAttributeValue("href"));
+ }
+ }
+ }
+
+ return module;
+ }
+
+ protected String getXmlInnerText(final Element e) {
+ final StringBuffer sb = new StringBuffer();
+ final XMLOutputter xo = new XMLOutputter();
+ final List children = e.getContent();
+ sb.append(xo.outputString(children));
+ return sb.toString();
+ }
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/itunes/io/ITunesParserOldNamespace.java b/rome-modules/src/main/java/com/rometools/modules/itunes/io/ITunesParserOldNamespace.java
new file mode 100644
index 0000000..ac05a7b
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/itunes/io/ITunesParserOldNamespace.java
@@ -0,0 +1,62 @@
+/*
+ * ITunesParserOldNamespace.java
+ *
+ * Created on April 23, 2006, 2:09 AM
+ *
+ * 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) 2006 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 com.rometools.modules.itunes.io;
+
+import org.jdom2.Namespace;
+
+/**
+ *
+ * @author Robert "kebernet" Cooper
+ */
+public class ITunesParserOldNamespace extends ITunesParser {
+ String URI = "http://www.itunes.com/DTDs/Podcast-1.0.dtd";
+
+ /** Creates a new instance of ITunesParserOldNamespace */
+ public ITunesParserOldNamespace() {
+ super();
+ super.ns = Namespace.getNamespace(URI);
+ }
+
+ @Override
+ public String getNamespaceUri() {
+ return URI;
+ }
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/itunes/package.html b/rome-modules/src/main/java/com/rometools/modules/itunes/package.html
new file mode 100644
index 0000000..a618e26
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/itunes/package.html
@@ -0,0 +1,74 @@
+
+
+
+
+
+
+
+
+ This is a ROME plug in that implements the iTunes RSS extensions as defined
+ by Apple in their
+ documentation. BTW, an anti-shoutout to Apple for moving the original
+ PDF spec
+ . Thanks for making it harder than it needed to be.
+
+
Sample Usage:
+
+ SyndFeedInput input = new SyndFeedInput();
+ SyndFeed syndfeed = input.build(new XmlReader(feed.toURL()));
+
+ Module module = syndfeed.getModule("http://www.itunes.com/DTDs/Podcast-1.0.dtd");
+ FeedInformation feedInfo = (FeedInformation) module;
+
+ System.out.println( feedInfo.getImage() );
+ System.out.println( feedInfo.getCategory() );
+
+ // Or to create a feed..
+
+ ArrayList modules = new ArrayList();
+ EntryInformation e = new EntryInformationImpl();
+ e.setDuration( new Duration( 10000 ) );
+ modules.add( e );
+ syndEntry.setModules( modules );
+
+
+ Similarly you can get an EntryInformation object off SyndEntries or Items.
+
+
+
+ * 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.
+
+
+
diff --git a/rome-modules/src/main/java/com/rometools/modules/itunes/types/Category.java b/rome-modules/src/main/java/com/rometools/modules/itunes/types/Category.java
new file mode 100644
index 0000000..50e6eaf
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/itunes/types/Category.java
@@ -0,0 +1,136 @@
+/*
+ * Category.java
+ *
+ * Created on August 1, 2005, 7:24 PM
+ *
+ * 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.
+ *
+ */
+package com.rometools.modules.itunes.types;
+
+import java.io.Serializable;
+
+/**
+ * This Category information. Basically a name and an optional Subcategory. Categories are defined
+ * by Apple. See ITMS for a view.
+ *
+ * @version $Revision: 1.2 $
+ * @author Robert "kebernet" Cooper
+ */
+public class Category implements Serializable {
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ private String name;
+ private Subcategory subcategory;
+
+ /** Creates a new instance of Category */
+ public Category() {
+ }
+
+ /**
+ * Creates a new instance of Category with a given name.
+ *
+ * @param name Name of the category.
+ */
+ public Category(final String name) {
+ setName(name);
+ }
+
+ /**
+ * Returns the name of the category
+ *
+ * @return Returns the name of the category
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Sets the name of the category
+ *
+ * @param name Sets the name of the category
+ */
+ public void setName(final String name) {
+ this.name = name;
+ }
+
+ /**
+ * Returns the Subcategory object for this category
+ *
+ * @return Returns the Subcategory object for this category
+ */
+ public Subcategory getSubcategory() {
+ return subcategory;
+ }
+
+ /**
+ * Sets the Subcategory object for this category
+ *
+ * @param subcategory Sets the Subcategory object for this category
+ */
+ public void setSubcategory(final Subcategory subcategory) {
+ this.subcategory = subcategory;
+ }
+
+ /**
+ * Returns a copy of this category.
+ *
+ * @return Returns a copy of this category.
+ */
+ @Override
+ public Object clone() {
+ final Category c = new Category();
+ c.setName(getName());
+
+ if (getSubcategory() != null) {
+ c.setSubcategory((Subcategory) getSubcategory().clone());
+ }
+
+ return c;
+ }
+
+ @Override
+ public String toString() {
+ final StringBuffer sb = new StringBuffer(getName());
+
+ if (getSubcategory() != null) {
+ sb.append(" -> " + getSubcategory().toString());
+ }
+
+ return sb.toString();
+ }
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/itunes/types/Duration.java b/rome-modules/src/main/java/com/rometools/modules/itunes/types/Duration.java
new file mode 100644
index 0000000..7d04273
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/itunes/types/Duration.java
@@ -0,0 +1,166 @@
+/*
+ * Duration.java
+ *
+ * Created on August 1, 2005, 7:45 PM
+ *
+ * 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.
+ */
+package com.rometools.modules.itunes.types;
+
+import java.io.Serializable;
+import java.text.NumberFormat;
+import java.util.StringTokenizer;
+
+import com.rometools.rome.io.impl.NumberParser;
+
+/**
+ * An encapsulation of the duration of a podcast. This will serialize (via .toString()) to HH:MM:SS
+ * format, and can parse [H]*H:[M]*M:[S]*S or [M]*M:[S]*S.
+ *
+ * @version $Revision: 1.7 $
+ * @author Robert "kebernet" Cooper
+ */
+public class Duration implements Serializable {
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ static final long SECOND = 1000;
+ static final long MINUTE = SECOND * 60;
+ static final long HOUR = MINUTE * 60;
+ static final NumberFormat NUM_FORMAT = NumberFormat.getNumberInstance();
+ static {
+ NUM_FORMAT.setMinimumFractionDigits(0);
+ NUM_FORMAT.setMaximumFractionDigits(0);
+ NUM_FORMAT.setMinimumIntegerDigits(2);
+ NUM_FORMAT.setGroupingUsed(false);
+ }
+ private long milliseconds;
+
+ /**
+ * Creates a new Duration object with 0 length.
+ */
+ public Duration() {
+ super();
+ }
+
+ /**
+ * Creates a new instance of Duration specifying a length in milliseconds
+ *
+ * @param milliseconds Creates a new instance of Duration specifying a length in milliseconds
+ */
+ public Duration(final long milliseconds) {
+ setMilliseconds(milliseconds);
+ }
+
+ /**
+ * Creates a new duration object with the given hours, minutes and seconds
+ *
+ * @param hours number of hours
+ * @param minutes number of minutes
+ * @param seconds number of seconds
+ */
+ public Duration(final int hours, final int minutes, final float seconds) {
+ setMilliseconds(hours * HOUR + minutes * MINUTE + (long) (seconds * SECOND));
+ }
+
+ /**
+ * Creates a new Duration parsing the String value.
+ *
+ * @param duration A String to parse
+ */
+ public Duration(final String duration) {
+ final StringTokenizer tok = new StringTokenizer(duration, ":");
+ switch (tok.countTokens()) {
+ case 1:
+ setMilliseconds((long) (NumberParser.parseFloat(tok.nextToken(), 0f) * SECOND));
+ break;
+ case 2:
+ setMilliseconds(NumberParser.parseLong(tok.nextToken(), 0l) * MINUTE + (long) (NumberParser.parseFloat(tok.nextToken(), 0f) * SECOND));
+ break;
+ case 3:
+ setMilliseconds(NumberParser.parseLong(tok.nextToken(), 0l) * HOUR + NumberParser.parseLong(tok.nextToken(), 0l) * MINUTE
+ + (long) (NumberParser.parseFloat(tok.nextToken(), 0f) * SECOND));
+ break;
+ default:
+ throw new RuntimeException("Illegal time value: " + duration);
+ }
+ }
+
+ /**
+ * Returns a String representation in the formation HH:MM:SS
+ *
+ * @return Returns a String representation in the formation HH:MM:SS
+ */
+ @Override
+ public String toString() {
+ final Time time = new Time();
+
+ return NUM_FORMAT.format(time.hours) + ":" + NUM_FORMAT.format(time.minutes) + ":" + NUM_FORMAT.format(Math.round(time.seconds));
+ }
+
+ /**
+ * Returns the millisecond length
+ *
+ * @return the millisecond length
+ */
+ public long getMilliseconds() {
+ return milliseconds;
+ }
+
+ /**
+ * Sets the millisecond length
+ *
+ * @param milliseconds the millisecond length
+ */
+ public void setMilliseconds(final long milliseconds) {
+ this.milliseconds = milliseconds;
+ }
+
+ private class Time {
+ int hours;
+ int minutes;
+ float seconds;
+
+ public Time() {
+ long time = getMilliseconds();
+ hours = (int) (time / HOUR);
+ time = time - hours * HOUR;
+ minutes = (int) (time / MINUTE);
+ time = time - minutes * MINUTE;
+ seconds = (float) time / (float) SECOND;
+ }
+ }
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/itunes/types/Subcategory.java b/rome-modules/src/main/java/com/rometools/modules/itunes/types/Subcategory.java
new file mode 100644
index 0000000..0c68b92
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/itunes/types/Subcategory.java
@@ -0,0 +1,111 @@
+/*
+ * SubCategory.java
+ *
+ * Created on August 1, 2005, 7:24 PM
+ *
+ * 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.
+ *
+ */
+package com.rometools.modules.itunes.types;
+
+import java.io.Serializable;
+
+/**
+ * This class represents a Subcategor of a Category.
+ *
+ * @author Robert "kebernet" Cooper
+ * @version $Revision: 1.2 $
+ */
+public class Subcategory implements Serializable {
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ private String name;
+
+ /** Creates a new instance of SubCategory */
+ public Subcategory() {
+ }
+
+ /**
+ * Creates a new instance of Category with a given name.
+ *
+ * @param name Name of the category.
+ */
+ public Subcategory(final String name) {
+ setName(name);
+ }
+
+ /**
+ * Returns the name of the subcategory.
+ *
+ * @return Returns the name of the subcategory.
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Set the name of the subcategory.
+ *
+ * @param name Set the name of the subcategory.
+ */
+ public void setName(final String name) {
+ this.name = name;
+ }
+
+ /**
+ * Clones the object.
+ *
+ * @return Clone of the object.
+ */
+ @Override
+ public Object clone() {
+ final Subcategory sc = new Subcategory();
+ sc.setName(getName());
+
+ return sc;
+ }
+
+ /**
+ * String representation of the object.
+ *
+ * @return String representation of the object.
+ */
+ @Override
+ public String toString() {
+ return new StringBuffer(getName()).toString();
+ }
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/itunes/types/package.html b/rome-modules/src/main/java/com/rometools/modules/itunes/types/package.html
new file mode 100644
index 0000000..98e5105
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/itunes/types/package.html
@@ -0,0 +1,47 @@
+
+
+
+
+
+
+
+ This package contains data types for use wit the iTunes plug in.
+
+
+ * 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.
+
+
+
+
diff --git a/rome-modules/src/main/java/com/rometools/modules/mediarss/MediaEntryModule.java b/rome-modules/src/main/java/com/rometools/modules/mediarss/MediaEntryModule.java
new file mode 100644
index 0000000..1b3b8b8
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/mediarss/MediaEntryModule.java
@@ -0,0 +1,47 @@
+/*
+ * MediaEntryModule.java
+ *
+ * Created on April 19, 2006, 1:15 AM
+ *
+ * This code is currently released under the Mozilla Public License.
+ * http://www.mozilla.org/MPL/
+ *
+ * Alternately you may apply the terms of the Apache Software License
+ *
+ * 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 com.rometools.modules.mediarss;
+
+import com.rometools.modules.mediarss.types.MediaContent;
+import com.rometools.modules.mediarss.types.MediaGroup;
+
+/**
+ * Represents entry/item level information.
+ *
+ * @author cooper
+ */
+public interface MediaEntryModule extends MediaModule {
+ /**
+ * Returns the MediaContent items for the entry.
+ *
+ * @return Returns the MediaContent items for the entry.
+ */
+ public MediaContent[] getMediaContents();
+
+ /**
+ * Returns the media groups for the entry.
+ *
+ * @return Returns the media groups for the entry.
+ */
+ public MediaGroup[] getMediaGroups();
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/mediarss/MediaEntryModuleImpl.java b/rome-modules/src/main/java/com/rometools/modules/mediarss/MediaEntryModuleImpl.java
new file mode 100644
index 0000000..ecf6871
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/mediarss/MediaEntryModuleImpl.java
@@ -0,0 +1,134 @@
+/*
+ * Copyright 2006 Nathanial X. Freitas, openvision.tv
+ *
+ * This code is currently released under the Mozilla Public License.
+ * http://www.mozilla.org/MPL/
+ *
+ * Alternately you may apply the terms of the Apache Software License
+ *
+ * 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 com.rometools.modules.mediarss;
+
+import java.io.Serializable;
+
+import com.rometools.modules.mediarss.types.MediaContent;
+import com.rometools.modules.mediarss.types.MediaGroup;
+import com.rometools.modules.mediarss.types.Metadata;
+import com.rometools.rome.feed.CopyFrom;
+import com.rometools.rome.feed.impl.EqualsBean;
+import com.rometools.rome.feed.impl.ToStringBean;
+
+/**
+ * Represents information for an Entry/Item level.
+ *
+ * @author Nathanial X. Freitas
+ */
+public class MediaEntryModuleImpl extends MediaModuleImpl implements MediaEntryModule, Cloneable, Serializable {
+ private static final long serialVersionUID = 1L;
+
+ /*
+ * the variables in the MediaModule are set when they apply to all MediaContent instances in the
+ * set
+ */
+ private MediaContent[] mediaContents = new MediaContent[0];
+ private MediaGroup[] mediaGroups = new MediaGroup[0];
+
+ /**
+ * Creates a new instance.
+ */
+ public MediaEntryModuleImpl() {
+ super(MediaEntryModule.class, MediaModule.URI);
+ }
+
+ /**
+ * MediaContent items for the entry
+ *
+ * @param mediaContents MediaContent items for the entry
+ */
+ public void setMediaContents(final MediaContent[] mediaContents) {
+ this.mediaContents = mediaContents == null ? new MediaContent[0] : mediaContents;
+ }
+
+ /**
+ * MediaContent items for the entry
+ *
+ * @return MediaContent items for the entry
+ */
+ @Override
+ public MediaContent[] getMediaContents() {
+ return mediaContents;
+ }
+
+ /**
+ * MediaGroups for the entry
+ *
+ * @param mediaGroups MediaGroups for the entry
+ */
+ public void setMediaGroups(final MediaGroup[] mediaGroups) {
+ this.mediaGroups = mediaGroups == null ? new MediaGroup[0] : mediaGroups;
+ }
+
+ /**
+ * MediaGroups for the entry
+ *
+ * @return MediaGroups for the entry
+ */
+ @Override
+ public MediaGroup[] getMediaGroups() {
+ return mediaGroups;
+ }
+
+ @Override
+ public Object clone() {
+ final MediaEntryModuleImpl m = new MediaEntryModuleImpl();
+ m.setMediaContents(mediaContents.clone());
+ m.setMediaGroups(mediaGroups.clone());
+ m.setMetadata(getMetadata() == null ? null : (Metadata) getMetadata().clone());
+ m.setPlayer(getPlayer());
+
+ return m;
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ final EqualsBean eBean = new EqualsBean(MediaEntryModuleImpl.class, this);
+
+ return eBean.beanEquals(obj);
+ }
+
+ @Override
+ public int hashCode() {
+ final EqualsBean equals = new EqualsBean(MediaEntryModuleImpl.class, this);
+
+ return equals.beanHashCode();
+ }
+
+ @Override
+ public String toString() {
+ final ToStringBean tsBean = new ToStringBean(MediaEntryModuleImpl.class, this);
+
+ return tsBean.toString();
+ }
+
+ @Override
+ public void copyFrom(final CopyFrom obj) {
+ MediaEntryModuleImpl other = (MediaEntryModuleImpl) obj;
+ other = (MediaEntryModuleImpl) other.clone();
+ setMediaContents(other.getMediaContents());
+ setMediaGroups(other.getMediaGroups());
+ setMetadata(other.getMetadata());
+ setPlayer(other.getPlayer());
+ }
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/mediarss/MediaModule.java b/rome-modules/src/main/java/com/rometools/modules/mediarss/MediaModule.java
new file mode 100644
index 0000000..9e1c56d
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/mediarss/MediaModule.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2006 Nathanial X. Freitas, openvision.tv
+ *
+ * This code is currently released under the Mozilla Public License.
+ * http://www.mozilla.org/MPL/
+ *
+ * Alternately you may apply the terms of the Apache Software License
+ *
+ * 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 com.rometools.modules.mediarss;
+
+import com.rometools.modules.mediarss.types.Metadata;
+import com.rometools.modules.mediarss.types.PlayerReference;
+import com.rometools.rome.feed.module.Module;
+
+/**
+ * This is the base module for MediaRSS.
+ *
+ * It represents information that can be stored at the feed level, as well is a base for entry level
+ * information, as the same information can apply.
+ *
+ *
+ * @author Nathanial X. Freitas
+ */
+public interface MediaModule extends Module {
+ // the URI of the MediaRSS specification as hosted by yahoo
+ public final static String URI = "http://search.yahoo.com/mrss/";
+
+ /**
+ * Returns Metadata associated with the feed.
+ *
+ * @return Returns Metadata associated with the feed.
+ */
+ public Metadata getMetadata();
+
+ /**
+ * Returns a player reference associated with the feed.
+ *
+ * @return Returns a player reference associated with the feed.
+ */
+ public PlayerReference getPlayer();
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/mediarss/MediaModuleImpl.java b/rome-modules/src/main/java/com/rometools/modules/mediarss/MediaModuleImpl.java
new file mode 100644
index 0000000..fbb0cc0
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/mediarss/MediaModuleImpl.java
@@ -0,0 +1,122 @@
+/*
+ * MediaModuleImpl.java
+ *
+ * Created on April 19, 2006, 1:17 AM
+ *
+ * This code is currently released under the Mozilla Public License.
+ * http://www.mozilla.org/MPL/
+ *
+ * Alternately you may apply the terms of the Apache Software License
+ *
+ * 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 com.rometools.modules.mediarss;
+
+import java.io.Serializable;
+
+import com.rometools.modules.mediarss.types.Metadata;
+import com.rometools.modules.mediarss.types.PlayerReference;
+import com.rometools.rome.feed.CopyFrom;
+import com.rometools.rome.feed.module.ModuleImpl;
+
+/**
+ *
+ * This class represents feed/channel level elements for MediaRSS
+ *
+ * @author cooper
+ */
+public class MediaModuleImpl extends ModuleImpl implements MediaModule, Serializable {
+ private static final long serialVersionUID = 1L;
+
+ private Metadata metadata;
+ private PlayerReference player;
+
+ /** Creates a new instance of MediaModuleImpl */
+ public MediaModuleImpl() {
+ this(MediaModule.class, MediaModule.URI);
+ }
+
+ /**
+ * constructor that passes values up to ModuleImpl.
+ *
+ * @param clazz
+ * @param uri
+ */
+ public MediaModuleImpl(final Class extends MediaModule> clazz, final String uri) {
+ super(clazz, uri);
+ }
+
+ @Override
+ public Class getInterface() {
+ return MediaModule.class;
+ }
+
+ /**
+ * Metadata for a feed.
+ *
+ * @param metadata Metadata for a feed.
+ */
+ public void setMetadata(final Metadata metadata) {
+ this.metadata = metadata;
+ }
+
+ /**
+ * Metadata for a feed.
+ *
+ * @return Metadata for a feed.
+ */
+ @Override
+ public Metadata getMetadata() {
+ return metadata;
+ }
+
+ /**
+ * Player for a feed.
+ *
+ * @param player Player for a feed.
+ */
+ public void setPlayer(final PlayerReference player) {
+ this.player = player;
+ }
+
+ /**
+ * Player for a feed.
+ *
+ * @return Player for a feed.
+ */
+ @Override
+ public PlayerReference getPlayer() {
+ return player;
+ }
+
+ @Override
+ public String getUri() {
+ return MediaModule.URI;
+ }
+
+ @Override
+ public Object clone() {
+ final MediaModuleImpl m = new MediaModuleImpl();
+ m.setMetadata((Metadata) metadata.clone());
+ m.setPlayer(player);
+
+ return m;
+ }
+
+ @Override
+ public void copyFrom(final CopyFrom obj) {
+ final MediaModule m = (MediaModule) obj;
+ metadata = (Metadata) m.getMetadata().clone();
+ player = m.getPlayer();
+ }
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/mediarss/io/AlternateMediaModuleParser.java b/rome-modules/src/main/java/com/rometools/modules/mediarss/io/AlternateMediaModuleParser.java
new file mode 100644
index 0000000..1f5883d
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/mediarss/io/AlternateMediaModuleParser.java
@@ -0,0 +1,43 @@
+/*
+ * 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 com.rometools.modules.mediarss.io;
+
+import org.jdom2.Namespace;
+
+/**
+ *
+ * @author cooper
+ */
+public class AlternateMediaModuleParser extends MediaModuleParser {
+
+ private static final Namespace NS = Namespace.getNamespace("http://search.yahoo.com/mrss");
+
+ /** Creates a new instance of AlternateMediaModuleParser */
+ public AlternateMediaModuleParser() {
+ super();
+ }
+
+ @Override
+ public String getNamespaceUri() {
+ return "http://search.yahoo.com/mrss";
+ }
+
+ @Override
+ public Namespace getNS() {
+ return AlternateMediaModuleParser.NS;
+ }
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/mediarss/io/MediaModuleGenerator.java b/rome-modules/src/main/java/com/rometools/modules/mediarss/io/MediaModuleGenerator.java
new file mode 100644
index 0000000..6d2ca05
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/mediarss/io/MediaModuleGenerator.java
@@ -0,0 +1,260 @@
+/*
+ * Copyright 2006 Nathanial X. Freitas, openvision.tv
+ *
+ * This code is currently released under the Mozilla Public License.
+ * http://www.mozilla.org/MPL/
+ *
+ * Alternately you may apply the terms of the Apache Software License
+ *
+ * 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 com.rometools.modules.mediarss.io;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.jdom2.Element;
+import org.jdom2.Namespace;
+
+import com.rometools.modules.mediarss.MediaEntryModule;
+import com.rometools.modules.mediarss.MediaModule;
+import com.rometools.modules.mediarss.types.Category;
+import com.rometools.modules.mediarss.types.Credit;
+import com.rometools.modules.mediarss.types.MediaContent;
+import com.rometools.modules.mediarss.types.MediaGroup;
+import com.rometools.modules.mediarss.types.Metadata;
+import com.rometools.modules.mediarss.types.PlayerReference;
+import com.rometools.modules.mediarss.types.Rating;
+import com.rometools.modules.mediarss.types.Restriction;
+import com.rometools.modules.mediarss.types.Text;
+import com.rometools.modules.mediarss.types.Thumbnail;
+import com.rometools.modules.mediarss.types.UrlReference;
+import com.rometools.rome.feed.module.Module;
+import com.rometools.rome.io.ModuleGenerator;
+
+//this class TBI
+public class MediaModuleGenerator implements ModuleGenerator {
+
+ private static final Namespace NS = Namespace.getNamespace("media", MediaModule.URI);
+ private static final Set NAMESPACES = new HashSet();
+
+ static {
+ NAMESPACES.add(NS);
+ }
+
+ @Override
+ public String getNamespaceUri() {
+ return MediaModule.URI;
+ }
+
+ @Override
+ public Set getNamespaces() {
+ return NAMESPACES;
+ }
+
+ @Override
+ public void generate(final Module module, final Element element) {
+ if (module instanceof MediaModule) {
+ final MediaModule m = (MediaModule) module;
+ generateMetadata(m.getMetadata(), element);
+ generatePlayer(m.getPlayer(), element);
+ }
+
+ if (module instanceof MediaEntryModule) {
+ final MediaEntryModule m = (MediaEntryModule) module;
+ final MediaGroup[] g = m.getMediaGroups();
+
+ for (final MediaGroup element2 : g) {
+ generateGroup(element2, element);
+ }
+
+ final MediaContent[] c = m.getMediaContents();
+
+ for (final MediaContent element2 : c) {
+ generateContent(element2, element);
+ }
+ }
+ }
+
+ public void generateContent(final MediaContent c, final Element e) {
+ final Element mc = new Element("content", NS);
+ addNotNullAttribute(mc, "medium", c.getMedium());
+ addNotNullAttribute(mc, "channels", c.getAudioChannels());
+ addNotNullAttribute(mc, "bitrate", c.getBitrate());
+ addNotNullAttribute(mc, "duration", c.getDuration());
+ addNotNullAttribute(mc, "expression", c.getExpression());
+ addNotNullAttribute(mc, "fileSize", c.getFileSize());
+ addNotNullAttribute(mc, "framerate", c.getFramerate());
+ addNotNullAttribute(mc, "height", c.getHeight());
+ addNotNullAttribute(mc, "lang", c.getLanguage());
+ addNotNullAttribute(mc, "samplingrate", c.getSamplingrate());
+ addNotNullAttribute(mc, "type", c.getType());
+ addNotNullAttribute(mc, "width", c.getWidth());
+
+ if (c.isDefaultContent()) {
+ addNotNullAttribute(mc, "isDefault", "true");
+ }
+
+ if (c.getReference() instanceof UrlReference) {
+ addNotNullAttribute(mc, "url", c.getReference());
+ generatePlayer(c.getPlayer(), mc);
+ } else {
+ generatePlayer(c.getPlayer(), mc);
+ }
+
+ generateMetadata(c.getMetadata(), mc);
+ e.addContent(mc);
+ }
+
+ public void generateGroup(final MediaGroup g, final Element e) {
+ final Element t = new Element("group", NS);
+ final MediaContent[] c = g.getContents();
+
+ for (final MediaContent element : c) {
+ generateContent(element, t);
+ }
+
+ generateMetadata(g.getMetadata(), t);
+ e.addContent(t);
+ }
+
+ public void generateMetadata(final Metadata m, final Element e) {
+ if (m == null) {
+ return;
+ }
+
+ final Category[] cats = m.getCategories();
+
+ for (final Category cat : cats) {
+ final Element c = generateSimpleElement("category", cat.getValue());
+ addNotNullAttribute(c, "scheme", cat.getScheme());
+ addNotNullAttribute(c, "label", cat.getLabel());
+ e.addContent(c);
+ }
+
+ final Element copyright = addNotNullElement(e, "copyright", m.getCopyright());
+ addNotNullAttribute(copyright, "url", m.getCopyrightUrl());
+
+ final Credit[] creds = m.getCredits();
+
+ for (final Credit cred : creds) {
+ final Element c = generateSimpleElement("credit", cred.getName());
+ addNotNullAttribute(c, "role", cred.getRole());
+ addNotNullAttribute(c, "scheme", cred.getScheme());
+ e.addContent(c);
+ }
+
+ final Element desc = addNotNullElement(e, "description", m.getDescription());
+ addNotNullAttribute(desc, "type", m.getDescriptionType());
+
+ if (m.getHash() != null) {
+ final Element hash = addNotNullElement(e, "hash", m.getHash().getValue());
+ addNotNullAttribute(hash, "algo", m.getHash().getAlgorithm());
+ }
+
+ final String[] keywords = m.getKeywords();
+
+ if (keywords.length > 0) {
+ String keyword = keywords[0];
+
+ for (int i = 1; i < keywords.length; i++) {
+ keyword += ", " + keywords[i];
+ }
+
+ addNotNullElement(e, "keywords", keyword);
+ }
+
+ final Rating[] rats = m.getRatings();
+
+ for (final Rating rat2 : rats) {
+ final Element rat = addNotNullElement(e, "rating", rat2.getValue());
+ addNotNullAttribute(rat, "scheme", rat2.getScheme());
+
+ if (rat2.equals(Rating.ADULT)) {
+ addNotNullElement(e, "adult", "true");
+ } else if (rat2.equals(Rating.NONADULT)) {
+ addNotNullElement(e, "adult", "false");
+ }
+ }
+
+ final Text[] text = m.getText();
+
+ for (final Text element : text) {
+ final Element t = addNotNullElement(e, "text", element.getValue());
+ addNotNullAttribute(t, "type", element.getType());
+ addNotNullAttribute(t, "start", element.getStart());
+ addNotNullAttribute(t, "end", element.getEnd());
+ }
+
+ final Thumbnail[] thumbs = m.getThumbnail();
+
+ for (final Thumbnail thumb : thumbs) {
+ final Element t = new Element("thumbnail", NS);
+ addNotNullAttribute(t, "url", thumb.getUrl());
+ addNotNullAttribute(t, "width", thumb.getWidth());
+ addNotNullAttribute(t, "height", thumb.getHeight());
+ addNotNullAttribute(t, "time", thumb.getTime());
+ e.addContent(t);
+ }
+
+ final Element title = addNotNullElement(e, "title", m.getTitle());
+ addNotNullAttribute(title, "type", m.getTitleType());
+
+ final Restriction[] r = m.getRestrictions();
+
+ for (final Restriction element : r) {
+ final Element res = addNotNullElement(e, "restriction", element.getValue());
+ addNotNullAttribute(res, "type", element.getType());
+ addNotNullAttribute(res, "relationship", element.getRelationship());
+ }
+ }
+
+ public void generatePlayer(final PlayerReference p, final Element e) {
+ if (p == null) {
+ return;
+ }
+
+ final Element t = new Element("player", NS);
+ addNotNullAttribute(t, "url", p.getUrl());
+ addNotNullAttribute(t, "width", p.getWidth());
+ addNotNullAttribute(t, "height", p.getHeight());
+ e.addContent(t);
+ }
+
+ protected void addNotNullAttribute(final Element target, final String name, final Object value) {
+ if (target == null || value == null) {
+ return;
+ } else {
+ target.setAttribute(name, value.toString());
+ }
+ }
+
+ protected Element addNotNullElement(final Element target, final String name, final Object value) {
+ if (value == null) {
+ return null;
+ } else {
+ final Element e = generateSimpleElement(name, value.toString());
+ target.addContent(e);
+
+ return e;
+ }
+ }
+
+ protected Element generateSimpleElement(final String name, final String value) {
+ final Element element = new Element(name, NS);
+ element.addContent(value);
+
+ return element;
+ }
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/mediarss/io/MediaModuleParser.java b/rome-modules/src/main/java/com/rometools/modules/mediarss/io/MediaModuleParser.java
new file mode 100644
index 0000000..2cfa573
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/mediarss/io/MediaModuleParser.java
@@ -0,0 +1,468 @@
+/*
+ * Copyright 2006 Nathanial X. Freitas, openvision.tv
+ *
+ * This code is currently released under the Mozilla Public License.
+ * http://www.mozilla.org/MPL/
+ *
+ * Alternately you may apply the terms of the Apache Software License
+ *
+ * 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 com.rometools.modules.mediarss.io;
+
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Locale;
+import java.util.StringTokenizer;
+
+import org.jdom2.Element;
+import org.jdom2.Namespace;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.rometools.modules.mediarss.MediaEntryModuleImpl;
+import com.rometools.modules.mediarss.MediaModule;
+import com.rometools.modules.mediarss.MediaModuleImpl;
+import com.rometools.modules.mediarss.types.Category;
+import com.rometools.modules.mediarss.types.Credit;
+import com.rometools.modules.mediarss.types.Expression;
+import com.rometools.modules.mediarss.types.Hash;
+import com.rometools.modules.mediarss.types.MediaContent;
+import com.rometools.modules.mediarss.types.MediaGroup;
+import com.rometools.modules.mediarss.types.Metadata;
+import com.rometools.modules.mediarss.types.PlayerReference;
+import com.rometools.modules.mediarss.types.Rating;
+import com.rometools.modules.mediarss.types.Restriction;
+import com.rometools.modules.mediarss.types.Text;
+import com.rometools.modules.mediarss.types.Thumbnail;
+import com.rometools.modules.mediarss.types.Time;
+import com.rometools.modules.mediarss.types.UrlReference;
+import com.rometools.rome.feed.module.Module;
+import com.rometools.rome.io.ModuleParser;
+import com.rometools.utils.Integers;
+import com.rometools.utils.Longs;
+import com.rometools.utils.Strings;
+
+/**
+ * @author Nathanial X. Freitas
+ *
+ */
+public class MediaModuleParser implements ModuleParser {
+
+ private static final Logger LOG = LoggerFactory.getLogger(MediaModuleParser.class);
+
+ private static final Namespace NS = Namespace.getNamespace(MediaModule.URI);
+
+ @Override
+ public String getNamespaceUri() {
+ return MediaModule.URI;
+ }
+
+ @Override
+ public Module parse(final Element mmRoot, final Locale locale) {
+ MediaModuleImpl mod = null;
+
+ if (mmRoot.getName().equals("channel") || mmRoot.getName().equals("feed")) {
+ mod = new MediaModuleImpl();
+ } else {
+ mod = new MediaEntryModuleImpl();
+ }
+
+ mod.setMetadata(parseMetadata(mmRoot));
+ mod.setPlayer(parsePlayer(mmRoot));
+
+ if (mod instanceof MediaEntryModuleImpl) {
+ final MediaEntryModuleImpl m = (MediaEntryModuleImpl) mod;
+ m.setMediaContents(parseContent(mmRoot));
+ m.setMediaGroups(parseGroup(mmRoot));
+ }
+
+ return mod;
+ }
+
+ private MediaContent[] parseContent(final Element e) {
+
+ final List contents = e.getChildren("content", getNS());
+ final ArrayList values = new ArrayList();
+
+ try {
+ for (int i = 0; contents != null && i < contents.size(); i++) {
+ final Element content = contents.get(i);
+ MediaContent mc = null;
+
+ if (content.getAttributeValue("url") != null) {
+ try {
+ mc = new MediaContent(new UrlReference(new URI(content.getAttributeValue("url").replace(' ', '+'))));
+ mc.setPlayer(parsePlayer(content));
+ } catch (final Exception ex) {
+ LOG.warn("Exception parsing content tag.", ex);
+ }
+ } else {
+ mc = new MediaContent(parsePlayer(content));
+ }
+ if (mc != null) {
+ values.add(mc);
+ try {
+ if (content.getAttributeValue("channels") != null) {
+ mc.setAudioChannels(Integer.valueOf(content.getAttributeValue("channels")));
+ }
+ } catch (final Exception ex) {
+ LOG.warn("Exception parsing content tag.", ex);
+ }
+ try {
+ if (content.getAttributeValue("bitrate") != null) {
+ mc.setBitrate(Float.valueOf(content.getAttributeValue("bitrate")));
+ }
+ } catch (final Exception ex) {
+ LOG.warn("Exception parsing content tag.", ex);
+ }
+ try {
+ if (content.getAttributeValue("duration") != null) {
+ mc.setDuration(Longs.parseDecimal(content.getAttributeValue("duration")));
+ }
+ } catch (final Exception ex) {
+ LOG.warn("Exception parsing content tag.", ex);
+ }
+
+ mc.setMedium(content.getAttributeValue("medium"));
+
+ final String expression = content.getAttributeValue("expression");
+
+ if (expression != null) {
+ if (expression.equalsIgnoreCase("full")) {
+ mc.setExpression(Expression.FULL);
+ } else if (expression.equalsIgnoreCase("sample")) {
+ mc.setExpression(Expression.SAMPLE);
+ } else if (expression.equalsIgnoreCase("nonstop")) {
+ mc.setExpression(Expression.NONSTOP);
+ }
+ }
+
+ try {
+ if (content.getAttributeValue("fileSize") != null) {
+ mc.setFileSize(Long.valueOf(content.getAttributeValue("fileSize")));
+ }
+ } catch (final Exception ex) {
+ LOG.warn("Exception parsing content tag.", ex);
+ }
+ try {
+ if (content.getAttributeValue("framerate") != null) {
+ mc.setFramerate(Float.valueOf(content.getAttributeValue("framerate")));
+ }
+ } catch (final Exception ex) {
+ LOG.warn("Exception parsing content tag.", ex);
+ }
+ try {
+ if (content.getAttributeValue("height") != null) {
+ mc.setHeight(Integer.valueOf(content.getAttributeValue("height")));
+ }
+ } catch (final Exception ex) {
+ LOG.warn("Exception parsing content tag.", ex);
+ }
+
+ mc.setLanguage(content.getAttributeValue("lang"));
+ mc.setMetadata(parseMetadata(content));
+ try {
+ if (content.getAttributeValue("samplingrate") != null) {
+ mc.setSamplingrate(Float.valueOf(content.getAttributeValue("samplingrate")));
+ }
+ } catch (final Exception ex) {
+ LOG.warn("Exception parsing content tag.", ex);
+ }
+
+ mc.setType(content.getAttributeValue("type"));
+ try {
+ if (content.getAttributeValue("width") != null) {
+ mc.setWidth(Integer.valueOf(content.getAttributeValue("width")));
+ }
+ } catch (final Exception ex) {
+ LOG.warn("Exception parsing content tag.", ex);
+ }
+
+ if (content.getAttributeValue("isDefault") != null) {
+ mc.setDefaultContent(Boolean.valueOf(content.getAttributeValue("isDefault")));
+ }
+ } else {
+ LOG.warn("Could not find MediaContent.");
+ }
+
+ }
+ } catch (final Exception ex) {
+ LOG.warn("Exception parsing content tag.", ex);
+ }
+
+ return values.toArray(new MediaContent[values.size()]);
+ }
+
+ private MediaGroup[] parseGroup(final Element e) {
+ final List groups = e.getChildren("group", getNS());
+ final ArrayList values = new ArrayList();
+
+ for (int i = 0; groups != null && i < groups.size(); i++) {
+ final Element group = groups.get(i);
+ final MediaGroup g = new MediaGroup(parseContent(group));
+
+ for (int j = 0; j < g.getContents().length; j++) {
+ if (g.getContents()[j].isDefaultContent()) {
+ g.setDefaultContentIndex(new Integer(j));
+
+ break;
+ }
+ }
+
+ g.setMetadata(parseMetadata(group));
+ values.add(g);
+ }
+
+ return values.toArray(new MediaGroup[values.size()]);
+ }
+
+ private Metadata parseMetadata(final Element e) {
+ final Metadata md = new Metadata();
+ // categories
+ {
+ final List categories = e.getChildren("category", getNS());
+ final ArrayList values = new ArrayList();
+
+ for (int i = 0; categories != null && i < categories.size(); i++) {
+ try {
+ final Element cat = categories.get(i);
+ values.add(new Category(cat.getAttributeValue("scheme"), cat.getAttributeValue("label"), cat.getText()));
+ } catch (final Exception ex) {
+ LOG.warn("Exception parsing category tag.", ex);
+ }
+ }
+
+ md.setCategories(values.toArray(new Category[values.size()]));
+ }
+
+ // copyright
+ try {
+ final Element copy = e.getChild("copyright", getNS());
+
+ if (copy != null) {
+ md.setCopyright(copy.getText());
+ md.setCopyrightUrl(copy.getAttributeValue("url") != null ? new URI(copy.getAttributeValue("url")) : null);
+ }
+ } catch (final Exception ex) {
+ LOG.warn("Exception parsing copyright tag.", ex);
+ }
+ // credits
+ {
+ final List credits = e.getChildren("credit", getNS());
+ final ArrayList values = new ArrayList();
+
+ for (int i = 0; credits != null && i < credits.size(); i++) {
+ try {
+ final Element cred = credits.get(i);
+ values.add(new Credit(cred.getAttributeValue("scheme"), cred.getAttributeValue("role"), cred.getText()));
+ md.setCredits(values.toArray(new Credit[values.size()]));
+ } catch (final Exception ex) {
+ LOG.warn("Exception parsing credit tag.", ex);
+ }
+ }
+ }
+
+ // description
+ try {
+ final Element description = e.getChild("description", getNS());
+
+ if (description != null) {
+ md.setDescription(description.getText());
+ md.setDescriptionType(description.getAttributeValue("type"));
+ }
+ } catch (final Exception ex) {
+ LOG.warn("Exception parsing description tag.", ex);
+ }
+
+ // hash
+ try {
+ final Element hash = e.getChild("hash", getNS());
+
+ if (hash != null) {
+ md.setHash(new Hash(hash.getAttributeValue("algo"), hash.getText()));
+ }
+ } catch (final Exception ex) {
+ LOG.warn("Exception parsing hash tag.", ex);
+ }
+ // keywords
+ {
+ final Element keywords = e.getChild("keywords", getNS());
+
+ if (keywords != null) {
+ final StringTokenizer tok = new StringTokenizer(keywords.getText(), ",");
+ final String[] value = new String[tok.countTokens()];
+
+ for (int i = 0; tok.hasMoreTokens(); i++) {
+ value[i] = tok.nextToken().trim();
+ }
+
+ md.setKeywords(value);
+ }
+ }
+ // ratings
+ {
+ final ArrayList values = new ArrayList();
+
+ final List ratings = e.getChildren("rating", getNS());
+ for (final Element ratingElement : ratings) {
+ try {
+ final String ratingText = ratingElement.getText();
+ String ratingScheme = Strings.trimToNull(ratingElement.getAttributeValue("scheme"));
+ if (ratingScheme == null) {
+ ratingScheme = "urn:simple";
+ }
+ final Rating rating = new Rating(ratingScheme, ratingText);
+ values.add(rating);
+ } catch (final Exception ex) {
+ LOG.warn("Exception parsing rating tag.", ex);
+ }
+ }
+
+ md.setRatings(values.toArray(new Rating[values.size()]));
+
+ }
+ // text
+ {
+ final List texts = e.getChildren("text", getNS());
+ final ArrayList values = new ArrayList();
+
+ for (int i = 0; texts != null && i < texts.size(); i++) {
+ try {
+ final Element text = texts.get(i);
+ final Time start = text.getAttributeValue("start") == null ? null : new Time(text.getAttributeValue("start"));
+ final Time end = text.getAttributeValue("end") == null ? null : new Time(text.getAttributeValue("end"));
+ values.add(new Text(text.getAttributeValue("type"), text.getTextTrim(), start, end));
+ } catch (final Exception ex) {
+ LOG.warn("Exception parsing text tag.", ex);
+ }
+ }
+
+ md.setText(values.toArray(new Text[values.size()]));
+ }
+ // thumbnails
+ {
+ final ArrayList values = new ArrayList();
+
+ final List thumbnails = e.getChildren("thumbnail", getNS());
+ for (final Element thumb : thumbnails) {
+ try {
+
+ final String timeAttr = Strings.trimToNull(thumb.getAttributeValue("time"));
+ Time time = null;
+ if (timeAttr != null) {
+ time = new Time(timeAttr);
+ }
+
+ final String widthAttr = thumb.getAttributeValue("width");
+ final Integer width = Integers.parse(widthAttr);
+
+ final String heightAttr = thumb.getAttributeValue("height");
+ final Integer height = Integers.parse(heightAttr);
+
+ final String url = thumb.getAttributeValue("url");
+ final URI uri = new URI(url);
+ final Thumbnail thumbnail = new Thumbnail(uri, width, height, time);
+
+ values.add(thumbnail);
+
+ } catch (final Exception ex) {
+ LOG.warn("Exception parsing thumbnail tag.", ex);
+ }
+ }
+
+ md.setThumbnail(values.toArray(new Thumbnail[values.size()]));
+ }
+ // title
+ {
+ final Element title = e.getChild("title", getNS());
+
+ if (title != null) {
+ md.setTitle(title.getText());
+ md.setTitleType(title.getAttributeValue("type"));
+ }
+ }
+ // restrictions
+ {
+ final List restrictions = e.getChildren("restriction", getNS());
+ final ArrayList values = new ArrayList();
+
+ for (int i = 0; i < restrictions.size(); i++) {
+ final Element r = restrictions.get(i);
+ Restriction.Type type = null;
+
+ if (r.getAttributeValue("type").equalsIgnoreCase("uri")) {
+ type = Restriction.Type.URI;
+ } else if (r.getAttributeValue("type").equalsIgnoreCase("country")) {
+ type = Restriction.Type.COUNTRY;
+ }
+
+ Restriction.Relationship relationship = null;
+
+ if (r.getAttributeValue("relationship").equalsIgnoreCase("allow")) {
+ relationship = Restriction.Relationship.ALLOW;
+ } else if (r.getAttributeValue("relationship").equalsIgnoreCase("deny")) {
+ relationship = Restriction.Relationship.DENY;
+ }
+
+ final Restriction value = new Restriction(relationship, type, r.getTextTrim());
+ values.add(value);
+ }
+
+ md.setRestrictions(values.toArray(new Restriction[values.size()]));
+ }
+ // handle adult
+ {
+ final Element adult = e.getChild("adult", getNS());
+
+ if (adult != null && md.getRatings().length == 0) {
+ final Rating[] r = new Rating[1];
+
+ if (adult.getTextTrim().equals("true")) {
+ r[0] = new Rating("urn:simple", "adult");
+ } else {
+ r[0] = new Rating("urn:simple", "nonadult");
+ }
+
+ md.setRatings(r);
+ }
+ }
+
+ return md;
+ }
+
+ private PlayerReference parsePlayer(final Element e) {
+ final Element player = e.getChild("player", getNS());
+ PlayerReference p = null;
+
+ if (player != null) {
+ final Integer width = player.getAttributeValue("width") == null ? null : new Integer(player.getAttributeValue("width"));
+ final Integer height = player.getAttributeValue("height") == null ? null : new Integer(player.getAttributeValue("height"));
+
+ try {
+ p = new PlayerReference(new URI(player.getAttributeValue("url")), width, height);
+ } catch (final Exception ex) {
+ LOG.warn("Exception parsing player tag.", ex);
+ }
+ }
+
+ return p;
+ }
+
+ public Namespace getNS() {
+ return NS;
+ }
+
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/mediarss/io/RSS20YahooParser.java b/rome-modules/src/main/java/com/rometools/modules/mediarss/io/RSS20YahooParser.java
new file mode 100644
index 0000000..3eadf25
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/mediarss/io/RSS20YahooParser.java
@@ -0,0 +1,95 @@
+/*
+ * Copyright 2006 Nathanial X. Freitas, openvision.tv
+ *
+ * This code is currently released under the Mozilla Public License.
+ * http://www.mozilla.org/MPL/
+ *
+ * Alternately you may apply the terms of the Apache Software License
+ *
+ * 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 com.rometools.modules.mediarss.io;
+
+import java.util.Locale;
+
+import org.jdom2.Document;
+import org.jdom2.Element;
+import org.jdom2.Namespace;
+
+import com.rometools.rome.feed.WireFeed;
+import com.rometools.rome.io.impl.RSS20Parser;
+
+/**
+ * @author Nathanial X. Freitas
+ *
+ *
+ */
+public class RSS20YahooParser extends RSS20Parser {
+ // the Yahoo Namespace URI they sometimes use in the returns for video.search.yahoo.com RSS feed
+ private static final String RSS_URI = "urn:yahoo:yn";
+
+ //
+ public RSS20YahooParser() {
+ this("rss_2.0yahoo");
+ }
+
+ protected RSS20YahooParser(final String type) {
+ super(type);
+ }
+
+ /**
+ * Indicates if a JDom document is an RSS instance that can be parsed with the parser.
+ *
+ * It checks for RDF ("http://www.w3.org/1999/02/22-rdf-syntax-ns#") and RSS
+ * ("http://purl.org/rss/1.0/") namespaces being defined in the root element.
+ *
+ * @param document document to check if it can be parsed with this parser implementation.
+ * @return true if the document is RSS1., false otherwise.
+ */
+ @Override
+ public boolean isMyType(final Document document) {
+ boolean ok = false;
+
+ final Element rssRoot = document.getRootElement();
+ final Namespace defaultNS = rssRoot.getNamespace();
+
+ ok = defaultNS != null && defaultNS.equals(getRSSNamespace());
+
+ return ok;
+ }
+
+ /**
+ * Returns the namespace used by RSS elements in document of the RSS 1.0
+ *
+ *
+ * @return returns "http://purl.org/rss/1.0/".
+ */
+ @Override
+ protected Namespace getRSSNamespace() {
+ return Namespace.getNamespace(RSS_URI);
+ }
+
+ /**
+ * After we parse the feed we put "rss_2.0" in it (so converters and generators work) this
+ * parser is a phantom.
+ *
+ */
+ @Override
+ protected WireFeed parseChannel(final Element rssRoot, final Locale locale) {
+ final WireFeed wFeed = super.parseChannel(rssRoot, locale);
+ wFeed.setFeedType("rss_2.0");
+
+ return wFeed;
+ }
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/mediarss/io/package.html b/rome-modules/src/main/java/com/rometools/modules/mediarss/io/package.html
new file mode 100644
index 0000000..328588a
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/mediarss/io/package.html
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+ This package contains parsers and generators for the module as well as a specia feed
+ parser for Yahoo's custom RSS2 namespace.
+
+
diff --git a/rome-modules/src/main/java/com/rometools/modules/mediarss/package.html b/rome-modules/src/main/java/com/rometools/modules/mediarss/package.html
new file mode 100644
index 0000000..ae93e29
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/mediarss/package.html
@@ -0,0 +1,54 @@
+
+
+
+
+
+
+
+ This module supports Yahoo! MediaRSS elements for ROME feeds.
+
+ Sample usage:
+
+ SyndFeed feed = input.build( myRSSFile );
+ List entries = feed.getEntries();
+ for( int i = 0; i < entries.size(); i++ ){
+ System.out.println( ((SyndEntry) entries.get(i)).getModule( MediaModule.URI ) );
+ }
+
+ Alternatively, to add a media item to an entry:
+
+ MediaContent[] contents = new MediaContent[1];
+ MediaContent myItem = new MediaContent( new UrlReference("http://me.com/movie.mpg") );
+ contents[0] = myItem();
+ Metadata md = new Metadata();
+ Thumbnail[] thumbs = new Thumbnail[2];
+ thumbs[0] = new Thumbnail( new URL("http://me.com/movie1.jpg") );
+ thumbs[1] = new Thumbnail( new URL("http://me.com/movie2.jpg") );
+ md.setThumbnail( thumbs );
+ myItem.setMetadata( md );
+ MediaEntryModuleImpl module = new MediaEntryModuleImpl();
+ module.setContents( contents );
+ mySyndEntry.getModules().add( module );
+
+
+
+
+ * This code is currently released under the Mozilla Public License.
+ * http://www.mozilla.org/MPL/
+ *
+ * Alternately you may apply the terms of the Apache Software License
+ *
+ * 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.
+
+
+
diff --git a/rome-modules/src/main/java/com/rometools/modules/mediarss/types/AbstractSchemeValue.java b/rome-modules/src/main/java/com/rometools/modules/mediarss/types/AbstractSchemeValue.java
new file mode 100644
index 0000000..9b6faa1
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/mediarss/types/AbstractSchemeValue.java
@@ -0,0 +1,54 @@
+/*
+ * AbstractSchemeValue.java
+ *
+ * Created on April 18, 2006, 8:03 PM
+ *
+ *
+ * This code is currently released under the Mozilla Public License.
+ * http://www.mozilla.org/MPL/
+ *
+ * Alternately you may apply the terms of the Apache Software License
+ *
+ * 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 com.rometools.modules.mediarss.types;
+
+import java.io.Serializable;
+
+/**
+ * Simple data bean parent for scheme-value type entities.
+ *
+ * @author cooper
+ */
+public abstract class AbstractSchemeValue implements Serializable {
+ private static final long serialVersionUID = 1L;
+ private final String scheme;
+ private final String value;
+
+ public AbstractSchemeValue(final String scheme, final String value) {
+ if (scheme == null || value == null) {
+ throw new NullPointerException("Scheme and value cannot be null.");
+ }
+
+ this.scheme = scheme;
+ this.value = value;
+ }
+
+ public String getScheme() {
+ return scheme;
+ }
+
+ public String getValue() {
+ return value;
+ }
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/mediarss/types/Category.java b/rome-modules/src/main/java/com/rometools/modules/mediarss/types/Category.java
new file mode 100644
index 0000000..60012c1
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/mediarss/types/Category.java
@@ -0,0 +1,148 @@
+/*
+ * Category.java
+ *
+ * Created on April 18, 2006, 8:04 PM
+ *
+ * This code is currently released under the Mozilla Public License.
+ * http://www.mozilla.org/MPL/
+ *
+ * Alternately you may apply the terms of the Apache Software License
+ *
+ * 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 com.rometools.modules.mediarss.types;
+
+import java.io.Serializable;
+
+import com.rometools.rome.feed.impl.EqualsBean;
+import com.rometools.rome.feed.impl.ToStringBean;
+
+/**
+ *
+ * <media:category>
+ *
+ * Allows a taxonomy to be set that gives an indication of the type of media content, and its
+ * particular contents. It has 2 optional attributes.
+ *
+ * scheme is the URI that identifies the categorization scheme. It is an optional
+ * attribute. If this attribute is not included, the default scheme is
+ * 'http://search.yahoo.com/mrss/category_schema'.
+ *
+ *
+ *
+ * label is the human readable label that can be displayed in end user applications. It is
+ * an optional attribute.
+ *
+ *
+ * @author cooper
+ */
+public class Category implements Serializable {
+ private static final long serialVersionUID = 1L;
+ /**
+ * Schem for FLICKR tags
+ */
+ public static final String SCHEME_FLICKR_TAGS = "urn:flickr:tags";
+ private String label;
+ private String scheme;
+ private final String value;
+
+ /**
+ * Creates a new instance of Category
+ *
+ * @param scheme scheme used
+ * @param label label for the category
+ * @param value value of the category item
+ */
+ public Category(final String scheme, final String label, final String value) {
+ this.scheme = scheme;
+ this.value = value;
+ this.label = label;
+ }
+
+ /**
+ * Creates a new Category.
+ *
+ * @param value value of the category.
+ */
+ public Category(final String value) {
+ this.value = value;
+ }
+
+ /**
+ * label is the human readable label that can be displayed in end user applications. It is an
+ * optional attribute.
+ *
+ * @return label is the human readable label that can be displayed in end user applications. It
+ * is an optional attribute.
+ */
+ public String getLabel() {
+ return label;
+ }
+
+ /**
+ * scheme is the URI that identifies the categorization scheme. It is an optional attribute. If
+ * this attribute is not included, the default scheme is
+ * 'http://search.yahoo.com/mrss/category_schema'.
+ *
+ * @return scheme is the URI that identifies the categorization scheme. It is an optional
+ * attribute. If this attribute is not included, the default scheme is
+ * 'http://search.yahoo.com/mrss/category_schema'.
+ */
+ public String getScheme() {
+ return scheme;
+ }
+
+ /**
+ * value of the category
+ *
+ * @return value of the category
+ */
+ public String getValue() {
+ return value;
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ final EqualsBean eBean = new EqualsBean(this.getClass(), this);
+
+ return eBean.beanEquals(obj);
+ }
+
+ @Override
+ public int hashCode() {
+ final EqualsBean equals = new EqualsBean(this.getClass(), this);
+
+ return equals.beanHashCode();
+ }
+
+ @Override
+ public String toString() {
+ final ToStringBean tsBean = new ToStringBean(this.getClass(), this);
+
+ return tsBean.toString();
+ }
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/mediarss/types/Credit.java b/rome-modules/src/main/java/com/rometools/modules/mediarss/types/Credit.java
new file mode 100644
index 0000000..0411560
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/mediarss/types/Credit.java
@@ -0,0 +1,163 @@
+/*
+ * Credit.java
+ *
+ * Created on April 18, 2006, 7:34 PM
+ *
+ * This code is currently released under the Mozilla Public License.
+ * http://www.mozilla.org/MPL/
+ *
+ * Alternately you may apply the terms of the Apache Software License
+ *
+ * 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 com.rometools.modules.mediarss.types;
+
+import java.io.Serializable;
+
+import com.rometools.rome.feed.impl.EqualsBean;
+import com.rometools.rome.feed.impl.ToStringBean;
+
+/**
+ *
+ * <media:credit>
+ *
+ *
+ * Notable entity and the contribution to the creation of the media object. Current entities can
+ * include people, companies, locations, etc. Specific entities can have multiple roles, and several
+ * entities can have the same role. These should appear as distinct <media:credit> elements.
+ * It has 2 optional attributes.
+ *
+ * role specifies the role the entity played. Must be lowercase. It is an optional attribute.
+ *
+ *
+ *
+ * scheme is the URI that identifies the role scheme. It is an optional attribute. If this
+ * attribute is not included, the default scheme is 'urn:ebu'. See: European Broadcasting Union Role
+ * Codes.
+ *
+ * Additional roles: European
+ * Broadcasting Union Role Codes
+ *
+ * @author cooper
+ */
+public class Credit implements Serializable {
+ private static final long serialVersionUID = 1L;
+ /**
+ * Scheme value for the EBU credits.
+ */
+ public static final String SCHEME_EBU = "urn:ebu";
+ private final String name;
+ private final String role;
+ private final String scheme;
+
+ /**
+ * Creates a new instance of Credit
+ *
+ * @param scheme schem used
+ * @param role role name
+ * @param name persons name
+ */
+ public Credit(final String scheme, final String role, final String name) {
+ if (name == null) {
+ throw new NullPointerException("A credit name cannot be null.");
+ }
+
+ this.scheme = scheme == null ? SCHEME_EBU : scheme;
+ this.role = role == null ? null : role.toLowerCase();
+ this.name = name;
+ }
+
+ /**
+ * Person/organizations name
+ *
+ * @return Person/organizations name
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Role name
+ *
+ * @return Role name
+ */
+ public String getRole() {
+ return role;
+ }
+
+ /**
+ * Scheme used.
+ *
+ * @return Scheme used.
+ */
+ public String getScheme() {
+ return scheme;
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ final EqualsBean eBean = new EqualsBean(this.getClass(), this);
+
+ return eBean.beanEquals(obj);
+ }
+
+ @Override
+ public int hashCode() {
+ final EqualsBean equals = new EqualsBean(this.getClass(), this);
+
+ return equals.beanHashCode();
+ }
+
+ @Override
+ public String toString() {
+ final ToStringBean tsBean = new ToStringBean(this.getClass(), this);
+
+ return tsBean.toString();
+ }
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/mediarss/types/Expression.java b/rome-modules/src/main/java/com/rometools/modules/mediarss/types/Expression.java
new file mode 100644
index 0000000..f632432
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/mediarss/types/Expression.java
@@ -0,0 +1,54 @@
+/* This code is currently released under the Mozilla Public License.
+ * http://www.mozilla.org/MPL/
+ *
+ * Alternately you may apply the terms of the Apache Software License
+ *
+ * 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 com.rometools.modules.mediarss.types;
+
+import java.io.Serializable;
+
+/**
+ * expression determines if the object is a sample or the full version of the object, or even if it
+ * is a continuous stream (sample | full | nonstop). Default value is 'full'. It is an optional
+ * attribute.
+ */
+public class Expression implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Represents a complete media object.
+ */
+ public static final Expression FULL = new Expression("full");
+
+ /**
+ * Represents a sample media object.
+ */
+ public static final Expression SAMPLE = new Expression("sample");
+
+ /**
+ * represents a streaming media object.
+ */
+ public static final Expression NONSTOP = new Expression("nonstop");
+ private final String value;
+
+ private Expression(final String value) {
+ this.value = value;
+ }
+
+ @Override
+ public String toString() {
+ return value;
+ }
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/mediarss/types/Hash.java b/rome-modules/src/main/java/com/rometools/modules/mediarss/types/Hash.java
new file mode 100644
index 0000000..c385dd6
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/mediarss/types/Hash.java
@@ -0,0 +1,102 @@
+/*
+ * Hash.java
+ *
+ * Created on April 18, 2006, 8:06 PM
+ *
+ * This code is currently released under the Mozilla Public License.
+ * http://www.mozilla.org/MPL/
+ *
+ * Alternately you may apply the terms of the Apache Software License
+ *
+ * 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 com.rometools.modules.mediarss.types;
+
+import java.io.Serializable;
+
+import com.rometools.rome.feed.impl.EqualsBean;
+import com.rometools.rome.feed.impl.ToStringBean;
+
+/**
+ *
+ * <media:hash>
+ *
+ *
+ * This is the hash of the binary media file. It can appear multiple times as long as each instance
+ * is a different algo. It has 1 optional attribute.
+ *
+ * algo indicates the algorithm used to create the hash. Possible values are 'md5' and
+ * 'sha-1'. Default value is 'md5'. It is an optional attribute.
+ *
+ * @author cooper
+ */
+public class Hash extends AbstractSchemeValue implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Creates a new instance of Hash
+ *
+ * @param algorithm algoright used
+ * @param value value of the hash
+ */
+ public Hash(final String algorithm, final String value) {
+ super(algorithm == null ? "MD5" : algorithm, value);
+ }
+
+ /**
+ * Creates a new instance of Hash assuming the default algorithm of MD5
+ *
+ * @param algorithm algoright used
+ */
+ public Hash(final String value) {
+ this(null, value);
+ }
+
+ /**
+ * Alsorithm used for the hash
+ *
+ * @return Alsorithm used for the hash
+ */
+ public String getAlgorithm() {
+ return super.getScheme();
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ final EqualsBean eBean = new EqualsBean(this.getClass(), this);
+
+ return eBean.beanEquals(obj);
+ }
+
+ @Override
+ public int hashCode() {
+ final EqualsBean equals = new EqualsBean(this.getClass(), this);
+
+ return equals.beanHashCode();
+ }
+
+ @Override
+ public String toString() {
+ final ToStringBean tsBean = new ToStringBean(this.getClass(), this);
+
+ return tsBean.toString();
+ }
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/mediarss/types/MediaContent.java b/rome-modules/src/main/java/com/rometools/modules/mediarss/types/MediaContent.java
new file mode 100644
index 0000000..850f422
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/mediarss/types/MediaContent.java
@@ -0,0 +1,608 @@
+/*
+ * Copyright 2006 Nathanial X. Freitas, openvision.tv
+ *
+ * This code is currently released under the Mozilla Public License.
+ * http://www.mozilla.org/MPL
+ *
+ * Alternately you may apply the terms of the Apache Software License
+ *
+ * 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 com.rometools.modules.mediarss.types;
+
+import java.io.Serializable;
+
+import com.rometools.rome.feed.impl.EqualsBean;
+import com.rometools.rome.feed.impl.ToStringBean;
+
+/**
+ * <media:content>
+ *
+ * <media:content> is a sub-element of either <item> or <media:group>. Media
+ * objects that are not the same content should not be included in the same <media:group>
+ * element. The sequence of these items implies the order of presentation. While many of the
+ * attributes appear to be audio/video specific, this element can be used to publish any type of
+ * media. It contains 14 attributes, most of which are optional.
+ *
+ * url should specify the direct url to the media object. If not included, a
+ * <media:player> element must be specified.
+ *
+ *
+ * fileSize is the number of bytes of the media object. It is an optional attribute.
+ *
+ *
+ * type is the standard MIME type of the object. It is an optional attribute.
+ *
+ *
+ *
+ * medium is the type of object (image | audio | video | document | executable). While this
+ * attribute can at times seem redundant if type is supplied, it is included because it
+ * simplifies decision making on the reader side, as well as flushes out any ambiguities between
+ * MIME type and object type. It is an optional attribute.
+ *
+ *
+ *
+ *
+ * isDefault determines if this is the default object that should be used for the
+ * <media:group>. There should only be one default object per <media:group>. It is an
+ * optional attribute.
+ *
+ *
+ *
+ * expression determines if the object is a sample or the full version of the object, or
+ * even if it is a continuous stream (sample | full | nonstop). Default value is 'full'. It is an
+ * optional attribute.
+ *
+ *
+ *
+ * bitrate is the kilobits per second rate of media. It is an optional attribute.
+ *
+ *
+ * framerate is the number of frames per second for the media object. It is an optional
+ * attribute.
+ *
+ *
+ * samplingrate is the number of samples per second taken to create the media object. It is
+ * expressed in thousands of samples per second (kHz). It is an optional attribute.
+ *
+ *
+ * channels is number of audio channels in the media object. It is an optional attribute.
+ *
+ *
+ * duration is the number of seconds the media object plays. It is an optional attribute.
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ * height is the height of the media object. It is an optional attribute.
+ *
+ *
+ * width is the width of the media object. It is an optional attribute.
+ *
+ *
+ *
+ * lang is the primary language encapsulated in the media object. Language codes possible
+ * are detailed in RFC 3066. This attribute is used similar to the xml:lang attribute
+ * detailed in the XML 1.0 Specification (Third Edition). It is an optional attribute.
+ *
+ *
+ *
+ *
+ * These optional attributes, along with the optional elements below, contain the primary metadata
+ * entries needed to index and organize media content. Additional supported attributes for
+ * describing images, audio, and video may be added in future revisions of this document.
+ *
+ *
+ * @author Nathanial X. Freitas
+ *
+ * MediaContent corresponds to the element defined within the MediaRSS
+ * specification. There may be one or more instances within each instance of
+ * an within an RSS 2.0 document.
+ */
+public class MediaContent implements Serializable {
+ private static final long serialVersionUID = 1L;
+ private Expression expression;
+ private Float bitrate = null;
+ private Float framerate = null;
+ private Float samplingrate = null;
+
+ /*
+ * private variable for storing instances of Thumbnail class each MediaContent can have zero to
+ * many thumbnails
+ */
+ private Integer audioChannels = null;
+
+ /* the height in pixels of the resource */
+ private Integer height = null;
+
+ /* the width in pixels of the resource */
+ private Integer width = null;
+
+ /* the duration in seconds of the resource */
+ private Long duration = null;
+
+ /* the file size in bytes of the resouce */
+ private Long fileSize = null;
+ private Metadata metadata;
+ private PlayerReference player;
+ private Reference reference;
+ private String language;
+ private String medium;
+
+ /* the MIME type of the resource */
+ private String type = null;
+ private boolean defaultContent;
+
+ /*
+ * MediaContent constructor
+ */
+
+ /**
+ * Creates a new MediaContent
+ *
+ * @param reference UrlReference or Player reference for the item.
+ */
+ public MediaContent(final Reference reference) {
+ super();
+
+ if (reference == null) {
+ throw new NullPointerException("You must provide either a PlayerReference or URL reference.");
+ }
+
+ setReference(reference);
+ }
+
+ /**
+ * channels is number of audio channels in the media object. It is an optional attribute.
+ *
+ * @param audioChannels channels is number of audio channels in the media object. It is an
+ * optional attribute.
+ */
+ public void setAudioChannels(final Integer audioChannels) {
+ this.audioChannels = audioChannels;
+ }
+
+ /**
+ * channels is number of audio channels in the media object. It is an optional attribute.
+ *
+ * @return channels is number of audio channels in the media object. It is an optional
+ * attribute.
+ */
+ public Integer getAudioChannels() {
+ return audioChannels;
+ }
+
+ /**
+ * bitrate is the kilobits per second rate of media. It is an optional attribute.
+ *
+ * @param bitrate bitrate is the kilobits per second rate of media. It is an optional attribute.
+ */
+ public void setBitrate(final Float bitrate) {
+ this.bitrate = bitrate;
+ }
+
+ /**
+ * bitrate is the kilobits per second rate of media. It is an optional attribute.
+ *
+ * @return bitrate is the kilobits per second rate of media. It is an optional attribute.
+ */
+ public Float getBitrate() {
+ return bitrate;
+ }
+
+ /**
+ * isDefault determines if this is the default object that should be used for the .
+ * There should only be one default object per . It is an optional attribute.
+ *
+ * @param defaultContent isDefault determines if this is the default object that should be used
+ * for the . There should only be one default object per .
+ * It is an optional attribute.
+ */
+ public void setDefaultContent(final boolean defaultContent) {
+ this.defaultContent = defaultContent;
+ }
+
+ /**
+ * isDefault determines if this is the default object that should be used for the .
+ * There should only be one default object per . It is an optional attribute.
+ *
+ * @return isDefault determines if this is the default object that should be used for the
+ * . There should only be one default object per . It is an
+ * optional attribute.
+ */
+ public boolean isDefaultContent() {
+ return defaultContent;
+ }
+
+ /**
+ * duration is the number of seconds the media object plays. It is an optional attribute.
+ *
+ * @param duration duration is the number of seconds the media object plays. It is an optional
+ * attribute.
+ */
+ public void setDuration(final Long duration) {
+ this.duration = duration;
+ }
+
+ /**
+ * duration is the number of seconds the media object plays. It is an optional attribute.
+ *
+ * @return duration is the number of seconds the media object plays. It is an optional
+ * attribute.
+ */
+ public Long getDuration() {
+ return duration;
+ }
+
+ /**
+ * expression determines if the object is a sample or the full version of the object, or even if
+ * it is a continuous stream (sample | full | nonstop). Default value is 'full'. It is an
+ * optional attribute.
+ *
+ * @param expression expression determines if the object is a sample or the full version of the
+ * object, or even if it is a continuous stream (sample | full | nonstop). Default
+ * value is 'full'. It is an optional attribute.
+ */
+ public void setExpression(final Expression expression) {
+ this.expression = expression;
+ }
+
+ /**
+ * expression determines if the object is a sample or the full version of the object, or even if
+ * it is a continuous stream (sample | full | nonstop). Default value is 'full'. It is an
+ * optional attribute.
+ *
+ * @return expression determines if the object is a sample or the full version of the object, or
+ * even if it is a continuous stream (sample | full | nonstop). Default value is 'full'.
+ * It is an optional attribute.
+ */
+ public Expression getExpression() {
+ return expression;
+ }
+
+ /**
+ *
+ * fileSize is the number of bytes of the media object. It is an optional attribute.
+ *
+ * @param fileSize The fileSize to set.
+ */
+ public void setFileSize(final Long fileSize) {
+ this.fileSize = fileSize;
+ }
+
+ /**
+ * fileSize is the number of bytes of the media object. It is an optional attribute.
+ *
+ * @return Returns the fileSize.
+ */
+ public Long getFileSize() {
+ return fileSize;
+ }
+
+ /**
+ * framerate is the number of frames per second for the media object. It is an optional
+ * attribute.
+ *
+ * @param framerate framerate is the number of frames per second for the media object. It is an
+ * optional attribute.
+ */
+ public void setFramerate(final Float framerate) {
+ this.framerate = framerate;
+ }
+
+ /**
+ * framerate is the number of frames per second for the media object. It is an optional
+ * attribute.
+ *
+ * @return framerate is the number of frames per second for the media object. It is an optional
+ * attribute.
+ */
+ public Float getFramerate() {
+ return framerate;
+ }
+
+ /**
+ * height is the height of the media object. It is an optional attribute.
+ *
+ * @param height height is the height of the media object. It is an optional attribute.
+ */
+ public void setHeight(final Integer height) {
+ this.height = height;
+ }
+
+ /**
+ * height is the height of the media object. It is an optional attribute.
+ *
+ * @return height is the height of the media object. It is an optional attribute.
+ */
+ public Integer getHeight() {
+ return height;
+ }
+
+ /**
+ * lang is the primary language encapsulated in the media object. Language codes possible are
+ * detailed in RFC 3066. This attribute is used similar to the xml:lang attribute detailed in
+ * the XML 1.0 Specification (Third Edition). It is an optional attribute.
+ *
+ * @param language lang is the primary language encapsulated in the media object. Language codes
+ * possible are detailed in RFC 3066. This attribute is used similar to the xml:lang
+ * attribute detailed in the XML 1.0 Specification (Third Edition). It is an optional
+ * attribute.
+ */
+ public void setLanguage(final String language) {
+ this.language = language;
+ }
+
+ /**
+ * lang is the primary language encapsulated in the media object. Language codes possible are
+ * detailed in RFC 3066. This attribute is used similar to the xml:lang attribute detailed in
+ * the XML 1.0 Specification (Third Edition). It is an optional attribute.
+ *
+ * @return lang is the primary language encapsulated in the media object. Language codes
+ * possible are detailed in RFC 3066. This attribute is used similar to the xml:lang
+ * attribute detailed in the XML 1.0 Specification (Third Edition). It is an optional
+ * attribute.
+ */
+ public String getLanguage() {
+ return language;
+ }
+
+ /**
+ * Set the value of medium
+ *
+ * @param newmedium new value of medium
+ */
+ public void setMedium(final String newmedium) {
+ medium = newmedium;
+ }
+
+ /**
+ * Get the value of medium
+ *
+ * @return the value of medium
+ */
+ public String getMedium() {
+ return medium;
+ }
+
+ /**
+ * The metadata for the item
+ *
+ * @param metadata The metadata for the item
+ */
+ public void setMetadata(final Metadata metadata) {
+ this.metadata = metadata;
+ }
+
+ /**
+ * The metadata for the item
+ *
+ * @return The metadata for the item
+ */
+ public Metadata getMetadata() {
+ return metadata;
+ }
+
+ /**
+ * <media:player>
+ *
+ * Allows the media object to be accessed through a web browser media player console. This
+ * element is required only if a direct media url attribute is not specified in the
+ * <media:content> element. It has 1 required attribute, and 2 optional attributes.
+ *
+ * url is the url of the player console that plays the media. It is a required
+ * attribute.
+ *
+ *
+ *
+ * height is the height of the browser window that the url should be opened
+ * in. It is an optional attribute.
+ *
+ *
+ * width is the width of the browser window that the url should be opened in.
+ * It is an optional attribute.
+ *
+ *
+ *
+ *
+ * @param player PlayerReference for the item.
+ */
+ public void setPlayer(final PlayerReference player) {
+ this.player = player;
+ }
+
+ /**
+ * <media:player>
+ *
+ * Allows the media object to be accessed through a web browser media player console. This
+ * element is required only if a direct media url attribute is not specified in the
+ * <media:content> element. It has 1 required attribute, and 2 optional attributes.
+ *
+ * url is the url of the player console that plays the media. It is a required
+ * attribute.
+ *
+ *
+ *
+ * height is the height of the browser window that the url should be opened
+ * in. It is an optional attribute.
+ *
+ *
+ * width is the width of the browser window that the url should be opened in.
+ * It is an optional attribute.
+ *
+ *
+ * @return PlayerReference for the item.
+ */
+ public PlayerReference getPlayer() {
+ return player;
+ }
+
+ /**
+ * The player or URL reference for the item
+ *
+ * @param reference The player or URL reference for the item
+ */
+ public void setReference(final Reference reference) {
+ this.reference = reference;
+
+ if (reference instanceof PlayerReference) {
+ setPlayer((PlayerReference) reference);
+ }
+ }
+
+ /**
+ * The player or URL reference for the item
+ *
+ * @return The player or URL reference for the item
+ */
+ public Reference getReference() {
+ return reference;
+ }
+
+ /**
+ * samplingrate is the number of samples per second taken to create the media object. It is
+ * expressed in thousands of samples per second (kHz). It is an optional attribute.
+ *
+ * @param samplingrate samplingrate is the number of samples per second taken to create the
+ * media object. It is expressed in thousands of samples per second (kHz). It is an
+ * optional attribute.
+ */
+ public void setSamplingrate(final Float samplingrate) {
+ this.samplingrate = samplingrate;
+ }
+
+ /**
+ * samplingrate is the number of samples per second taken to create the media object. It is
+ * expressed in thousands of samples per second (kHz). It is an optional attribute.
+ *
+ * @return samplingrate is the number of samples per second taken to create the media object. It
+ * is expressed in thousands of samples per second (kHz). It is an optional attribute.
+ */
+ public Float getSamplingrate() {
+ return samplingrate;
+ }
+
+ /**
+ *
+ * type is the standard MIME type of the object. It is an optional attribute.
+ *
+ * @param type The type to set.
+ */
+ public void setType(final String type) {
+ this.type = type;
+ }
+
+ /**
+ *
+ * type is the standard MIME type of the object. It is an optional attribute.
+ *
+ * @return Returns the type.
+ */
+ public String getType() {
+ return type;
+ }
+
+ /**
+ * width is the width of the media object. It is an optional attribute.
+ *
+ * @param width width is the width of the media object. It is an optional attribute.
+ */
+ public void setWidth(final Integer width) {
+ this.width = width;
+ }
+
+ /**
+ * width is the width of the media object. It is an optional attribute.
+ *
+ * @return width is the width of the media object. It is an optional attribute.
+ */
+ public Integer getWidth() {
+ return width;
+ }
+
+ @Override
+ public Object clone() {
+ final MediaContent c = new MediaContent(getReference());
+ c.setAudioChannels(getAudioChannels());
+ c.setBitrate(getBitrate());
+ c.setDefaultContent(isDefaultContent());
+ c.setDuration(getDuration());
+ c.setExpression(getExpression());
+ c.setFileSize(getFileSize());
+ c.setFramerate(getFramerate());
+ c.setHeight(getHeight());
+ c.setLanguage(getLanguage());
+ c.setMetadata(getMetadata() == null ? null : (Metadata) getMetadata().clone());
+ c.setPlayer(getPlayer());
+ c.setSamplingrate(getSamplingrate());
+ c.setType(getType());
+ c.setWidth(getWidth());
+
+ return c;
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ final EqualsBean eBean = new EqualsBean(MediaContent.class, this);
+
+ return eBean.beanEquals(obj);
+ }
+
+ @Override
+ public int hashCode() {
+ final EqualsBean equals = new EqualsBean(MediaContent.class, this);
+
+ return equals.beanHashCode();
+ }
+
+ @Override
+ public String toString() {
+ final ToStringBean tsBean = new ToStringBean(MediaContent.class, this);
+
+ return tsBean.toString();
+ }
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/mediarss/types/MediaGroup.java b/rome-modules/src/main/java/com/rometools/modules/mediarss/types/MediaGroup.java
new file mode 100644
index 0000000..2e5e5cd
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/mediarss/types/MediaGroup.java
@@ -0,0 +1,169 @@
+/*
+ * MediaGroup.java
+ *
+ * Created on April 19, 2006, 12:34 AM
+ *
+ *
+ * This code is currently released under the Mozilla Public License.
+ * http://www.mozilla.org/MPL/
+ *
+ * Alternately you may apply the terms of the Apache Software License
+ *
+ * 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 com.rometools.modules.mediarss.types;
+
+import java.io.Serializable;
+
+import com.rometools.rome.feed.impl.EqualsBean;
+import com.rometools.rome.feed.impl.ToStringBean;
+
+/**
+ * <media:group>
+ *
+ * <media:group> is a sub-element of <item>. It allows grouping of <media:content>
+ * elements that are effectively the same content, yet different representations. For instance:
+ * the same song recorded in both the WAV and MP3 format. It's an optional element that must only be
+ * used for this purpose.
+ *
+ *
+ * @author cooper
+ */
+public class MediaGroup implements Cloneable, Serializable {
+ private static final long serialVersionUID = 1L;
+
+ private Integer defaultContentIndex;
+ private Metadata metadata;
+ private MediaContent[] contents = new MediaContent[0];
+
+ /**
+ * Creates a new instance of MediaGroup
+ *
+ * @param contents Contents of the group.
+ */
+ public MediaGroup(final MediaContent[] contents) {
+ setContents(contents);
+ }
+
+ /**
+ * Creates a new instance of MediaGroup
+ *
+ * @param contents contents of the group
+ * @param defaultContentIndex index of the default content value.
+ */
+ public MediaGroup(final MediaContent[] contents, final Integer defaultContentIndex) {
+ setContents(contents);
+ setDefaultContentIndex(defaultContentIndex);
+ }
+
+ /**
+ * Creates a new instance of MediaGroup
+ *
+ * @param contents contents of the group
+ * @param defaultContentIndex index of the default content item.
+ * @param metadata metadata for the group.
+ */
+ public MediaGroup(final MediaContent[] contents, final Integer defaultContentIndex, final Metadata metadata) {
+ setContents(contents);
+ setDefaultContentIndex(defaultContentIndex);
+ setMetadata(metadata);
+ }
+
+ /**
+ * MediaContents for the group
+ *
+ * @param contents MediaContents for the group
+ */
+ public void setContents(final MediaContent[] contents) {
+ this.contents = contents == null ? new MediaContent[0] : contents;
+ }
+
+ /**
+ * MediaContents for the group
+ *
+ * @return MediaContents for the group
+ */
+ public MediaContent[] getContents() {
+ return contents;
+ }
+
+ /**
+ * Default content index MediaContent.
+ *
+ * @param defaultContentIndex Default content index MediaContent.
+ */
+ public void setDefaultContentIndex(final Integer defaultContentIndex) {
+ for (int i = 0; i < getContents().length; i++) {
+ if (i == defaultContentIndex.intValue()) {
+ getContents()[i].setDefaultContent(true);
+ } else {
+ getContents()[i].setDefaultContent(false);
+ }
+ }
+
+ this.defaultContentIndex = defaultContentIndex;
+ }
+
+ /**
+ * Default content index MediaContent.
+ *
+ * @return Default content index MediaContent.
+ */
+ public Integer getDefaultContentIndex() {
+ return defaultContentIndex;
+ }
+
+ /**
+ * Metadata for the group
+ *
+ * @param metadata Metadata for the group
+ */
+ public void setMetadata(final Metadata metadata) {
+ this.metadata = metadata;
+ }
+
+ /**
+ * Metadata for the group
+ *
+ * @return Metadata for the group
+ */
+ public Metadata getMetadata() {
+ return metadata;
+ }
+
+ @Override
+ public Object clone() {
+ return new MediaGroup(getContents(), getDefaultContentIndex(), getMetadata());
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ final EqualsBean eBean = new EqualsBean(this.getClass(), this);
+
+ return eBean.beanEquals(obj);
+ }
+
+ @Override
+ public int hashCode() {
+ final EqualsBean equals = new EqualsBean(this.getClass(), this);
+
+ return equals.beanHashCode();
+ }
+
+ @Override
+ public String toString() {
+ final ToStringBean tsBean = new ToStringBean(this.getClass(), this);
+
+ return tsBean.toString();
+ }
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/mediarss/types/Metadata.java b/rome-modules/src/main/java/com/rometools/modules/mediarss/types/Metadata.java
new file mode 100644
index 0000000..8f4b5c0
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/mediarss/types/Metadata.java
@@ -0,0 +1,990 @@
+/*
+ * Metadata.java
+ *
+ * Created on April 18, 2006, 7:57 PM
+ *
+ *
+ * This code is currently released under the Mozilla Public License.
+ * http://www.mozilla.org/MPL/
+ *
+ * Alternately you may apply the terms of the Apache Software License
+ *
+ * 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 com.rometools.modules.mediarss.types;
+
+import java.io.Serializable;
+import java.net.URI;
+
+import com.rometools.rome.feed.impl.EqualsBean;
+import com.rometools.rome.feed.impl.ToStringBean;
+
+/**
+ *
+ *
+ *
+ * Optional Elements
+ *
+ * The following elements are optional and may appear as sub-elements of <channel>,
+ * <item>, <media:content> and/or <media:group>.
+ *
+ *
+ *
+ *
+ *
+ * When an element appears at a shallow level, such as <channel> or <item>, it means
+ * that the element should be applied to every media object within its scope.
+ *
+ *
+ *
+ *
+ * Duplicated elements appearing at deeper levels of the document tree have higher priority over
+ * other levels.
+ *
+ * For example, <media:content> level elements are favored over <item> level elements.
+ * The priority level is listed from strongest to weakest: <media:content>,
+ * <media:group>, <item>, <channel>.
+ *
+ *
+ * @author cooper
+ */
+public class Metadata implements Cloneable, Serializable {
+ private static final long serialVersionUID = 1L;
+
+ private Hash hash;
+ private String copyright;
+ private String description;
+ private String descriptionType;
+ private String title;
+ private String titleType;
+ private URI copyrightUrl;
+ private Category[] categories = new Category[0];
+ private Credit[] credits = new Credit[0];
+ private String[] keywords = new String[0];
+ private Rating[] ratings = new Rating[0];
+ private Restriction[] restrictions = new Restriction[0];
+ private Text[] text = new Text[0];
+ private Thumbnail[] thumbnail = new Thumbnail[0];
+
+ /** Creates a new instance of Metadata */
+ public Metadata() {
+ super();
+ }
+
+ /**
+ * <media:category>
+ *
+ * Allows a taxonomy to be set that gives an indication of the type of media content, and its
+ * particular contents. It has 2 optional attributes.
+ *
+ * scheme is the URI that identifies the categorization scheme. It is an optional
+ * attribute. If this attribute is not included, the default scheme is
+ * 'http://search.yahoo.com/mrss/category_schema'.
+ *
+ *
+ *
+ * label is the human readable label that can be displayed in end user applications. It
+ * is an optional attribute.
+ *
+ *
+ * @param categories categories for the item
+ */
+ public void setCategories(final Category[] categories) {
+ this.categories = categories == null ? new Category[0] : categories;
+ }
+
+ /**
+ * <media:category>
+ *
+ * Allows a taxonomy to be set that gives an indication of the type of media content, and its
+ * particular contents. It has 2 optional attributes.
+ *
+ * scheme is the URI that identifies the categorization scheme. It is an optional
+ * attribute. If this attribute is not included, the default scheme is
+ * 'http://search.yahoo.com/mrss/category_schema'.
+ *
+ *
+ *
+ * label is the human readable label that can be displayed in end user applications. It
+ * is an optional attribute.
+ *
+ *
+ * @return categories for the item.
+ */
+ public Category[] getCategories() {
+ return categories;
+ }
+
+ /**
+ * <media:copyright>
+ *
+ * Copyright information for media object. It has 1 optional attribute.
+ *
+ * url is the url for a terms of use page or additional copyright information. If the
+ * media is operating under a Creative Commons license, the Creative Commons module should be
+ * used instead. It is an optional attribute.
+ *
+ * url is the url for a terms of use page or additional copyright information. If the
+ * media is operating under a Creative Commons license, the Creative Commons module should be
+ * used instead. It is an optional attribute.
+ *
+ * url is the url for a terms of use page or additional copyright information. If the
+ * media is operating under a Creative Commons license, the Creative Commons module should be
+ * used instead. It is an optional attribute.
+ *
+ *
+ * @param copyrightUrl link to more copyright information.
+ */
+ public void setCopyrightUrl(final URI copyrightUrl) {
+ this.copyrightUrl = copyrightUrl;
+ }
+
+ /**
+ * <media:copyright>
+ *
+ * Copyright information for media object. It has 1 optional attribute.
+ *
+ * url is the url for a terms of use page or additional copyright information. If the
+ * media is operating under a Creative Commons license, the Creative Commons module should be
+ * used instead. It is an optional attribute.
+ *
+ *
+ * @return Link to more copyright information.
+ */
+ public URI getCopyrightUrl() {
+ return copyrightUrl;
+ }
+
+ /**
+ * <media:credit>
+ *
+ *
+ * Notable entity and the contribution to the creation of the media object. Current entities can
+ * include people, companies, locations, etc. Specific entities can have multiple roles, and
+ * several entities can have the same role. These should appear as distinct <media:credit>
+ * elements. It has 2 optional attributes.
+ *
+ * role specifies the role the entity played. Must be lowercase. It is an optional attribute.
+ *
+ *
+ *
+ * scheme is the URI that identifies the role scheme. It is an optional attribute. If
+ * this attribute is not included, the default scheme is 'urn:ebu'. See: European Broadcasting
+ * Union Role Codes.
+ *
+ * Additional roles: European
+ * Broadcasting Union Role Codes
+ *
+ * @param credits credits for the item.
+ */
+ public void setCredits(final Credit[] credits) {
+ this.credits = credits == null ? new Credit[0] : credits;
+ }
+
+ /**
+ * <media:credit>
+ *
+ *
+ * Notable entity and the contribution to the creation of the media object. Current entities can
+ * include people, companies, locations, etc. Specific entities can have multiple roles, and
+ * several entities can have the same role. These should appear as distinct <media:credit>
+ * elements. It has 2 optional attributes.
+ *
+ * role specifies the role the entity played. Must be lowercase. It is an optional attribute.
+ *
+ *
+ *
+ * scheme is the URI that identifies the role scheme. It is an optional attribute. If
+ * this attribute is not included, the default scheme is 'urn:ebu'. See: European Broadcasting
+ * Union Role Codes.
+ *
+ * Additional roles: European
+ * Broadcasting Union Role Codes
+ *
+ * @return credits for the time.
+ */
+ public Credit[] getCredits() {
+ return credits;
+ }
+
+ /**
+ * <media:description>
+ *
+ * Short description describing the media object typically a sentence in length. It has 1
+ * optional attribute.
+ *
+ *
+ *
+ * <media:description type="plain">This was some really bizarre band I listened to as a young lad.</media:description>
+ *
+ *
+ * type specifies the type of text embedded. Possible values are either 'plain' or
+ * 'html'. Default value is 'plain'. All html must be entity-encoded. It is an optional
+ * attribute.
+ *
+ *
+ * @param description value of the description
+ */
+ public void setDescription(final String description) {
+ this.description = description;
+ }
+
+ /**
+ * <media:description>
+ *
+ * Short description describing the media object typically a sentence in length. It has 1
+ * optional attribute.
+ *
+ *
+ *
+ * <media:description type="plain">This was some really bizarre band I listened to as a young lad.</media:description>
+ *
+ *
+ * type specifies the type of text embedded. Possible values are either 'plain' or
+ * 'html'. Default value is 'plain'. All html must be entity-encoded. It is an optional
+ * attribute.
+ *
+ *
+ * @return value of the description
+ */
+ public String getDescription() {
+ return description;
+ }
+
+ /**
+ * <media:description>
+ *
+ * Short description describing the media object typically a sentence in length. It has 1
+ * optional attribute.
+ *
+ *
+ *
+ * <media:description type="plain">This was some really bizarre band I listened to as a young lad.</media:description>
+ *
+ *
+ * type specifies the type of text embedded. Possible values are either 'plain' or
+ * 'html'. Default value is 'plain'. All html must be entity-encoded. It is an optional
+ * attribute.
+ *
+ *
+ * @param descriptionType type of the description.
+ */
+ public void setDescriptionType(final String descriptionType) {
+ this.descriptionType = descriptionType;
+ }
+
+ /**
+ * <media:description>
+ *
+ * Short description describing the media object typically a sentence in length. It has 1
+ * optional attribute.
+ *
+ *
+ *
+ * <media:description type="plain">This was some really bizarre band I listened to as a young lad.</media:description>
+ *
+ *
+ * type specifies the type of text embedded. Possible values are either 'plain' or
+ * 'html'. Default value is 'plain'. All html must be entity-encoded. It is an optional
+ * attribute.
+ *
+ *
+ * @return type of the description
+ */
+ public String getDescriptionType() {
+ return descriptionType;
+ }
+
+ /**
+ * <media:hash>
+ *
+ *
+ * This is the hash of the binary media file. It can appear multiple times as long as each
+ * instance is a different algo. It has 1 optional attribute.
+ *
+ * algo indicates the algorithm used to create the hash. Possible values are 'md5' and
+ * 'sha-1'. Default value is 'md5'. It is an optional attribute.
+ *
+ * @param hash sets the hash for the item.
+ */
+ public void setHash(final Hash hash) {
+ this.hash = hash;
+ }
+
+ /**
+ * <media:hash>
+ *
+ *
+ * This is the hash of the binary media file. It can appear multiple times as long as each
+ * instance is a different algo. It has 1 optional attribute.
+ *
+ * algo indicates the algorithm used to create the hash. Possible values are 'md5' and
+ * 'sha-1'. Default value is 'md5'. It is an optional attribute.
+ *
+ * @return returns a Hash object for the item.
+ */
+ public Hash getHash() {
+ return hash;
+ }
+
+ /**
+ * <media:keywords>
+ *
+ * Highly relevant keywords describing the media object with typically a maximum of ten words.
+ * The keywords and phrases should be comma delimited.
+ *
+ *
+ *
+ * <media:keywords>kitty, cat, big dog, yarn, fluffy</media:keywords>
+ *
+ * Highly relevant keywords describing the media object with typically a maximum of ten words.
+ * The keywords and phrases should be comma delimited.
+ *
+ *
+ *
+ * <media:keywords>kitty, cat, big dog, yarn, fluffy</media:keywords>
+ *
+ * This allows the permissible audience to be declared. If this element is not included, it
+ * assumes that no restrictions are necessary. It has one optional attribute.
+ *
+ * scheme is the URI that identifies the rating scheme. It is an optional attribute. If
+ * this attribute is not included, the default scheme is urn:simple (adult | nonadult).
+ *
+ * This allows the permissible audience to be declared. If this element is not included, it
+ * assumes that no restrictions are necessary. It has one optional attribute.
+ *
+ * scheme is the URI that identifies the rating scheme. It is an optional attribute. If
+ * this attribute is not included, the default scheme is urn:simple (adult | nonadult).
+ *
+ * Allows restrictions to be placed on the aggregator rendering the media in the feed.
+ * Currently, restrictions are based on distributor (uri) and country codes. This element is
+ * purely informational and no obligation can be assumed or implied. Only one
+ * <media:restriction> element of the same type can be applied to a media object
+ * - all others will be ignored. Entities in this element should be space separated. To
+ * allow the producer to explicitly declare his/her intentions, two literals are reserved:
+ * 'all', 'none'. These literals can only be used once. This element has 1 required attribute,
+ * and 1 optional attribute (with strict requirements for its exclusion).
+ *
+ * relationship indicates the type of relationship that the restriction represents
+ * (allow | deny). In the example above, the media object should only be syndicated in Australia
+ * and the United States. It is a required attribute.
+ *
+ * Allows restrictions to be placed on the aggregator rendering the media in the feed.
+ * Currently, restrictions are based on distributor (uri) and country codes. This element is
+ * purely informational and no obligation can be assumed or implied. Only one
+ * <media:restriction> element of the same type can be applied to a media object
+ * - all others will be ignored. Entities in this element should be space separated. To
+ * allow the producer to explicitly declare his/her intentions, two literals are reserved:
+ * 'all', 'none'. These literals can only be used once. This element has 1 required attribute,
+ * and 1 optional attribute (with strict requirements for its exclusion).
+ *
+ * relationship indicates the type of relationship that the restriction represents
+ * (allow | deny). In the example above, the media object should only be syndicated in Australia
+ * and the United States. It is a required attribute.
+ *
+ *
+ * @return restrictions for the item.
+ */
+ public Restriction[] getRestrictions() {
+ return restrictions;
+ }
+
+ /**
+ * <media:text>
+ *
+ * Allows the inclusion of a text transcript, closed captioning, or lyrics of the media content.
+ * Many of these elements are permitted to provide a time series of text. In such cases, it is
+ * encouraged, but not required, that the elements be grouped by language and appear in time
+ * sequence order based on the start time. Elements can have overlapping start
+ * and end times. It has 4 optional attributes.
+ *
+ *
+ *
+ * <media:text type="plain" lang="en" start="00:00:03.000"
+ * end="00:00:10.000"> Oh, say, can you see</media:text>
+ *
+ * <media:text type="plain" lang="en" start="00:00:10.000"
+ * end="00:00:17.000">By the dawn's early light</media:text>
+ *
+ *
+ * type specifies the type of text embedded. Possible values are either 'plain' or
+ * 'html'. Default value is 'plain'. All html must be entity-encoded. It is an optional
+ * attribute.
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ * lang is the primary language encapsulated in the media object. Language codes
+ * possible are detailed in RFC 3066. This attribute is used similar to the xml:lang attribute
+ * detailed in the XML 1.0 Specification (Third Edition). It is an optional attribute.
+ *
+ *
+ *
+ * start specifies the start time offset that the text starts being relevant to the
+ * media object. An example of this would be for closed captioning. It uses the NTP time code
+ * format (see: the time attribute used in <media:thumbnail>). It is an optional
+ * attribute.
+ *
+ *
+ *
+ * end specifies the end time that the text is relevant. If this attribute is not
+ * provided, and a start time is used, it is expected that the end time is either the
+ * end of the clip or the start of the next <media:text> element.
+ *
+ * @param text text objects for the item.
+ */
+ public void setText(final Text[] text) {
+ this.text = text == null ? new Text[0] : text;
+ }
+
+ /**
+ * <media:text>
+ *
+ * Allows the inclusion of a text transcript, closed captioning, or lyrics of the media content.
+ * Many of these elements are permitted to provide a time series of text. In such cases, it is
+ * encouraged, but not required, that the elements be grouped by language and appear in time
+ * sequence order based on the start time. Elements can have overlapping start
+ * and end times. It has 4 optional attributes.
+ *
+ *
+ *
+ * <media:text type="plain" lang="en" start="00:00:03.000"
+ * end="00:00:10.000"> Oh, say, can you see</media:text>
+ *
+ * <media:text type="plain" lang="en" start="00:00:10.000"
+ * end="00:00:17.000">By the dawn's early light</media:text>
+ *
+ *
+ * type specifies the type of text embedded. Possible values are either 'plain' or
+ * 'html'. Default value is 'plain'. All html must be entity-encoded. It is an optional
+ * attribute.
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ * lang is the primary language encapsulated in the media object. Language codes
+ * possible are detailed in RFC 3066. This attribute is used similar to the xml:lang attribute
+ * detailed in the XML 1.0 Specification (Third Edition). It is an optional attribute.
+ *
+ *
+ *
+ * start specifies the start time offset that the text starts being relevant to the
+ * media object. An example of this would be for closed captioning. It uses the NTP time code
+ * format (see: the time attribute used in <media:thumbnail>). It is an optional
+ * attribute.
+ *
+ *
+ *
+ * end specifies the end time that the text is relevant. If this attribute is not
+ * provided, and a start time is used, it is expected that the end time is either the
+ * end of the clip or the start of the next <media:text> element.
+ *
+ * @return Text objects for the item.
+ */
+ public Text[] getText() {
+ return text;
+ }
+
+ /**
+ * <media:thumbnail>
+ *
+ *
+ *
+ * Allows particular images to be used as representative images for the media object. If
+ * multiple thumbnails are included, and time coding is not at play, it is assumed that the
+ * images are in order of importance. It has 1 required attribute and 3 optional attributes.
+ *
+ * url specifies the url of the thumbnail. It is a required attribute.
+ *
+ *
+ * height specifies the height of the thumbnail. It is an optional attribute.
+ *
+ *
+ * width specifies the width of the thumbnail. It is an optional attribute.
+ *
+ *
+ *
+ *
+ * time specifies the time offset in relation to the media object. Typically this is
+ * used when creating multiple keyframes within a single video. The format for this attribute
+ * should be in the DSM-CC's Normal Play Time (NTP) as used in RTSP [RFC 2326 3.6 Normal Play Time]. It is an
+ * optional attribute.
+ *
+ * Allows particular images to be used as representative images for the media object. If
+ * multiple thumbnails are included, and time coding is not at play, it is assumed that the
+ * images are in order of importance. It has 1 required attribute and 3 optional attributes.
+ *
+ * url specifies the url of the thumbnail. It is a required attribute.
+ *
+ *
+ * height specifies the height of the thumbnail. It is an optional attribute.
+ *
+ *
+ * width specifies the width of the thumbnail. It is an optional attribute.
+ *
+ *
+ *
+ *
+ * time specifies the time offset in relation to the media object. Typically this is
+ * used when creating multiple keyframes within a single video. The format for this attribute
+ * should be in the DSM-CC's Normal Play Time (NTP) as used in RTSP [RFC 2326 3.6 Normal Play Time]. It is an
+ * optional attribute.
+ *
+ *
+ * @return Thumbnails for the image
+ */
+ public Thumbnail[] getThumbnail() {
+ return thumbnail;
+ }
+
+ /**
+ * <media:title>
+ *
+ * The title of the particular media object. It has 1 optional attribute.
+ *
+ * type specifies the type of text embedded. Possible values are either 'plain' or
+ * 'html'. Default value is 'plain'. All html must be entity-encoded. It is an optional
+ * attribute.
+ *
+ *
+ * @param title Value of the title
+ */
+ public void setTitle(final String title) {
+ this.title = title;
+ }
+
+ /**
+ * <media:title>
+ *
+ * The title of the particular media object. It has 1 optional attribute.
+ *
+ * type specifies the type of text embedded. Possible values are either 'plain' or
+ * 'html'. Default value is 'plain'. All html must be entity-encoded. It is an optional
+ * attribute.
+ *
+ *
+ * @return value of the title.
+ */
+ public String getTitle() {
+ return title;
+ }
+
+ /**
+ * <media:title>
+ *
+ * The title of the particular media object. It has 1 optional attribute.
+ *
+ * type specifies the type of text embedded. Possible values are either 'plain' or
+ * 'html'. Default value is 'plain'. All html must be entity-encoded. It is an optional
+ * attribute.
+ *
+ *
+ * @param titleType type of the title.
+ */
+ public void setTitleType(final String titleType) {
+ this.titleType = titleType;
+ }
+
+ /**
+ * <media:title>
+ *
+ * The title of the particular media object. It has 1 optional attribute.
+ *
+ * type specifies the type of text embedded. Possible values are either 'plain' or
+ * 'html'. Default value is 'plain'. All html must be entity-encoded. It is an optional
+ * attribute.
+ *
+ *
+ * @return type of the title
+ */
+ public String getTitleType() {
+ return titleType;
+ }
+
+ /**
+ * <media:copyright>
+ *
+ * Copyright information for media object. It has 1 optional attribute.
+ *
+ * url is the url for a terms of use page or additional copyright information. If the
+ * media is operating under a Creative Commons license, the Creative Commons module should be
+ * used instead. It is an optional attribute.
+ *
+ *
+ * @return Link to more copyright information.
+ */
+ @Override
+ public Object clone() {
+ final Metadata md = new Metadata();
+ md.setCategories(getCategories());
+ md.setCopyright(getCopyright());
+ md.setCopyrightUrl(getCopyrightUrl());
+ md.setCredits(getCredits());
+ md.setDescription(getDescription());
+ md.setDescriptionType(getDescriptionType());
+ md.setHash(getHash());
+ md.setKeywords(getKeywords());
+ md.setRatings(getRatings());
+ md.setText(getText());
+ md.setThumbnail(getThumbnail());
+ md.setTitle(getTitle());
+ md.setTitleType(getTitleType());
+ md.setRestrictions(getRestrictions());
+
+ return md;
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ final EqualsBean eBean = new EqualsBean(Metadata.class, this);
+
+ return eBean.beanEquals(obj);
+ }
+
+ @Override
+ public int hashCode() {
+ final EqualsBean equals = new EqualsBean(Metadata.class, this);
+
+ return equals.beanHashCode();
+ }
+
+ @Override
+ public String toString() {
+ final ToStringBean tsBean = new ToStringBean(Metadata.class, this);
+
+ return tsBean.toString();
+ }
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/mediarss/types/PlayerReference.java b/rome-modules/src/main/java/com/rometools/modules/mediarss/types/PlayerReference.java
new file mode 100644
index 0000000..d8969be
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/mediarss/types/PlayerReference.java
@@ -0,0 +1,140 @@
+/*
+ * PlayerReference.java
+ *
+ * Created on April 18, 2006, 7:18 PM
+ *
+ * This code is currently released under the Mozilla Public License.
+ * http://www.mozilla.org/MPL/
+ *
+ * Alternately you may apply the terms of the Apache Software License
+ *
+ * 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 com.rometools.modules.mediarss.types;
+
+import java.io.Serializable;
+import java.net.URI;
+
+import com.rometools.rome.feed.impl.EqualsBean;
+import com.rometools.rome.feed.impl.ToStringBean;
+
+/**
+ *
+ * <media:player>
+ *
+ * Allows the media object to be accessed through a web browser media player console. This element
+ * is required only if a direct media url attribute is not specified in the
+ * <media:content> element. It has 1 required attribute, and 2 optional attributes.
+ *
+ * url is the url of the player console that plays the media. It is a required attribute.
+ *
+ *
+ *
+ * height is the height of the browser window that the url should be opened in. It
+ * is an optional attribute.
+ *
+ *
+ * width is the width of the browser window that the url should be opened in. It
+ * is an optional attribute.
+ *
+ *
+ * @author cooper
+ */
+public class PlayerReference implements Reference, Serializable {
+ private static final long serialVersionUID = 1L;
+
+ private final Integer height;
+ private final Integer width;
+ private final URI url;
+
+ /**
+ * Creates a new instance of PlayerReference
+ *
+ * @param url url of the player
+ * @param width width of the player
+ * @param height height of the player
+ */
+ public PlayerReference(final URI url, final Integer width, final Integer height) {
+ super();
+
+ if (url == null) {
+ throw new NullPointerException("url cannot be null.");
+ }
+
+ this.url = url;
+ this.height = height;
+ this.width = width;
+ }
+
+ /**
+ * Constructs a new PlayerReference
+ *
+ * @param url URL of the player
+ */
+ public PlayerReference(final URI url) {
+ this(url, null, null);
+ }
+
+ /**
+ * Height of the player
+ *
+ * @return Height of the player
+ */
+ public Integer getHeight() {
+ return height;
+ }
+
+ /**
+ * URL of the player
+ *
+ * @return URL of the player
+ */
+ public URI getUrl() {
+ return url;
+ }
+
+ /**
+ * Width of the player
+ *
+ * @return Width of the player
+ */
+ public Integer getWidth() {
+ return width;
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ final EqualsBean eBean = new EqualsBean(this.getClass(), this);
+
+ return eBean.beanEquals(obj);
+ }
+
+ @Override
+ public int hashCode() {
+ final EqualsBean equals = new EqualsBean(this.getClass(), this);
+
+ return equals.beanHashCode();
+ }
+
+ @Override
+ public String toString() {
+ final ToStringBean tsBean = new ToStringBean(this.getClass(), this);
+
+ return tsBean.toString();
+ }
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/mediarss/types/Rating.java b/rome-modules/src/main/java/com/rometools/modules/mediarss/types/Rating.java
new file mode 100644
index 0000000..8e2011c
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/mediarss/types/Rating.java
@@ -0,0 +1,111 @@
+/*
+ * Rating.java
+ *
+ * Created on April 18, 2006, 7:58 PM
+ *
+ * This code is currently released under the Mozilla Public License.
+ * http://www.mozilla.org/MPL/
+ *
+ * Alternately you may apply the terms of the Apache Software License
+ *
+ * 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 com.rometools.modules.mediarss.types;
+
+import com.rometools.rome.feed.impl.EqualsBean;
+import com.rometools.rome.feed.impl.ToStringBean;
+
+/**
+ * <media:rating>
+ *
+ *
+ *
+ * This allows the permissible audience to be declared. If this element is not included, it assumes
+ * that no restrictions are necessary. It has one optional attribute.
+ *
+ * scheme is the URI that identifies the rating scheme. It is an optional attribute. If
+ * this attribute is not included, the default scheme is urn:simple (adult | nonadult).
+ *
+ *
+ * For compatibility, a medai:adult tag will appear in the ratings as a urn:simple equiv.
+ *
+ * @author cooper
+ */
+public class Rating extends AbstractSchemeValue {
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * urn:simple adult. This will be populated on the deprecated media:adult tag as well,
+ */
+ public static final Rating ADULT = new Rating("urn:simple", "adult");
+
+ /**
+ * urn:simple nonadult. This will be populated on the deprecated media:adult tag as well,
+ */
+ public static final Rating NONADULT = new Rating("urn:simple", "nonadult");
+
+ /**
+ * Constructs a new Rating object.
+ *
+ * @param scheme scheme used for the rating
+ * @param value value of the rating.
+ */
+ public Rating(final String scheme, final String value) {
+ super(scheme, value);
+ }
+
+ /**
+ *
+ * @param obj
+ * @return
+ */
+ @Override
+ public boolean equals(final Object obj) {
+ final EqualsBean eBean = new EqualsBean(this.getClass(), this);
+
+ return eBean.beanEquals(obj);
+ }
+
+ /**
+ *
+ * @return
+ */
+ @Override
+ public int hashCode() {
+ final EqualsBean equals = new EqualsBean(this.getClass(), this);
+
+ return equals.beanHashCode();
+ }
+
+ /**
+ *
+ * @return
+ */
+ @Override
+ public String toString() {
+ final ToStringBean tsBean = new ToStringBean(this.getClass(), this);
+
+ return tsBean.toString();
+ }
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/mediarss/types/Reference.java b/rome-modules/src/main/java/com/rometools/modules/mediarss/types/Reference.java
new file mode 100644
index 0000000..e1819c4
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/mediarss/types/Reference.java
@@ -0,0 +1,32 @@
+/*
+ * Reference.java
+ *
+ * Created on April 18, 2006, 7:18 PM
+ *
+ * This code is currently released under the Mozilla Public License.
+ * http://www.mozilla.org/MPL/
+ *
+ * Alternately you may apply the terms of the Apache Software License
+ *
+ * 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 com.rometools.modules.mediarss.types;
+
+/**
+ * This class is an idenfier for UrlReference and PlayerReference and is required for constructing a
+ * MediaContent object.
+ *
+ * @author cooper
+ */
+public interface Reference {
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/mediarss/types/Restriction.java b/rome-modules/src/main/java/com/rometools/modules/mediarss/types/Restriction.java
new file mode 100644
index 0000000..1c518e1
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/mediarss/types/Restriction.java
@@ -0,0 +1,192 @@
+/*
+ * Restriction.java
+ *
+ * Created on April 19, 2006, 12:17 AM
+ *
+ * This code is currently released under the Mozilla Public License.
+ * http://www.mozilla.org/MPL/
+ *
+ * Alternately you may apply the terms of the Apache Software License
+ *
+ * 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 com.rometools.modules.mediarss.types;
+
+import java.io.Serializable;
+
+import com.rometools.rome.feed.impl.EqualsBean;
+import com.rometools.rome.feed.impl.ToStringBean;
+
+/**
+ * <media:restriction>
+ *
+ *
+ * Allows restrictions to be placed on the aggregator rendering the media in the feed. Currently,
+ * restrictions are based on distributor (uri) and country codes. This element is purely
+ * informational and no obligation can be assumed or implied. Only one <media:restriction>
+ * element of the same type can be applied to a media object - all others will be
+ * ignored. Entities in this element should be space separated. To allow the producer to
+ * explicitly declare his/her intentions, two literals are reserved: 'all', 'none'. These literals
+ * can only be used once. This element has 1 required attribute, and 1 optional attribute (with
+ * strict requirements for its exclusion).
+ *
+ * relationship indicates the type of relationship that the restriction represents (allow |
+ * deny). In the example above, the media object should only be syndicated in Australia and the
+ * United States. It is a required attribute.
+ *
+ *
+ *
+ * Note: If the "allow" element is empty and the type is relationship is "allow",
+ * it is assumed that the empty list means "allow nobody" and the media should not be syndicated.
+ *
+ * type specifies the type of restriction (country | uri) that the media can be syndicated.
+ * It is an optional attribute; however can only be excluded when using one of the literal values
+ * "all" or "none".
+ *
+ *
+ *
+ * "country" allows restrictions to be placed based on country code. [ISO 3166]
+ *
+ *
+ * "uri" allows restrictions based on URI. Examples: urn:apple, http://images.google.com, urn:yahoo,
+ * etc.
+ *
+ * @author cooper
+ */
+public class Restriction implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ private final Relationship relationship;
+ private final String value;
+ private final Type type;
+
+ /**
+ * Creates a new instance of Restriction
+ *
+ * @param relationship a Restriction.Relationship object
+ * @param type A Restriction.Type object
+ * @param value a value for the restriction.
+ */
+ public Restriction(final Relationship relationship, final Type type, final String value) {
+ if (value == null || relationship == null) {
+ throw new NullPointerException("Value and Relationship cannot be null.");
+ }
+
+ if (type == null && !(value.equals("all") || value.equals("none"))) {
+ throw new NullPointerException("Type is required if the value is other than 'all' or 'none'.");
+ }
+
+ this.relationship = relationship;
+ this.type = type;
+ this.value = value;
+ }
+
+ public Relationship getRelationship() {
+ return relationship;
+ }
+
+ public Type getType() {
+ return type;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ final EqualsBean eBean = new EqualsBean(this.getClass(), this);
+
+ return eBean.beanEquals(obj);
+ }
+
+ @Override
+ public int hashCode() {
+ final EqualsBean equals = new EqualsBean(this.getClass(), this);
+
+ return equals.beanHashCode();
+ }
+
+ @Override
+ public String toString() {
+ final ToStringBean tsBean = new ToStringBean(this.getClass(), this);
+
+ return tsBean.toString();
+ }
+
+ /**
+ * Indicates the action of the relationship
+ */
+ public static class Relationship {
+ /**
+ * An Allow relationship
+ */
+ public static final Relationship ALLOW = new Relationship("allow");
+
+ /**
+ * A deny relationship.
+ */
+ public static final Relationship DENY = new Relationship("deny");
+ private final String value;
+
+ private Relationship(final String value) {
+ this.value = value;
+ }
+
+ @Override
+ public String toString() {
+ return value;
+ }
+ }
+
+ /**
+ * Indicated the type of the relationship
+ */
+ public static class Type {
+ /**
+ * Indicates a Country type.
+ */
+ public static final Type COUNTRY = new Type("country");
+
+ /**
+ * Indicates a URI for a special restriction type.
+ */
+ public static final Type URI = new Type("uri");
+ private final String value;
+
+ private Type(final String value) {
+ this.value = value;
+ }
+
+ @Override
+ public String toString() {
+ return value;
+ }
+ }
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/mediarss/types/Text.java b/rome-modules/src/main/java/com/rometools/modules/mediarss/types/Text.java
new file mode 100644
index 0000000..495dae5
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/mediarss/types/Text.java
@@ -0,0 +1,174 @@
+/*
+ * Text.java
+ *
+ * Created on April 18, 2006, 10:25 PM
+ *
+ * This code is currently released under the Mozilla Public License.
+ * http://www.mozilla.org/MPL/
+ *
+ * Alternately you may apply the terms of the Apache Software License
+ *
+ * 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 com.rometools.modules.mediarss.types;
+
+import java.io.Serializable;
+
+import com.rometools.rome.feed.impl.EqualsBean;
+import com.rometools.rome.feed.impl.ToStringBean;
+
+/**
+ * <media:text>
+ *
+ * Allows the inclusion of a text transcript, closed captioning, or lyrics of the media content.
+ * Many of these elements are permitted to provide a time series of text. In such cases, it is
+ * encouraged, but not required, that the elements be grouped by language and appear in time
+ * sequence order based on the start time. Elements can have overlapping start and
+ * end times. It has 4 optional attributes.
+ *
+ *
+ *
+ * <media:text type="plain" lang="en" start="00:00:03.000"
+ * end="00:00:10.000"> Oh, say, can you see</media:text>
+ *
+ * <media:text type="plain" lang="en" start="00:00:10.000"
+ * end="00:00:17.000">By the dawn's early light</media:text>
+ *
+ *
+ * type specifies the type of text embedded. Possible values are either 'plain' or 'html'.
+ * Default value is 'plain'. All html must be entity-encoded. It is an optional attribute.
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ * lang is the primary language encapsulated in the media object. Language codes possible
+ * are detailed in RFC 3066. This attribute is used similar to the xml:lang attribute detailed in
+ * the XML 1.0 Specification (Third Edition). It is an optional attribute.
+ *
+ *
+ *
+ * start specifies the start time offset that the text starts being relevant to the media
+ * object. An example of this would be for closed captioning. It uses the NTP time code format (see:
+ * the time attribute used in <media:thumbnail>). It is an optional attribute.
+ *
+ *
+ *
+ * end specifies the end time that the text is relevant. If this attribute is not provided,
+ * and a start time is used, it is expected that the end time is either the end of the clip
+ * or the start of the next <media:text> element.
+ *
+ *
+ * @author cooper
+ */
+public class Text implements Serializable {
+ private static final long serialVersionUID = 1L;
+ private String type;
+ private final String value;
+ private Time end;
+ private Time start;
+
+ /**
+ * Creates a text object.
+ *
+ * @param value value of the text
+ */
+ public Text(final String value) {
+ this.value = value;
+ }
+
+ /**
+ * Creates a new instance of Text
+ *
+ * @param type type of text
+ * @param value value of text
+ */
+ public Text(final String type, final String value) {
+ this.type = type;
+ this.value = value;
+ }
+
+ /**
+ * Creates a text object with start and end times
+ *
+ * @param type type of text
+ * @param value value of text
+ * @param start start time
+ * @param end end time
+ */
+ public Text(final String type, final String value, final Time start, final Time end) {
+ this(type, value);
+ this.start = start;
+ this.end = end;
+ }
+
+ /**
+ * End time of the text
+ *
+ * @return End time of the text
+ */
+ public Time getEnd() {
+ return end;
+ }
+
+ /**
+ * Start time of the text
+ *
+ * @return Start time of the text
+ */
+ public Time getStart() {
+ return start;
+ }
+
+ /**
+ * type of the text
+ *
+ * @return type of the text
+ */
+ public String getType() {
+ return type;
+ }
+
+ /**
+ * Value of the text
+ *
+ * @return type of the text
+ */
+ public String getValue() {
+ return value;
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ final EqualsBean eBean = new EqualsBean(this.getClass(), this);
+
+ return eBean.beanEquals(obj);
+ }
+
+ @Override
+ public int hashCode() {
+ final EqualsBean equals = new EqualsBean(this.getClass(), this);
+
+ return equals.beanHashCode();
+ }
+
+ @Override
+ public String toString() {
+ final ToStringBean tsBean = new ToStringBean(this.getClass(), this);
+
+ return tsBean.toString();
+ }
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/mediarss/types/Thumbnail.java b/rome-modules/src/main/java/com/rometools/modules/mediarss/types/Thumbnail.java
new file mode 100644
index 0000000..1aa9e1a
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/mediarss/types/Thumbnail.java
@@ -0,0 +1,173 @@
+/*
+ * Copyright 2006 Nathanial X. Freitas, openvision.tv
+ *
+ * This code is currently released under the Mozilla Public License.
+ * http://www.mozilla.org/MPL/
+ *
+ * Alternately you may apply the terms of the Apache Software License
+ *
+ * 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 com.rometools.modules.mediarss.types;
+
+import java.io.Serializable;
+import java.net.URI;
+
+import com.rometools.rome.feed.impl.EqualsBean;
+import com.rometools.rome.feed.impl.ToStringBean;
+
+/**
+ * <media:thumbnail>
+ *
+ *
+ *
+ * Allows particular images to be used as representative images for the media object. If multiple
+ * thumbnails are included, and time coding is not at play, it is assumed that the images are in
+ * order of importance. It has 1 required attribute and 3 optional attributes.
+ *
+ * url specifies the url of the thumbnail. It is a required attribute.
+ *
+ *
+ * height specifies the height of the thumbnail. It is an optional attribute.
+ *
+ *
+ * width specifies the width of the thumbnail. It is an optional attribute.
+ *
+ *
+ *
+ *
+ * time specifies the time offset in relation to the media object. Typically this is used
+ * when creating multiple keyframes within a single video. The format for this attribute should be
+ * in the DSM-CC's Normal Play Time (NTP) as used in RTSP [RFC 2326 3.6 Normal Play Time]. It is an optional
+ * attribute.
+ *
+ */
+public class Thumbnail implements Cloneable, Serializable {
+ private static final long serialVersionUID = 1L;
+
+ private Integer thumbHeight = null;
+ private Integer thumbWidth = null;
+ private final Time time;
+ private URI thumbUrl = null;
+
+ /**
+ * Creates a new thumbnail
+ *
+ * @param url URL to thumbnail
+ * @param width width in pixels
+ * @param height height in pixels
+ * @param time Timecode representing the thumbnails position in a source.
+ */
+ public Thumbnail(final URI url, final Integer width, final Integer height, final Time time) {
+ thumbUrl = url;
+ thumbHeight = height;
+ thumbWidth = width;
+ this.time = time;
+ }
+
+ /**
+ * Creates a new thumbnail
+ *
+ * @param url URL
+ * @param width width
+ * @param height height
+ */
+ public Thumbnail(final URI url, final Integer width, final Integer height) {
+ this(url, width, height, null);
+ }
+
+ /**
+ * Creates a new thumbnail
+ *
+ * @param url URL
+ */
+ public Thumbnail(final URI url) {
+ this(url, null, null, null);
+ }
+
+ /**
+ *
+ * Returns the thumbHeight.
+ *
+ * @return Returns the thumbHeight.
+ */
+ public Integer getHeight() {
+ return thumbHeight;
+ }
+
+ /**
+ * returns the time that the thumbnail was captured from its source
+ *
+ * @return returns the time that the thumbnail was captured from its source
+ */
+ public Time getTime() {
+ return time;
+ }
+
+ /**
+ *
+ * Retursn the URL
+ *
+ * @return Returns the thumbUrl.
+ */
+ public URI getUrl() {
+ return thumbUrl;
+ }
+
+ /**
+ *
+ * Returns width.
+ *
+ * @return Returns the thumbWidth.
+ */
+ public Integer getWidth() {
+ return thumbWidth;
+ }
+
+ @Override
+ public Object clone() {
+ return new Thumbnail(thumbUrl, thumbWidth, thumbHeight);
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ final EqualsBean eBean = new EqualsBean(this.getClass(), this);
+
+ return eBean.beanEquals(obj);
+ }
+
+ @Override
+ public int hashCode() {
+ final EqualsBean equals = new EqualsBean(this.getClass(), this);
+
+ return equals.beanHashCode();
+ }
+
+ @Override
+ public String toString() {
+ final ToStringBean tsBean = new ToStringBean(this.getClass(), this);
+
+ return tsBean.toString();
+ }
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/mediarss/types/Time.java b/rome-modules/src/main/java/com/rometools/modules/mediarss/types/Time.java
new file mode 100644
index 0000000..8bf9354
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/mediarss/types/Time.java
@@ -0,0 +1,112 @@
+/*
+ * Time.java
+ *
+ * Created on April 18, 2006, 9:48 PM
+ *
+ * This code is currently released under the Mozilla Public License.
+ * http://www.mozilla.org/MPL/
+ *
+ * Alternately you may apply the terms of the Apache Software License
+ *
+ * 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 com.rometools.modules.mediarss.types;
+
+import java.io.Serializable;
+import java.text.NumberFormat;
+
+import com.rometools.rome.feed.impl.EqualsBean;
+
+/**
+ * Represents a RFC 2326 3.6 Normal Play Time
+ * timestamp.
+ *
+ * @author cooper
+ */
+public class Time implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ private static final long SECOND = 1000;
+ private static final long MINUTE = 60 * SECOND;
+ private static final long HOUR = 60 * MINUTE * SECOND;
+ private static final NumberFormat nf = NumberFormat.getInstance();
+
+ static {
+ nf.setMinimumIntegerDigits(2);
+ }
+
+ private long milliseconds = 0;
+
+ /**
+ * Creates a new instance of Time
+ *
+ * @param milliseconds milliseconds in length or offset.
+ */
+ public Time(final long milliseconds) {
+ this.milliseconds = milliseconds;
+ }
+
+ /**
+ * Creates a new instance of Time
+ *
+ * @param value RFC 2326 3.6 Normal Play Time
+ * value
+ */
+ public Time(final String value) {
+ final String[] values = value.split(":");
+ int count = values.length - 1;
+ milliseconds = (long) (Double.parseDouble(values[count]) * SECOND);
+ count--;
+
+ if (count >= 0) {
+ milliseconds += Long.parseLong(values[count]) * MINUTE;
+ count--;
+ }
+
+ if (count >= 0) {
+ milliseconds += Long.parseLong(values[count]) * HOUR;
+ }
+ }
+
+ public long getValue() {
+ return milliseconds;
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ final EqualsBean eBean = new EqualsBean(this.getClass(), this);
+
+ return eBean.beanEquals(obj);
+ }
+
+ @Override
+ public int hashCode() {
+ final EqualsBean equals = new EqualsBean(this.getClass(), this);
+
+ return equals.beanHashCode();
+ }
+
+ @Override
+ public String toString() {
+ long value = milliseconds;
+ final long hours = value / HOUR;
+ value -= hours * HOUR;
+
+ final long minutes = value / MINUTE;
+ value -= minutes * MINUTE;
+
+ final double seconds = (double) value / (double) SECOND;
+
+ return nf.format(hours) + ":" + nf.format(minutes) + ":" + seconds;
+ }
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/mediarss/types/UrlReference.java b/rome-modules/src/main/java/com/rometools/modules/mediarss/types/UrlReference.java
new file mode 100644
index 0000000..4c7b710
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/mediarss/types/UrlReference.java
@@ -0,0 +1,98 @@
+/*
+ * UrlReference.java
+ *
+ * Created on April 18, 2006, 7:18 PM
+ *
+ *
+ * This code is currently released under the Mozilla Public License.
+ * http://www.mozilla.org/MPL/
+ *
+ * Alternately you may apply the terms of the Apache Software License
+ *
+ * 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 com.rometools.modules.mediarss.types;
+
+import java.io.Serializable;
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import com.rometools.rome.feed.impl.EqualsBean;
+
+/**
+ * Used to indicate a URL primary reference for a MediaContent object.
+ *
+ * @author cooper
+ */
+public class UrlReference implements Reference, Serializable {
+ private static final long serialVersionUID = 1L;
+
+ private final URI url;
+
+ /**
+ * Creates a new UrlReference.
+ *
+ * @param url URL to the media source
+ */
+ public UrlReference(final URI url) {
+ if (url == null) {
+ throw new NullPointerException("url cannot be null.");
+ }
+
+ this.url = url;
+ }
+
+ /**
+ * Creates a new instance of UrlReference
+ *
+ * @param url String value of a URL
+ * @throws java.net.MalformedURLException thrown on bad URLs
+ */
+ public UrlReference(final String url) throws URISyntaxException {
+ super();
+
+ if (url == null) {
+ throw new NullPointerException("url cannot be null.");
+ }
+
+ this.url = new URI(url);
+ }
+
+ /**
+ * Returns the URL value
+ *
+ * @return Returns the URL value
+ */
+ public URI getUrl() {
+ return url;
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ final EqualsBean eBean = new EqualsBean(this.getClass(), this);
+
+ return eBean.beanEquals(obj);
+ }
+
+ @Override
+ public int hashCode() {
+ final EqualsBean equals = new EqualsBean(this.getClass(), this);
+
+ return equals.beanHashCode();
+ }
+
+ @Override
+ public String toString() {
+ return url.toString();
+ }
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/mediarss/types/package.html b/rome-modules/src/main/java/com/rometools/modules/mediarss/types/package.html
new file mode 100644
index 0000000..3ac4ff7
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/mediarss/types/package.html
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+ This package contains datatypes for working with MediaRSS.
+
+
diff --git a/rome-modules/src/main/java/com/rometools/modules/opensearch/OpenSearchModule.java b/rome-modules/src/main/java/com/rometools/modules/opensearch/OpenSearchModule.java
new file mode 100644
index 0000000..a1269aa
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/opensearch/OpenSearchModule.java
@@ -0,0 +1,29 @@
+/*
+ * 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 com.rometools.modules.opensearch;
+
+import com.rometools.rome.feed.module.Module;
+
+/**
+ * Provides access to A9 Open Search information.
+ *
+ * @author Michael W. Nassif (enrouteinc@gmail.com)
+ */
+public interface OpenSearchModule extends Module, OpenSearchResponse {
+
+ public final static String URI = "http://a9.com/-/spec/opensearch/1.1/";
+
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/opensearch/OpenSearchResponse.java b/rome-modules/src/main/java/com/rometools/modules/opensearch/OpenSearchResponse.java
new file mode 100644
index 0000000..bc9a45e
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/opensearch/OpenSearchResponse.java
@@ -0,0 +1,144 @@
+/*
+ * 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 com.rometools.modules.opensearch;
+
+import java.util.List;
+
+import com.rometools.modules.opensearch.entity.OSQuery;
+import com.rometools.rome.feed.atom.Link;
+
+/**
+ * Provides access to A9 Open Search information.
+ *
+ * @author Michael W. Nassif (enrouteinc@gmail.com)
+ */
+public interface OpenSearchResponse {
+
+ /**
+ * # totalResults – the maximum number of results available for these search terms
+ *
+ * * Restrictions: An integer greater than or equal to 0. * Default: The number of items that
+ * were returned in this set of results. * Requirements: May appear zero or one time.
+ *
+ * @param totalResults A positive integer value.
+ */
+ public void setTotalResults(int totalResults);
+
+ /**
+ * # totalResults – the maximum number of results available for these search terms
+ *
+ * * Restrictions: An integer greater than or equal to 0. * Default: The number of items that
+ * were returned in this set of results. * Requirements: May appear zero or one time.
+ *
+ * @return a positive integer value.
+ */
+ public int getTotalResults();
+
+ /**
+ * # startIndex – the index of the first item returned in the result.
+ *
+ * * Restrictions: An integer greater than or equal to 1. * Note: The first result is 1. *
+ * Default: 1 * Requirements: May appear zero or one time.
+ *
+ * @param startIndex int value >= 1.
+ */
+ public void setStartIndex(int startIndex);
+
+ /**
+ * # startIndex – the index of the first item returned in the result.
+ *
+ * * Restrictions: An integer greater than or equal to 1. * Note: The first result is 1. *
+ * Default: 1 * Requirements: May appear zero or one time.
+ *
+ * @return int value >= 1.
+ */
+ public int getStartIndex();
+
+ /**
+ * # itemsPerPage – the maximum number of items that can appear in one page of results.
+ *
+ * * Restrictions: An integer greater than or equal to 1. * Default: The number of items that
+ * were returned in this set of results. * Requirements: May appear zero or one time.
+ *
+ * @param itemsPerPage int value >= 1.
+ */
+ public void setItemsPerPage(int itemsPerPage);
+
+ /**
+ * # itemsPerPage – the maximum number of items that can appear in one page of results.
+ *
+ * * Restrictions: An integer greater than or equal to 1. * Default: The number of items that
+ * were returned in this set of results. * Requirements: May appear zero or one time.
+ *
+ * @return int value >= 1
+ */
+ public int getItemsPerPage();
+
+ /**
+ * # link – a reference back to the OpenSearch Description file
+ *
+ * * Attributes: This is a clone of the link element in Atom, including href, hreflang, rel, and
+ * type attributes. * Restrictions: The rel attribute must equal search. * Note: New in version
+ * 1.1. * Requirements: May appear zero or one time.
+ *
+ * @param link link to the open search spec.
+ */
+ public void setLink(Link link);
+
+ /**
+ * # link – a reference back to the OpenSearch Description file
+ *
+ * * Attributes: This is a clone of the link element in Atom, including href, hreflang, rel, and
+ * type attributes. * Restrictions: The rel attribute must equal search. * Note: New in version
+ * 1.1. * Requirements: May appear zero or one time.
+ *
+ * @return link to the opensearch spec.
+ */
+ public Link getLink();
+
+ // list of OSResponseQuery interfaces
+ /**
+ * Query – in an OpenSearch Response, can be used both to echo back the original
+ * query and to suggest new searches. Please see the OpenSearch Query
+ * specification for more information.
+ *
+ *
Note: New in version 1.1.
+ *
Requirements: May appear zero or more times. Note that the “Q” is capitalized.
+ *
+ * @param query List of OSQuery objects.
+ */
+ public void setQueries(List query);
+
+ /**
+ * Query – in an OpenSearch Response, can be used both to echo back the original
+ * query and to suggest new searches. Please see the OpenSearch Query
+ * specification for more information.
+ *
+ *
Note: New in version 1.1.
+ *
Requirements: May appear zero or more times. Note that the “Q” is capitalized.
+ *
+ * @return A list of OSQuery objects.
+ */
+ public List getQueries();
+
+ // convenience method
+ /**
+ * Adds a query to the module.
+ *
+ * @param query OSQuery object to add.
+ */
+ public void addQuery(OSQuery query);
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/opensearch/RequiredAttributeMissingException.java b/rome-modules/src/main/java/com/rometools/modules/opensearch/RequiredAttributeMissingException.java
new file mode 100644
index 0000000..ddb53ce
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/opensearch/RequiredAttributeMissingException.java
@@ -0,0 +1,36 @@
+/*
+ * 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 com.rometools.modules.opensearch;
+
+/**
+ * @author Michael W. Nassif (enrouteinc@gmail.com)
+ */
+public class RequiredAttributeMissingException extends RuntimeException {
+ private static final long serialVersionUID = 1L;
+
+ public RequiredAttributeMissingException(final String arg0, final Throwable arg1) {
+ super(arg0, arg1);
+ }
+
+ public RequiredAttributeMissingException(final String arg0) {
+ super(arg0);
+ }
+
+ public RequiredAttributeMissingException(final Throwable arg0) {
+ super(arg0);
+ }
+
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/opensearch/entity/OSQuery.java b/rome-modules/src/main/java/com/rometools/modules/opensearch/entity/OSQuery.java
new file mode 100644
index 0000000..ee8b011
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/opensearch/entity/OSQuery.java
@@ -0,0 +1,186 @@
+/*
+ * 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 com.rometools.modules.opensearch.entity;
+
+import java.io.Serializable;
+
+import com.rometools.rome.feed.impl.ObjectBean;
+
+/**
+ * @author Michael W. Nassif (enrouteinc@gmail.com) Class representation of the Query object
+ * (Response portion so far)
+ */
+public class OSQuery implements Cloneable, Serializable {
+ private static final long serialVersionUID = 1L;
+
+ ObjectBean _objBean = null;
+
+ // role is required
+ private String role;
+ private int startPage = -1;
+ private int totalResults = -1;
+ private String osd;
+ private String title;
+ private String searchTerms;
+
+ /**
+ * Default constructor. All properties are set to null.
+ *
+ */
+ public OSQuery() {
+ _objBean = new ObjectBean(this.getClass(), this);
+ }
+
+ /**
+ * Creates a deep 'bean' clone of the object.
+ *
+ *
+ * @return a clone of the object.
+ * @throws CloneNotSupportedException thrown if an element of the object cannot be cloned.
+ *
+ */
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ return _objBean.clone();
+ }
+
+ /**
+ * Indicates whether some other object is "equal to" this one as defined by the Object equals()
+ * method.
+ *
+ *
+ * @param other he reference object with which to compare.
+ * @return true if 'this' object is equal to the 'other' object.
+ *
+ */
+ @Override
+ public boolean equals(final Object other) {
+ return _objBean.equals(other);
+ }
+
+ /**
+ * Returns a hashcode value for the object.
+ *
+ * It follows the contract defined by the Object hashCode() method.
+ *
+ *
+ * @return the hashcode of the bean object.
+ *
+ */
+ @Override
+ public int hashCode() {
+ return _objBean.hashCode();
+ }
+
+ /**
+ * Returns the String representation for the object.
+ *
+ *
+ * @return String representation for the object.
+ *
+ */
+ @Override
+ public String toString() {
+ return _objBean.toString();
+ }
+
+ /**
+ * @return Returns the osd.
+ */
+ public String getOsd() {
+ return osd;
+ }
+
+ /**
+ * Typically represents a url link to the os description file
+ *
+ * @param osd The osd to set.
+ */
+ public void setOsd(final String osd) {
+ this.osd = osd;
+ }
+
+ /**
+ * @return Returns the role.
+ */
+ public String getRole() {
+ return role;
+ }
+
+ /**
+ * @param role The role to set.
+ */
+ public void setRole(final String role) {
+ this.role = role;
+ }
+
+ /**
+ * @return Returns the searchTerms.
+ */
+ public String getSearchTerms() {
+ return searchTerms;
+ }
+
+ /**
+ * @param searchTerms The searchTerms to set.
+ */
+ public void setSearchTerms(final String searchTerms) {
+ this.searchTerms = searchTerms;
+ }
+
+ /**
+ * @return Returns the startPage.
+ */
+ public int getStartPage() {
+ return startPage;
+ }
+
+ /**
+ * @param startPage The startPage to set.
+ */
+ public void setStartPage(final int startPage) {
+ this.startPage = startPage;
+ }
+
+ /**
+ * @return Returns the title.
+ */
+ public String getTitle() {
+ return title;
+ }
+
+ /**
+ * @param title The title to set.
+ */
+ public void setTitle(final String title) {
+ this.title = title;
+ }
+
+ /**
+ * @return Returns the totalResults.
+ */
+ public int getTotalResults() {
+ return totalResults;
+ }
+
+ /**
+ * @param totalResults The totalResults to set.
+ */
+ public void setTotalResults(final int totalResults) {
+ this.totalResults = totalResults;
+ }
+
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/opensearch/impl/OpenSearchModuleGenerator.java b/rome-modules/src/main/java/com/rometools/modules/opensearch/impl/OpenSearchModuleGenerator.java
new file mode 100644
index 0000000..529e0f6
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/opensearch/impl/OpenSearchModuleGenerator.java
@@ -0,0 +1,171 @@
+/*
+ * 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 com.rometools.modules.opensearch.impl;
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.jdom2.Attribute;
+import org.jdom2.Element;
+import org.jdom2.Namespace;
+
+import com.rometools.modules.opensearch.OpenSearchModule;
+import com.rometools.modules.opensearch.RequiredAttributeMissingException;
+import com.rometools.modules.opensearch.entity.OSQuery;
+import com.rometools.rome.feed.atom.Link;
+import com.rometools.rome.feed.module.Module;
+import com.rometools.rome.io.ModuleGenerator;
+
+/**
+ * @author Michael W. Nassif (enrouteinc@gmail.com) OpenSearch implementation of ModuleGenerator
+ */
+public class OpenSearchModuleGenerator implements ModuleGenerator {
+
+ private static final Namespace OS_NS = Namespace.getNamespace("opensearch", OpenSearchModule.URI);
+
+ @Override
+ public String getNamespaceUri() {
+ return OpenSearchModule.URI;
+ }
+
+ private static final Set NAMESPACES;
+
+ static {
+ final Set nss = new HashSet();
+ nss.add(OS_NS);
+ NAMESPACES = Collections.unmodifiableSet(nss);
+ }
+
+ /**
+ * Returns a set with all the URIs (JDOM Namespace elements) this module generator uses.
+ *
+ * It is used by the the feed generators to add their namespace definition in the root element
+ * of the generated document (forward-missing of Java 5.0 Generics).
+ *
+ *
+ * @return a set with all the URIs (JDOM Namespace elements) this module generator uses.
+ */
+ @Override
+ public Set getNamespaces() {
+ return NAMESPACES;
+ }
+
+ @Override
+ public void generate(final Module module, final Element element) {
+
+ final OpenSearchModule osm = (OpenSearchModule) module;
+
+ if (osm.getItemsPerPage() > -1) {
+ element.addContent(generateSimpleElement("itemsPerPage", Integer.toString(osm.getItemsPerPage())));
+ }
+
+ if (osm.getTotalResults() > -1) {
+ element.addContent(generateSimpleElement("totalResults", Integer.toString(osm.getTotalResults())));
+ }
+
+ final int startIndex = osm.getStartIndex() > 0 ? osm.getStartIndex() : 1;
+ element.addContent(generateSimpleElement("startIndex", Integer.toString(startIndex)));
+
+ if (osm.getQueries() != null) {
+
+ final List queries = osm.getQueries();
+
+ for (final OSQuery query : queries) {
+ if (query != null) {
+ element.addContent(generateQueryElement(query));
+ }
+ }
+ }
+
+ if (osm.getLink() != null) {
+ element.addContent(generateLinkElement(osm.getLink()));
+ }
+ }
+
+ protected Element generateQueryElement(final OSQuery query) {
+
+ final Element qElement = new Element("Query", OS_NS);
+
+ if (query.getRole() != null) {
+ final Attribute roleAttribute = new Attribute("role", query.getRole());
+ qElement.setAttribute(roleAttribute);
+ } else {
+ throw new RequiredAttributeMissingException("If declaring a Query element, the field 'role' must be be specified");
+ }
+
+ if (query.getOsd() != null) {
+ final Attribute osd = new Attribute("osd", query.getOsd());
+ qElement.setAttribute(osd);
+ }
+
+ if (query.getSearchTerms() != null) {
+ final Attribute searchTerms = new Attribute("searchTerms", query.getSearchTerms());
+ qElement.setAttribute(searchTerms);
+ }
+
+ if (query.getStartPage() > -1) {
+ final int startPage = query.getStartPage() != 0 ? query.getStartPage() : 1;
+ final Attribute sp = new Attribute("startPage", Integer.toString(startPage));
+ qElement.setAttribute(sp);
+ }
+
+ if (query.getTitle() != null) {
+ qElement.setAttribute(new Attribute("title", query.getTitle()));
+ }
+
+ if (query.getTotalResults() > -1) {
+ qElement.setAttribute(new Attribute("totalResults", Integer.toString(query.getTotalResults())));
+ }
+
+ return qElement;
+ }
+
+ protected Element generateLinkElement(final Link link) {
+ final Element linkElement = new Element("link", OS_NS);
+
+ if (link.getRel() != null) {
+ final Attribute relAttribute = new Attribute("rel", "search");
+ linkElement.setAttribute(relAttribute);
+ }
+
+ if (link.getType() != null) {
+ final Attribute typeAttribute = new Attribute("type", link.getType());
+ linkElement.setAttribute(typeAttribute);
+ }
+
+ if (link.getHref() != null) {
+ final Attribute hrefAttribute = new Attribute("href", link.getHref());
+ linkElement.setAttribute(hrefAttribute);
+ }
+
+ if (link.getHreflang() != null) {
+ final Attribute hreflangAttribute = new Attribute("hreflang", link.getHreflang());
+ linkElement.setAttribute(hreflangAttribute);
+ }
+ return linkElement;
+ }
+
+ protected Element generateSimpleElement(final String name, final String value) {
+
+ final Element element = new Element(name, OS_NS);
+ element.addContent(value);
+
+ return element;
+ }
+
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/opensearch/impl/OpenSearchModuleImpl.java b/rome-modules/src/main/java/com/rometools/modules/opensearch/impl/OpenSearchModuleImpl.java
new file mode 100644
index 0000000..a0a0f03
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/opensearch/impl/OpenSearchModuleImpl.java
@@ -0,0 +1,161 @@
+/*
+ * 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 com.rometools.modules.opensearch.impl;
+
+import java.io.Serializable;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.rometools.modules.opensearch.OpenSearchModule;
+import com.rometools.modules.opensearch.entity.OSQuery;
+import com.rometools.rome.feed.CopyFrom;
+import com.rometools.rome.feed.atom.Link;
+import com.rometools.rome.feed.module.ModuleImpl;
+
+/**
+ * @author Michael W. Nassif (enrouteinc@gmail.com) OpenSearch Module implementation
+ */
+public class OpenSearchModuleImpl extends ModuleImpl implements OpenSearchModule, Serializable {
+ private static final long serialVersionUID = 1L;
+ private static final Logger LOG = LoggerFactory.getLogger(OpenSearchModuleImpl.class);
+ private int totalResults = -1;
+ private int startIndex = 1;
+ private int itemsPerPage = -1;
+ private Link link;
+ private List queries;
+
+ public OpenSearchModuleImpl() {
+ super(OpenSearchModuleImpl.class, OpenSearchModule.URI);
+ }
+
+ /**
+ * @return Returns the itemsPerPage.
+ */
+ @Override
+ public int getItemsPerPage() {
+ return itemsPerPage;
+ }
+
+ /**
+ * @param itemsPerPage The itemsPerPage to set.
+ */
+ @Override
+ public void setItemsPerPage(final int itemsPerPage) {
+ this.itemsPerPage = itemsPerPage;
+ }
+
+ /**
+ * @return Returns the link.
+ */
+ @Override
+ public Link getLink() {
+ return link;
+ }
+
+ /**
+ * @param link The link to set.
+ */
+ @Override
+ public void setLink(final Link link) {
+ this.link = link;
+ }
+
+ /**
+ * @return Returns the queries.
+ */
+ @Override
+ public List getQueries() {
+ if (queries == null) {
+ queries = new LinkedList();
+ }
+ return queries;
+ }
+
+ /**
+ * @param queries The queries to set.
+ */
+ @Override
+ public void setQueries(final List queries) {
+ this.queries = queries;
+ }
+
+ @Override
+ public void addQuery(final OSQuery query) {
+ getQueries().add(query);
+ }
+
+ /**
+ * @return Returns the startIndex.
+ */
+ @Override
+ public int getStartIndex() {
+ return startIndex;
+ }
+
+ /**
+ * @param startIndex The startIndex to set.
+ */
+ @Override
+ public void setStartIndex(final int startIndex) {
+ this.startIndex = startIndex;
+ }
+
+ /**
+ * @return Returns the totalResults.
+ */
+ @Override
+ public int getTotalResults() {
+ return totalResults;
+ }
+
+ /**
+ * @param totalResults The totalResults to set.
+ */
+ @Override
+ public void setTotalResults(final int totalResults) {
+ this.totalResults = totalResults;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.rometools.rome.feed.CopyFrom#copyFrom(java.lang.Object)
+ */
+ @Override
+ public void copyFrom(final CopyFrom obj) {
+ final OpenSearchModule osm = (OpenSearchModule) obj;
+ setTotalResults(osm.getTotalResults());
+ setItemsPerPage(osm.getItemsPerPage());
+ setStartIndex(osm.getStartIndex());
+ setLink(osm.getLink());
+ for (final OSQuery q : osm.getQueries()) {
+ try {
+ getQueries().add((OSQuery) q.clone());
+ } catch (final CloneNotSupportedException e) {
+ LOG.error("Error", e);
+ }
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.rometools.rome.feed.CopyFrom#getInterface()
+ */
+ @Override
+ public Class getInterface() {
+ return OpenSearchModule.class;
+ }
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/opensearch/impl/OpenSearchModuleParser.java b/rome-modules/src/main/java/com/rometools/modules/opensearch/impl/OpenSearchModuleParser.java
new file mode 100644
index 0000000..1332b3d
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/opensearch/impl/OpenSearchModuleParser.java
@@ -0,0 +1,251 @@
+/*
+ * 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 com.rometools.modules.opensearch.impl;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Locale;
+
+import org.jdom2.Attribute;
+import org.jdom2.Element;
+import org.jdom2.Namespace;
+import org.jdom2.Parent;
+
+import com.rometools.modules.opensearch.OpenSearchModule;
+import com.rometools.modules.opensearch.entity.OSQuery;
+import com.rometools.rome.feed.atom.Link;
+import com.rometools.rome.feed.module.Module;
+import com.rometools.rome.io.ModuleParser;
+
+/**
+ * @author Michael W. Nassif (enrouteinc@gmail.com) OpenSearch implementation of the ModuleParser
+ * class
+ */
+public class OpenSearchModuleParser implements ModuleParser {
+
+ private static final Namespace OS_NS = Namespace.getNamespace("opensearch", OpenSearchModule.URI);
+
+ @Override
+ public String getNamespaceUri() {
+ return OpenSearchModule.URI;
+ }
+
+ @Override
+ public Module parse(final Element dcRoot, final Locale locale) {
+
+ final URL baseURI = findBaseURI(dcRoot);
+
+ boolean foundSomething = false;
+ final OpenSearchModule osm = new OpenSearchModuleImpl();
+
+ Element e = dcRoot.getChild("totalResults", OS_NS);
+
+ if (e != null) {
+ try {
+ osm.setTotalResults(Integer.parseInt(e.getText()));
+ foundSomething = true;
+ } catch (final NumberFormatException ex) {
+ // Ignore setting the field and post a warning
+ System.err.println("Warning: The element totalResults must be an integer value: " + ex.getMessage());
+ }
+ }
+
+ e = dcRoot.getChild("itemsPerPage", OS_NS);
+ if (e != null) {
+ try {
+ osm.setItemsPerPage(Integer.parseInt(e.getText()));
+ foundSomething = true;
+ } catch (final NumberFormatException ex) {
+ // Ignore setting the field and post a warning
+ System.err.println("Warning: The element itemsPerPage must be an integer value: " + ex.getMessage());
+ }
+ }
+
+ e = dcRoot.getChild("startIndex", OS_NS);
+ if (e != null) {
+ try {
+ osm.setStartIndex(Integer.parseInt(e.getText()));
+ foundSomething = true;
+ } catch (final NumberFormatException ex) {
+ // Ignore setting the field and post a warning
+ System.err.println("Warning: The element startIndex must be an integer value: " + ex.getMessage());
+ }
+ }
+
+ final List queries = dcRoot.getChildren("Query", OS_NS);
+
+ if (queries != null && !queries.isEmpty()) {
+
+ // Create the OSQuery list
+ final List osqList = new LinkedList();
+
+ for (final Iterator iter = queries.iterator(); iter.hasNext();) {
+ e = iter.next();
+ osqList.add(parseQuery(e));
+ }
+
+ osm.setQueries(osqList);
+ }
+
+ e = dcRoot.getChild("link", OS_NS);
+
+ if (e != null) {
+ osm.setLink(parseLink(e, baseURI));
+ }
+
+ return foundSomething ? osm : null;
+ }
+
+ private static OSQuery parseQuery(final Element e) {
+
+ final OSQuery query = new OSQuery();
+
+ String att = e.getAttributeValue("role");
+ query.setRole(att);
+
+ att = e.getAttributeValue("osd");
+ query.setOsd(att);
+
+ att = e.getAttributeValue("searchTerms");
+ query.setSearchTerms(att);
+
+ att = e.getAttributeValue("title");
+ query.setTitle(att);
+
+ try {
+
+ // someones mistake should not cause the parser to fail, since these
+ // are only optional attributes
+
+ att = e.getAttributeValue("totalResults");
+ if (att != null) {
+ query.setTotalResults(Integer.parseInt(att));
+ }
+
+ att = e.getAttributeValue("startPage");
+ if (att != null) {
+ query.setStartPage(Integer.parseInt(att));
+ }
+
+ } catch (final NumberFormatException ex) {
+ System.err.println("Warning: Exception caught while trying to parse a non-numeric Query attribute " + ex.getMessage());
+ }
+
+ return query;
+ }
+
+ private static Link parseLink(final Element e, final URL baseURI) {
+
+ final Link link = new Link();
+
+ String att = e.getAttributeValue("rel");// getAtomNamespace()); DONT
+ // KNOW WHY DOESN'T WORK
+
+ if (att != null) {
+ link.setRel(att);
+ }
+
+ att = e.getAttributeValue("type");// getAtomNamespace()); DONT KNOW WHY
+ // DOESN'T WORK
+
+ if (att != null) {
+ link.setType(att);
+ }
+
+ att = e.getAttributeValue("href");// getAtomNamespace()); DONT KNOW WHY
+ // DOESN'T WORK
+
+ if (att != null) {
+
+ if (isRelativeURI(att)) { //
+ link.setHref(resolveURI(baseURI, e, ""));
+ } else {
+ link.setHref(att);
+ }
+ }
+
+ att = e.getAttributeValue("hreflang");// getAtomNamespace()); DONT KNOW
+ // WHY DOESN'T WORK
+
+ if (att != null) {
+ link.setHreflang(att);
+ }
+
+ att = e.getAttributeValue("length");// getAtomNamespace()); DONT KNOW
+ // WHY DOESN'T WORK
+
+ return link;
+ }
+
+ private static boolean isRelativeURI(final String uri) {
+ if (uri.startsWith("http://") || uri.startsWith("https://") || uri.startsWith("/")) {
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Use xml:base attributes at feed and entry level to resolve relative links
+ */
+ private static String resolveURI(final URL baseURI, final Parent parent, String url) {
+ url = url.equals(".") || url.equals("./") ? "" : url;
+ if (isRelativeURI(url) && parent != null && parent instanceof Element) {
+ final Attribute baseAtt = ((Element) parent).getAttribute("base", Namespace.XML_NAMESPACE);
+ String xmlBase = baseAtt == null ? "" : baseAtt.getValue();
+ if (!isRelativeURI(xmlBase) && !xmlBase.endsWith("/")) {
+ xmlBase = xmlBase.substring(0, xmlBase.lastIndexOf("/") + 1);
+ }
+ return resolveURI(baseURI, parent.getParent(), xmlBase + url);
+ } else if (isRelativeURI(url) && parent == null) {
+ return baseURI + url;
+ } else if (baseURI != null && url.startsWith("/")) {
+ String hostURI = baseURI.getProtocol() + "://" + baseURI.getHost();
+ if (baseURI.getPort() != baseURI.getDefaultPort()) {
+ hostURI = hostURI + ":" + baseURI.getPort();
+ }
+ return hostURI + url;
+ }
+ return url;
+ }
+
+ /** Use feed links and/or xml:base attribute to determine baseURI of feed */
+ private static URL findBaseURI(final Element root) {
+ URL baseURI = null;
+ final List linksList = root.getChildren("link", OS_NS);
+ if (linksList != null) {
+ for (final Element element : linksList) {
+ final Element link = element;
+ if (!root.equals(link.getParent())) {
+ break;
+ }
+ String href = link.getAttribute("href").getValue();
+ if (link.getAttribute("rel", OS_NS) == null || link.getAttribute("rel", OS_NS).getValue().equals("alternate")) {
+ href = resolveURI(null, link, href);
+ try {
+ baseURI = new URL(href);
+ break;
+ } catch (final MalformedURLException e) {
+ System.err.println("Base URI is malformed: " + href);
+ }
+ }
+ }
+ }
+ return baseURI;
+ }
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/photocast/PhotocastModule.java b/rome-modules/src/main/java/com/rometools/modules/photocast/PhotocastModule.java
new file mode 100644
index 0000000..7d219b5
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/photocast/PhotocastModule.java
@@ -0,0 +1,131 @@
+/*
+ * PhotocastModule.java
+ *
+ * Created on March 30, 2006, 6:27 PM
+ *
+ * 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) 2006 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 com.rometools.modules.photocast;
+
+import java.net.URL;
+import java.util.Date;
+
+import com.rometools.modules.photocast.types.Metadata;
+import com.rometools.rome.feed.module.Module;
+
+/**
+ * This is a ROME module that provides support for the "http://www.apple.com/ilife/wallpapers"
+ * namespace.
+ *
+ * See the package information for example usage.
+ *
+ * @author Robert "kebernet" Cooper
+ */
+public interface PhotocastModule extends Module {
+ /**
+ * The URI of the namespace. ("http://www.apple.com/ilife/wallpapers")
+ */
+ public static final String URI = "http://www.apple.com/ilife/wallpapers";
+
+ /**
+ * Returns the Item level photoDate value.
+ *
+ * @return Returns the Item level photoDate value.
+ */
+ public Date getPhotoDate();
+
+ /**
+ * Set the Item level photoDate value.
+ *
+ * @param photoDate Item level photoDate value
+ */
+ public void setPhotoDate(Date photoDate);
+
+ /**
+ * Returns the cropDate value from the item level.
+ *
+ * @return Item level cropDate value
+ */
+ public Date getCropDate();
+
+ /**
+ * Sets the cropDate value for the item level.
+ *
+ * @param cropDate cropDate value for the item level
+ */
+ public void setCropDate(Date cropDate);
+
+ /**
+ * The URL of the image.
+ *
+ * @return The URL of the image.
+ */
+ public URL getImageUrl();
+
+ /**
+ * The URL of the image.
+ *
+ * @param imageUrl The URL of the image.
+ */
+ public void setImageUrl(URL imageUrl);
+
+ /**
+ * The URL of the image thumbnail.
+ *
+ * @return The URL of the image thumbnail.
+ */
+ public URL getThumbnailUrl();
+
+ /**
+ * The URL of the image thumbnail.
+ *
+ * @param thumbnailUrl The URL of the image thumbnail.
+ */
+ public void setThumbnailUrl(URL thumbnailUrl);
+
+ /**
+ * The iPhoto metadata for the image.
+ *
+ * @return The iPhoto metadata for the image.
+ */
+ public Metadata getMetadata();
+
+ /**
+ * The iPhoto metadata for the image.
+ *
+ * @param metadata The iPhoto metadata for the image.
+ */
+ public void setMetadata(Metadata metadata);
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/photocast/PhotocastModuleImpl.java b/rome-modules/src/main/java/com/rometools/modules/photocast/PhotocastModuleImpl.java
new file mode 100644
index 0000000..8f239de
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/photocast/PhotocastModuleImpl.java
@@ -0,0 +1,173 @@
+/*
+ * PhotocastModuleImpl.java
+ *
+ * Created on March 30, 2006, 6:23 PM
+ *
+ *
+ * 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) 2006 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 com.rometools.modules.photocast;
+
+import java.net.URL;
+import java.util.Date;
+
+import com.rometools.modules.photocast.types.Metadata;
+import com.rometools.rome.feed.CopyFrom;
+import com.rometools.rome.feed.impl.EqualsBean;
+import com.rometools.rome.feed.impl.ToStringBean;
+
+/**
+ *
+ * @author Robert "kebernet" Cooper
+ */
+public class PhotocastModuleImpl implements PhotocastModule {
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ private Date photoDate;
+ private Date cropDate;
+ private URL imageUrl;
+ private URL thumbnailUrl;
+ private Metadata metadata;
+
+ /** Creates a new instance of PhotocastModuleImpl */
+ public PhotocastModuleImpl() {
+ }
+
+ @Override
+ public Date getPhotoDate() {
+ return photoDate;
+ }
+
+ @Override
+ public void setPhotoDate(final Date photoDate) {
+ this.photoDate = photoDate;
+ }
+
+ @Override
+ public Date getCropDate() {
+ return cropDate;
+ }
+
+ @Override
+ public void setCropDate(final Date cropDate) {
+ this.cropDate = cropDate;
+ }
+
+ @Override
+ public URL getImageUrl() {
+ return imageUrl;
+ }
+
+ @Override
+ public void setImageUrl(final URL imageUrl) {
+ this.imageUrl = imageUrl;
+ }
+
+ @Override
+ public URL getThumbnailUrl() {
+ return thumbnailUrl;
+ }
+
+ @Override
+ public void setThumbnailUrl(final URL thumbnailUrl) {
+ this.thumbnailUrl = thumbnailUrl;
+ }
+
+ @Override
+ public Metadata getMetadata() {
+ return metadata;
+ }
+
+ @Override
+ public void setMetadata(final Metadata metadata) {
+ this.metadata = metadata;
+ }
+
+ @Override
+ public void copyFrom(final CopyFrom obj) {
+ final PhotocastModule pm = (PhotocastModule) obj;
+ setPhotoDate(pm.getPhotoDate() == null ? null : (Date) pm.getPhotoDate().clone());
+ setCropDate(pm.getCropDate() == null ? null : (Date) pm.getCropDate().clone());
+ setImageUrl(pm.getImageUrl());
+ setThumbnailUrl(pm.getThumbnailUrl());
+ setMetadata(pm.getMetadata());
+ }
+
+ @Override
+ public Object clone() {
+ final PhotocastModuleImpl pm = new PhotocastModuleImpl();
+ pm.setPhotoDate(getPhotoDate() == null ? null : (Date) getPhotoDate().clone());
+ pm.setCropDate(getCropDate() == null ? null : (Date) getCropDate().clone());
+ pm.setImageUrl(getThumbnailUrl());
+ pm.setThumbnailUrl(getThumbnailUrl());
+ pm.setMetadata(getMetadata());
+
+ return pm;
+ }
+
+ @Override
+ public String getUri() {
+ return PhotocastModule.URI;
+ }
+
+ @Override
+ public Class getInterface() {
+ return PhotocastModule.class;
+ }
+
+ @Override
+ public String toString() {
+ final ToStringBean tsBean = new ToStringBean(PhotocastModuleImpl.class, this);
+
+ return tsBean.toString();
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ final EqualsBean eBean = new EqualsBean(PhotocastModuleImpl.class, this);
+
+ return eBean.beanEquals(obj);
+ }
+
+ @Override
+ public int hashCode() {
+ final EqualsBean equals = new EqualsBean(PhotocastModuleImpl.class, this);
+
+ return equals.beanHashCode();
+ }
+}
diff --git a/rome-modules/src/main/java/com/rometools/modules/photocast/io/Generator.java b/rome-modules/src/main/java/com/rometools/modules/photocast/io/Generator.java
new file mode 100644
index 0000000..64780f4
--- /dev/null
+++ b/rome-modules/src/main/java/com/rometools/modules/photocast/io/Generator.java
@@ -0,0 +1,113 @@
+/*
+ * Generator.java
+ *
+ * Created on March 30, 2006, 6:43 PM
+ *
+ *
+ * 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) 2006 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 com.rometools.modules.photocast.io;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.jdom2.Element;
+import org.jdom2.Namespace;
+
+import com.rometools.modules.photocast.PhotocastModule;
+import com.rometools.rome.feed.module.Module;
+import com.rometools.rome.io.ModuleGenerator;
+
+/**
+ *
+ * @author