⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 blog.java

📁 Ajax开发精要——概念、案例与框架.很适合初学者学习。
💻 JAVA
字号:
package com.ajaxlab.ajax;
import java.util.List;
import java.util.ArrayList;
import org.jdom.*;

public class Blog {
	private String id = "";
	private String title = "";
	private String catalogue = "";
	private String publishdate = "";
	private String content = "";
	private String entry = "";
	private String track = "";
	private List images = null;
	private int commenttotal = 0;
	private int referencetotal = 0;
	private List comments = null;
	private List references = null;
	
	public Blog() {
		
	}
	public Blog(Element element) {
		this.setId(element.getAttributeValue("id"));
		this.setTitle(element.getChildText("title"));
		this.setCatalogue(element.getChildText("catalogue"));
		this.setPublishdate(element.getChildText("publishdate"));
		this.setContent(element.getChildText("content"));
		this.setEntry(element.getChildText("entry"));
		this.setTrack(element.getChildText("track"));
		this.images = new ArrayList();
		List iList = element.getChild("images").getChildren();
		if((iList!=null)&&(iList.size()!=0)) {
			Element[] elements = (Element[])iList.toArray(new Element[0]);
			for(int i=0;i<elements.length;i++) {
				BlogImage blogImage = new BlogImage();
				blogImage.setImageName(elements[i].getChildText("imageName"));
				blogImage.setUrl(elements[i].getChildText("url"));
				this.images.add(blogImage);
			}
		}
		this.setCommenttotal(Integer.parseInt(element.getChildText("commenttotal")));
		this.setReferencetotal(Integer.parseInt(element.getChildText("referencetotal")));
	}
	
	public void initialBlog(Element element) {
		this.setId(element.getAttributeValue("id"));
		this.setTitle(element.getChildText("title"));
		this.setCatalogue(element.getChildText("catalogue"));
		this.setPublishdate(element.getChildText("publishdate"));
		this.setContent(element.getChildText("content"));
		this.setEntry(element.getChildText("entry"));
		this.setTrack(element.getChildText("track"));
		this.images = new ArrayList();
		List iList = element.getChild("images").getChildren();
		if((iList!=null)&&(iList.size()!=0)) {
			Element[] elements = (Element[])iList.toArray(new Element[0]);
			for(int i=0;i<elements.length;i++) {
				BlogImage blogImage = new BlogImage();
				blogImage.setImageName(elements[i].getChildText("imageName"));
				blogImage.setUrl(elements[i].getChildText("url"));
				this.images.add(blogImage);
			}
		}
		this.setCommenttotal(Integer.parseInt(element.getChildText("commenttotal")));
		this.setReferencetotal(Integer.parseInt(element.getChildText("referencetotal")));
		this.comments = new ArrayList();
		List cList = element.getChild("comments").getChildren();
		if((cList!=null)&&(cList.size()!=0)) {
			Element[] elements = (Element[])cList.toArray(new Element[0]);
			for(int i=0;i<elements.length;i++) {
				BlogComment comment = new BlogComment();
				comment.setAuthor(elements[i].getChildText("author"));
				comment.setCommentdate(elements[i].getChildText("commentdate"));
				comment.setBlogurl(elements[i].getChildText("blogurl"));
				comment.setEmail(elements[i].getChildText("email"));
				comment.setCommentcontent(elements[i].getChildText("commentcontent"));
				this.comments.add(comment);
			}
		}
		this.references = new ArrayList();
		List rList = element.getChild("references").getChildren();
		if((rList!=null)&&(rList.size()!=0)) {
			Element[] elements = (Element[])rList.toArray(new Element[0]);
			for(int i=0;i<elements.length;i++) {
				BlogReference reference = new BlogReference();
				reference.setRefername(elements[i].getChildText("refername"));
				reference.setReferurl(elements[i].getChildText("referurl"));
				this.references.add(reference);
			}
		}		
	}
	public String getId() {
		return this.id;
	}
	public void setId(String id) {
		this.id = id;
	}
	public String getTitle() {
		return this.title;
	}
	public void setTitle(String title) {
		this.title = title;
	}
	public String getCatalogue() {
		return this.catalogue;
	}
	public void setCatalogue(String catalogue) {
		this.catalogue = catalogue;
	}
	public String getPublishdate() {
		return this.publishdate;
	}
	public void setPublishdate(String publishdate) {
		this.publishdate = publishdate;
	}
	public String getContent() {
		return this.content;
	}
	public void setContent(String content) {
		this.content = content;
	}
	public String getEntry() {
		return this.entry;
	}
	public void setEntry(String entry) {
		this.entry = entry;
	}
	public String getTrack() {
		return this.track;
	}
	public void setTrack(String track) {
		this.track = track;
	}
	public List getImages() {
		return this.images;
	}
	public void addImage(BlogImage image) {
		if(this.images==null) this.images = new ArrayList();
		this.images.add(image);
	}
	public int getCommenttotal() {
		return this.commenttotal;
	}
	public void setCommenttotal(int commenttotal) {
		this.commenttotal = commenttotal;
	}
	public int getReferencetotal() {
		return this.referencetotal;
	}
	public void setReferencetotal(int referencetotal) {
		this.referencetotal = referencetotal;
	}
	public List getComments() {
		return this.comments;
	}
	public void addComment(BlogComment comment) {
		if(this.comments==null) this.comments = new ArrayList();
		this.comments.add(comment);
	}
	public List getReferences() {
		return this.references;
	}
	public void addRererence(BlogReference reference) {
		if(this.references==null) this.references = new ArrayList();
		this.references.add(reference);
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -