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

Date

public class Date 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.util.Date

Fields Summary
private transient com.sun.jdo.spi.persistence.support.sqlstore.PersistenceCapable
owner
private transient String
fieldName
Constructors Summary
public Date(Object owner, String fieldName)
Creates a Date 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();
	if (owner instanceof PersistenceCapable)
        {
                this.owner = (PersistenceCapable)owner;
		this.fieldName = fieldName;
        }
    
public Date(Object owner, String fieldName, long date)
Creates a Date 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.

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

param
date the day of the month value between 1-31.
see
java.util.Calendar
see
java.util.Date
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 Date object to the specified value.

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

param
minutes the value of the minutes.
see
java.util.Calendar
see
java.util.Date
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.util.Date
deprecated
As of JDK version 1.1, replaced by Calendar.set(Calendar.MONTH, int month).

        this.makeDirty();
        super.setMonth(month);
    
public voidsetSeconds(int seconds)
Sets the seconds of this Date to the specified value.

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

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

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

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

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

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

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