Rakesh API

biz.wedoit4u.databeans
Class SitePropertyBean

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

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

A Java Bean that represents a record in the site_properties 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 customer_id.

Copyright 2003, Rakesh Vidyadharan

Version:
$Id: SitePropertyBean.java,v 1.6 2004/05/26 11:42:32 rakesh Exp $
Author:
Rakesh Vidyadharan on 25th October 2003
See Also:
Serialized Form

Field Summary
static int BOTTOM_RAIL
          The default value to be used for the bottom_rail flag.
 int bottomRail
          The value in the bottom_rail 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 customerId
          The value in the customer_id column.
 java.lang.String footer
          The value in the footer column.
static java.lang.String FOOTER
          The default value to be used for the footer column.
 java.lang.String header
          The value in the header column.
static java.lang.String HEADER
          The default value to be used for the header column.
static int LEFT_RAIL
          The default value to be used for the left_rail flag.
 int leftRail
          The value in the left_rail column.
private static java.lang.Object lockObject
          An object that is used to synchronise modifications to the system cache of instances of these beans.
static int RIGHT_RAIL
          The default value to be used for the right_rail flag.
 int rightRail
          The value in the right_rail column.
static int TOP_RAIL
          The default value to be used for the top_rail flag.
 int topRail
          The value in the top_rail column.
 
Constructor Summary
private SitePropertyBean()
          The default constructor.
 
Method Summary
static SitePropertyBean create(int customerId)
          Create a new instance of the bean for the specified customer_id with default values.
static SitePropertyBean create(int customerId, int topRail, int leftRail, int rightRail, int bottomRail, java.lang.String header, java.lang.String footer)
          Create a new instance of the bean that may be used to create a corresponding record in the site_properties table.
static void delete(SitePropertyBean spb)
          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 site_properties table.
 int getCustomerId()
          Returns customerId.
static SitePropertyBean getInstance(int customerId)
          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(SitePropertyBean 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

TOP_RAIL

public static final int TOP_RAIL
The default value to be used for the top_rail flag. Default to off (0).

See Also:
Constant Field Values

LEFT_RAIL

public static final int LEFT_RAIL
The default value to be used for the left_rail flag. Default to off (0).

See Also:
Constant Field Values

RIGHT_RAIL

public static final int RIGHT_RAIL
The default value to be used for the right_rail flag. Default to off (0).

See Also:
Constant Field Values

BOTTOM_RAIL

public static final int BOTTOM_RAIL
The default value to be used for the bottom_rail flag. Default to off (0).

See Also:
Constant Field Values

HEADER

public static final java.lang.String HEADER
The default value to be used for the header column. Default to an empty string.

See Also:
Constant Field Values

FOOTER

public static final java.lang.String FOOTER
The default value to be used for the footer column. Default to an empty string.

See Also:
Constant Field Values

customerId

private int customerId
The value in the customer_id column.


topRail

public int topRail
The value in the top_rail column.


leftRail

public int leftRail
The value in the left_rail column.


rightRail

public int rightRail
The value in the right_rail column.


bottomRail

public int bottomRail
The value in the bottom_rail column.


header

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


footer

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

Constructor Detail

SitePropertyBean

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

Method Detail

create

public static final SitePropertyBean create(int customerId)
                                     throws CMAException
Create a new instance of the bean for the specified customer_id with default values.

Note: The primary key column for this table also has a foreign key relation ship with the customers.customer_id column.

Parameters:
customerId - - The primary key value to use.
Returns:
SitePropertyBean - The newly created bean instance.
Throws:
CMAException - - If an attempt is made to create an instance of the object that already exists, as identified by the customerId value.

create

public static final SitePropertyBean create(int customerId,
                                            int topRail,
                                            int leftRail,
                                            int rightRail,
                                            int bottomRail,
                                            java.lang.String header,
                                            java.lang.String footer)
                                     throws CMAException
Create a new instance of the bean that may be used to create a corresponding record in the site_properties table.

Note: The primary key column for this table also has a foreign key relation ship with the customers.customer_id column.

Parameters:
customerId - - The primary key value to use.
topRail - - The top_rail value. This should be 0 or 1.
leftRail - - The left_rail value. This should be 0 or 1.
rightRail - - The right_rail value. This should be 0 or 1.
bottomRail - - The bottom_rail value. This should be 0 or 1.
header - - The header column value.
footer - - A footer column value.
Returns:
SitePropertyBean - The newly created bean instance.
Throws:
CMAException - - If an attempt is made to create an instance of the object that already exists, as identified by the customerId value.

delete

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

Parameters:
spb - - The bean instance that is to be removed.
Throws:
CMAException - - If errors are encountered while removing the associated record in the database.
See Also:
SitePropertyHelper.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 site_properties 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 site_properties 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 SitePropertyBean getInstance(int customerId)
                                          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:
customerId - - The customer_id value based upon which to fetch the instance.
Returns:
SitePropertyBean - The appropriate bean instance.
Throws:
CMAException - - If the specified bean instance is not available in the system cache.

setInstance

public static final void setInstance(SitePropertyBean 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.

getCustomerId

public final int getCustomerId()
Returns customerId.

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

Rakesh API

Copyright © 2002-2005 - Rakesh Vidyadharan