org.blojsom.blog
Class BlogCategory

java.lang.Object
  extended byorg.blojsom.blog.BlogCategory
All Implemented Interfaces:
java.lang.Comparable, java.io.Serializable
Direct Known Subclasses:
FileBackedBlogCategory

public abstract class BlogCategory
extends java.lang.Object
implements java.lang.Comparable, java.io.Serializable

BlogCategory

Version:
$Id: BlogCategory.java,v 1.15 2006/01/04 16:59:53 czarneckid Exp $
Author:
David Czarnecki, Mark Lussier
See Also:
Serialized Form

Field Summary
protected  BlogEntry _blogEntry
           
protected  java.lang.String _category
           
protected  java.lang.String _categoryURL
           
protected  java.lang.String _description
           
protected  org.apache.commons.logging.Log _logger
           
protected  java.util.Map _metadata
           
protected  java.lang.String _name
           
protected  BlogCategory _parentCategory
           
protected  java.util.List _subcategories
           
 
Constructor Summary
BlogCategory()
          Create a new BlogCategory.
BlogCategory(java.lang.String category, java.lang.String categoryURL)
          Create a new BlogCategory.
 
Method Summary
 int compareTo(java.lang.Object o)
          Compare the current category to the input category
abstract  int countBlogEntries(Blog blog, boolean recursive)
          Count the number of blog entries in this category.
abstract  void delete(Blog blog)
          Deprecated.  
abstract  void delete(BlogUser blogUser)
          Delete the blog category.
 boolean equals(java.lang.Object obj)
          Checks to see if this category is equal to the input category
 java.lang.String getCategory()
          Return the category name
 java.lang.String getCategoryURL()
          Return the URL for this category
 java.lang.String getDescription()
          Retrieves the description of this category
 java.lang.String getEncodedCategory()
          Return the category name encoded for a link
 java.lang.String getEncodedCategoryURL()
          Return the category URL encoded for a link
 java.util.Map getMetaData()
          Retrieves the meta-data associated with this category
 java.lang.String getName()
          Retrieves the name of this category
 BlogCategory getParentCategory()
          Returns the parent category of this category.
 java.util.List getSubcategories()
          Return a list of sub-categories under the current category
 java.util.List getSubcategories(int depth)
          Retrieve a list of sub-categories under the current category up to a certain depth
abstract  void load(Blog blog)
          Deprecated.  
abstract  void load(BlogUser blogUser)
          Load a blog category.
abstract  void save(Blog blog)
          Deprecated.  
abstract  void save(BlogUser blogUser)
          Save the blog category.
 void setAttributes(java.util.Map attributeMap)
          Set any attributes of the blog category using data from the map.
 void setCategory(java.lang.String category)
          Set a new name for this category
 void setCategoryURL(java.lang.String categoryURL)
          Set a new URL for this category
 void setDescription(java.lang.String desc)
          Sets the description of this category
 void setMetaData(java.util.Map metadata)
          Set the meta-data associated with this category
 void setMetaData(java.util.Properties data)
          Sets the meta-data associated with this category.
 void setName(java.lang.String name)
          Sets the name of this category
 void setParentCategory(BlogCategory cateogory)
          Sets the parent category of this category
 void setSubcategories(java.util.List subcategories)
          Set the sub-categories for this category
 java.lang.String toString()
          Returns the category name
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_logger

protected org.apache.commons.logging.Log _logger

_categoryURL

protected java.lang.String _categoryURL

_category

protected java.lang.String _category

_metadata

protected java.util.Map _metadata

_description

protected java.lang.String _description

_name

protected java.lang.String _name

_subcategories

protected java.util.List _subcategories

_blogEntry

protected BlogEntry _blogEntry

_parentCategory

protected BlogCategory _parentCategory
Constructor Detail

BlogCategory

public BlogCategory()
Create a new BlogCategory.


BlogCategory

public BlogCategory(java.lang.String category,
                    java.lang.String categoryURL)
Create a new BlogCategory.

Parameters:
category - Category name
categoryURL - Category URL
Method Detail

getCategoryURL

public java.lang.String getCategoryURL()
Return the URL for this category

Returns:
Category URL

setCategoryURL

public void setCategoryURL(java.lang.String categoryURL)
Set a new URL for this category

Parameters:
categoryURL - Category URL

getCategory

public java.lang.String getCategory()
Return the category name

Returns:
Category name

getEncodedCategory

public java.lang.String getEncodedCategory()
Return the category name encoded for a link

Returns:
Category name encoded as UTF-8 with preserved "/" and "+" characters
Since:
blojsom 2.08

getEncodedCategoryURL

public java.lang.String getEncodedCategoryURL()
Return the category URL encoded for a link

