org.datanucleus.store.types.sco.simple
Class SqlDate

java.lang.Object
  extended by java.util.Date
      extended by java.sql.Date
          extended by org.datanucleus.store.types.sco.simple.SqlDate
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Comparable<java.util.Date>, SCO

public class SqlDate
extends java.sql.Date
implements SCO

A mutable second-class SQL date object.

See Also:
Serialized Form

Field Summary
protected  java.lang.String fieldName
           
protected  java.lang.Object owner
           
protected  ObjectProvider ownerSM
           
 
Constructor Summary
SqlDate(ObjectProvider ownerSM, java.lang.String fieldName)
          Creates a SqlDate object that represents the time at which it was allocated.
 
Method Summary
 void attachCopy(java.lang.Object value)
          Method to return an attached version for the passed StateManager and field, using the passed value.
 java.lang.Object clone()
          Creates and returns a copy of this object.
 java.lang.Object detachCopy(FetchPlanState state)
          Method to detach a copy of this object.
 java.lang.String getFieldName()
          Accessor for the field name
 java.lang.Object getOwner()
          Accessor for the owner.
 java.lang.Object getValue()
          Accessor for the unwrapped value that we are wrapping.
 void initialise()
          Method to initialise the SCO for use.
 void initialise(java.lang.Object o, boolean forInsert, boolean forUpdate)
          Method to initialise the SCO from an existing value.
 void makeDirty()
          Utility to mark the object as dirty
 void setDate(int date)
          Deprecated. As of JDK version 1.1, replaced by Calendar.set(Calendar.DAY_OF_MONTH, int date).
 void setMonth(int month)
          Deprecated. As of JDK version 1.1, replaced by Calendar.set(Calendar.MONTH, int month).
 void setTime(long time)
          Mutator for the time.
 void setYear(int year)
          Deprecated. As of JDK version 1.1, replaced by Calendar.set(Calendar.YEAR, year + 1900).
 void unsetOwner()
          Utility to unset the owner.
protected  java.lang.Object writeReplace()
          The writeReplace method is called when ObjectOutputStream is preparing to write the object to the stream.
 
Methods inherited from class java.sql.Date
getHours, getMinutes, getSeconds, setHours, setMinutes, setSeconds, toString, valueOf
 
Methods inherited from class java.util.Date
after, before, compareTo, equals, getDate, getDay, getMonth, getTime, getTimezoneOffset, getYear, hashCode, parse, toGMTString, toLocaleString, UTC
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

owner

protected transient java.lang.Object owner

ownerSM

protected transient ObjectProvider ownerSM

fieldName

protected transient java.lang.String fieldName
Constructor Detail

SqlDate

public SqlDate(ObjectProvider ownerSM,
               java.lang.String fieldName)
Creates a SqlDate object that represents the time at which it was allocated. Assigns owning object and field name.

Parameters:
ownerSM - the owning object
fieldName - the owning field name
Method Detail

initialise

public void initialise()
Method to initialise the SCO for use.

Specified by:
initialise in interface SCO

initialise

public void initialise(java.lang.Object o,
                       boolean forInsert,
                       boolean forUpdate)
Method to initialise the SCO from an existing value.

Specified by:
initialise in interface SCO
Parameters:
o - The Object
forInsert - Whether the object needs inserting in the datastore with this value
forUpdate - Whether to update the datastore with this value

getValue

public java.lang.Object getValue()
Accessor for the unwrapped value that we are wrapping.

Specified by:
getValue in interface SCO
Returns:
The unwrapped value

unsetOwner

public void unsetOwner()
Utility to unset the owner.

Specified by:
unsetOwner in interface SCO

getOwner

public java.lang.Object getOwner()
Accessor for the owner.

Specified by:
getOwner in interface SCO
Returns:
The owner

getFieldName

public java.lang.String getFieldName()
Accessor for the field name

Specified by:
getFieldName in interface SCO
Returns:
The field name

makeDirty

public void makeDirty()
Utility to mark the object as dirty


detachCopy

public java.lang.Object detachCopy(FetchPlanState state)
Method to detach a copy of this object.

Specified by:
detachCopy in interface SCO
Parameters:
state - State for detachment process
Returns:
The detached object

attachCopy

public void attachCopy(java.lang.Object value)
Method to return an attached version for the passed StateManager and field, using the passed value.

Specified by:
attachCopy in interface SCO
Parameters:
value - The new value

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
Overrides:
clone in class java.util.Date
Returns:
Clone of the object

setTime

public void setTime(long time)
Mutator for the time.

Overrides:
setTime in class java.sql.Date
Parameters:
time - The time (millisecs)

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.)

Overrides:
setYear in class java.util.Date
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.

Overrides:
setMonth in class java.util.Date
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.

Overrides:
setDate in class java.util.Date
Parameters:
date - the day of the month value between 1-31.
See Also:
Calendar

writeReplace

protected java.lang.Object writeReplace()
                                 throws java.io.ObjectStreamException
The writeReplace method is called when ObjectOutputStream is preparing to write the object to the stream. The ObjectOutputStream checks whether the class defines the writeReplace method. If the method is defined, the writeReplace method is called to allow the object to designate its replacement in the stream. The object returned should be either of the same type as the object passed in or an object that when read and resolved will result in an object of a type that is compatible with all references to the object.

Returns:
the replaced object
Throws:
java.io.ObjectStreamException


Copyright © 2011. All Rights Reserved.