/**
* 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;
/**
* A class describing types of articles.
*
* @author Jørgen Binningsbø <jb@underdusken.no>
*/
public class ArticleType implements Serializable, Comparable {
/**
* The ID of this articleType
*/
private Integer id;
/**
* The name of this Article-type
*/
private String name;
/**
* The description of this article-type
*/
private String description;
/**
* The location of the template file for this article type.
* Location is relative to the xml root folder.
* example: templates/fullArtikkel.template
*/
private String template;
/**
* The root tag name for this article type.
* example: fullArtikkel
*/
private String tagname;
/**
* Empty constructor
*/
public ArticleType() {
}
/**
* Constructor taking an id as the argumeent
*
* @param id the id of the article type
*/
public ArticleType(Integer id) {
this.id = id;
}
/**
* Constructor taking an ID, a name and a description as arguments
*
* @param id the id
* @param name the name
* @param description the description
*/
public ArticleType(Integer id, String name, String description) {
this.id = id;
this.name = name;
this.description = description;
}
/**
* Returns the ID of this ArticleType
*
* @return the ID
*/
public Integer getId() {
return id;
}
/**
* Sets the ID of this ArticleType
*
* @param id the id
*/
public void setId(Integer id) {
this.id = id;
}
/**
* Sets the name of this article-type
*
* @param name the name of this article type
*/
public void setName(String name) {
this.name = name;
}
/**
* Returns the name of this ArticleType
*
* @return the name
*/
public String getName() {
return name;
}
/**
* Returns the description of this ArticleType
*
* @return the description
*/
public String getDescription() {
return description;
}
/**
* Sets the description of this article type
*
* @param description the description of this article type
*/
public void setDescription(String description) {
this.description = description;
}
/**
* @return Returns the tagname.
*/
public String getTagname() {
return tagname;
}
/**
* @param tagname The tagname to set.
*/
public void setTagname(String tagname) {
this.tagname = tagname;
}
/**
* @return Returns the template.
*/
public String getTemplate() {
return template;
}
/**
* @param template The template to set.
*/
public void setTemplate(String template) {
this.template = template;
}
/**
* Checks if this instance is equal to another object.
* ArticleType's should be equal if their ID is equal.
*
* @param obj an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean equals(Object obj) {
if (obj instanceof ArticleType) {
ArticleType arttyp = (ArticleType) obj;
return this.id.equals(arttyp.getId());
} else {
return false;
}
}
/**
* Returns a string representation of this ArticleType by calling getName()
*
* @return the string representation
*/
public String toString() {
return this.getName();
}
/**
* Compares this instance of ArticleType with another Object.
*
* @param o1 an <code>Object</code> value
* @return an <code>int</code> value
*/
public int compareTo(Object o1) {
if (o1 instanceof ArticleType) {
ArticleType artType1 = (ArticleType) o1;
return this.getName().compareTo(artType1.getName());
} else {
return getName().compareTo(o1.toString());
}
}
/**
* Clone this object. Will perform a deep clone.
*
* @return The clone.
*/
public Object clone() {
ArticleType c = new ArticleType(id);
c.name = name == null ? null : name;
c.description = description == null ? null : description;
return c;
}
}