FileDocCategorySizeDatePackage
SqlTime.javaAPI DocGlassfish v2 API8242Fri May 04 22:35:12 BST 2007com.sun.jdo.spi.persistence.support.sqlstore.sco

SqlTime

public class SqlTime extends Time implements com.sun.jdo.spi.persistence.support.sqlstore.SCODate
A mutable 2nd class object date.
author
Marina Vatkina
version
1.0
see
java.sql.Time

Fields Summary
private transient com.sun.jdo.spi.persistence.support.sqlstore.PersistenceCapable
owner
private transient String
fieldName
Constructors Summary
public SqlTime(Object owner, String fieldName)
Creates a SqlTime object that represents the time at which it was allocated. Assigns owning object and field name

param
owner the owning object
param
fieldName the owning field name

	super(0);
	if (owner instanceof PersistenceCapable)
        {
                this.owner = (PersistenceCapable)owner;
		this.fieldName = fieldName;
        }
    
public SqlTime(Object owner, String fieldName, long date)
Creates a SqlTime object that represents the given time in milliseconds. Assigns owning object and field name

param
owner the owning object
param
fieldName the owning field name
param
date the number of milliseconds

	super(date);
	if (owner instanceof PersistenceCapable)
        {
                this.owner = (PersistenceCapable)owner;
		this.fieldName = fieldName;
        }
    
Methods Summary
public voidapplyUpdates(com.sun.jdo.spi.persistence.support.sqlstore.StateManager sm, boolean modified)
Apply changes (no-op)

    
public java.lang.Objectclone()
Creates and returns a copy of this object.

Mutable Second Class Objects are required to provide a public clone method in order to allow for copying PersistenceCapable objects. In contrast to Object.clone(), this method must not throw a CloneNotSupportedException.

        SqlTime obj = (SqlTime) super.clone();

		obj.owner = null; 
		obj.fieldName = null; 

        return obj;
    
public java.lang.ObjectcloneInternal()
Creates and returns a copy of this object without resetting the owner and field value.

        return super.clone();
    
public java.lang.StringgetFieldName()
Returns the field name

return
field name as java.lang.String

        return this.fieldName;
    
public java.lang.ObjectgetOwner()
Returns the owner object of the SCO instance

return
owner object

    
        return this.owner; 
    
public com.sun.jdo.spi.persistence.support.sqlstore.StateManagermakeDirty()
Marks object dirty

		if (owner != null)
		{
			StateManager stateManager = owner.jdoGetStateManager();
			
			if (stateManager != null)
			{
				PersistenceManager pm = (PersistenceManager) stateManager.getPersistenceManagerInternal();

				pm.acquireShareLock();
				
				try
				{
					synchronized (stateManager)
					{	
						//
						// Need to recheck owner because it could be set to
						// null before we lock the stateManager.
						//
						if (owner != null)
						{
							stateManager.makeDirty(fieldName);
							return stateManager;
						}
					}
				}
				finally
				{
					pm.releaseShareLock();
				}
			}
		}
		return null;
     
public voidsetHours(int hours)
Sets the hour of this SqlTime object to the specified value.

param
hours the hour value.
see
java.util.Calendar
see
java.sql.Time
deprecated
As of JDK version 1.1, replaced by Calendar.set(Calendar.HOUR_OF_DAY, int hours).

	this.makeDirty();
        super.setHours(hours);
    
public voidsetMinutes(int minutes)
Sets the minutes of this SqlTime object to the specified value.

param
minutes the value of the minutes.
see
java.util.Calendar
see
java.sql.Time
deprecated
As of JDK version 1.1, replaced by Calendar.set(Calendar.MINUTE, int minutes).

	this.makeDirty();
        super.setMinutes(minutes);
    
public voidsetSeconds(int seconds)
Sets the seconds of this SqlTime to the specified value.

param
seconds the seconds value.
see
java.util.Calendar
see
java.sql.Time
deprecated
As of JDK version 1.1, replaced by Calendar.set(Calendar.SECOND, int seconds).

	this.makeDirty();
        super.setSeconds(seconds);
    
public voidsetTime(long time)
Sets the SqlTime object to represent a point in time that is time milliseconds after January 1, 1970 00:00:00 GMT.

param
time the number of milliseconds.
see
java.sql.Time

	this.makeDirty();
	super.setTime(time);
    
public voidsetTimeInternal(long time)
Sets the SqlTime object without notification of the Owner field. Used internaly to populate date from DB

param
time the number of milliseconds.
see
java.sql.Time

	super.setTime(time);
    
public voidunsetOwner()
Nullifies references to the owner Object and Field NOTE: This method should be called under the locking of the owener' state manager.

 
		this.owner = null; 
		this.fieldName = null; 
    
java.lang.ObjectwriteReplace()
Use java.sql.Time as the designated object to be used when writing this object to the stream.

return
java.sql.Time that represents the same value.
throw
ObjectStreamException.

        return new java.sql.Time(getTime());