| Package | system |
| Class | public class Version |
| Inheritance | Version Object |
| Implements | Equatable |
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.
| Property | Defined 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 | ||
| Method | Defined 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 | ||
| build | property |
build:uintIndicates the build value of this version.
public function get build():uint public function set build(value:uint):void| major | property |
major:uintIndicates the major value of this version.
public function get major():uint public function set major(value:uint):void| minor | property |
minor:uintIndicates the minor value of this version.
public function get minor():uint public function set minor(value:uint):void| revision | property |
revision:uintIndicates the revision value of this version.
public function get revision():uint public function set revision(value:uint):void| Version | () | Constructor |
public function Version(major:uint = 0, minor:uint = 0, build:uint = 0, revision:uint = 0)Creates a new Version instance.
Parametersmajor: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.
|
| equals | () | method |
public function equals(o:*):BooleanWe 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:* |
Boolean |
| fromNumber | () | method |
public static function fromNumber(value:Number = 0):VersionConstructs 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) |
Version |
| fromString | () | method |
public static function fromString(value:String, separator:String = .):VersionConstructs a Version object from a string.
Parameters
value:String | |
separator:String (default = .) |
Version |
| toString | () | method |
public function toString(fields:int = 0):StringReturns 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 :
Parameters
fields:int (default = 0) |
String |
| valueOf | () | method |
public function valueOf():uintReturns the primitive value of the object.
Returnsuint — the primitive value of the object.
|