edu.UCL.xmiddle.tree
Class PrimaryIDVersion

java.lang.Object
  |
  +--edu.UCL.xmiddle.tree.PrimaryIDVersion
All Implemented Interfaces:
Version

public class PrimaryIDVersion
extends java.lang.Object
implements Version

PrimaryIDVersion.java Stores a version identified by the primary ID of the localhost, the primary ID of the remote host, and the version number. Editions are also represented by this class. Created: Tue Aug 7 13:19:37 2001


Constructor Summary
PrimaryIDVersion(java.lang.String primaryID1, java.lang.String primaryID2, int number, boolean isEdition)
          Creates a new PrimaryIDVersion instance.
PrimaryIDVersion(java.lang.String primaryID1, java.lang.String primaryID2, java.lang.String version)
          Creates a new PrimaryIDVersion instance, using a version string.
 
Method Summary
 short compare(Version other)
          Compares this version with other
 java.lang.Object[] getIDs()
          Gets the two ids involved in this version
 int getNumber()
          Returns the version number
 Version inc()
           
 Version inc(java.lang.Object remoteID)
          Return a new version with the version number increased by one.
 Version inc(java.lang.Object primaryID1, java.lang.Object primaryID2)
          Return a new version with the version number increased by one.
 boolean isEdition()
          Returns true if this version is also an edition
 void setEdition(boolean edition)
          Sets whether this version is also an edition or not
 Version toEdition()
          Returns a new version of this Version's details, but with the isEdition flag set to true.
 java.lang.String toString()
          Returns a String representation of this version
 Version toVersion()
          Returns a new version of this Edition's details, but with the isEdition flag set to false.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PrimaryIDVersion

public PrimaryIDVersion(java.lang.String primaryID1,
                        java.lang.String primaryID2,
                        int number,
                        boolean isEdition)
Creates a new PrimaryIDVersion instance.

Parameters:
primaryID1 - The id of the first host involved in generating this version
primaryID2 - the id of the second host involved in generating this version
number - the version number
isEdition - If true then this version is an edition

PrimaryIDVersion

public PrimaryIDVersion(java.lang.String primaryID1,
                        java.lang.String primaryID2,
                        java.lang.String version)
                 throws java.lang.NumberFormatException
Creates a new PrimaryIDVersion instance, using a version string.

Parameters:
primaryID1 - The id of the first host involved in generating this version
primaryID2 - the id of the second host involved in generating this version (or $)
version - String holding a version. If this is a version, then the string will end in 'v'.
Throws:
java.lang.NumberFormatException - if the number contained in 'version' is invalid.
Method Detail

compare

public short compare(Version other)
Compares this version with other

Specified by:
compare in interface Version
Parameters:
other - another version with which this version is to be compared
Returns:
-1 if this versionother or 0 otherwise

getNumber

public int getNumber()
Returns the version number

Specified by:
getNumber in interface Version
Returns:
an int value

getIDs

public java.lang.Object[] getIDs()
Gets the two ids involved in this version

Specified by:
getIDs in interface Version
Returns:
The ids of the two hosts between which this version was generated

inc

public Version inc(java.lang.Object remoteID)
Return a new version with the version number increased by one. The new version will be generated by primaryID1 and remoteID

Specified by:
inc in interface Version
Parameters:
remoteID - The id of the remote host with which the new version was generated
Returns:
a new Version

inc

public Version inc(java.lang.Object primaryID1,
                   java.lang.Object primaryID2)
Return a new version with the version number increased by one. The new version will be generated by primaryID1 and primaryID2

Specified by:
inc in interface Version
Parameters:
primaryID1 - the ID of the first host which generated the new version
primaryID2 - the ID of the second host which generated the new version
Returns:
a new Version

setEdition

public void setEdition(boolean edition)
Sets whether this version is also an edition or not

Specified by:
setEdition in interface Version
Parameters:
edition - if TRUE then this version is an edition

inc

public Version inc()
Specified by:
inc in interface Version
Returns:

toString

public java.lang.String toString()
Returns a String representation of this version

Specified by:
toString in interface Version
Overrides:
toString in class java.lang.Object
Returns:
Format: primaryID1,primaryID2,versionNumber +v if it is not an edition

isEdition

public boolean isEdition()
Returns true if this version is also an edition

Specified by:
isEdition in interface Version
Returns:
a boolean value

toEdition

public Version toEdition()
Returns a new version of this Version's details, but with the isEdition flag set to true. (ie. it creates a new edition from an existing version)

Specified by:
toEdition in interface Version
Returns:
the new edition.

toVersion

public Version toVersion()
Returns a new version of this Edition's details, but with the isEdition flag set to false. (ie. it creates a new version from an existing edition)

Specified by:
toVersion in interface Version
Returns:
the new version.