Rakesh API

biz.wedoit4u.databeans
Class StyleClassBean

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

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

A Java Bean that represents a record in the style_classes table. This bean is used to cache the values read from the database, and to make modifications you need to the bean fields, and then send it back to the database for updating the associated record. All instances of this class are cached into a Map object that is stored in the System.getProperties() object under a property with name CACHE_NAME. All instances variables are public except the primary key column style_class_id.

Copyright 2003, Rakesh Vidyadharan

Version:
$Id: StyleClassBean.java,v 1.5 2004/05/26 11:42:33 rakesh Exp $
Author:
Rakesh Vidyadharan on 16th September 2003
See Also:
Serialized Form

Field Summary
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.
 java.lang.String className
          The value in the class_name column.
 java.lang.String description
          The value in 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.
private  int styleClassId
          The value in the style_class_id column.
 
Constructor Summary
private StyleClassBean()
          The default constructor.
 
Method Summary
static StyleClassBean create(int styleClassId, java.lang.String className, java.lang.String description)
          Create a new instance of the bean that may be used to create a corresponding record in the style_classes table.
static void delete(StyleClassBean 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 style_classes table.
static StyleClassBean getInstance(int styleClassId)
          Fetch the instance of the bean identified by the primary key value specified.
 int getStyleClassId()
          Returns styleClassId.
 void save()
          Write back all the values in the bean fields to the database.
static void setInstance(StyleClassBean scb)
          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

styleClassId

private int styleClassId
The value in the style_class_id column.


className

public java.lang.String className
The value in the class_name column.


description

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

Constructor Detail

StyleClassBean

private StyleClassBean()
The default constructor. Cannot be directly instantiated.

Method Detail

create

public static final StyleClassBean create(int styleClassId,
                                          java.lang.String className,
                                          java.lang.String description)
                                   throws CMAException
Create a new instance of the bean that may be used to create a corresponding record in the style_classes table. If you wish the database sequence value be used to populate the style_class_id value, then specify a value of 0 for styleClassId. All new instances created are added to the system cache, unless they are created with a customerId value of 0.

Parameters:
styleClassId - - The primary key value to use.
className - - The name of CSS class.
description - - A detailed description about the purpose of the CSS class.
Throws:
CMAException - - If an attempt is made to create an instance of the object that already exists, as identified by the styleClassId value.

delete

public static final void delete(StyleClassBean 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.
See Also:
StyleClassHelper.delete( int )

save

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

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

findAll

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

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

getInstance

public static final StyleClassBean getInstance(int styleClassId)
                                        throws CMAException
Fetch the instance of the bean identified by the primary key value specified. If the bean instance does not exist in the cache, try to fetch it from the database.

Parameters:
styleClassId - - The style_class_id value based upon which to fetch the instance.
Returns:
StyleClassBean - The appropriate bean instance.
Throws:
CMAException - - If the specified bean instance is not available in the system cache.

setInstance

public static final void setInstance(StyleClassBean scb)
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:
scb - - The instance that is being added to the system cache.

getStyleClassId

public final int getStyleClassId()
Returns styleClassId.

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

Rakesh API

Copyright © 2002-2005 - Rakesh Vidyadharan