Packagespark.globalization
Classpublic class SortingCollator
InheritanceSortingCollator Inheritance CollatorBase Inheritance GlobalizationBase Inheritance AdvancedStyleClient Inheritance flash.events.EventDispatcher

Language Version : ActionScript 3.0
Product Version : Flex 4.5
Runtime Versions : Flash Player 10.1, AIR 2.5

The SortingCollator class provides locale-sensitve string comparison capabilities with inital settings suitable for linguistic sorting purposes such as sorting a list of text strings that are displayed to an end-user.

This class is a wrapper class around the flash.globalization.Collator. Therefore the locale-specific string comparison is provided by the flash.globalization.Collator. However, this SortingCollator class can be used in MXML declartions, uses the locale style for the requested Locale ID name, and has methods and properties that are bindable. Additionally, LastOperationStatus is set, if there is an error or warning generated by the flash.globalization class.

The flash.globalization.Collator class uses the underlying operating system for the formatting functionality and to supply the locale specific data. On some operating systems, the flash.globalization classes are unsupported, this wrapper class provides a fallback functionality.

View the examples

See also

flash.globalization.Collator


Public Properties
 PropertyDefined By
 InheritedactualLocaleIDName : String
[override] [read-only] The name of the actual locale ID used by this class object.
CollatorBase
 InheritedclassName : String
[read-only] The name of the component class.
AdvancedStyleClient
 Inheritedid : String
The identity of the component.
AdvancedStyleClient
 InheritedignoreCase : Boolean
When this property is set to true, identical strings and strings that differ only in the case of the letters are evaluated as equal.
CollatorBase
 InheritedignoreCharacterWidth : Boolean
When this property is true, full-width and half-width forms of some Chinese and Japanese characters are evaluated as equal.
CollatorBase
 InheritedignoreDiacritics : Boolean
When this property is set to true, strings that use the same base characters but different accents or other diacritic marks are evaluated as equal.
CollatorBase
 InheritedignoreKanaType : Boolean
When this property is set to true, strings that differ only by the type of kana character being used are treated as equal.
CollatorBase
 InheritedignoreSymbols : Boolean
When this property is set to is true, symbol characters such as spaces, currency symbols, math symbols, and other types of symbols are ignored when sorting or matching.
CollatorBase
 InheritedinheritingStyles : Object
An object containing the inheritable styles for this non-visual style client instance.
AdvancedStyleClient
 InheritedlastOperationStatus : String
[override] [read-only] The status of the most recent operation that this class object performed.
CollatorBase
 InheritedmoduleFactory : IFlexModuleFactory
A module factory is used as context for finding the style manager that controls the styles for this non-visual style client instance.
AdvancedStyleClient
 InheritednonInheritingStyles : Object
The beginning of this component's chain of non-inheriting styles.
AdvancedStyleClient
 InheritednumericComparison : Boolean
Controls how numeric values embedded in strings are handled during string comparison.
CollatorBase
 InheritedstyleDeclaration : CSSStyleDeclaration
The style declaration that holds the inline styles declared by this object.
AdvancedStyleClient
 InheritedstyleManager : IStyleManager2
[read-only] Returns the StyleManager instance used by this component.
AdvancedStyleClient
 InheritedstyleName : Object
The source of this object's style values.
AdvancedStyleClient
 InheritedstyleParent : IAdvancedStyleClient
A component's parent is used to evaluate descendant selectors.
AdvancedStyleClient
Public Methods
 MethodDefined By
  
Constructs a new SortingCollator object to provide string comparisons according to the conventions of a specified locale.
SortingCollator
 Inherited
clearStyle(styleProp:String):void
Deletes a style property from this component instance.
AdvancedStyleClient
 Inherited
compare(string1:String, string2:String):int
Compares two strings and returns an integer value indicating whether the first string is less than, equal to, or greater than the second string.
CollatorBase
 Inherited
equals(string1:String, string2:String):Boolean
Compares two strings and returns a Boolean value indicating whether the strings are equal.
CollatorBase
 Inherited
getAvailableLocaleIDNames():Vector.<String>
[static] Lists all of the locale ID names supported by this class.
CollatorBase
 Inherited
Returns an Array of CSSStyleDeclaration objects for the type selector that applies to this component, or null if none exist.
AdvancedStyleClient
 Inherited
getStyle(styleProp:String):*
[override] Gets a style property that has been set anywhere in this component's style lookup chain.
GlobalizationBase
 Inherited
hasCSSState():Boolean
Returns true if currentCSSState is not null.
AdvancedStyleClient
 Inherited
initialized(document:Object, id:String):void
The initialized method is called when this class or a class that extends this class is used in an MXML declaration.
AdvancedStyleClient
 Inherited
matchesCSSState(cssState:String):Boolean
Returns true if cssState matches currentCSSState.
AdvancedStyleClient
 Inherited
