Packageorg.as3coreaddendum.system.comparators
Classpublic class StringComparator
InheritanceStringComparator Inheritance Object
Implements IComparator

A comparator for String objects.

View the examples



Public Properties
 PropertyDefined By
  stringCase : StringCase
Defines whether case is considered in the comparison.
StringComparator
Public Methods
 MethodDefined By
  
Constructor, creates a new StringComparator object.
StringComparator
  
compare(o1:*, o2:*):int
Performs the comparison between the two arguments.
StringComparator
  
toString():String
Returns the string representation of this object.
StringComparator
Property Detail
stringCaseproperty
stringCase:StringCase

Defines whether case is considered in the comparison.


Implementation
    public function get stringCase():StringCase
    public function set stringCase(value:StringCase):void
Constructor Detail
StringComparator()Constructor
public function StringComparator(stringCase:StringCase)

Constructor, creates a new StringComparator object.

Parameters
stringCase:StringCase — Indicates whether case sensitivity is considered or not in the comparison.
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.StringComparator;
     
     var c1:StringComparator = new StringComparator();
     
     c1.compare("comparison", "between");    // 1
     c1.compare("between", "comparison");    // -1
     c1.compare("between", "strings");       // 1
     c1.compare("strings", "between");       // -1
     c1.compare("STRINGS", "strings");       // 1
     c1.compare("strings", "Strings");       // -1
     c1.compare("strings", "strings");       // 0
     
     var c2:StringComparator = new StringComparator(false);
     
     c2.compare("STRINGS", "strings");    // 0
     c2.compare("strings", "Strings");    // 0
     c2.compare("between", "strings");    // 1