ProductVersionImpl (Media Authoring with Java API)
Date: 2016-02-05

tv.amwa.maj.record.impl

## Class ProductVersionImpl

- java.lang.Object
- - tv.amwa.maj.record.impl.ProductVersionImpl

- All Implemented Interfaces:
    Serializable, Cloneable, CommonConstants, XMLSerializable, ProductVersion

      public final class ProductVersionImpl
      extends Object
      implements ProductVersion, Serializable, XMLSerializable, Cloneable, CommonConstants

  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_BuildType' 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

  See Also:
    `ProductReleaseType`, `VersionTypeImpl`, `TypeDefinitions.ProductVersionType`, `IdentificationImpl.getApplicationVersion()`, `IdentificationImpl.getRefImplVersion()`, Serialized Form

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `ProductVersionImpl.XMLHandler` XML parser event handler for converting product version elements into product version values.

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `PRODUCTVERSION_TAG`

    - ### Fields inherited from interface tv.amwa.maj.constant.CommonConstants

      `AAF_METADICT_NAMESPACE, AAF_METADICT_PREFIX, AAF_XML_NAMESPACE, AAF_XML_PREFIX, ApplicationPluginObjectID, ApplicationPluginsID, MAX_NUM_RGBA_COMPS, MemberOfID, ObjectClassID, ParentClassID, PropertiesID, XMLClassIDAsAttributeName`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ProductVersionImpl(short major, short minor, short tertiary, short patchLevel, ProductReleaseType type)` Create a product version value that represents the version of an application.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `appendXMLChildren(Node parent)` Append extra 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.
    `ProductVersion` | `clone()` Create a cloned copy of this product version.
    `static ProductVersion` | `createFromBuffer(ByteBuffer buffer)`
    `boolean` | `equals(Object o)`
    `static ProductVersion` | `fromPersistentForm(String productVersion)`
    `ProductReleaseType` | `getBuildType()` Returns the associated application's product release type, for example final, debug, beta etc..
    `String` | `getComment()` Include a comment when serializing a value to XML.
    `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.
    `int` | `hashCode()`
    `static long` | `lengthAsBuffer(ProductVersion value)`
    `static ProductVersionImpl` | `parseFactory(String versionString)` Creates an instance of this product version class by parsing the given pseudo-XML version.
    `void` | `setBuildType(ProductReleaseType buildType)` Sets the associated application's product release type, for example final, debug, beta etc..
    `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` | `setTertiary(short tertiary)` Sets the tertiary component of the version number.
    `static String` | `toPersistentForm(ProductVersion productVersion)`
    `String` | `toString()` Creates a pseudo-XML representation of the current value of this product version.
    `static void` | `writeToBuffer(ProductVersion version, ByteBuffer buffer)`

    - ### 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

    - #### ProductVersionImpl

          public ProductVersionImpl(@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

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

    - #### getBuildType

          public final ProductReleaseType getBuildType()

      Description copied from interface: `ProductVersion`

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

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

    - #### setBuildType

          public final void setBuildType(ProductReleaseType buildType)
                                  throws NullPointerException

      Description copied from interface: `ProductVersion`

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

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

    - #### equals

          public final boolean equals(Object o)

      Overrides:
        `equals` in class `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>
                 <BuildType>VersionDebug</BuildType>
               </ProductVersion>

      Specified by:
        `toString` in interface `ProductVersion`
      Overrides:
        `toString` in class `Object`
      Returns:
        Pseudo-XML representation of this product version.

    - #### parseFactory

          public static final ProductVersionImpl parseFactory(String versionString)
                                                       throws NullPointerException,
                                                              ParseException

      Creates an instance of this product version class by parsing the given pseudo-XML version. This method will create an instance from the result of calling the `toString()` method. The pseudo-XML format is illustrated below:

               <ProductVersion>
                 <Major>0</Major>
                 <Minor>3</Minor>
                 <Tertiary>1</Tertiary>
                 <PatchLevel>2</PatchLevel>
                 <BuildType>VersionDebug</BuildType>
               </ProductVersion>

      If any tags are missing, default values are used and the method returns successfully. This method ignores any namespace prefix found in an element name.

      Parameters:
        `versionString` - Pseudo-XML string to convert into a product version instance.
      Returns:
        Product version created from the given string.
      Throws:
        `NullPointerException` - The given version string is `null`.
        `NumberFormatException` - Parse error creating a numerical value (major, minor, tertiary, patch level) or the given build type does not match the tokens of the product release type enumeration.
        `ParseException`

    - #### clone

          public final ProductVersion clone()

      Description copied from interface: `ProductVersion`

      Create a cloned copy of this product version.

      Specified by:
        `clone` in interface `ProductVersion`
      Overrides:
        `clone` in class `Object`
      Returns:
        Cloned copy of this product version.

    - #### hashCode

          public final int hashCode()

      Overrides:
        `hashCode` in class `Object`

    - #### appendXMLChildren

          public final void appendXMLChildren(Node parent)

      Description copied from interface: `XMLSerializable`

      Append extra 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.

    - #### getComment

          public String getComment()

      Description copied from interface: `XMLSerializable`

      Include a comment when serializing a value to XML. The comment will be inserted as the first child node of the element representing the class.

      Specified by:
        `getComment` in interface `XMLSerializable`
      Returns:
        Comment to add as the first child node of the element representing this class.

    - #### createFromBuffer

          public static final ProductVersion createFromBuffer(ByteBuffer buffer)
                                                       throws NullPointerException,
                                                              EndOfDataException

      Throws:
        `NullPointerException`
        `EndOfDataException`

    - #### lengthAsBuffer

          public static final long lengthAsBuffer(ProductVersion value)

    - #### writeToBuffer

          public static final void writeToBuffer(ProductVersion version,
                                                 ByteBuffer buffer)
                                          throws NullPointerException,
                                                 InsufficientSpaceException

      Throws:
        `NullPointerException`
        `InsufficientSpaceException`

    - #### toPersistentForm

          public static final String toPersistentForm(ProductVersion productVersion)

    - #### fromPersistentForm

          public static final ProductVersion fromPersistentForm(String productVersion)

(c)2007-2016 Richard Cartwright, all rights reserved. Licensed under Apache 2 license and subject to the AMWA IPR policy.