public class Version extends Object implements Serializable, Encodable
ObjectAdapter and is used
to represent a particular version (at a point in time) of domain object
wrapped by that adapter.
This is normally done using some form of incrementing number or timestamp, which would be held within the implementing class. The numbers, timestamps, etc should change for each changed object, and the different() method should indicate that the two Version objects are different.
The user's name and a timestamp should alos be kept so that when an message is passed to the user it can be of the form "user has change object at time"
| Constructor and Description |
|---|
Version(DataInputExtended input) |
| Modifier and Type | Method and Description |
|---|---|
static Version |
create(Long sequence) |
static Version |
create(Long sequence,
String user,
Date time) |
static Version |
create(Long sequence,
String user,
Long utcTimestamp) |
static Version |
create(String sequence,
String user,
String utcTimestamp) |
boolean |
different(Version version)
Compares this version against the specified version and returns true if
they are different versions (by checking
getSequence()). |
void |
encode(DataOutputExtended output)
Returns the domain object's value as an encoded byte array via the
encoder.
|
String |
enString(OidMarshaller oidMarshaller) |
boolean |
equals(Object obj) |
long |
getSequence()
The internal, strictly monotonically increasing, version number.
|
Date |
getTime()
Returns the time of the last change (used for display/reporting only, not comparison)
|
String |
getUser()
Returns the user who made the last change (used for display/reporting only)
|
Long |
getUtcTimestamp()
The time of the last change, as UTC milliseconds.
|
int |
hashCode() |
String |
sequence()
Returns the sequence for printing/display
|
String |
toString() |
public Version(DataInputExtended input) throws IOException
IOExceptionpublic void encode(DataOutputExtended output) throws IOException
Encodableencode in interface EncodableIOExceptionpublic long getSequence()
This might be the timestamp of the change, or it might be simply a number incrementing 1,2,3...
public String getUser()
May be null.
public Long getUtcTimestamp()
May be null.
getTime()public Date getTime()
May be null.
getUtcTimestamp()public String enString(OidMarshaller oidMarshaller)
public boolean different(Version version)
getSequence()).
This is use for optimistic checking, where the existence of a different version will normally cause a concurrency exception.
Copyright © 2010–2014 The Apache Software Foundation. All rights reserved.