Packagesystem
Classpublic class Version
InheritanceVersion Inheritance Object
Implements Equatable

A basic Version class which is composed by four fields: major, minor, build and revision.

implementation note:

internaly we stock the value of a version (the total of each fields) as a uint which max value is 4294967295 (0xFFFFFFFF) this is done to be able to use operators.

     var v1:Version = new Version( 1, 0 );
     var v2:Version = new Version( 2, 0 );
     trace( v1 < v2 ); //true
     
by default operators in ECMAScript will use the valueOf of the class and this is neat because we can use operators without the need to really implement them. But this cause some little limitations on how much data each fields of a version object can stock
     > 0x  F F FF FFFF
     >     | |  |   |
     >     | |  |   \revision (max 65535)
     >     | |  \build (max 255)
     >     | \minor (max 15)
     >     \major (max 15)
     
Here the choice has been to favorise a lot the revision field, favorise a little the build field, and well give the rest to the major and minor fields. The logic behind that is: - revision should be able to cover the full cycle of a project during all its life - build should be able to cover all the different builds between two minor update - major and minor should cover all the different versions of a project considering you don't update them that much So the max version you can have is v15.15.255.65535 This logic and these limitations can change later.



Public Properties
 PropertyDefined By
  build : uint
Indicates the build value of this version.
Version
  major : uint
Indicates the major value of this version.
Version
  minor : uint
Indicates the minor value of this version.
Version
  revision : uint
Indicates the revision value of this version.
Version
Public Methods
 MethodDefined By
  
Version(major:uint = 0, minor:uint = 0, build:uint = 0, revision:uint = 0)
Creates a new Version instance.
Version
  
equals(o:*):Boolean
We don't really need an equals method as we override the valueOf, we can do something as var v1:Version = new Version( 1,0,0,0 ); var v2:Version = new Version( 1,0,0,0 ); trace( int(v1) == int(v2) ); //true A cast to Number/int force the valueOf, not ideal but sufficient, and the same for any other operators.
Version
  
fromNumber(value:Number = 0):Version
[static] Constructs a Version object from a number.
Version
  
fromString(value:String, separator:String = .):Version
[static] Constructs a Version object from a string.
Version
  
toString(fields:int = 0):String
Returns a string representation of the object.
Version
  
valueOf():uint
Returns the primitive value of the object.
Version
Property Detail
buildproperty
build:uint

Indicates the build value of this version.


Implementation
    public function get build():uint
    public function set build(value:uint):void
majorproperty 
major:uint

Indicates the major value of this version.


Implementation
    public function get major():uint
    public function set major(value:uint):void
minorproperty 
minor:uint

Indicates the minor value of this version.


Implementation
    public function get minor():uint
    public function set minor(value:uint):void
revisionproperty 
revision:uint

Indicates the revision value of this version.


Implementation
    public function get revision():uint
    public function set revision(value:uint):void
Constructor Detail
Version()Constructor
public function Version(major:uint = 0, minor:uint = 0, build:uint = 0, revision:uint = 0)

Creates a new Version instance.

Parameters
major:uint (default = 0) — The major value of the version.
 
minor:uint (default = 0) — The minor value of the version.
 
build:uint (default = 0) — The build value of the version.
 
revision:uint (default = 0) — The revision value of the version.
Method Detail
equals()method
public function equals(o:*):Boolean

We don't really need an equals method as we override the valueOf, we can do something as

         var v1:Version = new Version( 1,0,0,0 );
         var v2:Version = new Version( 1,0,0,0 );
         trace( int(v1) == int(v2) ); //true
         
A cast to Number/int force the valueOf, not ideal but sufficient, and the same for any other operators. But as we keep IEquatable for now, then we have no reason to not use it.

Parameters

o:*

Returns
Boolean
fromNumber()method 
public static function fromNumber(value:Number = 0):Version

Constructs a Version object from a number. If the number is zero or negative, or is NaN or Infity returns an empty version object.

Parameters

value:Number (default = 0)

Returns
Version
fromString()method 
public static function fromString(value:String, separator:String = .):Version

Constructs a Version object from a string.

Parameters

value:String
 
separator:String (default = .)

Returns
Version
toString()method 
public function toString(fields:int = 0):String

Returns a string representation of the object. By default, the format returned will include only the fields greater than zero

         var v:Version = new Version( 1, 5 );
         trace( v ); // "1.5"
         
note : the fields parameter allow you to force or limit the output format
         var v:Version = new Version( 1, 5 );
         trace( v.toString( 1 ) ); // "1"
         trace( v.toString( 4 ) ); // "1.5.0.0"
         

format :

  • major.minor.build.revision
  • major.minor.build
  • major.minor
  • major
  • Parameters

    fields:int (default = 0)

    Returns
    String
    valueOf()method 
    public function valueOf():uint

    Returns the primitive value of the object.

    Returns
    uint — the primitive value of the object.