Returns:
Category URL encoded as UTF-8 with preserved "/" characters and "+" characters
Since:
blojsom 2.14
See Also:
{@link BlojsomUtils#urlEncodeForLink(java.lang.String)}

setCategory

public void setCategory(java.lang.String category)
Set a new name for this category

Parameters:
category - Category name

equals

public boolean equals(java.lang.Object obj)
Checks to see if this category is equal to the input category

Parameters:
obj - Input category
Returns:
true if the category name and category URL are equal, false otherwise

compareTo

public int compareTo(java.lang.Object o)
Compare the current category to the input category

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
o - Input category
Returns:

toString

public java.lang.String toString()
Returns the category name

Returns:
Category name
See Also:
getCategory()

setDescription

public void setDescription(java.lang.String desc)
Sets the description of this category

Parameters:
desc - The new description of the category

getDescription

public java.lang.String getDescription()
Retrieves the description of this category

Returns:
The description of the category

setName

public void setName(java.lang.String name)
Sets the name of this category

Parameters:
name - The new name of the category

getName

public java.lang.String getName()
Retrieves the name of this category

Returns:
The name of the category

setMetaData

public void setMetaData(java.util.Map metadata)
Set the meta-data associated with this category

Parameters:
metadata - The map to be associated with the category as meta-data

setMetaData

public void setMetaData(java.util.Properties data)
Sets the meta-data associated with this category. This method will also try to set the description and name properties from the meta-data by looking for the DESCRIPTION_KEY and NAME_KEY, respectively

Parameters:
data - The properties to be associated with the category as meta-data

getMetaData

public java.util.Map getMetaData()
Retrieves the meta-data associated with this category

Returns:
The properties associated with the category as meta-data, or null if no metadata exists

setAttributes

public void setAttributes(java.util.Map attributeMap)
Set any attributes of the blog category using data from the map.

Parameters:
attributeMap - Attributes
Since:
blojsom 1.9.1

load

public abstract void load(Blog blog)
                   throws BlojsomException
Deprecated.  

Load a blog category.

Parameters:
blog - Blog
Throws:
BlojsomException - If there is an error loading the category
Since:
blojsom 1.9.1

save

public abstract void save(Blog blog)
                   throws BlojsomException
Deprecated.  

Save the blog category.

Parameters:
blog - Blog
Throws:
BlojsomException - If there is an error saving the category
Since:
blojsom 1.9.1

delete

public abstract void delete(Blog blog)
                     throws BlojsomException
Deprecated.  

Delete the blog category.

Parameters:
blog - Blog
Throws:
BlojsomException - If there is an error deleting the category
Since:
blojsom 1.9.1

load

public abstract void load(BlogUser blogUser)
                   throws BlojsomException
Load a blog category.

Parameters:
blogUser - BlogUser
Throws:
BlojsomException - If there is an error loading the category
Since:
blojsom 2.22

save

public abstract void save(BlogUser blogUser)
                   throws BlojsomException
Save the blog category.

Parameters:
blogUser - BlogUser
Throws:
BlojsomException - If there is an error saving the category
Since:
blojsom 2.22

delete

public abstract void delete(BlogUser blogUser)
                     throws BlojsomException
Delete the blog category.

Parameters:
blogUser - BlogUser
Throws:
BlojsomException - If there is an error deleting the category
Since:
blojsom 2.22

countBlogEntries

public abstract int countBlogEntries(Blog blog,
                                     boolean recursive)
Count the number of blog entries in this category. If recursive is true, the method will also count entries in all sub-categories.

Parameters:
blog - Blog
recursive - Set to true if entries in sub-categories should be counted
Returns:
Number of blog entries in this category
Since:
blojsom 2.22

getSubcategories

public java.util.List getSubcategories()
Return a list of sub-categories under the current category

Returns:
List of sub-categories as BlogCategory objects
Since:
blojsom 2.22

getSubcategories

public java.util.List getSubcategories(int depth)
Retrieve a list of sub-categories under the current category up to a certain depth

Parameters:
depth - Depth of sub-categories to retrieve, use -1 for all sub-categories
Returns:
@link List} of sub-categories as BlogCategory objects
Since:
blojsom 2.26

setSubcategories

public void setSubcategories(java.util.List subcategories)
Set the sub-categories for this category

Parameters:
subcategories - List of BlogCategory objects
Since:
blojsom 2.22

getParentCategory

public BlogCategory getParentCategory()
Returns the parent category of this category. Defaults to "/"

Returns:
BlogCategory containing the parent category
Since:
blojsom 2.25

setParentCategory

public void setParentCategory(BlogCategory cateogory)
Sets the parent category of this category

Parameters:
cateogory - BlogCategory that represents the parent category
Since:
blojsom 2.25