Packageorg.as3coreaddendum.system.comparators
Classpublic class AlphabeticalComparator
InheritanceAlphabeticalComparator Inheritance Object
Implements IComparator

A comparator for alphabetic order of String objects.

View the examples

See also

AlphabeticalComparison


Public Properties
 PropertyDefined By
  comparison : AlphabeticalComparison
Defines the type of comparison to be used.
AlphabeticalComparator
Public Methods
 MethodDefined By
  
Constructor, creates a new AlphabeticComparator object.
AlphabeticalComparator
  
compare(o1:*, o2:*):int
Performs the comparison between the two arguments.
AlphabeticalComparator
  
toString():String
Returns the string representation of this object.
AlphabeticalComparator
Property Detail
comparisonproperty
comparison:AlphabeticalComparison

Defines the type of comparison to be used.


Implementation
    public function get comparison():AlphabeticalComparison
    public function set comparison(value:AlphabeticalComparison):void

Throws
ArgumentError — If is assigned a null value.

See also

Constructor Detail
AlphabeticalComparator()Constructor
public function AlphabeticalComparator(comparison:AlphabeticalComparison)

Constructor, creates a new AlphabeticComparator object.

Parameters
comparison:AlphabeticalComparison — Indicates which type of comparison will be used.

Throws
ArgumentError — If the 'comparison' argument is null.

See also

Method Detail
compare()method
public function compare(o1:*, o2:*):int

Performs the comparison between the two arguments.

Parameters

o1:* — The first String object to be compared.
 
o2:* — The second String object to be compared.

Returns
int — A negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.

Throws
ArgumentError — if any of the arguments is null.
toString()method 
public function toString():String

Returns the string representation of this object.

Returns
String — the string representation of the this object.
Examples
     import org.as3coreaddendum.system.comparators.AlphabeticComparator;
     
     var c1:AlphabeticComparator = new AlphabeticComparator(AlphabeticComparison.LOWER_CASE_FIRST);
     
     c1.compare("a", "a")                      // 0
     c1.compare("a", "b")                      // -1
     c1.compare("b", "a")                      // 1
     c1.compare("a", "A")                      // -1
     c1.compare("A", "a")                      // 1
     c1.compare("comparison", "comparison")    // 0
     c1.compare("comparison", "comParison")    // -1
     c1.compare("comParison", "comparison")    // 1
     c1.compare("comparison", "Comparison")    // -1
     c1.compare("Comparison", "comparison")    // 1
     c1.compare("between", "strings")          // -1
     c1.compare("between", "Strings")          // -1
     c1.compare("Between", "strings")          // -1
     c1.compare("Between", "Strings")          // -1
     c1.compare("between", "between")          // 0
     c1.compare("between", "betweena")         // -1
     c1.compare("betweena", "betweenA")        // -1
     c1.compare("betweenA", "betweena")        // 1
     c1.compare("TestA", "TestB")              // -1
     c1.compare("TestB", "TestA")              // 1
     
     import org.as3coreaddendum.system.comparators.AlphabeticComparator;
     
     var c2:AlphabeticComparator = new AlphabeticComparator(AlphabeticComparison.UPPER_CASE_FIRST);
     
     c2.compare("a", "a")                      // 0
     c2.compare("a", "b")                      // -1
     c2.compare("b", "a")                      // 1
     c2.compare("a", "A")                      // 1
     c2.compare("A", "a")                      // -1
     c2.compare("comparison", "comparison")    // 0
     c2.compare("comparison", "comParison")    // 1
     c2.compare("comParison", "comparison")    // -1
     c2.compare("comparison", "Comparison")    // 1
     c2.compare("Comparison", "comparison")    // -1
     c2.compare("between", "strings")          // -1
     c2.compare("between", "Strings")          // -1
     c2.compare("Between", "strings")          // -1
     c2.compare("Between", "Strings")          // -1
     c2.compare("between", "between")          // 0
     c2.compare("between", "betweena")         // -1
     c2.compare("betweena", "betweenA")        // 1
     c2.compare("betweenA", "betweena")        // -1
     c2.compare("TestA", "TestB")              // -1
     c2.compare("TestB", "TestA")              // 1
     
     import org.as3coreaddendum.system.comparators.AlphabeticComparator;
     
     var c3:AlphabeticComparator = new AlphabeticComparator(AlphabeticalComparison.CASE_INSENSITIVE);
     
     c3.compare("a", "a")                      // 0
     c3.compare("a", "b")                      // -1
     c3.compare("b", "a")                      // 1
     c3.compare("a", "A")                      // 0
     c3.compare("A", "a")                      // 0
     c3.compare("comparison", "comparison")    // 0
     c3.compare("comparison", "comParison")    // 0
     c3.compare("comParison", "comparison")    // 0
     c3.compare("comparison", "Comparison")    // 0
     c3.compare("Comparison", "comparison")    // 0
     c3.compare("between", "strings")          // -1
     c3.compare("between", "Strings")          // -1
     c3.compare("Between", "strings")          // -1
     c3.compare("Between", "Strings")          // -1
     c3.compare("between", "between")          // 0
     c3.compare("between", "betweena")         // -1
     c3.compare("betweena", "betweenA")        // 0
     c3.compare("betweenA", "betweena")        // 0
     c3.compare("TestA", "TestB")              // -1
     c3.compare("TestB", "TestA")              // 1