Statistics
| Revision:

root / tmp / org.txm.groovy.core / src / groovy / org / txm / macroproto / CollatorTesterMacro.groovy @ 499

History | View | Annotate | Download (1.3 kB)

1
package org.txm.macroproto;
2
import org.kohsuke.args4j.*
3
import groovy.transform.Field
4
import org.txm.rcp.swt.widget.parameters.*
5
import java.text.Collator
6

    
7
// BEGINNING OF PARAMETERS
8
@Field @Option(name="string", usage="an example string", widget="String", required=false, def="δὲ ξυνεχὴς εἶχε εἶχεν βληχρός ἐπέβαλε ἔλαβε οὐ ἐπέλαβε ἐπεγίνετο")
9
def string
10

    
11
@Field @Option(name="localeName", usage="an example string", widget="String", required=false, def="el")
12
def localeName
13

    
14
@Field @Option(name="strengh", usage="0 1 or 2 for PRIMARY, SECONDARY and TERTIARY", widget="Integer", required=false, def="2")
15
def strengh
16

    
17
@Field @Option(name="decomposition", usage="0 1 or 2 for NO_DECOMPOSITION, CANONICAL_DECOMPOSITION, FULL_DECOMPOSITION", widget="Integer", required=false, def="2")
18
def decomposition
19

    
20
if (!ParametersDialog.open(this)) return;
21
// END OF PARAMETERS
22

    
23
Locale locale = new Locale(localeName)
24

    
25
def collator = Collator.getInstance(locale)
26

    
27
if (strengh < 0) strengh = 0
28
if (strengh > 2) strengh = 2
29
collator.setStrength(strengh)
30

    
31
if (decomposition < 0) decomposition = 0
32
if (decomposition > 2) decomposition = 2
33
collator.setDecomposition(decomposition)
34

    
35
println "RESULT"
36
Collections.sort(string.tokenize(), collator);
37
println tokenize