com.youyounet.db
Class SimpleBean

java.lang.Object
  |
  +--com.youyounet.db.SimpleBean

public class SimpleBean
extends java.lang.Object

SimpleBean is a class which can set and get unlimited number of properties. The property value from the get method will all have type Object. Users should cast that property value to the appropriate type. To set the property that is of Java primitive type, users should wrap the primitive type property value into a corresponding wrap class, for example: asimplebean.set("id", new Integer(100));


Field Summary
protected static java.util.logging.Logger log
           
protected  java.util.HashMap properties
           
 
Constructor Summary
SimpleBean()
          constructor.
 
Method Summary
 void clear()
          Clear all the properties of the bean.
 void create(java.lang.String table)
          Insert the bean to the database table specified.
 void create(java.lang.String table, DBContext c)
          Insert the bean to the database table specified.
 java.lang.Object get(java.lang.String propertyName)
          Get the property value of the property named propertyName.
 void set(java.lang.String propertyName, java.lang.Object object)
          Set the property value of the property named propertyName.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static java.util.logging.Logger log

properties

protected java.util.HashMap properties
Constructor Detail

SimpleBean

public SimpleBean()
constructor.

Method Detail

get

public java.lang.Object get(java.lang.String propertyName)
Get the property value of the property named propertyName.

Parameters:
propertyName - the name of the property whose value will be fetched.
Returns:
the property value of tyle Object, users should cast that to the appropriate type.

set

public void set(java.lang.String propertyName,
                java.lang.Object object)
Set the property value of the property named propertyName.

Parameters:
propertyName - the name of the property whose value will be set.
object - the property value. If it has Java primitive type, it should be wrapped into a corresponding wrap class.

create

public void create(java.lang.String table)
            throws java.sql.SQLException,
                   DataTransferException
Insert the bean to the database table specified.

Parameters:
table - the name of the database table that this SimpleBean object will be inserted.
Throws:
java.sql.SQLException - if database error occured.
DataTransferException - if other error occured.

create

public void create(java.lang.String table,
                   DBContext c)
            throws java.sql.SQLException,
                   DataTransferException
Insert the bean to the database table specified.

Parameters:
table - the name of the database table that this SompleBean object will be inserted.
c - this create operation is part of the transaction associated with this DBContext object.
Throws:
java.sql.SQLException - if database error occured.
DataTransferException - if other error occured.

clear

public void clear()
Clear all the properties of the bean.