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

SqlDate

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

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

        SqlDate obj = (SqlDate) 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 SqlDate object to the specified value.

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

	this.makeDirty(); 
        super.setDate(date);
    
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.Date
deprecated
As of JDK version 1.1, replaced by Calendar.set(Calendar.MONTH, int month).

	this.makeDirty(); 
        super.setMonth(month);
    
public voidsetTime(long time)
Sets the SqlDate 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.Date

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

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

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

param
year the year value.
see
java.util.Calendar
see
java.sql.Date
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.Date as the designated object to be used when writing this object to the stream.

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

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