Media Authoring
with Java API

tv.amwa.maj.embeddable
Class ProductVersion

java.lang.Object
  extended by tv.amwa.maj.embeddable.ProductVersion
All Implemented Interfaces:
Serializable, Cloneable, MAJCommon, XMLSerializable, ProductVersion

public final class ProductVersion
extends Object
implements ProductVersion, Serializable, XMLSerializable, Cloneable, MAJCommon

Implementation of a version number for an application, represented with four release levels and its product release type. The four release levels specify the major, minor, tertiary and patch level of a product.

A persistent representation of a product version may be represented by the following columns in a database:

     'ProductVersion_type' int(11) DEFAULT NULL,
     'ProductVersion_major' smallint(6) NOT NULL,
     'ProductVersion_minor' smallint(6) NOT NULL,
     'ProductVersion_tertiary' smallint(6) NOT NULL,
     'ProductVersion_patchLevel' smallint(6) NOT NULL
 

Author:
Richard Cartwright
See Also:
ProductReleaseType, VersionType, TypeDefinitionRecord.ProductVersion, Identification.getProductVersion(), Identification.getRefImplVersion(), Serialized Form

Nested Class Summary
static class ProductVersion.XMLHandler
          XML parser event handler for converting product version elements into product version values.
 
Field Summary
static String PRODUCTVERSION_TAG
           
 
Constructor Summary
ProductVersion(short major, short minor, short tertiary, short patchLevel, ProductReleaseType type)
          Create a product version value that represents the version of an application.
 
Method Summary
 void appendXMLChildren(Node parent)
          Append child elements to the given parent node to serialize the value of an object to an XML fragment.
 void appendXMLChildren(Node parent, String alternativeTag)
          Additional version of appendXMLChildren(Node) that allows the tag name for the version number tag to be altered.
static ProductVersion castFromInterface(ProductVersion alien)
          Cast a tv.amwa.maj.record.ProductVersion value from the generic interface to this implementation.
 ProductVersion clone()
          Creates a cloned deep copy of this embeddable value.
 boolean equals(Object o)
          Tests to see if the given object is equal to this embeddable value.
 short getMajor()
          Returns the major component of the version number.
 short getMinor()
          Returns the minor component of the version number.
 short getPatchLevel()
          Returns the patch level component of the version number.
 short getTertiary()
          Returns the tertiary component of the version number.
 ProductReleaseType getType()
          Returns the associated application's product release type, for example final, debug, beta etc..
 int hashCode()
          Returns a hash code value for this embeddable object.
 void setMajor(short major)
          Sets the major component of this version number.
 void setMinor(short minor)
          Sets the minor component of the version number.
 void setPatchLevel(short patchLevel)
          Sets the patch level component of the version number.
 void setPropertiesFromInterface(ProductVersion castFrom)
          Set the properties of this value from those available in the given value, which is specified by the product version interface.
 void setTertiary(short tertiary)
          Sets the tertiary component of the version number.
 void setType(ProductReleaseType type)
          Sets the associated application's product release type, for example final, debug, beta etc..
 String toString()
          Creates a pseudo-XML representation of the current value of this product version.
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

PRODUCTVERSION_TAG

public static final String PRODUCTVERSION_TAG
See Also:
Constant Field Values
Constructor Detail

ProductVersion

public ProductVersion(@UInt16
                      short major,
                      @UInt16
                      short minor,
                      @UInt16
                      short tertiary,
                      @UInt16
                      short patchLevel,
                      ProductReleaseType type)
               throws NullPointerException,
                      IllegalArgumentException

Create a product version value that represents the version of an application.

Parameters:
major - Application's major version number.
minor - Application's minor version number.
tertiary - Application's tertiary version number.
patchLevel - Application's patch level.
type - Application's product release type.
Throws:
NullPointerException - The product release type argument is null.
IllegalArgumentException - One of more of the major, minor, tertiary or patch level values is negative.
Method Detail

castFromInterface

public static final ProductVersion castFromInterface(ProductVersion alien)
                                              throws NullPointerException

Cast a tv.amwa.maj.record.ProductVersion value from the generic interface to this implementation. If the given value is not this MAJ API implementation, a copy will be instantiated of this type and with an equivalent value.

Parameters:
alien - A potentially alien implementation of an instance of the product version interface.
Returns:
Instance of this class that is equal to the given value.
Throws:
NullPointerException - The given alien value is null.
See Also:
setPropertiesFromInterface(tv.amwa.maj.record.ProductVersion)

setPropertiesFromInterface

public final void setPropertiesFromInterface(ProductVersion castFrom)
                                      throws NullPointerException

Set the properties of this value from those available in the given value, which is specified by the product version interface.

Parameters:
castFrom - Value to extract properties from.
Throws:
NullPointerException - The given value to use to set this value is null.
See Also:
castFromInterface(tv.amwa.maj.record.ProductVersion)

getMajor

@UInt16
public final short getMajor()
Description copied from interface: ProductVersion

Returns the major component of the version number.

Specified by:
getMajor in interface ProductVersion
Returns:
Major component of the version number.

setMajor

public final void setMajor(@UInt16
                           short major)
                    throws IllegalArgumentException
Description copied from interface: ProductVersion

