Packagevegas.util.comparators
Classpublic class StringComparator
InheritanceStringComparator Inheritance CoreObject
ImplementsICloneable, IComparator, ICopyable

This comparator compare String objects.

Example :

  import vegas.util.comparators.StringComparator ;
  
  var comp1:StringComparator = new StringComparator() ;
  var comp2:StringComparator = new StringComparator(true) ; // ignore case
  
  var s0:String = "HELLO" ;
  var s1:String = "hello" ;
  var s2:String = "welcome" ;
  var s3:String = "world" ;
  
  trace( comp1.compare(s1, s2) ) ;  -1
  trace( comp1.compare(s2, s1) ) ;   1
  trace( comp1.compare(s1, s3) ) ;  -1
  trace( comp1.compare(s1, s1) ) ;  0
  
  trace( comp1.compare(s1, s0) ) ;  -1
  trace( comp2.compare(s1, s0) ) ;  0
  



Public Properties
 PropertyDefined by
  ignoreCase : Boolean
Allow to take into account the case for comparison.
StringComparator
Public Methods
 MethodDefined by
  
StringComparator(ignoreCase:Boolean = false)
Creates a new StringComparator instance.
StringComparator
  
clone():*
Creates and returns a shallow copy of the object.
StringComparator
  
compare(o1:*, o2:*):int
Returns an integer value to compare two String objects.
StringComparator
  
copy():*
Creates and returns a deep copy of the object.
StringComparator
  
[static] Returns the StringComparator singleton with the a true ignoreCase property.
StringComparator
 Inherited
Returns the internal ILogger reference of this ILogable object.
CoreObject
  
[static] Returns the StringComparator singleton with the a false ignoreCase property.
StringComparator
 Inherited
hashCode():uint
Returns a hashcode value for the object.
CoreObject
 Inherited
setLogger(log:ILogger = null):void
Sets the internal ILogger reference of this ILogable object.
CoreObject
  
toSource(indent:int = 0):String
Returns a Eden representation of the object.
StringComparator
 Inherited
toString():String
Returns the string representation of this instance.
CoreObject
Property detail
ignoreCaseproperty
public var ignoreCase:Boolean

Allow to take into account the case for comparison.

Constructor detail
StringComparator()constructor
public function StringComparator(ignoreCase:Boolean = false)

Creates a new StringComparator instance.

Parameters
ignoreCase:Boolean (default = false) — a boolean to define if the comparator ignore case or not.
Method detail
clone()method
public function clone():*

Creates and returns a shallow copy of the object.

Returns
* — A new object that is a shallow copy of this instance.
compare()method 
public function compare(o1:*, o2:*):int

Returns an integer value to compare two String objects.

Parameters
o1:* — the first String object to compare.
 
o2:* — the second String object to compare.

Returns
int

  • -1 if o1 is "lower" than (less than, before, etc.) o2 ;
  • 1 if o1 is "higher" than (greater than, after, etc.) o2 ;
  • 0 if o1 and o2 are equal.

  • Throws
    — if compare(a, b) and 'a' or 'b' aren't String objects.
    copy()method 
    public function copy():*

    Creates and returns a deep copy of the object.

    Returns
    * — A new object that is a deep copy of this instance.
    getIgnoreCaseStringComparator()method 
    public static function getIgnoreCaseStringComparator():IComparator

    Returns the StringComparator singleton with the a true ignoreCase property. Clients are encouraged to use the value returned from this method instead of constructing a new instance to reduce allocation and garbage collection overhead when multiple StringComparators may be used in the same application.

    Returns
    IComparator — the StringComparator singleton with the a true ignoreCase property.
    getStringComparator()method 
    public static function getStringComparator():IComparator

    Returns the StringComparator singleton with the a false ignoreCase property. Clients are encouraged to use the value returned from this method instead of constructing a new instance to reduce allocation and garbage collection overhead when multiple StringComparators may be used in the same application.

    Returns
    IComparator — the StringComparator singleton with the a false ignoreCase property.
    toSource()method 
    public override function toSource(indent:int = 0):String

    Returns a Eden representation of the object.

    Parameters
    indent:int (default = 0)

    Returns
    String — a string representation the source code of the object.