- java.lang.Object
-
- java.util.Calendar
-
- java.util.GregorianCalendar
-
- org.datanucleus.store.types.wrappers.GregorianCalendar
-
- All Implemented Interfaces:
Serializable
,Cloneable
,Comparable<Calendar>
,SCO<GregorianCalendar>
public class GregorianCalendar extends GregorianCalendar implements SCO<GregorianCalendar>
A mutable second-class GregorianCalendar object.- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class java.util.Calendar
Calendar.Builder
-
-
Field Summary
Fields Modifier and Type Field Description protected AbstractMemberMetaData
ownerMmd
protected DNStateManager
ownerSM
-
Fields inherited from class java.util.GregorianCalendar
AD, BC
-
Fields inherited from class java.util.Calendar
ALL_STYLES, AM, AM_PM, APRIL, areFieldsSet, AUGUST, DATE, DAY_OF_MONTH, DAY_OF_WEEK, DAY_OF_WEEK_IN_MONTH, DAY_OF_YEAR, DECEMBER, DST_OFFSET, ERA, FEBRUARY, FIELD_COUNT, fields, FRIDAY, HOUR, HOUR_OF_DAY, isSet, isTimeSet, JANUARY, JULY, JUNE, LONG, LONG_FORMAT, LONG_STANDALONE, MARCH, MAY, MILLISECOND, MINUTE, MONDAY, MONTH, NARROW_FORMAT, NARROW_STANDALONE, NOVEMBER, OCTOBER, PM, SATURDAY, SECOND, SEPTEMBER, SHORT, SHORT_FORMAT, SHORT_STANDALONE, SUNDAY, THURSDAY, time, TUESDAY, UNDECIMBER, WEDNESDAY, WEEK_OF_MONTH, WEEK_OF_YEAR, YEAR, ZONE_OFFSET
-
-
Constructor Summary
Constructors Constructor Description GregorianCalendar(DNStateManager sm, AbstractMemberMetaData mmd)
Creates a GregorianCalendar object that represents the time at which it was allocated.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(int field, int amount)
Method to add an amount to a fieldvoid
attachCopy(GregorianCalendar value)
Method to return an attached version for the passed StateManager and field, using the passed value.Object
clone()
Creates and returns a copy of this object.GregorianCalendar
detachCopy(FetchPlanState state)
Method to return a detached copy of the value object.String
getFieldName()
Accessor for the field nameObject
getOwner()
Accessor for the owner.GregorianCalendar
getValue()
Accessor for the unwrapped value that we are wrapping.void
initialise()
Method to initialise the SCO for use, and allowing the SCO to be loaded from the datastore (when we have a backing store).void
initialise(GregorianCalendar cal)
Method to initialise the SCO for use with the provided initial value.void
initialise(GregorianCalendar newValue, Object oldValue)
Method to initialise the SCO for use, where replacing an old value with a new value such as when calling a setter field passing in a new value.void
makeDirty()
Utility to mark the object as dirtyvoid
roll(int field, boolean up)
Method to roll a field by 1.void
roll(int field, int amount)
Method to roll the value of a fieldvoid
set(int field, int value)
Method to set a fieldvoid
setFirstDayOfWeek(int value)
Method to set the first day of the weekvoid
setGregorianChange(Date date)
Method to set the gregorian cal change datevoid
setLenient(boolean lenient)
Method to set the lenient settingvoid
setMinimalDaysInFirstWeek(int value)
Method to set the minimal days in the weekvoid
setTimeInMillis(long millis)
Method to set the time in millisecondsvoid
setTimeZone(TimeZone value)
Method to set the timezonevoid
unsetOwner()
Utility to unset the owner.protected Object
writeReplace()
The writeReplace method is called when ObjectOutputStream is preparing to write the object to the stream.-
Methods inherited from class java.util.GregorianCalendar
computeFields, computeTime, equals, from, getActualMaximum, getActualMinimum, getCalendarType, getGreatestMinimum, getGregorianChange, getLeastMaximum, getMaximum, getMinimum, getTimeZone, getWeeksInWeekYear, getWeekYear, hashCode, isLeapYear, isWeekDateSupported, setWeekDate, toZonedDateTime
-
Methods inherited from class java.util.Calendar
after, before, clear, clear, compareTo, complete, get, getAvailableCalendarTypes, getAvailableLocales, getDisplayName, getDisplayNames, getFirstDayOfWeek, getInstance, getInstance, getInstance, getInstance, getMinimalDaysInFirstWeek, getTime, getTimeInMillis, internalGet, isLenient, isSet, set, set, set, setTime, toInstant, toString
-
-
-
-
Field Detail
-
ownerSM
protected transient DNStateManager ownerSM
-
ownerMmd
protected transient AbstractMemberMetaData ownerMmd
-
-
Constructor Detail
-
GregorianCalendar
public GregorianCalendar(DNStateManager sm, AbstractMemberMetaData mmd)
Creates a GregorianCalendar object that represents the time at which it was allocated. Assigns owning object and field name.- Parameters:
sm
- StateManager for the owning objectmmd
- Metadata for the member
-
-
Method Detail
-
initialise
public void initialise()
Description copied from interface:SCO
Method to initialise the SCO for use, and allowing the SCO to be loaded from the datastore (when we have a backing store). This can be utilised to perform any eager loading of information from the datastore.- Specified by:
initialise
in interfaceSCO<GregorianCalendar>
-
initialise
public void initialise(GregorianCalendar newValue, Object oldValue)
Description copied from interface:SCO
Method to initialise the SCO for use, where replacing an old value with a new value such as when calling a setter field passing in a new value. Note that oldValue is marked as Object since for cases where the member type is Collection the newValue could be, for example, ArrayList, and the oldValue of type Collection (representing null).- Specified by:
initialise
in interfaceSCO<GregorianCalendar>
- Parameters:
newValue
- New value (to wrap)oldValue
- Old value (to use in deciding what needs deleting etc)
-
initialise
public void initialise(GregorianCalendar cal)
Description copied from interface:SCO
Method to initialise the SCO for use with the provided initial value. This is used, for example, when retrieving the field from the datastore and setting it in the persistable object.- Specified by:
initialise
in interfaceSCO<GregorianCalendar>
- Parameters:
cal
- the object from which to copy the value.
-
getValue
public GregorianCalendar getValue()
Accessor for the unwrapped value that we are wrapping.- Specified by:
getValue
in interfaceSCO<GregorianCalendar>
- Returns:
- The unwrapped value
-
unsetOwner
public void unsetOwner()
Utility to unset the owner.- Specified by:
unsetOwner
in interfaceSCO<GregorianCalendar>
-
getOwner
public Object getOwner()
Accessor for the owner.- Specified by:
getOwner
in interfaceSCO<GregorianCalendar>
- Returns:
- The owner
-
getFieldName
public String getFieldName()
Accessor for the field name- Specified by:
getFieldName
in interfaceSCO<GregorianCalendar>
- Returns:
- The field name
-
makeDirty
public void makeDirty()
Utility to mark the object as dirty
-
detachCopy
public GregorianCalendar detachCopy(FetchPlanState state)
Method to return a detached copy of the value object.- Specified by:
detachCopy
in interfaceSCO<GregorianCalendar>
- Parameters:
state
- State for detachment process- Returns:
- The detached copy
-
attachCopy
public void attachCopy(GregorianCalendar value)
Method to return an attached version for the passed StateManager and field, using the passed value.- Specified by:
attachCopy
in interfaceSCO<GregorianCalendar>
- Parameters:
value
- The new value
-
clone
public 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 persistable objects. In contrast to Object.clone(), this method must not throw a CloneNotSupportedException.
- Specified by:
clone
in interfaceSCO<GregorianCalendar>
- Overrides:
clone
in classGregorianCalendar
- Returns:
- A clone of the object
-
writeReplace
protected Object writeReplace() throws 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:
ObjectStreamException
- if an error occurs
-
add
public void add(int field, int amount)
Method to add an amount to a field- Overrides:
add
in classGregorianCalendar
- Parameters:
field
- The fieldamount
- The amount to add
-
roll
public void roll(int field, boolean up)
Method to roll a field by 1.- Overrides:
roll
in classGregorianCalendar
- Parameters:
field
- The fieldup
- The whether to move it up
-
roll
public void roll(int field, int amount)
Method to roll the value of a field- Overrides:
roll
in classGregorianCalendar
- Parameters:
field
- The fieldamount
- The amount to roll by
-
set
public void set(int field, int value)
Method to set a field
-
setGregorianChange
public void setGregorianChange(Date date)
Method to set the gregorian cal change date- Overrides:
setGregorianChange
in classGregorianCalendar
- Parameters:
date
- The new change date
-
setFirstDayOfWeek
public void setFirstDayOfWeek(int value)
Method to set the first day of the week- Overrides:
setFirstDayOfWeek
in classCalendar
- Parameters:
value
- The first day of the week
-
setLenient
public void setLenient(boolean lenient)
Method to set the lenient setting- Overrides:
setLenient
in classCalendar
- Parameters:
lenient
- Whether it is lenient
-
setMinimalDaysInFirstWeek
public void setMinimalDaysInFirstWeek(int value)
Method to set the minimal days in the week- Overrides:
setMinimalDaysInFirstWeek
in classCalendar
- Parameters:
value
- The minimal days in the week
-
setTimeInMillis
public void setTimeInMillis(long millis)
Method to set the time in milliseconds- Overrides:
setTimeInMillis
in classCalendar
- Parameters:
millis
- The new time in millisecs
-
setTimeZone
public void setTimeZone(TimeZone value)
Method to set the timezone- Overrides:
setTimeZone
in classGregorianCalendar
- Parameters:
value
- The new timezone
-
-