📄 item.java
字号:
package cn.pfc.ywt.writer;
import java.util.ArrayList;
import java.util.Date;
/**
* <p>
* Name: Item.java
*
* <p>
* Title: 频道类中的项目类
*
* <p>
* Description: 一个频道可以包含许多项目(item)节点。<br>
* 一个项目可以代表一个故事——比如说一份报纸或杂志上的故事,<br>
* 如果是这样的话,那么项目的描述则是故事的概要,项目的链接则指向整个故事的存放位置。<br>
* 项目的所有节点都是可选的,但是至少要包含至少一个标题(title)和描述 (description)。
*
* <p>
* Copyright: Copyright (c) 2007
*
* <p>
* Company: 北大方正软件技术学院实训基地
*
* <p>
* Modified: 2007年12月22日
*
* @author 杨文通
* @version 1.0
*/
public class Item extends RssElement {
private String title;// item的标题
private String link;// item的URL
private String description;// item概要
private String author;// 作者的email地址
private ArrayList<Category> categories = new ArrayList<Category>();// item可以包含在一个或多个分类中
private String comments;// 与item相关的评论的地址
private Enclosure enclosure;// 附加的媒体对象
private String guid;// 可以唯一确定item的字符串
private String pubDate;// item发布的时间 Sun, 19 May 2002 15:21:36 GMT
private Source source;// rss频道来源 Quotes of the Day
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getGuid() {
return guid;
}
public void setGuid(String guid) {
this.guid = guid;
}
public String getLink() {
return link;
}
public void setLink(String link) {
this.link = link;
}
public String getPubDate() {
return pubDate;
}
public void setPubDate(String pubDate) {
this.pubDate = pubDate;
}
public void setPubDate(Date date){
this.pubDate = this.getDateAsString(date);
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public ArrayList<Category> getCategories() {
return categories;
}
public String getAuthor() {
return author;
}
public void setAuthor(String author) {
this.author = author;
}
public String getComments() {
return comments;
}
public void setComments(String comments) {
this.comments = comments;
}
public Enclosure getEnclosure() {
return enclosure;
}
public void setEnclosure(Enclosure enclosure) {
this.enclosure = enclosure;
}
public Source getSource() {
return source;
}
public void setSource(Source source) {
this.source = source;
}
public void setCategories(ArrayList<Category> categories) {
this.categories = categories;
}
public Item(String title, String link, String description) {
super();
this.title = title;
this.link = link;
this.description = description;
}
public Item(String title, String description) {
super();
this.title = title;
this.description = description;
}
public Item() {
super();
}
public void addCategory(Category category) {
this.categories.add(category);
}
@Override
public String toString() {
StringBuilder str = new StringBuilder(32);
str.append("<item>");
str.append("<title><![CDATA[" + strNotNull(this.title) + "]]></title>");
str.append("<description><![CDATA[" + this.description
+ "]]></description>");
if (this.link.trim().length() > 0) {
str.append("<link>" + this.link + "</link>");
}
if (strNotNull(this.pubDate).length() > 0) {
str.append("<pubDate>" + this.pubDate + "</pubDate>");
}
if (strNotNull(this.guid).trim().length() > 0) {
str.append("<guid>" + this.guid + "</guid>");
}
if (strNotNull(comments).length() > 0) {
str.append("<comments>" + comments + "</comments>");
}
if (strNotNull(author).length() > 0) {
str.append("<author>" + author + "</author>");
}
for (Category category : this.categories) {
str.append(category);
}
if (enclosure != null) {
str.append(enclosure);
}
if (source != null) {
str.append(source);
}
str.append("</item>");
return str.toString();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -