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

SqlTimestamp

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

Fields Summary
private transient com.sun.jdo.spi.persistence.support.sqlstore.PersistenceCapable
owner
private transient String
fieldName
Constructors Summary
public SqlTimestamp(Object owner, String fieldName)
Creates a SqlTimestamp 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 SqlTimestamp(Object owner, String fieldName, long date)
Creates a SqlTimestamp 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.

        SqlTimestamp obj = (SqlTimestamp) 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 voidsetDate(int date)
Sets the day of the month of this SqlTimestamp object to the specified value.

param
date the day of the month value between 1-31.
see
java.util.Calendar
see
java.sql.Timestamp
deprecated
As of JDK version 1.1, replaced by Calendar.set(Calendar.DAY_OF_MONTH, int date).

	this.makeDirty();
        super.setDate(date);
    
public voidsetHours(int hours)
Sets the hour of this SqlTimestamp object to the specified value.

param
hours the hour value.
see
java.util.Calendar
see
java.sql.Timestamp
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 SqlTimestamp object to the specified value.

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

	this.makeDirty();
        super.setMinutes(minutes);
    
public voidsetMonth(int month)
Sets the month of this date to the specified value.

param
month the month value between 0-11.
see
java.util.Calendar
see
java.sql.Timestamp
deprecated
As of JDK version 1.1, replaced by Calendar.set(Calendar.MONTH, int month).

	this.makeDirty();
        super.setMonth(month);
    
public voidsetNanos(int n)
Sets this Timestamp object's nanos value to the given value.

param
n the new fractional seconds component
exception
java.lang.IllegalArgumentException if the given argument is greater than 999999999 or less than 0
see
java.sql.Timestamp

	this.makeDirty();
        try {
		super.setNanos(n);
	} catch (IllegalArgumentException e) {
		throw e;
	}
    
public voidsetNanosInternal(int n)
Sets the SqlTimestamp object's nanos value without notification of the Owner field. Used internaly to populate date from DB

param
n the new fractional seconds component
exception
java.lang.IllegalArgumentException if the given argument is greater than 999999999 or less than 0
see
java.sql.Timestamp

	super.setNanos(n);
    
public voidsetSeconds(int seconds)
Sets the seconds of this SqlTimestamp to the specified value.

param
seconds the seconds value.
see
java.util.Calendar
see
java.sql.Timestamp
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 SqlTimestamp 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.Timestamp

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

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

	super.setTime(time);
    
public voidsetYear(int year)
Sets the year of this SqlTimestamp object to be the specified value plus 1900.

param
year the year value.
see
java.util.Calendar
see
java.sql.Timestamp
deprecated
As of JDK version 1.1, replaced by Calendar.set(Calendar.YEAR, year + 1900).

	this.makeDirty();
        super.setYear(year);
    
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.Timestamp as the designated object to be used when writing this object to the stream.

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

 
        java.sql.Timestamp t = new java.sql.Timestamp(getTime()); 
        t.setNanos(this.getNanos());
        return t;