Rakesh API

biz.wedoit4u.databeans
Class CategoryBean

java.lang.Object
  extended by biz.wedoit4u.databeans.CategoryBean
All Implemented Interfaces:
java.io.Serializable

public class CategoryBean
extends java.lang.Object
implements java.io.Serializable

A Java Bean that is used to represent a record in the categories table. This bean can be used to cache the contents of a database record, as well as insulate entity beans from client code. All instance variables are public, except the primary key column (category_id), which has only a accessor. All instances of this class are cached in the runtime environment System.getProperties(), under a property indentified by the value of CACHE_NAME.

Copyright 2003, Rakesh Vidyadharan

Version:
$Id: CategoryBean.java,v 1.8 2004/05/26 11:42:30 rakesh Exp $
Author:
Rakesh Vidyadharan on 4th October 2003
See Also:
Serialized Form

Field Summary
 java.lang.String brief
          The value in the brief column.
private static java.util.Map cache
          The Map that is used to cache instances of this bean.
static java.lang.String CACHE_NAME
          A constant that denotes the name of the system property at which all instances of this class are cached.
private  int categoryId
          The value in category_id column.
 int customerId
          The value in the customer_id column.
 java.lang.String description
          The value of the description column.
private static java.lang.Object lockObject
          An object that is used to synchronise modifications to the system cache of instances of these beans.
 java.lang.String longName
          The value in the long_name column.
 java.lang.String menuName
          The value in the menu_name column.
 java.lang.String picture
          The value in the picture column.
 int sortOrder
          The value of the sort_order column.
 
Constructor Summary
private CategoryBean()
          Default constructor.
 
Method Summary
static CategoryBean create(int categoryId, int customerId, java.lang.String menuName, java.lang.String longName, java.lang.String brief, java.lang.String picture, java.lang.String description, int sortOrder)
          Create a new category record with all the column values.
static void delete(CategoryBean cb)
          Delete the specified instance of this class from the system cache as well as from the database.
static java.util.Collection findAll()
          Return a Collection of bean instances that represent all the records in the categories table.
static java.util.Collection findByCustomer(int customerId)
          Return a Collection of bean instances that represent all the records in the categories table that are associated with the specified customer_id.
 int getCategoryId()
          Returns the value in category_id column.
private static java.util.Collection getCollection(java.util.Collection list)
          Return a Collection of bean instances from the specified Collection of primary key values.
static CategoryBean getInstance(int categoryId)
          Fetch the instance of the bean identified by the primary key value specified.
 void save()
          Write back all the values in the bean fields to the database.
static void setInstance(CategoryBean ctb)
          Add the specified bean instance to the system cache.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

lockObject

private static final java.lang.Object lockObject
An object that is used to synchronise modifications to the system cache of instances of these beans.


cache

private static final java.util.Map cache
The Map that is used to cache instances of this bean.


CACHE_NAME

public static final java.lang.String CACHE_NAME
A constant that denotes the name of the system property at which all instances of this class are cached.

See Also:
Constant Field Values

categoryId

private int categoryId
The value in category_id column.


customerId

public int customerId
The value in the customer_id column.


menuName

public java.lang.String menuName
The value in the menu_name column.


longName

public java.lang.String longName
The value in the long_name column.


brief

public java.lang.String brief
The value in the brief column.


picture

public java.lang.String picture
The value in the picture column.


description

public java.lang.String description
The value of the description column.


sortOrder

public int sortOrder
The value of the sort_order column.

Constructor Detail

CategoryBean

private CategoryBean()
Default constructor. Cannot be directly instantiated.

Method Detail

create

public static final CategoryBean create(int categoryId,
                                        int customerId,
                                        java.lang.String menuName,
                                        java.lang.String longName,
                                        java.lang.String brief,
                                        java.lang.String picture,
                                        java.lang.String description,
                                        int sortOrder)
                                 throws CMAException
Create a new category record with all the column values. When creating a temporary instace (for client code) specify a value of 0 for the customerId parameter. Creating a new instance of the class also adds the new instance to the system cache, unless the categoryId value is 0.

Parameters:
categoryId - - The category_id value.
customerId - - The customer_id value.
menuName - - The value for the menu_name column.
longName - - The value for the long_name column.
brief - - The value for the brief column.
picture - - The value for the picture column.
description - - The value for the description column.
sortOrder - - The value for the sort_order column.
Throws:
CMAException - - If an attempt is made to create an instance of the object that already exists, as identified by the customerTypeId value.

save

public void save()
          throws CMAException
Write back all the values in the bean fields to the database. All the columns in the categories table are updated with the values in the bean fields.

Throws:
CMAException - - If errors are encountered while writing the values to the database.

delete

public static final void delete(CategoryBean cb)
                         throws CMAException
Delete the specified instance of this class from the system cache as well as from the database.

Parameters:
cb - - The bean instance that is to be removed.
Throws:
CMAException - - If errors are encountered while removing the associated record in the database.

getInstance

public static final CategoryBean getInstance(int categoryId)
                                      throws CMAException
Fetch the instance of the bean identified by the primary key value specified.

Parameters:
categoryId - - The category_id value that uniquely identifies an instance of this object.
Returns:
CategoryBean - The appropriate bean instance.
Throws:
CMAException - - If the bean instance is not available in the system cache.

findAll

public static final java.util.Collection findAll()
                                          throws CMAException
Return a Collection of bean instances that represent all the records in the categories table.

Returns:
Collection - The collection of java bean instances.
Throws:
CMAException - - If errors are encountered while fetching all the bean instances.

findByCustomer

public static final java.util.Collection findByCustomer(int customerId)
                                                 throws CMAException
Return a Collection of bean instances that represent all the records in the categories table that are associated with the specified customer_id.

Returns:
Collection - The collection of java bean instances.
Throws:
CMAException - - If errors are encountered while fetching all the bean instances.

getCollection

private static final java.util.Collection getCollection(java.util.Collection list)
                                                 throws CMAException
Return a Collection of bean instances from the specified Collection of primary key values.

Parameters:
list - - The Collection of primary key values.
Throws:
CMAException - - If errors are encountered while fetching the bean instances.

setInstance

public static final void setInstance(CategoryBean ctb)
Add the specified bean instance to the system cache. This method follows the general contract provided by the Map interface in that, if an entry with the same key already exists, then that entry is replaced, or a new one created. This method uses the lockObject to synchronise modifications to the Map cache.

Parameters:
ctb - - The instance that is being added to the system cache.

getCategoryId

public final int getCategoryId()
Returns the value in category_id column.

Returns:
int - The value/reference of/to categoryId.

Rakesh API

Copyright © 2002-2005 - Rakesh Vidyadharan