You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@marmotta.apache.org by ja...@apache.org on 2014/01/08 16:26:03 UTC
[47/51] [abbrv] [partial] MARMOTTA-397: Reorganized and renamed
Marmotta Sesame Tools
http://git-wip-us.apache.org/repos/asf/marmotta/blob/00c22e7c/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/feed/atom/Category.java
----------------------------------------------------------------------
diff --git a/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/feed/atom/Category.java b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/feed/atom/Category.java
new file mode 100644
index 0000000..f521957
--- /dev/null
+++ b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/feed/atom/Category.java
@@ -0,0 +1,158 @@
+/*
+ * 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.sun.syndication.feed.atom;
+
+import com.sun.syndication.feed.impl.ObjectBean;
+
+import java.io.Serializable;
+
+/**
+ * Bean for category elements of Atom feeds.
+ * <p>
+ * @author Dave Johnson (added for Atom 1.0)
+ */
+public class Category implements Cloneable, Serializable {
+
+ private ObjectBean _objBean;
+
+ private String _term;
+ private String _scheme;
+ private String _schemeResolved;
+ private String _label;
+
+ /**
+ * Default constructor. All properties are set to <b>null</b>.
+ * <p>
+ *
+ */
+ public Category() {
+ _objBean = new ObjectBean(this.getClass(),this);
+ }
+
+ /**
+ * Creates a deep 'bean' clone of the object.
+ * <p>
+ * @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.
+ * <p>
+ * @param other he reference object with which to compare.
+ * @return <b>true</b> if 'this' object is equal to the 'other' object.
+ *
+ */
+ @Override
+ public boolean equals(Object other) {
+ if(!(other instanceof Category)){
+ return false;
+ }
+ return _objBean.equals(other);
+ }
+
+ /**
+ * Returns a hashcode value for the object.
+ * <p>
+ * It follows the contract defined by the Object hashCode() method.
+ * <p>
+ * @return the hashcode of the bean object.
+ *
+ */
+ @Override
+ public int hashCode() {
+ return _objBean.hashCode();
+ }
+
+ /**
+ * Returns the String representation for the object.
+ * <p>
+ * @return String representation for the object.
+ *
+ */
+ @Override
+ public String toString() {
+ return _objBean.toString();
+ }
+
+ /**
+ * Get label for category.
+ * <p>
+ * @return Label for category.
+ */
+ public String getLabel() {
+ return _label;
+ }
+
+ /**
+ * Set label for category.
+ * <p>
+ * @param label Label for category.
+ */
+ public void setLabel(String label) {
+ this._label = label;
+ }
+
+ /**
+ * Get Scheme URI for category.
+ * <p>
+ * @return Scheme URI for category.
+ */
+ public String getScheme() {
+ return _scheme;
+ }
+
+ /**
+ * Set scheme URI for category.
+ * <p>
+ * @param scheme Scheme URI for category.
+ */
+ public void setScheme(String scheme) {
+ this._scheme = scheme;
+ }
+
+ public void setSchemeResolved(String schemeResolved) {
+ _schemeResolved = schemeResolved;
+ }
+
+ public String getSchemeResolved() {
+ return _schemeResolved != null ? _schemeResolved : _scheme;
+ }
+
+ /**
+ * Return term for category.
+ * <p>
+ * @return Term for category.
+ */
+ public String getTerm() {
+ return _term;
+ }
+
+ /**
+ * Set term for category.
+ * <p>
+ * @param term Term for category.
+ */
+ public void setTerm(String term) {
+ this._term = term;
+ }
+}
http://git-wip-us.apache.org/repos/asf/marmotta/blob/00c22e7c/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/feed/atom/Content.java
----------------------------------------------------------------------
diff --git a/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/feed/atom/Content.java b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/feed/atom/Content.java
new file mode 100644
index 0000000..8e90181
--- /dev/null
+++ b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/feed/atom/Content.java
@@ -0,0 +1,219 @@
+/*
+ * 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.sun.syndication.feed.atom;
+
+import com.sun.syndication.feed.impl.ObjectBean;
+
+import java.io.Serializable;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * Bean for content elements of Atom feeds.
+ * <p>
+ * @author Alejandro Abdelnur
+ * @author Dave Johnson (updated for Atom 1.0)
+ */
+public class Content implements Cloneable,Serializable {
+
+ private ObjectBean _objBean;
+
+ private String _type;
+ private String _value;
+ private String _src;
+
+ /** @since Atom 1.0 */
+ public static final String TEXT = "text";
+
+ /** @since Atom 1.0 */
+ public static final String HTML = "html";
+
+ /** @since Atom 1.0 */
+ public static final String XHTML = "xhtml";
+
+ /** Atom 0.3 only */
+ public static final String XML = "xml";
+
+ /** Atom 0.3 only */
+ public static final String BASE64 = "base64";
+
+ /** Atom 0.3 only */
+ public static final String ESCAPED = "escaped";
+
+ private String _mode;
+ private static final Set<String> MODES = new HashSet<String>();
+ static {
+ MODES.add(XML);
+ MODES.add(BASE64);
+ MODES.add(ESCAPED);
+ }
+
+
+ /**
+ * Default constructor. All properties are set to <b>null</b>.
+ * <p>
+ *
+ */
+ public Content() {
+ _objBean = new ObjectBean(this.getClass(),this);
+ }
+
+ /**
+ * Creates a deep 'bean' clone of the object.
+ * <p>
+ * @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.
+ * <p>
+ * @param other he reference object with which to compare.
+ * @return <b>true</b> if 'this' object is equal to the 'other' object.
+ *
+ */
+ @Override
+ public boolean equals(Object other) {
+ if(!(other instanceof Content)){
+ return false;
+ }
+ return _objBean.equals(other);
+ }
+
+ /**
+ * Returns a hashcode value for the object.
+ * <p>
+ * It follows the contract defined by the Object hashCode() method.
+ * <p>
+ * @return the hashcode of the bean object.
+ *
+ */
+ @Override
+ public int hashCode() {
+ return _objBean.hashCode();
+ }
+
+ /**
+ * Returns the String representation for the object.
+ * <p>
+ * @return String representation for the object.
+ *
+ */
+ @Override
+ public String toString() {
+ return _objBean.toString();
+ }
+
+ /**
+ * Returns the content type.
+ * <p>
+ * The type indicates how the value was/will-be encoded in the XML feed.
+ * </p>
+ * @since Atom 1.0
+ */
+ public String getType() {
+ return _type;
+ }
+
+ /**
+ * Sets the content type.
+ * <p>
+ * The type indicates how the value was/will-be encoded in the XML feed.
+ * </p>
+ * @since Atom 1.0
+ */
+ public void setType(String type) {
+ _type = type;
+ }
+
+ /**
+ * Returns the content mode (Atom 0.3 only).
+ * <p>
+ * The mode indicates how the value was/will-be encoded in the XML feed.
+ * <p>
+ * @return the content mode, <b>null</b> if none.
+ */
+ public String getMode() {
+ return _mode;
+ }
+
+ /**
+ * Sets the content mode (Atom 0.3 only).
+ * <p>
+ * The mode indicates how the value was/will-be encoded in the XML feed.
+ * <p>
+ * @param mode the content mode, <b>null</b> if none.
+ */
+ public void setMode(String mode) {
+ mode = (mode!=null) ? mode.toLowerCase() : null;
+ if (mode==null || !MODES.contains(mode)) {
+ throw new IllegalArgumentException("Invalid mode ["+mode+"]");
+ }
+ _mode = mode;
+ }
+
+ /**
+ * Returns the content value.
+ * <p>
+ * The return value should be decoded.
+ * <p>
+ * @return the content value, <b>null</b> if none.
+ *
+ */
+ public String getValue() {
+ return _value;
+ }
+
+ /**
+ * Sets the content value.
+ * <p>
+ * The value being set should be decoded.
+ * <p>
+ * @param value the content value, <b>null</b> if none.
+ *
+ */
+ public void setValue(String value) {
+ _value = value;
+ }
+
+ /**
+ * Returns the src
+ * <p>
+ * @return Returns the src.
+ * @since Atom 1.0
+ */
+ public String getSrc() {
+ return _src;
+ }
+
+ /**
+ * Set the src
+ * <p>
+ * @param src The src to set.
+ * @since Atom 1.0
+ */
+ public void setSrc(String src) {
+ _src = src;
+ }
+}
+
+
http://git-wip-us.apache.org/repos/asf/marmotta/blob/00c22e7c/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/feed/atom/Entry.java
----------------------------------------------------------------------
diff --git a/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/feed/atom/Entry.java b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/feed/atom/Entry.java
new file mode 100644
index 0000000..848188d
--- /dev/null
+++ b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/feed/atom/Entry.java
@@ -0,0 +1,573 @@
+/*
+ * Copyright 2004 Sun Microsystems, Inc.
+ * Copyright 2011 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.
+ *
+ */
+package com.sun.syndication.feed.atom;
+
+import com.sun.syndication.feed.impl.ObjectBean;
+import com.sun.syndication.feed.module.Extendable;
+import com.sun.syndication.feed.module.Module;
+import com.sun.syndication.feed.module.impl.ModuleUtils;
+
+import java.io.Serializable;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
+
+
+/**
+ * Bean for entry elements of Atom feeds.
+ * <p>
+ * @author Alejandro Abdelnur
+ * @author Dave Johnson (updated for Atom 1.0)
+ */
+public class Entry implements Cloneable, Serializable, Extendable {
+ private Content _summary;
+ private Content _title;
+ private Date _created; // Atom 0.3 only
+ private Date _published; // AKA issued
+ private Date _updated; // AKA modified
+ private Feed _source;
+ private List<Link> _alternateLinks;
+ private List<Person> _authors;
+ private List<Category> _categories;
+ private List<Content> _contents;
+ private List<Person> _contributors;
+ private List<Link> _foreignMarkup;
+ private List<Module> _modules;
+ private List<Link> _otherLinks;
+ private ObjectBean _objBean;
+ private String _id;
+ private String _rights;
+ private String _xmlBase;
+
+ /**
+ * Default constructor. All properties are set to <b>null</b>.
+ * <p>
+ *
+ */
+ public Entry() {
+ _objBean = new ObjectBean(this.getClass(), this);
+ }
+
+ /**
+ * Sets the entry alternate links.
+ * <p>
+ * @param alternateLinks the list of Link elements with the entry alternate links to set,
+ * an empty list or <b>null</b> if none.
+ */
+ public void setAlternateLinks(List<Link> alternateLinks) {
+ _alternateLinks = alternateLinks;
+ }
+
+ /**
+ * Returns the entry alternate links.
+ * <p>
+ * @return a list of Link elements with the entry alternate links, an empty list if none.
+ */
+ public List<Link> getAlternateLinks() {
+ return (_alternateLinks == null) ? (_alternateLinks = new ArrayList()) : _alternateLinks;
+ }
+
+ /**
+ * Sets the author of the entry.
+ * <p>
+ * @param authors the author of the entry, <b>null</b> if none.
+ *
+ */
+ public void setAuthors(List<Person> authors) {
+ _authors = authors;
+ }
+
+ /**
+ * Returns the entry author.
+ * <p>
+ * @return the entry author, <b>null</b> if none.
+ *
+ */
+ public List<Person> getAuthors() {
+ return (_authors == null) ? (_authors = new ArrayList<Person>()) : _authors;
+ }
+
+ /**
+ * Set the categories
+ * <p>
+ * @param categories The categories to set.
+ * @since Atom 1.0
+ */
+ public void setCategories(List categories) {
+ _categories = categories;
+ }
+
+ /**
+ * Returns the categories
+ * <p>
+ * @return Returns the categories.
+ * @since Atom 1.0
+ */
+ public List getCategories() {
+ return (_categories == null) ? (_categories = new ArrayList()) : _categories;
+ }
+
+ /**
+ * Sets the entry contents.
+ * <p>
+ * @param contents the list of Content elements with the entry contents to set,
+ * an empty list or <b>null</b> if none.
+ */
+ public void setContents(List contents) {
+ _contents = contents;
+ }
+
+ /**
+ * Returns the entry contents.
+ * <p>
+ * @return a list of Content elements with the entry contents,
+ * an empty list if none.
+ */
+ public List<Content> getContents() {
+ return (_contents == null) ? (_contents = new ArrayList<Content>()) : _contents;
+ }
+
+ /**
+ * Sets the entry contributors.
+ * <p>
+ * @param contributors the list of Person elements with the entry contributors to set,
+ * an empty list or <b>null</b> if none.
+ *
+ */
+ public void setContributors(List<Person> contributors) {
+ _contributors = contributors;
+ }
+
+ /**
+ * Returns the entry contributors.
+ * <p>
+ * @return a list of Person elements with the entry contributors,
+ * an empty list if none.
+ *
+ */
+ public List<Person> getContributors() {
+ return (_contributors == null) ? (_contributors = new ArrayList()) : _contributors;
+ }
+
+ /**
+ * Sets the entry created date (Atom 0.3 only)
+ * <p>
+ * @param created the entry created date, <b>null</b> if none.
+ */
+ public void setCreated(Date created) {
+ _created = new Date(created.getTime());
+ }
+
+ /**
+ * Returns the entry created date (Atom 0.3 only)
+ * <p>
+ * @return the entry created date, <b>null</b> if none.
+ */
+ public Date getCreated() {
+ return _created == null ? null : new Date(_created.getTime());
+ }
+
+ /**
+ * Sets foreign markup found at entry level.
+ * <p>
+ * @param foreignMarkup Opaque object to discourage use
+ *
+ */
+ public void setForeignMarkup(Object foreignMarkup) {
+ _foreignMarkup = (List) foreignMarkup;
+ }
+
+ /**
+ * Returns foreign markup found at entry level.
+ * <p>
+ * @return list of Opaque object to discourage use
+ *
+ */
+ public Object getForeignMarkup() {
+ return (_foreignMarkup == null) ? (_foreignMarkup = new ArrayList()) : _foreignMarkup;
+ }
+
+ /**
+ * Sets the entry ID.
+ * <p>
+ * @param id the entry ID, <b>null</b> if none.
+ *
+ */
+ public void setId(String id) {
+ _id = id;
+ }
+
+ /**
+ * Returns the entry ID.
+ * <p>
+ * @return the entry ID, <b>null</b> if none.
+ *
+ */
+ public String getId() {
+ return _id;
+ }
+
+ /**
+ * Sets the entry issued date (Atom 0.3, maps to {@link #setPublished(java.util.Date)}).
+ * <p>
+ * @param issued the entry issued date, <b>null</b> if none.
+ */
+ public void setIssued(Date issued) {
+ _published = issued == null ? null : new Date(issued.getTime());
+ }
+
+ /**
+ * Returns the entry issued date (Atom 0.3, maps to {@link #getPublished()}).
+ * <p>
+ * @return the entry issued date, <b>null</b> if none.
+ */
+ public Date getIssued() {
+ return _published == null ? null : new Date(_published.getTime());
+ }
+
+ /**
+ * Returns true if entry is a media entry, i.e. has rel="edit-media".
+ *
+ * @return true if entry is a media entry
+ */
+ public boolean isMediaEntry() {
+ boolean mediaEntry = false;
+ List links = getOtherLinks();
+
+ for (Iterator<Link> it = links.iterator(); it.hasNext();) {
+ Link link = it.next();
+
+ if ("edit-media".equals(link.getRel())) {
+ mediaEntry = true;
+
+ break;
+ }
+ }
+
+ return mediaEntry;
+ }
+
+ /**
+ * Sets the entry modified date (Atom 0.3, maps to {@link #setUpdated(java.util.Date)}).
+ * <p>
+ * @param modified the entry modified date, <b>null</b> if none.
+ */
+ public void setModified(Date modified) {
+ _updated = modified == null ? null : new Date(modified.getTime());
+ }
+
+ /**
+ * Returns the entry modified date (Atom 0.3, maps to {@link #getUpdated()}).
+ * <p>
+ * @return the entry modified date, <b>null</b> if none.
+ */
+ public Date getModified() {
+ return _updated == null ? null : new Date(_updated.getTime());
+ }
+
+ /**
+ * Returns the module identified by a given URI.
+ * <p>
+ * @param uri the URI of the ModuleImpl.
+ * @return The module with the given URI, <b>null</b> if none.
+ */
+ public Module getModule(String uri) {
+ return ModuleUtils.getModule(_modules, uri);
+ }
+
+ /**
+ * Sets the entry modules.
+ * <p>
+ * @param modules the list of ModuleImpl elements with the entry modules to set,
+ * an empty list or <b>null</b> if none.
+ *
+ */
+ public void setModules(List modules) {
+ _modules = modules;
+ }
+
+ /**
+ * Returns the entry modules.
+ * <p>
+ * @return a list of ModuleImpl elements with the entry modules,
+ * an emtpy list if none.
+ *
+ */
+ public List getModules() {
+ return (_modules == null) ? (_modules = new ArrayList()) : _modules;
+ }
+
+ /**
+ * Sets the entry non-alternate links.
+ * <p>
+ * @param otherLinks the list Link elements with the entry non-alternate links to set,
+ * an empty list or <b>null</b> if none.
+ */
+ public void setOtherLinks(List<Link> otherLinks) {
+ _otherLinks = otherLinks;
+ }
+
+ /**
+ * Returns the entry non-alternate links.
+ * <p>
+ * @return the list of Link elements with the entry non-alternate links to set,
+ * an empty list if none.
+ */
+ public List<Link> getOtherLinks() {
+ return (_otherLinks == null) ? (_otherLinks = new ArrayList<Link>()) : _otherLinks;
+ }
+
+ /**
+ * Set the published
+ * <p>
+ * @param published The published to set.
+ * @since Atom 1.0
+ */
+ public void setPublished(Date published) {
+ _published = published == null ? null : new Date(published.getTime());
+ }
+
+ /**
+ * Returns the published
+ * <p>
+ * @return Returns the published.
+ * @since Atom 1.0
+ */
+ public Date getPublished() {
+ return _published == null ? null : new Date(_published.getTime());
+ }
+
+ /**
+ * Set the rights
+ * <p>
+ * @param rights The rights to set.
+ * @since Atom 1.0
+ */
+ public void setRights(String rights) {
+ _rights = rights;
+ }
+
+ /**
+ * Returns the rights
+ * <p>
+ * @return Returns the rights.
+ * @since Atom 1.0
+ */
+ public String getRights() {
+ return _rights;
+ }
+
+ /**
+ * Set the source
+ * <p>
+ * @param source The source to set.
+ */
+ public void setSource(Feed source) {
+ _source = source;
+ }
+
+ /**
+ * Returns the source
+ * <p>
+ * @return Returns the source.
+ */
+ public Feed getSource() {
+ return _source;
+ }
+
+ /**
+ * Sets the entry summary.
+ * <p>
+ * @param summary the entry summary, <b>null</b> if none.
+ *
+ */
+ public void setSummary(Content summary) {
+ _summary = summary;
+ }
+
+ /**
+ * Returns the entry summary.
+ * <p>
+ * @return the entry summary, <b>null</b> if none.
+ *
+ */
+ public Content getSummary() {
+ return _summary;
+ }
+
+ /**
+ * Sets the entry title.
+ * <p>
+ * @param title the entry title, <b>null</b> if none.
+ *
+ */
+ public void setTitle(String title) {
+ if (_title == null) {
+ _title = new Content();
+ }
+
+ _title.setValue(title);
+ }
+
+ /**
+ * Returns the entry title.
+ * <p>
+ * @return the entry title, <b>null</b> if none.
+ *
+ */
+ public String getTitle() {
+ if (_title != null) {
+ return _title.getValue();
+ }
+
+ return null;
+ }
+
+ /**
+ * Sets the entry title as a text construct.
+ * <p>
+ * @param title the entry title, <b>null</b> if none.
+ *
+ */
+ public void setTitleEx(Content title) {
+ _title = title;
+ }
+
+ /**
+ * Returns the entry title as a text construct.
+ * <p>
+ * @return the entry title, <b>null</b> if none.
+ *
+ */
+ public Content getTitleEx() {
+ return _title;
+ }
+
+ /**
+ * Set the updated
+ * <p>
+ * @param updated The updated to set.
+ * @since Atom 1.0
+ */
+ public void setUpdated(Date updated) {
+ _updated = updated == null? null : new Date(updated.getTime());
+ }
+
+ /**
+ * Returns the updated
+ * <p>
+ * @return Returns the updated.
+ * @since Atom 1.0
+ */
+ public Date getUpdated() {
+ return _updated == null ? null : new Date(_updated.getTime());
+ }
+
+ /**
+ * Set the xmlBase
+ * <p>
+ * @param xmlBase The xmlBase to set.
+ * @since Atom 1.0
+ */
+ public void setXmlBase(String xmlBase) {
+ _xmlBase = xmlBase;
+ }
+
+ /**
+ * Returns the xmlBase
+ * <p>
+ * @return Returns the xmlBase.
+ * @since Atom 1.0
+ */
+ public String getXmlBase() {
+ return _xmlBase;
+ }
+
+ /**
+ * Creates a deep 'bean' clone of the object.
+ * <p>
+ * @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.
+ * <p>
+ * @param other he reference object with which to compare.
+ * @return <b>true</b> if 'this' object is equal to the 'other' object.
+ *
+ */
+ @Override
+ public boolean equals(Object other) {
+ if (other == null) {
+ return false;
+ }
+ if(!(other instanceof Entry)){
+ return false;
+ }
+ // can't use foreign markup in equals, due to JDOM equals impl
+ Object fm = getForeignMarkup();
+ setForeignMarkup(((Entry) other).getForeignMarkup());
+
+ boolean ret = _objBean.equals(other);
+ // restore foreign markup
+ setForeignMarkup(fm);
+
+ return ret;
+ }
+
+ /**
+ * Returns a hashcode value for the object.
+ * <p>
+ * It follows the contract defined by the Object hashCode() method.
+ * <p>
+ * @return the hashcode of the bean object.
+ *
+ */
+ @Override
+ public int hashCode() {
+ return _objBean.hashCode();
+ }
+
+ /**
+ * Returns the String representation for the object.
+ * <p>
+ * @return String representation for the object.
+ *
+ */
+ @Override
+ public String toString() {
+ return _objBean.toString();
+ }
+
+
+ public Link findRelatedLink(String relation){
+ for(Link l : this._otherLinks){
+ if(relation.equals(l.getRel())){
+ return l;
+ }
+ }
+ return null;
+ }
+}
http://git-wip-us.apache.org/repos/asf/marmotta/blob/00c22e7c/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/feed/atom/Feed.java
----------------------------------------------------------------------
diff --git a/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/feed/atom/Feed.java b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/feed/atom/Feed.java
new file mode 100644
index 0000000..e79b81b
--- /dev/null
+++ b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/feed/atom/Feed.java
@@ -0,0 +1,527 @@
+/*
+ * 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.sun.syndication.feed.atom;
+
+import com.sun.syndication.feed.WireFeed;
+import com.sun.syndication.feed.module.Module;
+import com.sun.syndication.feed.module.impl.ModuleUtils;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * Bean for Atom feeds.
+ * <p>
+ * It handles Atom feeds version 0.3 without loosing any feed information.
+ * <p>
+ * @author Alejandro Abdelnur
+ * @author Dave Johnson (updated for Atom 1.0)
+ */
+public class Feed extends WireFeed {
+
+ private String _xmlBase;
+ private List<Category> _categories;
+ private List<Person> _authors;
+ private List<Person> _contributors;
+ private Generator _generator;
+ private String _icon;
+ private String _id;
+ private String _logo;
+ private String _rights; // AKA copyright
+ private Content _subtitle; // AKA tagline
+ private Content _title;
+ private Date _updated; // AKA modified
+ private List<Link> _alternateLinks;
+ private List<Link> _otherLinks;
+ private List<Entry> _entries;
+
+ private List<Module> _modules;
+
+ private Content _info; // Atom 0.3 only
+ private String _language; // Atom 0.3 only
+
+ /**
+ * Default constructor, for bean cloning purposes only.
+ *
+ */
+ public Feed() {
+ }
+
+ /**
+ * Feed Constructor. All properties, except the type, are set to <b>null</b>.
+ * <p>
+ * @param type the type of the Atom feed.
+ *
+ */
+ public Feed(String type) {
+ super(type);
+ }
+
+ /**
+ * Returns the feed language (Atom 0.3 only)
+ * <p>
+ * @return the feed language, <b>null</b> if none.
+ *
+ */
+ public String getLanguage() {
+ return _language;
+ }
+
+ /**
+ * Sets the feed language (Atom 0.3 only)
+ * <p>
+ * @param language the feed language to set, <b>null</b> if none.
+ *
+ */
+ public void setLanguage(String language) {
+ _language = language;
+ }
+
+ /**
+ * Returns the feed title.
+ * <p>
+ * @return the feed title, <b>null</b> if none.
+ *
+ */
+ public String getTitle() {
+ if (_title != null) return _title.getValue();
+ return null;
+ }
+
+ /**
+ * Sets the feed title.
+ * <p>
+ * @param title the feed title to set, <b>null</b> if none.
+ *
+ */
+ public void setTitle(String title) {
+ if (_title == null) _title = new Content();
+ _title.setValue(title);
+ }
+
+ /**
+ * Returns the feed title.
+ * <p>
+ * @return the feed title, <b>null</b> if none.
+ *
+ */
+ public Content getTitleEx() {
+ return _title;
+ }
+
+ /**
+ * Sets the feed title.
+ * <p>
+ * @param title the feed title to set, <b>null</b> if none.
+ *
+ */
+ public void setTitleEx(Content title) {
+ _title = title;
+ }
+
+ /**
+ * Returns the feed alternate links.
+ * <p>
+ * @return a list of Link elements with the feed alternate links,
+ * an empty list if none.
+ */
+ public List<Link> getAlternateLinks() {
+ return (_alternateLinks==null) ? (_alternateLinks=new ArrayList<Link>()) : _alternateLinks;
+ }
+
+ /**
+ * Sets the feed alternate links.
+ * <p>
+ * @param alternateLinks the list of Link elements with the feed alternate links to set,
+ * an empty list or <b>null</b> if none.
+ */
+ public void setAlternateLinks(List<Link> alternateLinks) {
+ _alternateLinks = alternateLinks;
+ }
+
+ /**
+ * Returns the feed other links (non-alternate ones).
+ * <p>
+ * @return a list of Link elements with the feed other links (non-alternate ones),
+ * an empty list if none.
+ */
+ public List<Link> getOtherLinks() {
+ return (_otherLinks==null) ? (_otherLinks=new ArrayList()) : _otherLinks;
+ }
+
+ /**
+ * Sets the feed other links (non-alternate ones).
+ * <p>
+ * @param otherLinks the list of Link elements with the feed other links (non-alternate ones) to set,
+ * an empty list or <b>null</b> if none.
+ */
+ public void setOtherLinks(List<Link> otherLinks) {
+ _otherLinks = otherLinks;
+ }
+
+ /**
+ * Returns the feed author.
+ * <p>
+ * @return the feed author, <b>null</b> if none.
+ *
+ */
+ public List<Person> getAuthors() {
+ return (_authors==null) ? (_authors=new ArrayList<Person>()) : _authors;
+ }
+
+ /**
+ * Sets the feed author.
+ * <p>
+ * @param authors the feed author to set, <b>null</b> if none.
+ *
+ */
+ public void setAuthors(List<Person> authors) {
+ _authors = authors;
+ }
+
+ /**
+ * Returns the feed contributors.
+ * <p>
+ * @return a list of Person elements with the feed contributors,
+ * an empty list if none.
+ *
+ */
+ public List<Person> getContributors() {
+ return (_contributors==null) ? (_contributors=new ArrayList<Person>()) : _contributors;
+ }
+
+ /**
+ * Sets the feed contributors.
+ * <p>
+ * @param contributors the list of Person elements with the feed contributors to set,
+ * an empty list or <b>null</b> if none.
+ *
+ */
+ public void setContributors(List<Person> contributors) {
+ _contributors = contributors;
+ }
+
+ /**
+ * Returns the feed tag line (Atom 0.3, maps to {@link #getSubtitle()}).
+ * <p>
+ * @return the feed tag line, <b>null</b> if none.
+ */
+ public Content getTagline() {
+ return _subtitle;
+ }
+
+ /**
+ * Sets the feed tagline (Atom 0.3, maps to {@link #setSubtitle(com.sun.syndication.feed.atom.Content)}).
+ * <p>
+ * @param tagline the feed tagline to set, <b>null</b> if none.
+ */
+ public void setTagline(Content tagline) {
+ _subtitle = tagline;
+ }
+
+ /**
+ * Returns the feed ID.
+ * <p>
+ * @return the feed ID, <b>null</b> if none.
+ *
+ */
+ public String getId() {
+ return _id;
+ }
+
+ /**
+ * Sets the feed ID.
+ * <p>
+ * @param id the feed ID to set, <b>null</b> if none.
+ *
+ */
+ public void setId(String id) {
+ _id = id;
+ }
+
+ /**
+ * Returns the feed generator.
+ * <p>
+ * @return the feed generator, <b>null</b> if none.
+ *
+ */
+ public Generator getGenerator() {
+ return _generator;
+ }
+
+ /**
+ * Sets the feed generator.
+ * <p>
+ * @param generator the feed generator to set, <b>null</b> if none.
+ *
+ */
+ public void setGenerator(Generator generator) {
+ _generator = generator;
+ }
+
+ /**
+ * Returns the feed copyright (Atom 0.3, maps to {@link #getRights()}).
+ * <p>
+ * @return the feed copyright, <b>null</b> if none.
+ */
+ public String getCopyright() {
+ return _rights;
+ }
+
+ /**
+ * Sets the feed copyright (Atom 0.3, maps to {@link #setRights(java.lang.String)}).
+ * <p>
+ * @param copyright the feed copyright to set, <b>null</b> if none.
+ */
+ public void setCopyright(String copyright) {
+ _rights = copyright;
+ }
+
+ /**
+ * Returns the feed info (Atom 0.3 only)
+ * <p>
+ * @return the feed info, <b>null</b> if none.
+ */
+ public Content getInfo() {
+ return _info;
+ }
+
+ /**
+ * Sets the feed info (Atom 0.3 only)
+ * <p>
+ * @param info the feed info to set, <b>null</b> if none.
+ */
+ public void setInfo(Content info) {
+ _info = info;
+ }
+
+ /**
+ * Returns the feed modified date (Atom 0.3, maps to {@link #getUpdated()}).
+ * <p>
+ * @return the feed modified date, <b>null</b> if none.
+ */
+ public Date getModified() {
+ return _updated;
+ }
+
+ /**
+ * Sets the feed modified date (Atom 0.3, maps to {@link #setUpdated(java.util.Date)}).
+ * <p>
+ * @param modified the feed modified date to set, <b>null</b> if none.
+ */
+ public void setModified(Date modified) {
+ _updated = modified;
+ }
+
+ /**
+ * Returns the feed entries.
+ * <p>
+ * @return a list of Entry elements with the feed entries,
+ * an empty list if none.
+ *
+ */
+ public List<Entry> getEntries() {
+ return (_entries==null) ? (_entries=new ArrayList<Entry>()) : _entries;
+ }
+
+ /**
+ * Sets the feed entries.
+ * <p>
+ * @param entries the list of Entry elements with the feed entries to set,
+ * an empty list or <b>null</b> if none.
+ *
+ */
+ public void setEntries(List entries) {
+ _entries = entries;
+ }
+
+ /**
+ * Returns the feed modules.
+ * <p>
+ * @return a list of ModuleImpl elements with the feed modules,
+ * an empty list if none.
+ *
+ */
+ public List<Module> getModules() {
+ return (_modules==null) ? (_modules=new ArrayList<Module>()) : _modules;
+ }
+
+ /**
+ * Sets the feed moduless.
+ * <p>
+ * @param modules the list of ModuleImpl elements with the feed moduless to set,
+ * an empty list or <b>null</b> if none.
+ *
+ */
+ @Override
+ public void setModules(List<Module> modules) {
+ _modules = modules;
+ }
+
+ /**
+ * Returns the module identified by a given URI.
+ * <p>
+ * @param uri the URI of the ModuleImpl.
+ * @return The module with the given URI, <b>null</b> if none.
+ */
+ @Override
+ public Module getModule(String uri) {
+ return ModuleUtils.getModule(_modules,uri);
+ }
+
+ /**
+ * Returns the categories
+ * <p>
+ * @return Returns the categories.
+ * @since Atom 1.0
+ */
+ public List getCategories() {
+ return (_categories==null) ? (_categories=new ArrayList()) : _categories;
+ }
+
+ /**
+ * Set the categories
+ * <p>
+ * @param categories The categories to set.
+ * @since Atom 1.0
+ */
+ public void setCategories(List<Category> categories) {
+ _categories = categories;
+ }
+
+ /**
+ * Returns the icon
+ * <p>
+ * @return Returns the icon.
+ * @since Atom 1.0
+ */
+ public String getIcon() {
+ return _icon;
+ }
+
+ /**
+ * Set the icon
+ * <p>
+ * @param icon The icon to set.
+ * @since Atom 1.0
+ */
+ public void setIcon(String icon) {
+ _icon = icon;
+ }
+
+ /**
+ * Returns the logo
+ * <p>
+ * @return Returns the logo.
+ * @since Atom 1.0
+ */
+ public String getLogo() {
+ return _logo;
+ }
+
+ /**
+ * Set the logo
+ * <p>
+ * @param logo The logo to set.
+ * @since Atom 1.0
+ */
+ public void setLogo(String logo) {
+ _logo = logo;
+ }
+
+ /**
+ * Returns the rights
+ * <p>
+ * @return Returns the rights.
+ * @since Atom 1.0
+ */
+ public String getRights() {
+ return _rights;
+ }
+
+ /**
+ * Set the rights
+ * <p>
+ * @param rights The rights to set.
+ * @since Atom 1.0
+ */
+ public void setRights(String rights) {
+ _rights = rights;
+ }
+
+ /**
+ * Returns the subtitle
+ * <p>
+ * @return Returns the subtitle.
+ * @since Atom 1.0
+ */
+ public Content getSubtitle() {
+ return _subtitle;
+ }
+
+ /**
+ * Set the subtitle
+ * <p>
+ * @param subtitle The subtitle to set.
+ * @since Atom 1.0
+ */
+ public void setSubtitle(Content subtitle) {
+ _subtitle = subtitle;
+ }
+
+ /**
+ * Returns the updated
+ * <p>
+ * @return Returns the updated.
+ * @since Atom 1.0
+ */
+ public Date getUpdated() {
+ return _updated;
+ }
+
+ /**
+ * Set the updated
+ * <p>
+ * @param updated The updated to set.
+ * @since Atom 1.0
+ */
+ public void setUpdated(Date updated) {
+ _updated = updated;
+ }
+
+ /**
+ * Returns the xmlBase
+ * <p>
+ * @return Returns the xmlBase.
+ * @since Atom 1.0
+ */
+ public String getXmlBase() {
+ return _xmlBase;
+ }
+
+ /**
+ * Set the xmlBase
+ * <p>
+ * @param xmlBase The xmlBase to set.
+ * @since Atom 1.0
+ */
+ public void setXmlBase(String xmlBase) {
+ _xmlBase = xmlBase;
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/marmotta/blob/00c22e7c/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/feed/atom/Generator.java
----------------------------------------------------------------------
diff --git a/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/feed/atom/Generator.java b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/feed/atom/Generator.java
new file mode 100644
index 0000000..2763fb5
--- /dev/null
+++ b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/feed/atom/Generator.java
@@ -0,0 +1,155 @@
+/*
+ * 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.sun.syndication.feed.atom;
+
+import com.sun.syndication.feed.impl.ObjectBean;
+
+import java.io.Serializable;
+
+/**
+ * Bean for the generator element of Atom feeds.
+ * <p>
+ * @author Alejandro Abdelnur
+ *
+ */
+public class Generator implements Cloneable,Serializable {
+ private ObjectBean _objBean;
+ private String _url;
+ private String _version;
+ private String _value;
+
+ /**
+ * Default constructor. All properties are set to <b>null</b>.
+ * <p>
+ *
+ */
+ public Generator() {
+ _objBean = new ObjectBean(this.getClass(),this);
+ }
+
+ /**
+ * Creates a deep 'bean' clone of the object.
+ * <p>
+ * @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.
+ * <p>
+ * @param other he reference object with which to compare.
+ * @return <b>true</b> if 'this' object is equal to the 'other' object.
+ *
+ */
+ @Override
+ public boolean equals(Object other) {
+ if(!(other instanceof Generator)){
+ return false;
+ }
+ return _objBean.equals(other);
+ }
+
+ /**
+ * Returns a hashcode value for the object.
+ * <p>
+ * It follows the contract defined by the Object hashCode() method.
+ * <p>
+ * @return the hashcode of the bean object.
+ *
+ */
+ @Override
+ public int hashCode() {
+ return _objBean.hashCode();
+ }
+
+ /**
+ * Returns the String representation for the object.
+ * <p>
+ * @return String representation for the object.
+ *
+ */
+ @Override
+ public String toString() {
+ return _objBean.toString();
+ }
+
+ /**
+ * Returns the generator URL.
+ * <p>
+ * @return the generator URL, <b>null</b> if none.
+ *
+ */
+ public String getUrl() {
+ return _url;
+ }
+
+ /**
+ * Sets the generator URL.
+ * <p>
+ * @param url the generator URL, <b>null</b> if none.
+ *
+ */
+ public void setUrl(String url) {
+ _url = url;
+ }
+
+ /**
+ * Returns the generator version.
+ * <p>
+ * @return the generator version, <b>null</b> if none.
+ *
+ */
+ public String getVersion() {
+ return _version;
+ }
+
+ /**
+ * Sets the generator version.
+ * <p>
+ * @param version the generator version, <b>null</b> if none.
+ *
+ */
+ public void setVersion(String version) {
+ _version = version;
+ }
+
+ /**
+ * Returns the generator value.
+ * <p>
+ * @return the generator value, <b>null</b> if none.
+ *
+ */
+ public String getValue() {
+ return _value;
+ }
+
+ /**
+ * Sets the generator value.
+ * <p>
+ * @param value the generator value, <b>null</b> if none.
+ *
+ */
+ public void setValue(String value) {
+ _value = value;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/marmotta/blob/00c22e7c/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/feed/atom/Link.java
----------------------------------------------------------------------
diff --git a/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/feed/atom/Link.java b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/feed/atom/Link.java
new file mode 100644
index 0000000..5a88cfa
--- /dev/null
+++ b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/feed/atom/Link.java
@@ -0,0 +1,224 @@
+/*
+ * 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.sun.syndication.feed.atom;
+
+import com.sun.syndication.feed.impl.ObjectBean;
+
+import java.io.Serializable;
+
+/**
+ * Bean for link elements of Atom feeds.
+ * <p>
+ * @author Alejandro Abdelnur
+ * @author Dave Johnson (updated for Atom 1.0)
+ */
+public class Link implements Cloneable,Serializable {
+
+ private ObjectBean _objBean;
+
+ private String _href;
+ private String _hrefResolved;
+ private String _rel = "alternate";
+ private String _type;
+ private String _hreflang;
+ private String _title;
+ private long _length;
+
+ /**
+ * Default constructor. All properties are set to <b>null</b>.
+ * <p>
+ *
+ */
+ public Link() {
+ _objBean = new ObjectBean(this.getClass(),this);
+ }
+
+ /**
+ * Creates a deep 'bean' clone of the object.
+ * <p>
+ * @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.
+ * <p>
+ * @param other he reference object with which to compare.
+ * @return <b>true</b> if 'this' object is equal to the 'other' object.
+ *
+ */
+ @Override
+ public boolean equals(Object other) {
+ return _objBean.equals(other);
+ }
+
+ /**
+ * Returns a hashcode value for the object.
+ * <p>
+ * It follows the contract defined by the Object hashCode() method.
+ * <p>
+ * @return the hashcode of the bean object.
+ *
+ */
+ @Override
+ public int hashCode() {
+ return _objBean.hashCode();
+ }
+
+ /**
+ * Returns the String representation for the object.
+ * <p>
+ * @return String representation for the object.
+ *
+ */
+ @Override
+ public String toString() {
+ return _objBean.toString();
+ }
+
+ /**
+ * Returns the link rel.
+ * <p>
+ * @return the link rel, <b>null</b> if none.
+ *
+ */
+ public String getRel() {
+ return _rel;
+ }
+
+ /**
+ * Sets the link rel.
+ * <p>
+ * @param rel the link rel,, <b>null</b> if none.
+ *
+ */
+ public void setRel(String rel) {
+ //TODO add check, ask P@ about the check
+ _rel = rel;
+ }
+
+ /**
+ * Returns the link type.
+ * <p>
+ * @return the link type, <b>null</b> if none.
+ *
+ */
+ public String getType() {
+ return _type;
+ }
+
+ /**
+ * Sets the link type.
+ * <p>
+ * @param type the link type, <b>null</b> if none.
+ *
+ */
+ public void setType(String type) {
+ _type = type;
+ }
+
+ /**
+ * Returns the link href.
+ * <p>
+ * @return the link href, <b>null</b> if none.
+ *
+ */
+ public String getHref() {
+ return _href;
+ }
+
+ /**
+ * Sets the link href.
+ * <p>
+ * @param href the link href, <b>null</b> if none.
+ *
+ */
+ public void setHref(String href) {
+ _href = href;
+ }
+
+ public void setHrefResolved(String hrefResolved) {
+ _hrefResolved = hrefResolved;
+ }
+
+ public String getHrefResolved() {
+ return _hrefResolved != null ? _hrefResolved : _href;
+ }
+
+ /**
+ * Returns the link title.
+ * <p>
+ * @return the link title, <b>null</b> if none.
+ *
+ */
+ public String getTitle() {
+ return _title;
+ }
+
+ /**
+ * Sets the link title.
+ * <p>
+ * @param title the link title, <b>null</b> if none.
+ *
+ */
+ public void setTitle(String title) {
+ _title = title;
+ }
+
+ /**
+ * Returns the hreflang
+ * <p>
+ * @return Returns the hreflang.
+ * @since Atom 1.0
+ */
+ public String getHreflang() {
+ return _hreflang;
+ }
+
+ /**
+ * Set the hreflang
+ * <p>
+ * @param hreflang The hreflang to set.
+ * @since Atom 1.0
+ */
+ public void setHreflang(String hreflang) {
+ _hreflang = hreflang;
+ }
+
+ /**
+ * Returns the length
+ * <p>
+ * @return Returns the length.
+ */
+ public long getLength() {
+ return _length;
+ }
+
+ /**
+ * Set the length
+ * <p>
+ * @param length The length to set.
+ */
+ public void setLength(long length) {
+ _length = length;
+ }
+}
http://git-wip-us.apache.org/repos/asf/marmotta/blob/00c22e7c/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/feed/atom/Person.java
----------------------------------------------------------------------
diff --git a/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/feed/atom/Person.java b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/feed/atom/Person.java
new file mode 100644
index 0000000..29f178f
--- /dev/null
+++ b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/feed/atom/Person.java
@@ -0,0 +1,220 @@
+/*
+ * 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.sun.syndication.feed.atom;
+
+import com.sun.syndication.feed.impl.ObjectBean;
+import com.sun.syndication.feed.module.Extendable;
+import com.sun.syndication.feed.module.Module;
+import com.sun.syndication.feed.module.impl.ModuleUtils;
+
+import java.io.Serializable;
+import java.util.List;
+import java.util.ArrayList;
+
+/**
+ * Bean for person elements of Atom feeds.
+ * <p>
+ * @author Alejandro Abdelnur
+ * @author Dave Johnson (updated for Atom 1.0)
+ */
+public class Person implements Cloneable,Serializable, Extendable
+{
+
+ private ObjectBean _objBean;
+
+ private String _name;
+ private String _uri; // since Atom 1.0 (was called url)
+ private String _uriResolved;
+ private String _email;
+ private List _modules;
+
+ /**
+ * Default constructor. All properties are set to <b>null</b>.
+ * <p>
+ *
+ */
+ public Person() {
+ _objBean = new ObjectBean(this.getClass(),this);
+ }
+
+ /**
+ * Creates a deep 'bean' clone of the object.
+ * <p>
+ * @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.
+ * <p>
+ * @param other he reference object with which to compare.
+ * @return <b>true</b> if 'this' object is equal to the 'other' object.
+ *
+ */
+ @Override
+ public boolean equals(Object other) {
+ return _objBean.equals(other);
+ }
+
+ /**
+ * Returns a hashcode value for the object.
+ * <p>
+ * It follows the contract defined by the Object hashCode() method.
+ * <p>
+ * @return the hashcode of the bean object.
+ *
+ */
+ @Override
+ public int hashCode() {
+ return _objBean.hashCode();
+ }
+
+ /**
+ * Returns the String representation for the object.
+ * <p>
+ * @return String representation for the object.
+ *
+ */
+ @Override
+ public String toString() {
+ return _objBean.toString();
+ }
+
+ /**
+ * Returns the person name.
+ * <p>
+ * @return the person name, <b>null</b> if none.
+ *
+ */
+ public String getName() {
+ return _name;
+ }
+
+ /**
+ * Sets the personname.
+ * <p>
+ * @param name the person name, <b>null</b> if none.
+ *
+ */
+ public void setName(String name) {
+ _name = name;
+ }
+
+ /**
+ * Returns the person URL (same as {@link #getUri()})
+ * <p>
+ * @return the person URL, <b>null</b> if none.
+ */
+ public String getUrl() {
+ return _uri;
+ }
+
+ /**
+ * Sets the person URL (same as {@link #setUri(java.lang.String)})
+ * <p>
+ * @param url the person URL, <b>null</b> if none.
+ */
+ public void setUrl(String url) {
+ _uri = url;
+ }
+
+ public void setUriResolved(String uriResolved) {
+ _uriResolved = uriResolved;
+ }
+
+ public String getUriResolved(String resolveURI) {
+ return _uriResolved != null ? _uriResolved : _uri;
+ }
+
+ /**
+ * Returns the person email.
+ * <p>
+ * @return the person email, <b>null</b> if none.
+ *
+ */
+ public String getEmail() {
+ return _email;
+ }
+
+ /**
+ * Sets the person email.
+ * <p>
+ * @param email the person email, <b>null</b> if none.
+ *
+ */
+ public void setEmail(String email) {
+ _email = email;
+ }
+
+ /**
+ * Returns the uri
+ * <p>
+ * @return Returns the uri.
+ * @since Atom 1.0
+ */
+ public String getUri() {
+ return _uri;
+ }
+
+ /**
+ * Set the uri
+ * <p>
+ * @param uri The uri to set.
+ * @since Atom 1.0
+ */
+ public void setUri(String uri) {
+ _uri = uri;
+ }
+
+ /**
+ * Returns the entry modules.
+ * <p>
+ * @return a list of ModuleImpl elements with the entry modules,
+ * an emtpy list if none.
+ *
+ */
+ public List getModules() {
+ return (_modules==null) ? (_modules=new ArrayList()) : _modules;
+ }
+
+ /**
+ * Sets the entry modules.
+ * <p>
+ * @param modules the list of ModuleImpl elements with the entry modules to set,
+ * an empty list or <b>null</b> if none.
+ *
+ */
+ public void setModules(List modules) {
+ _modules = modules;
+ }
+
+ /**
+ * Returns the module identified by a given URI.
+ * <p>
+ * @param uri the URI of the ModuleImpl.
+ * @return The module with the given URI, <b>null</b> if none.
+ */
+ public Module getModule(String uri) {
+ return ModuleUtils.getModule(_modules,uri);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/marmotta/blob/00c22e7c/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/feed/impl/BeanIntrospector.java
----------------------------------------------------------------------
diff --git a/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/feed/impl/BeanIntrospector.java b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/feed/impl/BeanIntrospector.java
new file mode 100644
index 0000000..dded484
--- /dev/null
+++ b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/feed/impl/BeanIntrospector.java
@@ -0,0 +1,123 @@
+/*
+ * 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.sun.syndication.feed.impl;
+
+import java.beans.IntrospectionException;
+import java.beans.Introspector;
+import java.beans.PropertyDescriptor;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.util.*;
+
+/**
+ * Obtains all property descriptors from a bean (interface or implementation).
+ * <p>
+ * The java.beans.Introspector does not process the interfaces hierarchy chain, this one does.
+ * <p>
+ * @author Alejandro Abdelnur
+ *
+ */
+public class BeanIntrospector {
+
+ private static final Map _introspected = new HashMap();
+
+ public static synchronized PropertyDescriptor[] getPropertyDescriptors(Class klass) throws IntrospectionException {
+ PropertyDescriptor[] descriptors = (PropertyDescriptor[]) _introspected.get(klass);
+ if (descriptors==null) {
+ descriptors = getPDs(klass);
+ _introspected.put(klass,descriptors);
+ }
+ return descriptors;
+ }
+
+ private static PropertyDescriptor[] getPDs(Class klass) throws IntrospectionException {
+ Method[] methods = klass.getMethods();
+ Map getters = getPDs(methods,false);
+ Map setters = getPDs(methods,true);
+ List pds = merge(getters,setters);
+ PropertyDescriptor[] array = new PropertyDescriptor[pds.size()];
+ pds.toArray(array);
+ return array;
+ }
+
+ private static final String SETTER = "set";
+ private static final String GETTER = "get";
+ private static final String BOOLEAN_GETTER = "is";
+
+ private static Map getPDs(Method[] methods,boolean setters) throws IntrospectionException {
+ Map pds = new HashMap();
+ for (int i=0;i<methods.length;i++) {
+ String pName = null;
+ PropertyDescriptor pDescriptor = null;
+ if ((methods[i].getModifiers()&Modifier.PUBLIC)!=0) {
+ if (setters) {
+ if (methods[i].getName().startsWith(SETTER) &&
+ methods[i].getReturnType()==void.class && methods[i].getParameterTypes().length==1) {
+ pName = Introspector.decapitalize(methods[i].getName().substring(3));
+ pDescriptor = new PropertyDescriptor(pName,null,methods[i]);
+ }
+ }
+ else {
+ if (methods[i].getName().startsWith(GETTER) &&
+ methods[i].getReturnType()!=void.class && methods[i].getParameterTypes().length==0) {
+ pName = Introspector.decapitalize(methods[i].getName().substring(3));
+ pDescriptor = new PropertyDescriptor(pName,methods[i],null);
+ }
+ else
+ if (methods[i].getName().startsWith(BOOLEAN_GETTER) &&
+ methods[i].getReturnType()==boolean.class && methods[i].getParameterTypes().length==0) {
+ pName = Introspector.decapitalize(methods[i].getName().substring(2));
+ pDescriptor = new PropertyDescriptor(pName,methods[i],null);
+ }
+ }
+ }
+ if (pName!=null) {
+ pds.put(pName,pDescriptor);
+ }
+ }
+ return pds;
+ }
+
+ private static List merge(Map getters,Map setters) throws IntrospectionException {
+ List props = new ArrayList();
+ Set processedProps = new HashSet();
+ Iterator gs = getters.keySet().iterator();
+ while (gs.hasNext()) {
+ String name = (String) gs.next();
+ PropertyDescriptor getter = (PropertyDescriptor) getters.get(name);
+ PropertyDescriptor setter = (PropertyDescriptor) setters.get(name);
+ if (setter!=null) {
+ processedProps.add(name);
+ PropertyDescriptor prop = new PropertyDescriptor(name,getter.getReadMethod(),setter.getWriteMethod());
+ props.add(prop);
+ }
+ else {
+ props.add(getter);
+ }
+ }
+ Set writeOnlyProps = new HashSet(setters.keySet());
+ writeOnlyProps.removeAll(processedProps);
+ Iterator ss = writeOnlyProps.iterator();
+ while (ss.hasNext()) {
+ String name = (String) ss.next();
+ PropertyDescriptor setter = (PropertyDescriptor) setters.get(name);
+ props.add(setter);
+ }
+ return props;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/marmotta/blob/00c22e7c/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/feed/impl/CloneableBean.java
----------------------------------------------------------------------
diff --git a/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/feed/impl/CloneableBean.java b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/feed/impl/CloneableBean.java
new file mode 100644
index 0000000..5e2051b
--- /dev/null
+++ b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/feed/impl/CloneableBean.java
@@ -0,0 +1,272 @@
+/*
+ * 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.sun.syndication.feed.impl;
+
+import java.beans.PropertyDescriptor;
+import java.io.Serializable;
+import java.lang.reflect.Array;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.util.*;
+
+/**
+ * Provides deep <b>Bean</b> clonning support.
+ * <p>
+ * It works on all read/write properties, recursively. It support all primitive types, Strings, Collections,
+ * Cloneable objects and multi-dimensional arrays of any of them.
+ * <p>
+ * @author Alejandro Abdelnur
+ *
+ */
+public class CloneableBean implements Serializable, Cloneable {
+
+ private static final Class[] NO_PARAMS_DEF = new Class[0];
+ private static final Object[] NO_PARAMS = new Object[0];
+
+ private Object _obj;
+ private Set _ignoreProperties;
+
+ /**
+ * Default constructor.
+ * <p>
+ * To be used by classes extending CloneableBean only.
+ * <p>
+ *
+ */
+ protected CloneableBean() {
+ _obj = this;
+ }
+
+ /**
+ * Creates a CloneableBean to be used in a delegation pattern.
+ * <p>
+ * For example:
+ * <p>
+ * <code>
+ * public class Foo implements Cloneable {
+ * private CloneableBean _cloneableBean;
+ *
+ * public Foo() {
+ * _cloneableBean = new CloneableBean(this);
+ * }
+ *
+ * public Object clone() throws CloneNotSupportedException {
+ * return _cloneableBean.beanClone();
+ * }
+ *
+ * }
+ * </code>
+ * <p>
+ * @param obj object bean to clone.
+ *
+ */
+ public CloneableBean(Object obj) {
+ this(obj,null);
+ }
+
+ /**
+ * Creates a CloneableBean to be used in a delegation pattern.
+ * <p>
+ * The property names in the ignoreProperties Set will not be copied into
+ * the cloned instance. This is useful for cases where the Bean has convenience
+ * properties (properties that are actually references to other properties or
+ * properties of properties). For example SyndFeed and SyndEntry beans have
+ * convenience properties, publishedDate, author, copyright and categories all
+ * of them mapped to properties in the DC Module.
+ * <p>
+ * @param obj object bean to clone.
+ * @param ignoreProperties properties to ignore when cloning.
+ *
+ */
+ public CloneableBean(Object obj,Set ignoreProperties) {
+ _obj = obj;
+ _ignoreProperties = (ignoreProperties!=null) ? ignoreProperties : Collections.EMPTY_SET;
+ }
+
+ /**
+ * Makes a deep bean clone of the object.
+ * <p>
+ * To be used by classes extending CloneableBean. Although it works also for classes using
+ * CloneableBean in a delegation pattern, for correctness those classes should use the
+ * @see #beanClone() beanClone method.
+ * <p>
+ * @return a clone of the object bean.
+ * @throws CloneNotSupportedException thrown if the object bean could not be cloned.
+ *
+ */
+ public Object clone() throws CloneNotSupportedException {
+ return beanClone();
+ }
+
+ /**
+ * Makes a deep bean clone of the object passed in the constructor.
+ * <p>
+ * To be used by classes using CloneableBean in a delegation pattern,
+ * @see #CloneableBean(Object) constructor.
+ *
+ * @return a clone of the object bean.
+ * @throws CloneNotSupportedException thrown if the object bean could not be cloned.
+ *
+ */
+ public Object beanClone() throws CloneNotSupportedException {
+ Object clonedBean;
+ try {
+ clonedBean = _obj.getClass().newInstance();
+ PropertyDescriptor[] pds = BeanIntrospector.getPropertyDescriptors(_obj.getClass());
+ if (pds!=null) {
+ for (int i=0;i<pds.length;i++) {
+ Method pReadMethod = pds[i].getReadMethod();
+ Method pWriteMethod = pds[i].getWriteMethod();
+ if (pReadMethod!=null && pWriteMethod!=null && // ensure it has getter and setter methods
+ !_ignoreProperties.contains(pds[i].getName()) && // is not in the list of properties to ignore
+ pReadMethod.getDeclaringClass()!=Object.class && // filter Object.class getter methods
+ pReadMethod.getParameterTypes().length==0) { // filter getter methods that take parameters
+ Object value = pReadMethod.invoke(_obj,NO_PARAMS);
+ if (value!=null) {
+ value = doClone(value);
+ pWriteMethod.invoke(clonedBean,new Object[]{value});
+ }
+ }
+ }
+ }
+ }
+ catch (CloneNotSupportedException cnsEx) {
+ throw cnsEx;
+ }
+ catch (Exception ex) {
+ System.out.println(ex);
+ ex.printStackTrace(System.out);
+ throw new CloneNotSupportedException("Cannot clone a "+_obj.getClass()+" object");
+ }
+ return clonedBean;
+ }
+
+ private Object doClone(Object value) throws Exception {
+ if (value!=null) {
+ Class vClass = value.getClass();
+ if (vClass.isArray()) {
+ value = cloneArray(value);
+ }
+ else
+ if (value instanceof Collection) {
+ value = cloneCollection((Collection)value);
+ }
+ else
+ if (value instanceof Map) {
+ value = cloneMap((Map)value);
+ }
+ else
+ if (isBasicType(vClass)) {
+ // NOTHING SPECIAL TO DO HERE, THEY ARE INMUTABLE
+ }
+ else
+ if (value instanceof Cloneable) {
+ Method cloneMethod = vClass.getMethod("clone",NO_PARAMS_DEF);
+ if (Modifier.isPublic(cloneMethod.getModifiers())) {
+ value = cloneMethod.invoke(value,NO_PARAMS);
+ }
+ else {
+ throw new CloneNotSupportedException("Cannot clone a "+value.getClass()+" object, clone() is not public");
+ }
+ }
+ else {
+ throw new CloneNotSupportedException("Cannot clone a "+vClass.getName()+" object");
+ }
+ }
+ return value;
+ }
+
+ private Object cloneArray(Object array) throws Exception {
+ Class elementClass = array.getClass().getComponentType();
+ int length = Array.getLength(array);
+ Object newArray = Array.newInstance(elementClass,length);
+ for (int i=0;i<length;i++) {
+ Object element = doClone(Array.get(array,i));
+ Array.set(newArray,i,element);
+ }
+ return newArray;
+ }
+
+ private Object cloneCollection(Collection collection) throws Exception {
+ Class mClass = collection.getClass();
+ Collection newColl = (Collection) mClass.newInstance();
+ Iterator i = collection.iterator();
+ while (i.hasNext()) {
+ Object element = doClone(i.next());
+ newColl.add(element);
+ }
+ return newColl;
+ }
+
+ private Object cloneMap(Map map) throws Exception {
+ Class mClass = map.getClass();
+ Map newMap = (Map) mClass.newInstance();
+ Iterator entries = map.entrySet().iterator();
+ while (entries.hasNext()) {
+ Map.Entry entry = (Map.Entry) entries.next();
+ Object key = doClone(entry.getKey());
+ Object value = doClone(entry.getValue());
+ newMap.put(key,value);
+ }
+ return newMap;
+ }
+
+ private static final Set BASIC_TYPES = new HashSet();
+
+ static {
+ BASIC_TYPES.add(Boolean.class);
+ BASIC_TYPES.add(Byte.class);
+ BASIC_TYPES.add(Character.class);
+ BASIC_TYPES.add(Double.class);
+ BASIC_TYPES.add(Float.class);
+ BASIC_TYPES.add(Integer.class);
+ BASIC_TYPES.add(Long.class);
+ BASIC_TYPES.add(Short.class);
+ BASIC_TYPES.add(String.class);
+ }
+
+ private static final Map CONSTRUCTOR_BASIC_TYPES = new HashMap();
+
+ static {
+ CONSTRUCTOR_BASIC_TYPES.put(Boolean.class,new Class[]{Boolean.TYPE});
+ CONSTRUCTOR_BASIC_TYPES.put(Byte.class,new Class[]{Byte.TYPE});
+ CONSTRUCTOR_BASIC_TYPES.put(Character.class,new Class[]{Character.TYPE});
+ CONSTRUCTOR_BASIC_TYPES.put(Double.class,new Class[]{Double.TYPE});
+ CONSTRUCTOR_BASIC_TYPES.put(Float.class,new Class[]{Float.TYPE});
+ CONSTRUCTOR_BASIC_TYPES.put(Integer.class,new Class[]{Integer.TYPE});
+ CONSTRUCTOR_BASIC_TYPES.put(Long.class,new Class[]{Long.TYPE});
+ CONSTRUCTOR_BASIC_TYPES.put(Short.class,new Class[]{Short.TYPE});
+ CONSTRUCTOR_BASIC_TYPES.put(String.class,new Class[]{String.class});
+ }
+
+ private boolean isBasicType(Class vClass) {
+ return BASIC_TYPES.contains(vClass);
+ }
+
+ // THIS IS NOT NEEDED, BASIC TYPES ARE INMUTABLE, TUCU 20040710
+ /**
+ private Object cloneBasicType(Object value) throws Exception {
+ Class pClass = value.getClass();
+ Class[] defType = (Class[]) CONSTRUCTOR_BASIC_TYPES.get(pClass);
+ Constructor cons = pClass.getDeclaredConstructor(defType);
+ value = cons.newInstance(new Object[]{value});
+ return value;
+ }
+ **/
+
+}
+
http://git-wip-us.apache.org/repos/asf/marmotta/blob/00c22e7c/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/feed/impl/CopyFromHelper.java
----------------------------------------------------------------------
diff --git a/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/feed/impl/CopyFromHelper.java b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/feed/impl/CopyFromHelper.java
new file mode 100644
index 0000000..f13a14a
--- /dev/null
+++ b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/feed/impl/CopyFromHelper.java
@@ -0,0 +1,169 @@
+/*
+ * 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.sun.syndication.feed.impl;
+
+import com.sun.syndication.feed.CopyFrom;
+import com.sun.syndication.feed.impl.BeanIntrospector;
+
+import java.beans.PropertyDescriptor;
+import java.lang.reflect.Array;
+import java.lang.reflect.Method;
+import java.util.*;
+
+/**
+ * @author Alejandro Abdelnur
+ */
+public class CopyFromHelper {
+ private static final Object[] NO_PARAMS = new Object[0];
+
+ private Class _beanInterfaceClass;
+ private Map _baseInterfaceMap; //ENTRIES(propertyName,interface.class)
+ private Map _baseImplMap; //ENTRIES(interface.class,implementation.class)
+
+ public CopyFromHelper(Class beanInterfaceClass,Map basePropInterfaceMap,Map basePropClassImplMap) {
+ _beanInterfaceClass = beanInterfaceClass;
+ _baseInterfaceMap = basePropInterfaceMap;
+ _baseImplMap = basePropClassImplMap;
+ }
+
+ public void copy(Object target,Object source) {
+ try {
+ PropertyDescriptor[] pds = BeanIntrospector.getPropertyDescriptors(_beanInterfaceClass);
+ if (pds!=null) {
+ for (int i=0;i<pds.length;i++) {
+ String propertyName = pds[i].getName();
+ Method pReadMethod = pds[i].getReadMethod();
+ Method pWriteMethod = pds[i].getWriteMethod();
+ if (pReadMethod!=null && pWriteMethod!=null && // ensure it has getter and setter methods
+ pReadMethod.getDeclaringClass()!=Object.class && // filter Object.class getter methods
+ pReadMethod.getParameterTypes().length==0 && // filter getter methods that take parameters
+ _baseInterfaceMap.containsKey(propertyName)) { // only copies properties defined as copyFrom-able
+ Object value = pReadMethod.invoke(source,NO_PARAMS);
+ if (value!=null) {
+ Class baseInterface = (Class) _baseInterfaceMap.get(propertyName);
+ value = doCopy(value,baseInterface);
+ pWriteMethod.invoke(target,new Object[]{value});
+ }
+ }
+ }
+ }
+ }
+ catch (Exception ex) {
+ throw new RuntimeException("Could not do a copyFrom "+ex, ex);
+ }
+ }
+
+ private CopyFrom createInstance(Class interfaceClass) throws Exception {
+ if( _baseImplMap.get(interfaceClass) == null ){
+ return null;
+ }
+ else {
+ return (CopyFrom) ((Class)_baseImplMap.get(interfaceClass)).newInstance();
+ }
+ }
+
+ private Object doCopy(Object value,Class baseInterface) throws Exception {
+ if (value!=null) {
+ Class vClass = value.getClass();
+ if (vClass.isArray()) {
+ value = doCopyArray(value,baseInterface);
+ }
+ else
+ if (value instanceof Collection) {
+ value = doCopyCollection((Collection)value,baseInterface);
+ }
+ else
+ if (value instanceof Map) {
+ value = doCopyMap((Map)value,baseInterface);
+ }
+ else
+ if (isBasicType(vClass)) {
+ // value = value; // nothing to do here
+ if (value instanceof Date) { // because Date it is not inmutable
+ value = ((Date)value).clone();
+ }
+ }
+ else { // it goes CopyFrom
+ if (value instanceof CopyFrom) {
+ CopyFrom source = (CopyFrom) value;
+ CopyFrom target = createInstance(source.getInterface());
+ target = target == null ? (CopyFrom) value.getClass().newInstance() : target;
+ target.copyFrom(source);
+ value = target;
+ }
+ else {
+ throw new Exception("unsupported class for 'copyFrom' "+value.getClass());
+ }
+ }
+ }
+ return value;
+ }
+
+ private Object doCopyArray(Object array,Class baseInterface) throws Exception {
+ Class elementClass = array.getClass().getComponentType();
+ int length = Array.getLength(array);
+ Object newArray = Array.newInstance(elementClass,length);
+ for (int i=0;i<length;i++) {
+ Object element = doCopy(Array.get(array,i),baseInterface);
+ Array.set(newArray,i,element);
+ }
+ return newArray;
+ }
+
+ private Object doCopyCollection(Collection collection,Class baseInterface) throws Exception {
+ // expecting SETs or LISTs only, going default implementation of them
+ Collection newColl = (collection instanceof Set) ? (Collection)new HashSet() : (Collection)new ArrayList();
+ Iterator i = collection.iterator();
+ while (i.hasNext()) {
+ Object element = doCopy(i.next(),baseInterface);
+ newColl.add(element);
+ }
+ return newColl;
+ }
+
+ private Object doCopyMap(Map map,Class baseInterface) throws Exception {
+ Map newMap = new HashMap();
+ Iterator entries = map.entrySet().iterator();
+ while (entries.hasNext()) {
+ Map.Entry entry = (Map.Entry) entries.next();
+ Object key = entry.getKey(); // we are assuming string KEYS
+ Object element = doCopy(entry.getValue(),baseInterface);
+ newMap.put(key,element);
+ }
+ return newMap;
+ }
+
+ private static final Set BASIC_TYPES = new HashSet();
+
+ static {
+ BASIC_TYPES.add(Boolean.class);
+ BASIC_TYPES.add(Byte.class);
+ BASIC_TYPES.add(Character.class);
+ BASIC_TYPES.add(Double.class);
+ BASIC_TYPES.add(Float.class);
+ BASIC_TYPES.add(Integer.class);
+ BASIC_TYPES.add(Long.class);
+ BASIC_TYPES.add(Short.class);
+ BASIC_TYPES.add(String.class);
+ BASIC_TYPES.add(Date.class);
+ }
+
+ private boolean isBasicType(Class vClass) {
+ return BASIC_TYPES.contains(vClass);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/marmotta/blob/00c22e7c/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/feed/impl/EqualsBean.java
----------------------------------------------------------------------
diff --git a/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/feed/impl/EqualsBean.java b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/feed/impl/EqualsBean.java
new file mode 100644
index 0000000..49f8186
--- /dev/null
+++ b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/feed/impl/EqualsBean.java
@@ -0,0 +1,231 @@
+/*
+ * 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.sun.syndication.feed.impl;
+
+import java.beans.PropertyDescriptor;
+import java.lang.reflect.Array;
+import java.lang.reflect.Method;
+import java.io.Serializable;
+
+/**
+ * Provides deep <b>Bean</b> equals() and hashCode() functionality for Java Beans.
+ * <p>
+ * It works on all read/write properties, recursively. It support all primitive types, Strings, Collections,
+ * bean-like objects and multi-dimensional arrays of any of them.
+ * <p>
+ * The hashcode is calculated by getting the hashcode of the Bean String representation.
+ * <p>
+ * @author Alejandro Abdelnur
+ *
+ */
+public class EqualsBean implements Serializable {
+
+ private static final Object[] NO_PARAMS = new Object[0];
+
+ private Class _beanClass;
+ private Object _obj;
+
+ /**
+ * Default constructor.
+ * <p>
+ * To be used by classes extending EqualsBean only.
+ * <p>
+ * @param beanClass the class/interface to be used for property scanning.
+ *
+ */
+ protected EqualsBean(Class beanClass) {
+ _beanClass = beanClass;
+ _obj = this;
+ }
+
+ /**
+ * Creates a EqualsBean to be used in a delegation pattern.
+ * <p>
+ * For example:
+ * <p>
+ * <code>
+ * public class Foo implements FooI {
+ * private EqualsBean _equalsBean;
+ *
+ * public Foo() {
+ * _equalsBean = new EqualsBean(FooI.class);
+ * }
+ *
+ * public boolean equals(Object obj) {
+ * return _equalsBean.beanEquals(obj);
+ * }
+ *
+ * public int hashCode() {
+ * return _equalsBean.beanHashCode();
+ * }
+ *
+ * }
+ * </code>
+ * <p>
+ * @param beanClass the class/interface to be used for property scanning.
+ * @param obj object bean to test equality.
+ *
+ */
+ public EqualsBean(Class beanClass,Object obj) {
+ if (!beanClass.isInstance(obj)) {
+ throw new IllegalArgumentException(obj.getClass()+" is not instance of "+beanClass);
+ }
+ _beanClass = beanClass;
+ _obj = obj;
+ }
+
+ /**
+ * Indicates whether some other object is "equal to" this object as defined by the Object equals() method.
+ * <p>
+ * To be used by classes extending EqualsBean. Although it works also for classes using
+ * EqualsBean in a delegation pattern, for correctness those classes should use the
+ * @see #beanEquals(Object) beanEquals method.
+ * <p>
+ * @param obj he reference object with which to compare.
+ * @return <b>true</b> if 'this' object is equal to the 'other' object.
+ *
+ */
+ public boolean equals(Object obj) {
+ return beanEquals(obj);
+ }
+
+ /**
+ * Indicates whether some other object is "equal to" the object passed in the constructor,
+ * as defined by the Object equals() method.
+ * <p>
+ * To be used by classes using EqualsBean in a delegation pattern,
+ * @see #EqualsBean(Class,Object) constructor.
+ * <p>
+ * @param obj he reference object with which to compare.
+ * @return <b>true</b> if the object passed in the constructor is equal to the 'obj' object.
+ *
+ */
+ public boolean beanEquals(Object obj) {
+ Object bean1 = _obj;
+ Object bean2 = obj;
+ boolean eq;
+ if (bean2==null) {
+ eq = false;
+ }
+ else
+ if (bean1==null && bean2==null) {
+ eq = true;
+ }
+ else
+ if (bean1==null || bean2==null) {
+ eq = false;
+ }
+ else {
+ if (!_beanClass.isInstance(bean2)) {
+ eq = false;
+ }
+ else {
+ eq = true;
+ try {
+ PropertyDescriptor[] pds = BeanIntrospector.getPropertyDescriptors(_beanClass);
+ if (pds!=null) {
+ for (int i = 0; eq && i<pds.length; i++) {
+ Method pReadMethod = pds[i].getReadMethod();
+ if (pReadMethod!=null && // ensure it has a getter method
+ pReadMethod.getDeclaringClass()!=Object.class && // filter Object.class getter methods
+ pReadMethod.getParameterTypes().length==0) { // filter getter methods that take parameters
+ Object value1 = pReadMethod.invoke(bean1, NO_PARAMS);
+ Object value2 = pReadMethod.invoke(bean2, NO_PARAMS);
+ eq = doEquals(value1, value2);
+ }
+ }
+ }
+ }
+ catch (Exception ex) {
+ throw new RuntimeException("Could not execute equals()", ex);
+ }
+ }
+ }
+ return eq;
+ }
+
+ /**
+ * Returns the hashcode for this object.
+ * <p>
+ * It follows the contract defined by the Object hashCode() method.
+ * <p>
+ * The hashcode is calculated by getting the hashcode of the Bean String representation.
+ * <p>
+ * To be used by classes extending EqualsBean. Although it works also for classes using
+ * EqualsBean in a delegation pattern, for correctness those classes should use the
+ * @see #beanHashCode() beanHashCode method.
+ * <p>
+ * @return the hashcode of the bean object.
+ *
+ */
+ public int hashCode() {
+ return beanHashCode();
+ }
+
+ /**
+ * Returns the hashcode for the object passed in the constructor.
+ * <p>
+ * It follows the contract defined by the Object hashCode() method.
+ * <p>
+ * The hashcode is calculated by getting the hashcode of the Bean String representation.
+ * <p>
+ * To be used by classes using EqualsBean in a delegation pattern,
+ * @see #EqualsBean(Class,Object) constructor.
+ * <p>
+ * @return the hashcode of the bean object.
+ *
+ */
+ public int beanHashCode() {
+ return _obj.toString().hashCode();
+ }
+
+
+ private boolean doEquals(Object obj1, Object obj2) {
+ boolean eq = obj1==obj2;
+ if (!eq && obj1!=null && obj2!=null) {
+ Class classObj1 = obj1.getClass();
+ Class classObj2 = obj2.getClass();
+ if (classObj1.isArray() && classObj2.isArray()) {
+ eq = equalsArray(obj1, obj2);
+ }
+ else {
+ eq = obj1.equals(obj2);
+ }
+ }
+ return eq;
+ }
+
+ private boolean equalsArray(Object array1, Object array2) {
+ boolean eq;
+ int length1 = Array.getLength(array1);
+ int length2 = Array.getLength(array2);
+ if (length1==length2) {
+ eq = true;
+ for (int i = 0; eq && i<length1; i++) {
+ Object e1 = Array.get(array1, i);
+ Object e2 = Array.get(array2, i);
+ eq = doEquals(e1, e2);
+ }
+ }
+ else {
+ eq = false;
+ }
+ return eq;
+ }
+
+}
+