org.apache.turbine.services.security.torque
Class TorqueObject

java.lang.Object
  extended byorg.apache.turbine.services.security.torque.TorqueObject
All Implemented Interfaces:
java.lang.Comparable, org.apache.torque.om.Persistent, SecurityEntity, java.io.Serializable
Direct Known Subclasses:
TorqueGroup, TorquePermission, TorqueRole, TorqueUser

public abstract class TorqueObject
extends java.lang.Object
implements SecurityEntity, java.lang.Comparable, org.apache.torque.om.Persistent, java.io.Serializable

All the Torque Security objects (User, Group, Role, Permission) are derived from this class which contains the base compare and management methods for all security objects.

Version:
$Id: TorqueObject.java 534527 2007-05-02 16:10:59Z tv $
Author:
Henning P. Schmiedehausen
See Also:
Serialized Form

Field Summary
protected  org.apache.torque.om.Persistent obj
          The underlying database Object which is proxied
 
Constructor Summary
TorqueObject()
          Constructs a new TorqueObject
TorqueObject(org.apache.torque.om.Persistent obj)
          This Constructor is used when a Manager has retrieved a list of Database Objects from the peer and must 'wrap' them into TorqueObjects.
TorqueObject(java.lang.String name)
          Constructs a new Object with the specified name.
 
Method Summary
 int compareTo(java.lang.Object obj)
          Used for ordering TorqueObjects.
 boolean equals(java.lang.Object obj)
          Compares this with another BaseObject instance.
 boolean equals(TorqueObject torqueObject)
          Compares the primary key of this instance with the key of another.
abstract  java.lang.String getName()
          Returns the name of this object
abstract  org.apache.torque.om.Persistent getPersistentObj()
          Returns the underlying Object for the Peer
 org.apache.torque.om.ObjectKey getPrimaryKey()
          getter for the object primaryKey.
 int hashCode()
          If the primary key is not null, return the hashcode of the primary key.
 boolean isModified()
          Returns whether the object has been modified, since it was last retrieved from storage.
 boolean isNew()
          Returns whether the object has ever been saved.
abstract  void save()
          Makes changes made to the TorqueObject permanent.
 void save(java.sql.Connection con)
          Stores the object in the database.
 void save(java.lang.String torqueName)
          Stores the object in the database.
 void setModified(boolean m)
          Sets the modified state for the object.
abstract  void setName(java.lang.String name)
          Sets the name of this object
 void setNew(boolean b)
          Setter for the isNew attribute.
 void setPrimaryKey(org.apache.torque.om.ObjectKey primaryKey)
          Sets the PrimaryKey for the object.
 void setPrimaryKey(java.lang.String primaryKey)
          Sets the PrimaryKey for the object.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.turbine.om.security.SecurityEntity
getId, getIdAsObj, setId
 

Field Detail

obj

protected org.apache.torque.om.Persistent obj
The underlying database Object which is proxied

Constructor Detail

TorqueObject

public TorqueObject()
Constructs a new TorqueObject


TorqueObject

public TorqueObject(java.lang.String name)
Constructs a new Object with the specified name.

Parameters:
name - The name of the new object.

TorqueObject

public TorqueObject(org.apache.torque.om.Persistent obj)
This Constructor is used when a Manager has retrieved a list of Database Objects from the peer and must 'wrap' them into TorqueObjects.

Parameters:
obj - An Object from the peer
Method Detail

getPersistentObj

public abstract org.apache.torque.om.Persistent getPersistentObj()
Returns the underlying Object for the Peer

Returns:
The underlying persistent object

getName

public abstract java.lang.String getName()
Returns the name of this object

Specified by:
getName in interface SecurityEntity
Returns:
The name of the object

setName

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

Specified by:
setName in interface SecurityEntity
Parameters:
name - The name of the object

getPrimaryKey

public org.apache.torque.om.ObjectKey getPrimaryKey()
getter for the object primaryKey.

Specified by:
getPrimaryKey in interface org.apache.torque.om.Persistent
Returns:
the object primaryKey as an Object

setPrimaryKey

public void setPrimaryKey(org.apache.torque.om.ObjectKey primaryKey)
                   throws java.lang.Exception
Sets the PrimaryKey for the object.

Specified by:
setPrimaryKey in interface org.apache.torque.om.Persistent
Parameters:
primaryKey - The new PrimaryKey for the object.
Throws:
java.lang.Exception - This method might throw an exceptions

setPrimaryKey

public void setPrimaryKey(java.lang.String primaryKey)
                   throws java.lang.Exception
Sets the PrimaryKey for the object.

Specified by:
setPrimaryKey in interface org.apache.torque.om.Persistent
Parameters:
primaryKey - the String should be of the form produced by ObjectKey.toString().
Throws:
java.lang.Exception - This method might throw an exceptions

isModified

public boolean isModified()
Returns whether the object has been modified, since it was last retrieved from storage.

Specified by:
isModified in interface org.apache.torque.om.Persistent
Returns:
True if the object has been modified.

isNew

public boolean isNew()
Returns whether the object has ever been saved. This will be false, if the object was retrieved from storage or was created and then saved.

Specified by:
isNew in interface org.apache.torque.om.Persistent
Returns:
true, if the object has never been persisted.

setNew

public void setNew(boolean b)
Setter for the isNew attribute. This method will be called by Torque-generated children and Peers.

Specified by:
setNew in interface org.apache.torque.om.Persistent
Parameters:
b - the state of the object.

setModified

public void setModified(boolean m)
Sets the modified state for the object.

Specified by:
setModified in interface org.apache.torque.om.Persistent
Parameters:
m - The new modified state for the object.

save

public void save(java.lang.String torqueName)
          throws java.lang.Exception
Stores the object in the database. If the object is new, it inserts it; otherwise an update is performed.

Specified by:
save in interface org.apache.torque.om.Persistent
Parameters:
torqueName - The name under which the object should be stored.
Throws:
java.lang.Exception - This method might throw an exceptions

save

public void save(java.sql.Connection con)
          throws java.lang.Exception
Stores the object in the database. If the object is new, it inserts it; otherwise an update is performed. This method is meant to be used as part of a transaction, otherwise use the save() method and the connection details will be handled internally

Specified by:
save in interface org.apache.torque.om.Persistent
Parameters:
con - A Connection object to save the object
Throws:
java.lang.Exception - This method might throw an exceptions

save

public abstract void save()
                   throws TurbineSecurityException
Makes changes made to the TorqueObject permanent.

Specified by:
save in interface org.apache.torque.om.Persistent
Throws:
TurbineSecurityException - if there is a problem while saving data.

compareTo

public int compareTo(java.lang.Object obj)
Used for ordering TorqueObjects.

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
obj - The Object to compare to.
Returns:
-1 if the name of the other object is lexically greater than this group, 1 if it is lexically lesser, 0 if they are equal.

equals

public boolean equals(java.lang.Object obj)
Compares this with another BaseObject instance. If obj is an instance of BaseObject, delegates to equals(BaseObject). Otherwise, returns false.

Parameters:
obj - The object to compare to.
Returns:
Whether equal to the object specified.

equals

public boolean equals(TorqueObject torqueObject)
Compares the primary key of this instance with the key of another.

Parameters:
torqueObject - The TorqueObject to compare to.
Returns:
Whether the primary keys are equal.

hashCode

public int hashCode()
If the primary key is not null, return the hashcode of the primary key. Otherwise calls Object.hashCode().

Returns:
an int value


Copyright © 2000-2008 Apache Software Foundation. All Rights Reserved.