1 /* -*- Mode: idl; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #include
"nsISupports.idl"
8 interface nsICollation
;
10 [scriptable
, uuid(04971e14
-d6b3
-4ada
-8cbb
-c3a13842b349
)]
11 interface nsICollationFactory
: nsISupports
14 * Create a new collation for the current application locale.
16 * @return A new collation.
18 nsICollation CreateCollation
();
21 * Create a new collation for a given locale.
23 * @return A new collation.
25 nsICollation CreateCollationForLocale
(in ACString locale
);
28 [scriptable
, uuid(b0132cc0
-3786-4557-9874-910d7def5f93
)]
29 interface nsICollation
: nsISupports
{
31 // use the primary comparison for the given locale - no flags
32 const long kCollationStrengthDefault
= 0;
34 // do not consider case differences when doing the comparison i.e. A=a)
35 const long kCollationCaseInsensitiveAscii
= 1;
37 // do not consider accent differences when doing the comparison a=รก)
38 const long kCollationAccentInsenstive
= 2;
40 // case sensitive collation (default)
41 const long kCollationCaseSensitive
= kCollationStrengthDefault
;
43 // case insensitive collation
44 const long kCollationCaseInSensitive
= (kCollationCaseInsensitiveAscii | kCollationAccentInsenstive
);
46 // init this interface to a specified locale (should only be called by collation factory)
47 void initialize
(in ACString locale
);
49 // compare two strings
50 // result is same as strcmp
51 long compareString
(in long strength
, in AString string1
, in AString string2
);
53 // allocate sort key from input string
54 // returns newly allocated key
55 [noscript
] Array
<octet
> allocateRawSortKey
(in long strength
,
58 // compare two sort keys
59 // result is same as strcmp
60 [noscript
] long compareRawSortKey
(in Array
<octet
> key1
,
61 in Array
<octet
> key2
);