matchesCSSType(cssType:String):Boolean
Determines whether this instance is the same as, or is a subclass of, the given type.
AdvancedStyleClient
 Inherited
notifyStyleChangeInChildren(styleProp:String, recursive:Boolean):void
Propagates style changes to the children of this style client instance.
AdvancedStyleClient
 Inherited
regenerateStyleCache(recursive:Boolean):void
Sets up the internal style cache values so that the getStyle() method functions.
AdvancedStyleClient
 Inherited
registerEffects(effects:Array):void
Registers the EffectManager as one of the event listeners for each effect event.
AdvancedStyleClient
 Inherited
setStyle(styleProp:String, newValue:*):void
Sets a style property on this component instance.
AdvancedStyleClient
 Inherited
styleChanged(styleProp:String):void
Detects changes to style properties.
AdvancedStyleClient
 Inherited
Flex calls the stylesInitialized() method when the styles for a component are first initialized.
AdvancedStyleClient
Protected Methods
 MethodDefined By
 Inherited
AdvancedStyleClient
Events
 Event Summary Defined By
 InheritedThe change event is generated whenever the locale style is changed or another property is set that would cause the format of a number to change or cause updates to the other values available through this class.GlobalizationBase
Styles
 Style Description Defined By
 InheritedType: String CSS Inheritance: yes
The locale identifier that specifies the language, region, script and optionally other related tags and keys.

See also

GlobalizationBase
Constructor Detail
SortingCollator()Constructor
public function SortingCollator()

Language Version : ActionScript 3.0
Product Version : Flex 4.5
Runtime Versions : Flash Player 10.1, AIR 2.5

Constructs a new SortingCollator object to provide string comparisons according to the conventions of a specified locale.

This class sets the initial values of the various collation options for general linguistic sorting usages such as sorting a list of text strings that are displayed to an end user. In this mode, differences in uppercase and lowercase letters, accented characters, and other differences specific to the locale are considered when doing string comparisons.

The comparison provided by an instance of this class is equivalent to constructing an instance of the flash.globalization.Collator with the initialMode paramater set to CollatorMode.SORTING. For more details and examples of this mode, please see the documentation for the flash.globalization.Collator class.

The locale for this class is supplied by the locale style. The locale style can be set in several ways:

If the locale style is not set by one of the above techniques, the instance of this class will be added as a StyleClient to the topLevelApplication and will therefore inherit the locale style from the topLevelApplication object when the locale dependent property getter or locale dependent method is called.

See also

flash.globalization.Collator
Examples
SortingCollatorExample.mxml
<?xml version="1.0" encoding="utf-8"?>
<!--

  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License.  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.

-->
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
               xmlns:s="library://ns.adobe.com/flex/spark"
               xmlns:mx="library://ns.adobe.com/flex/mx"
               width="100%" height="100%">

    <fx:Declarations>
        <s:SortingCollator id="sortingCollator"/>
    </fx:Declarations>

    <fx:Script>
        <![CDATA[
            import mx.collections.ArrayCollection;
            import mx.events.ListEvent;

            [Bindable]
            private var localeList:ArrayCollection
                = new ArrayCollection([
                    { label:"English (en)", data:"en" },
                    { label:"French (fr)", data:"fr" },
                    { label:"German (de)", data:"de" },
                    { label:"Latvian (lt)", data:"lt" },
                    { label:"Sweedish (sv)", data:"sv" },
                    { label:"Chinese (zh)", data:"zh" }]);

            private static const wordList:ArrayCollection
                = new ArrayCollection([
                    "B", "b", "a", "A" ,
                    "y (lt)", "i (lt)", "k (lt)",
                    "n (sv)", "ö (sv)", "o (sv)", "z (sv)",
                    "vu (sv)", "wo (sv)",
                    "däd (de)", "daed (de)",
                    "öf (de)", "of (de)",
                    "côte (fr)", "coté (fr)",
                    "手 (zh)", "中 (zh)", "土 (zh)", "岀 (zh)" ]);

            protected function localeSelector_changeHandler(
                                                        event:ListEvent):void
            {
                setStyle("locale", ComboBox(event.target).selectedItem.data);
                wordList.refresh();
            }
        ]]>
    </fx:Script>

    <mx:VBox>
        <mx:HBox>
            <s:Label text="Select Language"/>
            <mx:ComboBox id="localeSelector"
                change="localeSelector_changeHandler(event)"
                dataProvider="{localeList}"/>
        </mx:HBox>
        <mx:DataGrid id="dataGrid" width="100%"
            dataProvider="{wordList}" rowCount="{wordList.length}">
            <mx:columns>
                <mx:DataGridColumn headerText="Click here to sort"
                    sortCompareFunction="{sortingCollator.compare}"/>
            </mx:columns>
        </mx:DataGrid>
     </mx:VBox>
</s:Application>