All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.apache.wink.common.model.rss.RssItem Maven / Gradle / Ivy

The newest version!
/*******************************************************************************
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you 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.
 *  
 *******************************************************************************/
//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-456 
// See http://java.sun.com/xml/jaxb 
// Any modifications to this file will be lost upon recompilation of the source schema. 
// Generated on: 2009.07.20 at 10:55:05 AM IST 
//
package org.apache.wink.common.model.rss;

import java.util.ArrayList;
import java.util.List;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAnyElement;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlSchemaType;
import javax.xml.bind.annotation.XmlType;

import org.apache.wink.common.model.synd.SyndCategory;
import org.apache.wink.common.model.synd.SyndEntry;
import org.apache.wink.common.model.synd.SyndLink;
import org.apache.wink.common.model.synd.SyndPerson;
import org.apache.wink.common.model.synd.SyndText;
import org.apache.wink.common.model.synd.SyndTextType;

/**
 * 

* Java class for "item" element of RSS 2.0 Specification. *

* The following schema fragment specifies the expected content contained within * this class. * *

 * <complexType name="rssItem">
 *   <complexContent>
 *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
 *       <sequence>
 *         <element name="title" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
 *         <element name="link" type="{http://www.w3.org/2001/XMLSchema}anyURI" minOccurs="0"/>
 *         <element name="description" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
 *         <element name="author" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
 *         <element name="category" type="{}rssCategory" maxOccurs="unbounded" minOccurs="0"/>
 *         <element name="comments" type="{http://www.w3.org/2001/XMLSchema}anyURI" minOccurs="0"/>
 *         <element name="enclosure" type="{}rssEnclosure" minOccurs="0"/>
 *         <element name="guid" type="{}rssGuid" minOccurs="0"/>
 *         <element name="pubDate" type="{http://www.w3.org/2001/XMLSchema}string"/>
 *         <element name="source" type="{}rssSource" minOccurs="0"/>
 *         <any/>
 *       </sequence>
 *     </restriction>
 *   </complexContent>
 * </complexType>
 * 
* *

Elements of <item>

*

* A channel may contain any number of <item>s. An item may represent a * "story" -- much like a story in a newspaper or magazine; if so its * description is a synopsis of the story, and the link points to the full * story. An item may also be complete in itself, if so, the description * contains the text (entity-encoded HTML is allowed; see examples), and the * link and title may be omitted. All elements of an item are optional, however * at least one of title or description must be present. *

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
ElementDescriptionExample
titleThe title of the item.Venice Film Festival Tries to Quit Sinking
linkThe URL of the item.http://nytimes.com/2004/12/07FEST.html
descriptionThe item synopsis.<description>Some of the most heated chatter at the Venice Film * Festival this week was about the way that the arrival of the stars at the * Palazzo del Cinema was being staged.</description>
authorEmail address of the author of the item. For newspapers and magazines * syndicating via RSS, the author is the person who wrote the article that the * <item> describes. For collaborative weblogs, the author of the item * might be different from the managing editor or webmaster. For a weblog * authored by a single individual it would make sense to omit the * <author> element.<author>[email protected] (Lawyer Boyer)</author>
categoryIncludes the item in one or more categories. More * {@linkplain RssCategory here}.
commentsURL of a page for comments relating to the item. More here..<comments>http://ekzemplo.com/entry/4403/comments</comments>
enclosureDescribes a media object that is attached to the item. More * {@linkplain RssEnclosure here}.
guidA string that uniquely identifies the item. More {@linkplain RssGuid * here}.
pubDateIndicates when the item was published. If it's a date in the future, * aggregators may choose to not display the item until that date.<pubDate>Sun, 19 May 2002 15:21:36 GMT</pubDate>
sourceThe RSS channel that the item came from. More {@linkplain RssSource here} * .
*/ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "rssItem", propOrder = {}) public class RssItem { protected String title; @XmlSchemaType(name = "anyURI") protected String link; protected String description; protected String author; protected List category; @XmlSchemaType(name = "anyURI") protected String comments; protected RssEnclosure enclosure; protected RssGuid guid; @XmlElement(required = true) protected String pubDate; protected RssSource source; @XmlAnyElement(lax = true) protected List any; /** * Creates an RssItem object */ public RssItem() { } /** * Creates an RssItem object out of a SyndEntry object. Used for mapping * Syndication Object Model into RSS. * * @param syndEntry the SyndEntry object which has to be mapped into an * RssItem object. */ public RssItem(SyndEntry syndEntry) { if (syndEntry.getTitle() != null && syndEntry.getTitle().getValue() != null) { setTitle(syndEntry.getTitle().getValue()); } SyndLink link = syndEntry.getLink("alternate"); //$NON-NLS-1$ if (link != null && link.getHref() != null) { setLink(link.getHref()); } if (syndEntry.getSummary() != null && syndEntry.getSummary().getValue() != null) { setDescription(syndEntry.getSummary().getValue()); } if (syndEntry.getAuthors().size() > 0) { SyndPerson syndAuthor = syndEntry.getAuthors().get(0); if (syndAuthor.getEmail() != null) { setAuthor(syndAuthor.getEmail()); } } getCategories().clear(); for (SyndCategory syndCategory : syndEntry.getCategories()) { getCategories().add(new RssCategory(syndCategory)); } link = syndEntry.getLink("enclosure"); //$NON-NLS-1$ if (link != null) { setEnclosure(new RssEnclosure(link)); } if (syndEntry.getId() != null) { RssGuid rssGuid = new RssGuid(); rssGuid.setContent(syndEntry.getId()); setGuid(rssGuid); } if (syndEntry.getPublished() != null) { setPubDate(RssChannel.convertJavaDateToRssDate(syndEntry.getPublished())); } } /** * Maps an RssItem object into a SyndEntry object. Used for mapping RSS into * Syndication Object Model. * * @param syndEntry the SyndEntry object into which the given RssItem object * has to be mapped into * @return the SyndEntry object into which the given RssItem object has been * mapped into */ public SyndEntry toSynd(SyndEntry syndEntry) { if (syndEntry == null) { return syndEntry; } if (getTitle() != null) { syndEntry.setTitle(new SyndText(getTitle(), SyndTextType.text)); } if (getLink() != null) { SyndLink syndLink = new SyndLink(); syndLink.setHref(getLink()); syndLink.setRel("alternate"); //$NON-NLS-1$ syndEntry.getLinks().add(syndLink); } if (getDescription() != null) { syndEntry.setSummary(new SyndText(getDescription())); } if (getAuthor() != null) { SyndPerson syndAuthor = new SyndPerson(); String authorEmail = getAuthor(); syndAuthor.setEmail(authorEmail); syndAuthor.setName(authorEmail.substring(0, authorEmail.indexOf("@"))); //$NON-NLS-1$ syndEntry.getAuthors().add(syndAuthor); } syndEntry.getCategories().clear(); for (RssCategory rssCategory : getCategories()) { SyndCategory syndCategory = new SyndCategory(); syndCategory = rssCategory.toSynd(syndCategory); syndEntry.getCategories().add(syndCategory); } if (getEnclosure() != null) { SyndLink syndEnclosureLink = new SyndLink(); syndEnclosureLink = getEnclosure().toSynd(syndEnclosureLink); syndEntry.getLinks().add(syndEnclosureLink); } if (getGuid() != null) { syndEntry.setId(getGuid().getContent()); } if (getPubDate() != null) { syndEntry.setPublished(RssChannel.convertRssDateToJavaDate(getPubDate())); } return syndEntry; } /** * Gets the value of the title property. * * @return possible object is {@link String } */ public String getTitle() { return title; } /** * Sets the value of the title property. * * @param value allowed object is {@link String } */ public void setTitle(String value) { this.title = value; } /** * Gets the value of the link property. * * @return possible object is {@link String } */ public String getLink() { return link; } /** * Sets the value of the link property. * * @param value allowed object is {@link String } */ public void setLink(String value) { this.link = value; } /** * Gets the value of the description property. * * @return possible object is {@link String } */ public String getDescription() { return description; } /** * Sets the value of the description property. * * @param value allowed object is {@link String } */ public void setDescription(String value) { this.description = value; } /** * Gets the value of the author property. * * @return possible object is {@link String } */ public String getAuthor() { return author; } /** * Sets the value of the author property. * * @param value allowed object is {@link String } */ public void setAuthor(String value) { this.author = value; } /** * Gets the value of the category property. *

* This accessor method returns a reference to the live list, not a * snapshot. Therefore any modification you make to the returned list will * be present inside the JAXB object. This is why there is not a * set method for the category property. *

* For example, to add a new item, do as follows: * *

     * getCategories().add(newItem);
     * 
*

* Objects of the following type(s) are allowed in the list * {@link RssCategory } */ public List getCategories() { if (category == null) { category = new ArrayList(); } return this.category; } /** * Gets the value of the comments property. * * @return possible object is {@link String } */ public String getComments() { return comments; } /** * Sets the value of the comments property. * * @param value allowed object is {@link String } */ public void setComments(String value) { this.comments = value; } /** * Gets the value of the enclosure property. * * @return possible object is {@link RssEnclosure } */ public RssEnclosure getEnclosure() { return enclosure; } /** * Sets the value of the enclosure property. * * @param value allowed object is {@link RssEnclosure } */ public void setEnclosure(RssEnclosure value) { this.enclosure = value; } /** * Gets the value of the guid property. * * @return possible object is {@link RssGuid } */ public RssGuid getGuid() { return guid; } /** * Sets the value of the guid property. * * @param value allowed object is {@link RssGuid } */ public void setGuid(RssGuid value) { this.guid = value; } /** * Gets the value of the pubDate property. * * @return possible object is {@link String } */ public String getPubDate() { return pubDate; } /** * Sets the value of the pubDate property. * * @param value allowed object is {@link String } */ public void setPubDate(String value) { this.pubDate = value; } /** * Gets the value of the source property. * * @return possible object is {@link RssSource } */ public RssSource getSource() { return source; } /** * Sets the value of the source property. * * @param value allowed object is {@link RssSource } */ public void setSource(RssSource value) { this.source = value; } /** * Gets the value of the any property. *

* This accessor method returns a reference to the live list, not a * snapshot. Therefore any modification you make to the returned list will * be present inside the JAXB object. This is why there is not a * set method for the any property. *

* For example, to add a new item, do as follows: * *

     * getAny().add(newItem);
     * 
*

* Objects of the following type(s) are allowed in the list {@link Object } */ public List getAny() { if (any == null) { any = new ArrayList(); } return this.any; } }