com.triactive.jdo.sco
Class Date

java.lang.Object
  extended byjava.util.Date
      extended bycom.triactive.jdo.sco.Date
All Implemented Interfaces:
java.lang.Cloneable, java.lang.Comparable, SCO, java.io.Serializable

public class Date
extends java.util.Date
implements SCO

A mutable second-class date object.

Author:
Mike Martin
See Also:
Serialized Form

Constructor Summary
Date(java.lang.Object owner, java.lang.String fieldName, java.util.Date date)
          Creates a Date object that represents the same time as the given java.util.Date.
 
Method Summary
 void applyUpdates()
          Called to indicate that the owning object is being made persistent, or that the persistent state of this field is being updated.
 java.lang.Object clone()
          Creates and returns a copy of this object.
 java.lang.String getFieldName()
          Returns the field name in the owner object.
 java.lang.Object getOwner()
          Returns the owner object of the SCO instance.
 void makeDirty()
          Marks this object dirty.
 void setDate(int date)
          Deprecated. As of JDK version 1.1, replaced by Calendar.set(Calendar.DAY_OF_MONTH, int date).
 void setHours(int hours)
          Deprecated. As of JDK version 1.1, replaced by Calendar.set(Calendar.HOUR_OF_DAY, int hours).
 void setMinutes(int minutes)
          Deprecated. As of JDK version 1.1, replaced by Calendar.set(Calendar.MINUTE, int minutes).
 void setMonth(int month)
          Deprecated. As of JDK version 1.1, replaced by Calendar.set(Calendar.MONTH, int month).
 void setSeconds(int seconds)
          Deprecated. As of JDK version 1.1, replaced by Calendar.set(Calendar.SECOND, int seconds).
 void setTime(long time)
           
 void setYear(int year)
          Deprecated. As of JDK version 1.1, replaced by Calendar.set(Calendar.YEAR, year + 1900).
 void unsetOwner()
          Disconnects this object from its owner.
protected  java.lang.Object writeReplace()
          Replaces the object to be serialized with a java.util.Date object.
 
Methods inherited from class java.util.Date
after, before, compareTo, compareTo, equals, getDate, getDay, getHours, getMinutes, getMonth, getSeconds, getTime, getTimezoneOffset, getYear, hashCode, parse, toGMTString, toLocaleString, toString, UTC
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Date

public Date(java.lang.Object owner,
            java.lang.String fieldName,
            java.util.Date date)
Creates a Date object that represents the same time as the given java.util.Date. Assigns owning object and field name.

Parameters:
owner - the owning object
fieldName - the owning field name
date - the initial date value
Method Detail

getOwner

public java.lang.Object getOwner()
Description copied from interface: SCO
Returns the owner object of the SCO instance.

Specified by:
getOwner in interface SCO
Returns:
The owner object or null if currently unowned.

getFieldName

public java.lang.String getFieldName()
Description copied from interface: SCO
Returns the field name in the owner object.

Specified by:
getFieldName in interface SCO
Returns:
The field name or null if currently unowned.

makeDirty

public void makeDirty()
Description copied from interface: SCO
Marks this object dirty. If the SCO is currently owned this method should mark the corresponding field in the owning object as dirty.

Specified by:
makeDirty in interface SCO

applyUpdates

public void applyUpdates()
Description copied from interface: SCO
Called to indicate that the owning object is being made persistent, or that the persistent state of this field is being updated.

Specified by:
applyUpdates in interface SCO

unsetOwner

public void unsetOwner()
Description copied from interface: SCO
Disconnects this object from its owner.

Specified by:
unsetOwner in interface SCO

clone

public java.lang.Object clone()
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.

Specified by:
clone in interface SCO

setTime

public void setTime(long time)

setYear

public void setYear(int year)
Deprecated. As of JDK version 1.1, replaced by Calendar.set(Calendar.YEAR, year + 1900).

Sets the year of this Date object to be the specified value plus 1900. This Date object is modified so that it represents a point in time within the specified year, with the month, date, hour, minute, and second the same as before, as interpreted in the local time zone. (Of course, if the date was February 29, for example, and the year is set to a non-leap year, then the new date will be treated as if it were on March 1.)

Parameters:
year - the year value.
See Also:
Calendar

setMonth

public void setMonth(int month)
Deprecated. As of JDK version 1.1, replaced by Calendar.set(Calendar.MONTH, int month).

Sets the month of this date to the specified value. This Date object is modified so that it represents a point in time within the specified month, with the year, date, hour, minute, and second the same as before, as interpreted in the local time zone. If the date was October 31, for example, and the month is set to June, then the new date will be treated as if it were on July 1, because June has only 30 days.

Parameters:
month - the month value between 0-11.
See Also:
Calendar

setDate

public void setDate(int date)
Deprecated. As of JDK version 1.1, replaced by Calendar.set(Calendar.DAY_OF_MONTH, int date).

Sets the day of the month of this Date object to the specified value. This Date object is modified so that it represents a point in time within the specified day of the month, with the year, month, hour, minute, and second the same as before, as interpreted in the local time zone. If the date was April 30, for example, and the date is set to 31, then it will be treated as if it were on May 1, because April has only 30 days.

Parameters:
date - the day of the month value between 1-31.
See Also:
Calendar

setHours

public void setHours(int hours)
Deprecated. As of JDK version 1.1, replaced by Calendar.set(Calendar.HOUR_OF_DAY, int hours).

Sets the hour of this Date object to the specified value. This Date object is modified so that it represents a point in time within the specified hour of the day, with the year, month, date, minute, and second the same as before, as interpreted in the local time zone.

Parameters:
hours - the hour value.
See Also:
Calendar

setMinutes

public void setMinutes(int minutes)
Deprecated. As of JDK version 1.1, replaced by Calendar.set(Calendar.MINUTE, int minutes).

Sets the minutes of this Date object to the specified value. This Date object is modified so that it represents a point in time within the specified minute of the hour, with the year, month, date, hour, and second the same as before, as interpreted in the local time zone.

Parameters:
minutes - the value of the minutes.
See Also:
Calendar

setSeconds

public void setSeconds(int seconds)
Deprecated. As of JDK version 1.1, replaced by Calendar.set(Calendar.SECOND, int seconds).

Sets the seconds of this Date to the specified value. This Date object is modified so that it represents a point in time within the specified second of the minute, with the year, month, date, hour, and minute the same as before, as interpreted in the local time zone.

Parameters:
seconds - the seconds value.
See Also:
Calendar

writeReplace

protected java.lang.Object writeReplace()
Replaces the object to be serialized with a java.util.Date object. Invoked by the serialization mechanism to obtain an alternative object to be used when writing an object to the stream.

Returns:
The Date to be serialized instead of this object.


Copyright 2001-2007 The TJDO Project All Rights Reserved.