/** * Copyright 1999-2009 The Pegadi 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 org.pegadi.model; import java.io.Serializable; import java.util.Date; /** * A class for publications * * @version $Revision$, $Date$ */ public class Publication implements Serializable, Comparable { /** * The ID of this publication */ private Integer id; /** * The name of this publication */ private String name; /** * The description of this publication */ private String description; /** * The release date of this publication */ private Date releaseDate; /** * The date of printing of this publication */ private Date printDate; /** * The deadline of this publication */ private Date deadlineText; /** * The number of this publication in the current year */ private int number; /** * Constructor taking an ID as an argument * * @param id the ID */ public Publication(int id) { setId(id); } /** * Empty constructor */ public Publication() { setId(0); } /** * Constructor taking an ID and a name as an argument * * @param id the ID * @param name the name */ public Publication(Integer id, String name) { this.id = id; this.name = name; } /** * Returns the ID of this publication. * * @return the ID */ public Integer getId() { return id; } /** * Sets the ID of this publication. * * @param id the ID */ public void setId(Integer id) { this.id = id; } /** * Gets the name of the publication * * @return the name */ public String getName() { return name; } /** * Need a toString-method for some GUI components. (comboboxes, eg.) * * @return a string representation */ public String toString() { return this.getName(); } /** * Checks this publication to another object for equality * * @param obj the object * @return <code>true</code> if equal */ public boolean equals(Object obj) { if (obj instanceof Publication) { Publication object = (Publication) obj; return this.getId().equals(object.getId()); } else { return false; } } /** * Compares this publication to another object * * @param o1 the object to compare to * @return positive if larger/after */ public int compareTo(Object o1) { Publication publicationobj = (Publication) o1; return this.getName().compareTo(publicationobj.getName()); } /** * Sets the name of the publication * * @param name the name */ public void setName(String name) { this.name = name; } /** * Gets the release date: the date the publication hits the streets. * * @return the release date */ public Date getReleaseDate() { return releaseDate; } /** * Sets the release date: the date the publication hits the streets. * * @param date the release date */ public void setReleaseDate(Date date) { releaseDate = date; } /** * Gets the print-date: the date the publication must be delivered to * the publisher. * * @return the print date */ public Date getPrintDate() { return printDate; } /** * Sets the print-date: the date the publication must be deliverent to * the publisher. * * @param date the print date */ public void setPrintDate(Date date) { printDate = date; } /** * Gets the description of this publication * * @return the description */ public String getDescription() { return description; } /** * Sets the description of this publication * * @param desc the description */ public void setDescription(String desc) { description = desc; } /** * Returns the deadlineText (a date) for this publication * * @return the deadline */ public Date getDeadlineText() { return deadlineText; } /** * Sets the description of this publication * * @param dead the deadline of text */ public void setDeadlineText(Date dead) { deadlineText = dead; } /** * Returns the number of this publication in the current year * * @return the number */ public int getNumber() { return number; } /** * Sets the number of this publication in the current year * * @param number the number */ public void setNumber(int number) { this.number = number; } /** * Clone this object. Will perform a deep clone. * * @return The clone. */ public Object clone() { Publication clone = new Publication(this.id); clone.deadlineText = deadlineText == null ? null : (Date) deadlineText.clone(); clone.description = description == null ? null : description; clone.name = name == null ? null : name; clone.printDate = printDate == null ? null : (Date) printDate.clone(); clone.releaseDate = releaseDate == null ? null : (Date) releaseDate.clone(); clone.number = number; return clone; } }