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

📄 booknews.java

📁 beginJsp2.0外文书籍源代码
💻 JAVA
字号:
package com.wrox.publish.om;import java.sql.Timestamp;import org.apache.struts.validator.ValidatorForm;/** * JavaBean encapsulating a single news item for a book. This class * has a natural sorting order which is by publishing date descending. * It extends ValidatorForm for easy population and validation within  * the Struts framework. */public class BookNews extends ValidatorForm implements Comparable {    private long id;    private Book book;    private String title;    private String body;    private String user;    private Timestamp published = new Timestamp(System.currentTimeMillis());        /**     * Getter for property id (the primary key).     * @return Value of property id.     */    public long getId() {        return this.id;    }        /**     * Setter for property id (the primary key).     * @param id New value of property id.     */    public void setId(long id) {        this.id = id;    }        /**     * Getter for the book the news item is associated with.     * @return The Book object.     */    public Book getBook() {        return this.book;    }        /**     * Setter for the book the news item is associated with.     * @param book The new Book association for this item.     */    public void setBook(Book book) {        this.book = book;    }        /**     * Getter for the news item title.     * @return The title.     */    public String getTitle() {        return this.title;    }        /**     * Setter for the news item title.     * @param title The new title.     */    public void setTitle(String title) {        this.title = title;    }    /**     * Retrieves the item's author.     * @return The user who authored the news item.     */    public String getUser() {        return this.user;    }        /**     * Sets the item author.     * @param user The user who authored the new news item.     */    public void setUser(String user) {        this.user = user;    }        /**     * Getter for the body text of this news item.     * @return The body as a String.     */    public String getBody() {        return this.body;    }        /**     * Setter for the body text of this news item.     * @param body The new body.     */    public void setBody(String body) {        this.body = body;    }        /**     * When the news item was first published.     * @return The publication date and time as a Timestamp.     */    public Timestamp getPublished() {        return this.published;    }        /**     * Sets when the news item was first published. This property defaults     * to the current date and time for new BookNews objects.     * @param published The new publication Timestamp.     */    public void setPublished(Timestamp published) {        this.published = published;    }       /**     * Compares this BookNews item to the given Object, which must     * also be a BookNews item.     * @param o the Object to be compared.     * @return a negative integer, zero, or a positive integer as this object     * is less than, equal to, or greater than the specified object.     */    public int compareTo(Object o) {        return compareTo((BookNews)o);    }        /**     * Compares this BookNews item to the given item.     * @param that The BookNews to be compared.     * @return a negative integer, zero, or a positive integer as this object     * is less than, equal to, or greater than the specified object.     */        public int compareTo(BookNews that) {        int cf;        if (this.published == null) {            cf = (that.published == null) ? 0 : 1;        } else if (that.published == null) {            cf = -1;        } else {            cf = -this.published.compareTo(that.published);        }        if (cf == 0 && this.id != that.id) {            cf = (this.id > that.id) ? -1 : 0;        }        return cf;    }        /**      * Compares this BookNews item to the given Object for equality.     * @param o The object to compare with.     * @return <code>true</code> if the object is also a BookNews item,      *  and has the same primary key (id).     */        public boolean equals(Object o) {        return o instanceof BookNews && equals((BookNews)o);    }        /**      * Compares this BookNews item to the given item for equality.     * @param that The BookNews to compare with.     * @return <code>true</code> if the item has the same primary key (id).     */        public boolean equals(BookNews that) {        return this.id == that.id;    }        /**     * Returns a hash code consistent with equals().     * @return The hash code.     */    public int hashCode() {        return (int)id;    }        /**     * Returns a String representation which is mainly useful for     * debugging purposes.     * @return A String representation of this BookNews item.     */        public String toString() {        return "[" + super.toString() + " " +        "id=" + id + " book=" + book + "title=" + title + "]";    }}

⌨️ 快捷键说明

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