Statistics
| Revision:

root / tmp / org.txm.core / src / groovy / org / txm / macro / txt / CharListMacro.groovy @ 187

History | View | Annotate | Download (752 Bytes)

1
package org.txm.macro.txt;
2
// STANDARD DECLARATIONS
3

    
4
import org.kohsuke.args4j.*
5
import groovy.transform.Field
6
import org.txm.rcpapplication.swt.widget.parameters.*
7

    
8
// BEGINNING OF PARAMETERS
9

    
10
// Declare each parameter here
11
// (available widget types: Query, File, Folder, String, Text, Boolean, Integer, Float and Date)
12

    
13
@Field @Option(name="inputFile", usage="The file to read", widget="File", required=true, def="C:/Temp/foo.txt")
14
def inputFile
15

    
16
// Open the parameters input dialog box
17
if (!ParametersDialog.open(this)) return;
18

    
19
// END OF PARAMETERS
20

    
21
String s = inputFile.getText()
22

    
23
def dic = [:]
24

    
25
for (char c : s) {
26
        if (!dic.containsKey(c)) { dic[c] = 0 }
27
        dic[c]++
28
}
29

    
30
for (def e : dic) { println(sprintf("%c\t%d", [e.getKey(), e.getValue()])) }