Sets the major component of this version number.

Specified by:
setMajor in interface ProductVersion
Parameters:
major - Major component of the version number.
Throws:
IllegalArgumentException - Cannot set the major component of this product version to a negative value.

getMinor

@UInt16
public final short getMinor()
Description copied from interface: ProductVersion

Returns the minor component of the version number.

Specified by:
getMinor in interface ProductVersion
Returns:
Minor component of the version number.

setMinor

public final void setMinor(@UInt16
                           short minor)
                    throws IllegalArgumentException
Description copied from interface: ProductVersion

Sets the minor component of the version number.

Specified by:
setMinor in interface ProductVersion
Parameters:
minor - Minor component of the version number.
Throws:
IllegalArgumentException - Cannot set the minor component of this product version to a negative value.

getPatchLevel

@UInt16
public final short getPatchLevel()
Description copied from interface: ProductVersion

Returns the patch level component of the version number.

Specified by:
getPatchLevel in interface ProductVersion
Returns:
Patch level component of the version number.

setPatchLevel

public final void setPatchLevel(@UInt16
                                short patchLevel)
                         throws IllegalArgumentException
Description copied from interface: ProductVersion

Sets the patch level component of the version number.

Specified by:
setPatchLevel in interface ProductVersion
Parameters:
patchLevel - Patch level component of the version number.
Throws:
IllegalArgumentException - Cannot set the patch level component of this product version to a negative value.

getTertiary

@UInt16
public final short getTertiary()
Description copied from interface: ProductVersion

Returns the tertiary component of the version number.

Specified by:
getTertiary in interface ProductVersion
Returns:
Tertiary component of the version number.

setTertiary

public final void setTertiary(@UInt16
                              short tertiary)
                       throws IllegalArgumentException
Description copied from interface: ProductVersion

Sets the tertiary component of the version number.

Specified by:
setTertiary in interface ProductVersion
Parameters:
tertiary - Tertiary component of the version number.
Throws:
IllegalArgumentException - Cannot set the tertiary component of this product version to a negative value.

getType

public final ProductReleaseType getType()
Description copied from interface: ProductVersion

Returns the associated application's product release type, for example final, debug, beta etc..

Specified by:
getType in interface ProductVersion
Returns:
Associated application's release type.

setType

public final void setType(ProductReleaseType type)
                   throws NullPointerException
Description copied from interface: ProductVersion

Sets the associated application's product release type, for example final, debug, beta etc..

Specified by:
setType in interface ProductVersion
Parameters:
type - Associated application's release type.
Throws:
NullPointerException - The given product release type is null.

equals

public final boolean equals(Object o)
Description copied from interface: MAJCommon

Tests to see if the given object is equal to this embeddable value. To be equal, the given value must be not null, share the same interface to its value and each of the properties of the value must each be equal.

Specified by:
equals in interface MAJCommon
Overrides:
equals in class Object
Parameters:
o - Object to test for equality with.
Returns:
Is the given object equals to this value?
See Also:
Object.equals(Object)

toString

public final String toString()

Creates a pseudo-XML representation of the current value of this product version. The value will be formatted in a similar way to the following example:

     <ProductVersion>
       <major>0</major>
       <minor>3</minor>
       <tertiary>1</tertiary>
       <patchLevel>2</patchLevel>
       <type>VersionDebug</type>
     </ProductVersion>
 

Specified by:
toString in interface MAJCommon
Overrides:
toString in class Object
Returns:
Pseudo-XML representation of this product version.
See Also:
Object.toString()

clone

public final ProductVersion clone()
Description copied from interface: MAJCommon

Creates a cloned deep copy of this embeddable value. The clone will be initialized to have the same value as this value but exists independently from then on. Changes to this value will not effect the clone and changes to the clone will not effect this. MAJ API clones are true deep clones with no shared references to areas of memory within the original.

This method does not throw a CloneNotSupportedException as all embeddable values must implement the Cloneable interface.

Specified by:
clone in interface MAJCommon
Overrides:
clone in class Object
Returns:
Independent clone of this value, which is a deep copy.
See Also:
Object.clone()

hashCode

public final int hashCode()
Description copied from interface: MAJCommon

Returns a hash code value for this embeddable object.

Specified by:
hashCode in interface MAJCommon
Overrides:
hashCode in class Object
Returns:
Hash code value for this embeddable object.
See Also:
Object.hashCode()

appendXMLChildren

public final void appendXMLChildren(Node parent)
Description copied from interface: XMLSerializable

Append child elements to the given parent node to serialize the value of an object to an XML fragment. Methods of the XMLBuilder class are provided to help with this process.

Specified by:
appendXMLChildren in interface XMLSerializable
Parameters:
parent - XML parent element to append child nodes to.

appendXMLChildren

public final void appendXMLChildren(Node parent,
                                    String alternativeTag)

Additional version of appendXMLChildren(Node) that allows the tag name for the version number tag to be altered.

Parameters:
parent - Parent node to append this product version to as an XML child.
alternativeTag - Name of the tag to use to represent the product version.

Media Authoring
with Java API

(c) 2007-2008 Richard Cartwright, all rights reserved. Subject to the terms of the AAF SDK Public Source License.