Révision 3857
TXM/trunk/bundles/org.txm.utils.core/src/org/txm/utils/StreamHog.java (revision 3857) | ||
---|---|---|
59 | 59 |
* the capture |
60 | 60 |
*/ |
61 | 61 |
public StreamHog(InputStream is, boolean log) { |
62 |
this.setName(""); |
|
62 |
this.setName(""); //$NON-NLS-1$
|
|
63 | 63 |
this.is = is; |
64 | 64 |
this.log = log; |
65 | 65 |
start(); |
TXM/trunk/bundles/org.txm.utils.core/src/org/txm/utils/Tuple.java (revision 3857) | ||
---|---|---|
11 | 11 |
this.b = b; |
12 | 12 |
} |
13 | 13 |
|
14 |
static String format = "%s %s"; |
|
14 |
static String format = "%s %s"; //$NON-NLS-1$
|
|
15 | 15 |
|
16 | 16 |
public String toString() { |
17 | 17 |
return String.format(format, a, b); |
TXM/trunk/bundles/org.txm.utils.core/src/org/txm/utils/logger/TXMLogger.java (revision 3857) | ||
---|---|---|
231 | 231 |
} else { |
232 | 232 |
if (!isLoggerImpl) { |
233 | 233 |
// skip reflection call |
234 |
if (!cname.startsWith("java.lang.reflect.") && !cname.startsWith("sun.reflect.")) { |
|
234 |
if (!cname.startsWith("java.lang.reflect.") && !cname.startsWith("sun.reflect.")) { //$NON-NLS-1$ //$NON-NLS-2$
|
|
235 | 235 |
// We've found the relevant frame. |
236 | 236 |
sourceClassName = cname; |
237 | 237 |
sourceMethodName = frame.getMethodName(); |
TXM/trunk/bundles/org.txm.utils.core/src/org/txm/utils/logger/Log.java (revision 3857) | ||
---|---|---|
51 | 51 |
*/ |
52 | 52 |
public class Log { |
53 | 53 |
/** The class id. */ |
54 |
public static final String id = "org.txm.utils.logger.Log"; |
|
54 |
public static final String id = "org.txm.utils.logger.Log"; //$NON-NLS-1$
|
|
55 | 55 |
|
56 | 56 |
/** The txm Logger. */ |
57 | 57 |
protected static TXMLogger txm; |
... | ... | |
77 | 77 |
|
78 | 78 |
static { |
79 | 79 |
// System.out.println("INIT TXMLOGGER"); |
80 |
txm = new TXMLogger("TXMFileLogger", null); |
|
80 |
txm = new TXMLogger("TXMFileLogger", null); //$NON-NLS-1$
|
|
81 | 81 |
txm.setLevel(Level.SEVERE); // default is to show errors |
82 | 82 |
txm.setUseParentHandlers(true); |
83 | 83 |
frameList = new ArrayList<>(); |
... | ... | |
107 | 107 |
try { |
108 | 108 |
SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd"); //$NON-NLS-1$ |
109 | 109 |
|
110 |
filename = System.getProperty("java.io.tmpdir") + "/TXM-" + f.format(new Date()) + ".log"; //$NON-NLS-1$ //$NON-NLS-2$ |
|
110 |
filename = System.getProperty("java.io.tmpdir") + "/TXM-" + f.format(new Date()) + ".log"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
|
111 | 111 |
|
112 | 112 |
fh = new FileHandler(filename, false); |
113 | 113 |
System.out.println(UtilsCoreMessages.Log_3 + new File(filename).getAbsolutePath()); |
... | ... | |
229 | 229 |
public static void severe(String message) { |
230 | 230 |
|
231 | 231 |
if (message.length()> MAX_LINE_LENGTH) { // cut if too long |
232 |
message = message.substring(0, MAX_LINE_LENGTH) + "[...]"; |
|
232 |
message = message.substring(0, MAX_LINE_LENGTH) + "[...]"; //$NON-NLS-1$
|
|
233 | 233 |
} |
234 |
if (StringUtils.countMatches(message, "\n") > MAX_NEWLINES) { |
|
235 |
message = message.replace("\n", "⏎"); |
|
234 |
if (StringUtils.countMatches(message, "\n") > MAX_NEWLINES) { //$NON-NLS-1$
|
|
235 |
message = message.replace("\n", "⏎"); //$NON-NLS-1$ //$NON-NLS-2$
|
|
236 | 236 |
} |
237 | 237 |
|
238 | 238 |
if (Level.SEVERE.intValue() >= txm.getLevel().intValue()) { |
... | ... | |
245 | 245 |
|
246 | 246 |
for (StackTraceElement t : st) { |
247 | 247 |
String cn = t.getClassName(); |
248 |
if (cn.startsWith("org.txm.") && !cn.startsWith(Log.class.getName())) { |
|
248 |
if (cn.startsWith("org.txm.") && !cn.startsWith(Log.class.getName())) { //$NON-NLS-1$
|
|
249 | 249 |
int cns = cn.length(); |
250 | 250 |
if (cns > maxClassNameLength) |
251 | 251 |
maxClassNameLength = cns; |
... | ... | |
257 | 257 |
} |
258 | 258 |
|
259 | 259 |
int stLs = (int) Math.log10(stL) + 1; |
260 |
String format = String.format("[%%%dd] %%%ds.%%%ds %%s, %%s", stLs, maxClassNameLength, maxMethodNameLength); |
|
260 |
String format = String.format("[%%%dd] %%%ds.%%%ds %%s, %%s", stLs, maxClassNameLength, maxMethodNameLength); //$NON-NLS-1$
|
|
261 | 261 |
|
262 |
System.out.println("Stacktrace: "); |
|
262 |
System.out.println("Stacktrace: "); //$NON-NLS-1$
|
|
263 | 263 |
int n = 1; |
264 | 264 |
for (StackTraceElement t : st) { |
265 |
if (t.getClassName().startsWith("org.txm.") && !t.getClassName().startsWith(Log.class.getName())) { |
|
265 |
if (t.getClassName().startsWith("org.txm.") && !t.getClassName().startsWith(Log.class.getName())) { //$NON-NLS-1$
|
|
266 | 266 |
System.out.println(String.format(format, n++, t.getClassName(), t.getMethodName(), t.getFileName(), t.getLineNumber())); |
267 | 267 |
} |
268 | 268 |
} |
... | ... | |
299 | 299 |
public static void warning(String message) { |
300 | 300 |
|
301 | 301 |
if (message.length()> MAX_LINE_LENGTH) { // cut if too long |
302 |
message = message.substring(0, MAX_LINE_LENGTH) + "[...]"; |
|
302 |
message = message.substring(0, MAX_LINE_LENGTH) + "[...]"; //$NON-NLS-1$
|
|
303 | 303 |
} |
304 |
message = message.replace("\n", "⏎"); |
|
304 |
message = message.replace("\n", "⏎"); //$NON-NLS-1$ //$NON-NLS-2$
|
|
305 | 305 |
|
306 | 306 |
|
307 | 307 |
if (Level.WARNING.intValue() >= txm.getLevel().intValue()) { |
... | ... | |
351 | 351 |
public static void info(String message, boolean newline) { |
352 | 352 |
|
353 | 353 |
if (message.length()> MAX_LINE_LENGTH) { // cut if too long |
354 |
message = message.substring(0, MAX_LINE_LENGTH) + "[...]"; |
|
354 |
message = message.substring(0, MAX_LINE_LENGTH) + "[...]"; //$NON-NLS-1$
|
|
355 | 355 |
} |
356 |
message = message.replace("\n", "⏎"); |
|
356 |
message = message.replace("\n", "⏎"); //$NON-NLS-1$ //$NON-NLS-2$
|
|
357 | 357 |
|
358 | 358 |
|
359 | 359 |
if (Level.INFO.intValue() >= txm.getLevel().intValue()) { |
... | ... | |
494 | 494 |
|
495 | 495 |
for (StackTraceElement t : st) { |
496 | 496 |
String cn = t.getClassName(); |
497 |
if (cn.startsWith("org.txm.") && !cn.startsWith(Log.class.getName())) { |
|
497 |
if (cn.startsWith("org.txm.") && !cn.startsWith(Log.class.getName())) { //$NON-NLS-1$
|
|
498 | 498 |
int cns = cn.length(); |
499 | 499 |
if (cns > maxClassNameLength) |
500 | 500 |
maxClassNameLength = cns; |
... | ... | |
506 | 506 |
} |
507 | 507 |
|
508 | 508 |
int stLs = (int) Math.log10(stL) + 1; |
509 |
String format = String.format("[%%%dd] %%%ds.%%%ds %%s, %%s", stLs, maxClassNameLength, maxMethodNameLength); |
|
509 |
String format = String.format("[%%%dd] %%%ds.%%%ds %%s, %%s", stLs, maxClassNameLength, maxMethodNameLength); //$NON-NLS-1$
|
|
510 | 510 |
|
511 |
System.out.println("Stacktrace: "); |
|
511 |
System.out.println("Stacktrace: "); //$NON-NLS-1$
|
|
512 | 512 |
int n = 1; |
513 | 513 |
for (StackTraceElement t : st) { |
514 |
if (t.getClassName().startsWith("org.txm.") && !t.getClassName().startsWith(Log.class.getName())) {
|
|
514 |
if (t.getClassName().startsWith(UtilsCoreMessages.Log_23) && !t.getClassName().startsWith(Log.class.getName())) {
|
|
515 | 515 |
System.out.println(String.format(format, n++, t.getClassName(), t.getMethodName(), t.getFileName(), t.getLineNumber())); |
516 | 516 |
} |
517 | 517 |
} |
TXM/trunk/bundles/org.txm.utils.core/src/org/txm/utils/DeleteDir.java (revision 3857) | ||
---|---|---|
75 | 75 |
} |
76 | 76 |
try { // try using system for faster reply and prefer OS-dependent directory removal tool |
77 | 77 |
if (SystemUtils.IS_OS_WINDOWS) { |
78 |
Runtime.getRuntime().exec(new String[] { "%ComSpec%", "/C", "RD /S /Q \"" + path + '"' }).waitFor(); // FIXME: SJ: "%ComSpec%" is not defined, at least on my Win7 |
|
78 |
Runtime.getRuntime().exec(new String[] { "%ComSpec%", "/C", "RD /S /Q \"" + path + '"' }).waitFor(); // FIXME: SJ: "%ComSpec%" is not defined, at least on my Win7 //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
|
79 | 79 |
} else if (SystemUtils.IS_OS_UNIX) { |
80 | 80 |
if (definitive) { |
81 |
Runtime.getRuntime().exec(new String[] { "/bin/rm", "-rf", path.toString() }).waitFor(); |
|
81 |
Runtime.getRuntime().exec(new String[] { "/bin/rm", "-rf", path.toString() }).waitFor(); //$NON-NLS-1$ //$NON-NLS-2$
|
|
82 | 82 |
} else { |
83 |
Runtime.getRuntime().exec(new String[] { "gio", "trash", path.toString() }).waitFor(); |
|
83 |
Runtime.getRuntime().exec(new String[] { "gio", "trash", path.toString() }).waitFor(); //$NON-NLS-1$ //$NON-NLS-2$
|
|
84 | 84 |
} |
85 | 85 |
} |
86 | 86 |
|
TXM/trunk/bundles/org.txm.utils.core/src/org/txm/utils/image/BMPUtils.java (revision 3857) | ||
---|---|---|
12 | 12 |
public class BMPUtils { |
13 | 13 |
|
14 | 14 |
public static void toRLE8(File inputFile, File outputFile) throws Exception { |
15 |
fromTo(inputFile, outputFile, "BI_RLE8"); |
|
15 |
fromTo(inputFile, outputFile, "BI_RLE8"); //$NON-NLS-1$
|
|
16 | 16 |
} |
17 | 17 |
|
18 | 18 |
public static void toRLE4(File inputFile, File outputFile) throws Exception { |
19 |
fromTo(inputFile, outputFile, "BI_RLE4"); |
|
19 |
fromTo(inputFile, outputFile, "BI_RLE4"); //$NON-NLS-1$
|
|
20 | 20 |
} |
21 | 21 |
|
22 | 22 |
public static void emptySquare(File outputFile, int size, String comp) throws Exception { |
23 | 23 |
|
24 | 24 |
BufferedImage bi = new BufferedImage(size, size, BufferedImage.TYPE_BYTE_INDEXED); |
25 | 25 |
|
26 |
ImageWriter writer = ImageIO.getImageWritersByFormatName("bmp").next(); |
|
26 |
ImageWriter writer = ImageIO.getImageWritersByFormatName("bmp").next(); //$NON-NLS-1$
|
|
27 | 27 |
ImageWriteParam param = writer.getDefaultWriteParam(); |
28 | 28 |
|
29 | 29 |
param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT); |
... | ... | |
38 | 38 |
|
39 | 39 |
BufferedImage bi = ImageIO.read(inputFile); //new BufferedImage(size, size, BufferedImage.TYPE_BYTE_INDEXED); |
40 | 40 |
|
41 |
ImageWriter writer = ImageIO.getImageWritersByFormatName("bmp").next(); |
|
41 |
ImageWriter writer = ImageIO.getImageWritersByFormatName("bmp").next(); //$NON-NLS-1$
|
|
42 | 42 |
ImageWriteParam param = writer.getDefaultWriteParam(); |
43 | 43 |
|
44 | 44 |
param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT); |
... | ... | |
61 | 61 |
// new File("/home/mdecorde/eclipse-tycho2022-09/bundles/org.txm.rcp/icons/logo/TXM logo 256x256 32-bit RLE8.bmp")); |
62 | 62 |
|
63 | 63 |
emptySquare( |
64 |
new File("/home/mdecorde/eclipse-tycho2022-09/bundles/org.txm.rcp/icons/logo/TXM logo 32x32 8-bit RLE8.bmp"), |
|
65 |
32, "BI_RLE8"); |
|
64 |
new File("/home/mdecorde/eclipse-tycho2022-09/bundles/org.txm.rcp/icons/logo/TXM logo 32x32 8-bit RLE8.bmp"), //$NON-NLS-1$
|
|
65 |
32, "BI_RLE8"); //$NON-NLS-1$
|
|
66 | 66 |
|
67 | 67 |
// emptySquare( |
68 | 68 |
// new File("/home/mdecorde/eclipse-tycho2022-09/bundles/org.txm.rcp/icons/logo/TXM logo 48x48 8-bit RLE8.bmp"), |
TXM/trunk/bundles/org.txm.utils.core/src/org/txm/utils/treetagger/TreeTagger.java (revision 3857) | ||
---|---|---|
523 | 523 |
args.add("" + outfile); //$NON-NLS-1$ |
524 | 524 |
|
525 | 525 |
if (debug) |
526 |
System.out.println(StringUtils.join(args.toArray(), " ")); |
|
526 |
System.out.println(StringUtils.join(args.toArray(), " ")); //$NON-NLS-1$
|
|
527 | 527 |
|
528 |
Log.fine(StringUtils.join(args.toArray(), " ")); |
|
528 |
Log.fine(StringUtils.join(args.toArray(), " ")); //$NON-NLS-1$
|
|
529 | 529 |
|
530 | 530 |
ProcessBuilder pb = new ProcessBuilder(args); |
531 | 531 |
pb.redirectErrorStream(true); |
... | ... | |
550 | 550 |
if (e != 0) { |
551 | 551 |
System.err.println("Process exited abnormally with code " + e + " at " + DateFormat.getDateInstance(DateFormat.FULL, Locale.UK).format(new Date())); //$NON-NLS-1$ //$NON-NLS-2$ |
552 | 552 |
|
553 |
System.out.println("Args: "); |
|
553 |
System.out.println("Args: "); //$NON-NLS-1$
|
|
554 | 554 |
for (int c = 0; c < args.size(); c++) |
555 | 555 |
System.out.print("" + args.get(c) + " "); //$NON-NLS-1$ //$NON-NLS-2$ |
556 | 556 |
System.out.println(); |
... | ... | |
839 | 839 |
|
840 | 840 |
ProcessBuilder pb = new ProcessBuilder(args); |
841 | 841 |
if (debug) |
842 |
System.out.println(StringUtils.join(args.toArray(), " ")); |
|
842 |
System.out.println(StringUtils.join(args.toArray(), " ")); //$NON-NLS-1$
|
|
843 | 843 |
pb.redirectErrorStream(true); |
844 | 844 |
Process process = null; |
845 | 845 |
try { |
... | ... | |
861 | 861 |
} |
862 | 862 |
if (e != 0) { |
863 | 863 |
System.err.println("Process exited abnormally with code " + e + " at " + DateFormat.getDateInstance(DateFormat.FULL, Locale.UK).format(new Date())); //$NON-NLS-1$ //$NON-NLS-2$ |
864 |
System.out.println("Args: "); |
|
864 |
System.out.println("Args: "); //$NON-NLS-1$
|
|
865 | 865 |
for (int c = 0; c < args.size(); c++) |
866 | 866 |
System.out.print("" + args.get(c) + " "); //$NON-NLS-1$ //$NON-NLS-2$ |
867 | 867 |
System.out.println(); |
TXM/trunk/bundles/org.txm.utils.core/src/org/txm/utils/TableReader.java (revision 3857) | ||
---|---|---|
23 | 23 |
public class TableReader { |
24 | 24 |
|
25 | 25 |
File tableFile; |
26 |
String mode = "tsv"; |
|
26 |
String mode = "tsv"; //$NON-NLS-1$
|
|
27 | 27 |
|
28 | 28 |
HashMap<String, String> record; |
29 | 29 |
CsvReader tsvReader = null; |
... | ... | |
90 | 90 |
public TableReader(File tableFile, String sheet) throws Exception { |
91 | 91 |
this.tableFile = tableFile; |
92 | 92 |
|
93 |
if (tableFile.getName().toLowerCase().endsWith(".xlsx")) { |
|
94 |
mode = "excel"; |
|
93 |
if (tableFile.getName().toLowerCase().endsWith(".xlsx")) { //$NON-NLS-1$
|
|
94 |
mode = "excel"; //$NON-NLS-1$
|
|
95 | 95 |
excelReader = new ReadExcel(tableFile, sheet); |
96 |
} else if (tableFile.getName().toLowerCase().endsWith(".ods")) { |
|
97 |
mode = "ods"; |
|
96 |
} else if (tableFile.getName().toLowerCase().endsWith(".ods")) { //$NON-NLS-1$
|
|
97 |
mode = "ods"; //$NON-NLS-1$
|
|
98 | 98 |
odsReader = new ReadODS(tableFile, sheet); |
99 |
} else if (tableFile.getName().toLowerCase().endsWith(".tsv")) { |
|
100 |
tsvReader = new CsvReader(tableFile.getAbsolutePath(), "\t".charAt(0), Charset.forName("UTF-8")); |
|
101 |
mode = "tsv"; |
|
102 |
} else if (tableFile.getName().toLowerCase().endsWith(".csv")) { |
|
103 |
tsvReader = new CsvReader(tableFile.getAbsolutePath(), ",".charAt(0), Charset.forName("UTF-8")); |
|
104 |
mode = "tsv"; |
|
99 |
} else if (tableFile.getName().toLowerCase().endsWith(".tsv")) { //$NON-NLS-1$
|
|
100 |
tsvReader = new CsvReader(tableFile.getAbsolutePath(), "\t".charAt(0), Charset.forName("UTF-8")); //$NON-NLS-1$ //$NON-NLS-2$
|
|
101 |
mode = "tsv"; //$NON-NLS-1$
|
|
102 |
} else if (tableFile.getName().toLowerCase().endsWith(".csv")) { //$NON-NLS-1$
|
|
103 |
tsvReader = new CsvReader(tableFile.getAbsolutePath(), ",".charAt(0), Charset.forName("UTF-8")); //$NON-NLS-1$ //$NON-NLS-2$
|
|
104 |
mode = "tsv"; //$NON-NLS-1$
|
|
105 | 105 |
} |
106 | 106 |
} |
107 | 107 |
|
... | ... | |
170 | 170 |
return null; |
171 | 171 |
} |
172 | 172 |
|
173 |
String EMPTY = ""; |
|
173 |
String EMPTY = ""; //$NON-NLS-1$
|
|
174 | 174 |
|
175 | 175 |
public String get(String h) throws IOException { |
176 | 176 |
String s = getRecord().get(h); |
... | ... | |
192 | 192 |
|
193 | 193 |
public static void main(String[] args) { |
194 | 194 |
try { |
195 |
System.out.println("Loading..."); |
|
196 |
TableReader reader = new TableReader(new File("/home/mdecorde/TEMP/ANTRACT/AF/ANTRACT_AF_Notices_3oct19.xlsx")); |
|
197 |
System.out.println("Table loaded"); |
|
195 |
System.out.println("Loading..."); //$NON-NLS-1$
|
|
196 |
TableReader reader = new TableReader(new File("/home/mdecorde/TEMP/ANTRACT/AF/ANTRACT_AF_Notices_3oct19.xlsx")); //$NON-NLS-1$
|
|
197 |
System.out.println("Table loaded"); //$NON-NLS-1$
|
|
198 | 198 |
|
199 |
System.out.println("Reading headers..."); |
|
199 |
System.out.println("Reading headers..."); //$NON-NLS-1$
|
|
200 | 200 |
reader.readHeaders(); |
201 | 201 |
System.out.println(Arrays.toString(reader.getHeaders())); |
202 | 202 |
|
203 |
System.out.println("Reading record..."); |
|
203 |
System.out.println("Reading record..."); //$NON-NLS-1$
|
|
204 | 204 |
reader.readRecord(); |
205 | 205 |
System.out.println(reader.getRecord()); |
206 | 206 |
|
207 |
System.out.println("Reading record..."); |
|
207 |
System.out.println("Reading record..."); //$NON-NLS-1$
|
|
208 | 208 |
reader.readRecord(); |
209 | 209 |
System.out.println(reader.getRecord()); |
210 | 210 |
} catch (Exception e) { |
TXM/trunk/bundles/org.txm.utils.core/src/org/txm/utils/OSDetector.java (revision 3857) | ||
---|---|---|
56 | 56 |
* @param args |
57 | 57 |
*/ |
58 | 58 |
public static void main(String[] args) { |
59 |
System.out.println("Runtime OS name: " + System.getProperty("os.name")); //$NON-NLS-1$ |
|
60 |
System.out.println("Runtime OS arch: " + System.getProperty("os.arch")); //$NON-NLS-1$ |
|
61 |
System.out.println("Runtime OS version: " + System.getProperty("os.version")); //$NON-NLS-1$ |
|
59 |
System.out.println("Runtime OS name: " + System.getProperty("os.name")); //$NON-NLS-1$ //$NON-NLS-2$
|
|
60 |
System.out.println("Runtime OS arch: " + System.getProperty("os.arch")); //$NON-NLS-1$ //$NON-NLS-2$
|
|
61 |
System.out.println("Runtime OS version: " + System.getProperty("os.version")); //$NON-NLS-1$ //$NON-NLS-2$
|
|
62 | 62 |
System.out.println("Is arch 64bit ?: " + isArch64()); //$NON-NLS-1$ |
63 | 63 |
System.out.println("Windows OS family: " + isFamilyWindows()); //$NON-NLS-1$ |
64 | 64 |
System.out.println("Unix OS family: " + isFamilyUnix()); //$NON-NLS-1$ |
TXM/trunk/bundles/org.txm.utils.core/src/org/txm/utils/messages/UtilsCoreMessages.java (revision 3857) | ||
---|---|---|
24 | 24 |
public static String FileCopy_4; |
25 | 25 |
public static String LS_0; |
26 | 26 |
public static String LS_1; |
27 |
public static String Log_23; |
|
28 |
|
|
27 | 29 |
public static String Log_3; |
28 | 30 |
public static String Log_5; |
29 | 31 |
public static String Log_8; |
TXM/trunk/bundles/org.txm.utils.core/src/org/txm/utils/messages/messages.properties (revision 3857) | ||
---|---|---|
12 | 12 |
ExecTimer_2=min and |
13 | 13 |
ExecTimer_1=sec |
14 | 14 |
Sh_4=Process exited abnormally with code |
15 |
Log_23=org.txm. |
|
15 | 16 |
Log_5=Start loging in |
16 | 17 |
LS_1=is not a Directory\! |
17 | 18 |
Log_3=Copying logs in |
TXM/trunk/bundles/org.txm.utils.core/src/org/txm/utils/messages/Utf8NLS.java (revision 3857) | ||
---|---|---|
22 | 22 |
* @param clazz |
23 | 23 |
*/ |
24 | 24 |
public static void initializeMessages(Class<?> clazz) { |
25 |
initializeMessages(clazz.getPackage().getName() + ".messages", clazz); |
|
25 |
initializeMessages(clazz.getPackage().getName() + ".messages", clazz); //$NON-NLS-1$
|
|
26 | 26 |
} |
27 | 27 |
|
28 | 28 |
/** |
TXM/trunk/bundles/org.txm.utils.core/src/org/txm/utils/i18n/DetectBOM.java (revision 3857) | ||
---|---|---|
102 | 102 |
} |
103 | 103 |
|
104 | 104 |
public static void main(String args[]) { |
105 |
DetectBOM db = new DetectBOM(new File(System.getProperty("user.home"), "xml/SUPPORT/CS/3-revues_eng_complet2.txt")); |
|
105 |
DetectBOM db = new DetectBOM(new File(System.getProperty("user.home"), "xml/SUPPORT/CS/3-revues_eng_complet2.txt")); //$NON-NLS-1$ //$NON-NLS-2$
|
|
106 | 106 |
System.out.println(db.getBOMSize()); |
107 | 107 |
System.out.println(db.getCharSet()); |
108 | 108 |
} |
TXM/trunk/bundles/org.txm.utils.core/src/org/txm/utils/AsciiUtils.java (revision 3857) | ||
---|---|---|
75 | 75 |
private AsciiUtils() { |
76 | 76 |
} |
77 | 77 |
|
78 |
public static Transliterator asciiFormmater = Transliterator.getInstance("Any-Latin; NFD; [^\\p{Alnum}\\p{p}] Remove"); |
|
78 |
public static Transliterator asciiFormmater = Transliterator.getInstance("Any-Latin; NFD; [^\\p{Alnum}\\p{p}] Remove"); //$NON-NLS-1$
|
|
79 | 79 |
|
80 | 80 |
/** |
81 | 81 |
* Convert non ascii characters. Warning punctuations are not removed |
... | ... | |
129 | 129 |
} |
130 | 130 |
|
131 | 131 |
// ensure the "w_" prefix presence |
132 |
if (s.startsWith("w")) { |
|
133 |
if (!s.startsWith("w_")) { |
|
134 |
s = "w_" + s.substring(1); |
|
132 |
if (s.startsWith("w")) { //$NON-NLS-1$
|
|
133 |
if (!s.startsWith("w_")) { //$NON-NLS-1$
|
|
134 |
s = "w_" + s.substring(1); //$NON-NLS-1$
|
|
135 | 135 |
} |
136 | 136 |
} else { |
137 |
s = "w_" + s; |
|
137 |
s = "w_" + s; //$NON-NLS-1$
|
|
138 | 138 |
} |
139 | 139 |
// System.out.println("first="+s); |
140 | 140 |
|
141 | 141 |
String rez = convertNonAscii(s);// .toLowerCase(); |
142 | 142 |
// System.out.println("nonasscii="+rez); |
143 |
rez = rez.replaceAll("\\p{Space}++", "_"); |
|
143 |
rez = rez.replaceAll("\\p{Space}++", "_"); //$NON-NLS-1$ //$NON-NLS-2$
|
|
144 | 144 |
// System.out.println("spaces="+rez); |
145 | 145 |
rez = rez.replaceAll("[¤€§µ£°().,;:/?!@§%\\\\\"’ʹ'*+\\-}\\]\\[{#~&]", ""); //$NON-NLS-1$ //$NON-NLS-2$ // "[^\\P{P}_]" |
146 | 146 |
// System.out.println("ponc="+rez); |
... | ... | |
172 | 172 |
return s; |
173 | 173 |
} |
174 | 174 |
String rez = s.trim(); |
175 |
rez = rez.replaceAll("\\p{Space}++", "_"); |
|
176 |
rez = rez.replaceAll("_", "-"); |
|
175 |
rez = rez.replaceAll("\\p{Space}++", "_"); //$NON-NLS-1$ //$NON-NLS-2$
|
|
176 |
rez = rez.replaceAll("_", "-"); //$NON-NLS-1$ //$NON-NLS-2$
|
|
177 | 177 |
rez = convertNonAscii(rez).toLowerCase(); |
178 | 178 |
|
179 | 179 |
rez = rez.replaceAll("[¤€§µ£°().,;:/?!@§%\\\\\"’ʹ'*+\\}\\]\\[{#~&]", ""); //$NON-NLS-1$ //$NON-NLS-2$ |
... | ... | |
182 | 182 |
while (c == '0' || c == '1' || c == '2' || c == '3' || c == '4' || c == '5' || c == '6' || c == '7' || c == '8' || c == '9') { |
183 | 183 |
rez = rez.substring(1); |
184 | 184 |
if (rez.length() == 0) { |
185 |
return ""; |
|
185 |
return ""; //$NON-NLS-1$
|
|
186 | 186 |
} |
187 | 187 |
c = rez.charAt(0); |
188 | 188 |
} |
... | ... | |
200 | 200 |
String s = "01The result : - - _ тврьдо È,É,Ê,Ë,Û,Ù,Ï,Î,À,Â,Ô,è,é,ê,ë,û,ù,ï,î,à,â,ô,ç 0 1 2 3 4 5 6 7 8 9 10"; //$NON-NLS-1$ |
201 | 201 |
System.out.println(AsciiUtils.convertNonAscii(s)); |
202 | 202 |
// System.out.println(AsciiUtils.buildId(s)); |
203 |
String s2 = "w_ТВРЬДОтврьдо_123&é\"'(-è_çà)=/*-+~#{[|`\\^@]}¤;:!§/.?µ%£°"; |
|
204 |
System.out.println("nonascii=" + AsciiUtils.convertNonAscii(s2)); |
|
205 |
System.out.println("word_id=" + AsciiUtils.buildWordId(s2)); |
|
206 |
System.out.println("attribute_id=" + AsciiUtils.buildAttributeId(s2)); |
|
203 |
String s2 = "w_ТВРЬДОтврьдо_123&é\"'(-è_çà)=/*-+~#{[|`\\^@]}¤;:!§/.?µ%£°"; //$NON-NLS-1$
|
|
204 |
System.out.println("nonascii=" + AsciiUtils.convertNonAscii(s2)); //$NON-NLS-1$
|
|
205 |
System.out.println("word_id=" + AsciiUtils.buildWordId(s2)); //$NON-NLS-1$
|
|
206 |
System.out.println("attribute_id=" + AsciiUtils.buildAttributeId(s2)); //$NON-NLS-1$
|
|
207 | 207 |
// output : |
208 | 208 |
// The result : E,E,E,E,U,U,I,I,A,A,O,e,e,e,e,u,u,i,i,a,a,o,c |
209 | 209 |
|
TXM/trunk/bundles/org.txm.utils.core/src/org/txm/utils/xml/UpdateXSLParameters.java (revision 3857) | ||
---|---|---|
39 | 39 |
*/ |
40 | 40 |
public boolean process(HashMap<String, String> parameters) throws ParserConfigurationException, SAXException, IOException { |
41 | 41 |
if (!xslFile.exists()) { |
42 |
System.out.println("Error: $xslFile doest not exists. Aborting."); |
|
42 |
System.out.println("Error: $xslFile doest not exists. Aborting."); //$NON-NLS-1$
|
|
43 | 43 |
return false; |
44 | 44 |
} |
45 | 45 |
|
46 | 46 |
Document doc = DomUtils.load(xslFile); |
47 |
NodeList list = doc.getElementsByTagName("xsl:param"); |
|
47 |
NodeList list = doc.getElementsByTagName("xsl:param"); //$NON-NLS-1$
|
|
48 | 48 |
for (int i = 0; i < list.getLength(); i++) { |
49 | 49 |
Element e = (Element) list.item(i); |
50 |
String name = e.getAttribute("name"); |
|
50 |
String name = e.getAttribute("name"); //$NON-NLS-1$
|
|
51 | 51 |
|
52 | 52 |
if (parameters.keySet().contains(name)) { |
53 | 53 |
e.setTextContent(parameters.get(name)); |
... | ... | |
58 | 58 |
} |
59 | 59 |
|
60 | 60 |
public static void main(String[] args) throws ParserConfigurationException, SAXException, IOException { |
61 |
File xslFile = new File("/home/mdecorde/TEMP/testori/mss-dates/txm/mss-dates-w/xsl/4-edition/1-facsimile-pager.xsl"); |
|
61 |
File xslFile = new File("/home/mdecorde/TEMP/testori/mss-dates/txm/mss-dates-w/xsl/4-edition/1-facsimile-pager.xsl"); //$NON-NLS-1$
|
|
62 | 62 |
HashMap<String, String> parameters = new HashMap<String, String>(); |
63 |
parameters.put("image-directory", "/home/mdecorde/TEMP/testori/mss-dates/img222222222222"); |
|
63 |
parameters.put("image-directory", "/home/mdecorde/TEMP/testori/mss-dates/img222222222222"); //$NON-NLS-1$ //$NON-NLS-2$
|
|
64 | 64 |
UpdateXSLParameters p = new UpdateXSLParameters(xslFile); |
65 | 65 |
if (!p.process(parameters)) { |
66 |
System.out.println("Fail"); |
|
66 |
System.out.println("Fail"); //$NON-NLS-1$
|
|
67 | 67 |
} else { |
68 |
System.out.println("Success"); |
|
68 |
System.out.println("Success"); //$NON-NLS-1$
|
|
69 | 69 |
} |
70 | 70 |
} |
71 | 71 |
} |
TXM/trunk/bundles/org.txm.utils.core/src/org/txm/utils/LocalXhtmlDtdEntityResolver.java (revision 3857) | ||
---|---|---|
16 | 16 |
*/ |
17 | 17 |
@Override |
18 | 18 |
public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException { |
19 |
String fileName = systemId.substring(systemId.lastIndexOf("/") + 1); |
|
20 |
System.out.println("FILENAME: " + fileName); |
|
19 |
String fileName = systemId.substring(systemId.lastIndexOf("/") + 1); //$NON-NLS-1$
|
|
20 |
System.out.println("FILENAME: " + fileName); //$NON-NLS-1$
|
|
21 | 21 |
|
22 | 22 |
return new InputSource(getClass().getClassLoader().getResourceAsStream(fileName)); |
23 | 23 |
} |
TXM/trunk/bundles/org.txm.utils.core/src/org/txm/utils/io/IOUtils.java (revision 3857) | ||
---|---|---|
56 | 56 |
ArrayList<String> matches = new ArrayList<String>(); |
57 | 57 |
String text = IOUtils.getText(file, encoding); |
58 | 58 |
if (normalizeSeparators) { |
59 |
text = text.replaceAll("\\s", " "); //$NON-NLS-1$ |
|
60 |
text = text.replaceAll("\\t", " "); //$NON-NLS-1$ |
|
61 |
text = text.replaceAll("\\n", " "); //$NON-NLS-1$ |
|
62 |
text = text.replaceAll("[ ]+", " "); //$NON-NLS-1$ |
|
59 |
text = text.replaceAll("\\s", " "); //$NON-NLS-1$ //$NON-NLS-2$
|
|
60 |
text = text.replaceAll("\\t", " "); //$NON-NLS-1$ //$NON-NLS-2$
|
|
61 |
text = text.replaceAll("\\n", " "); //$NON-NLS-1$ //$NON-NLS-2$
|
|
62 |
text = text.replaceAll("[ ]+", " "); //$NON-NLS-1$ //$NON-NLS-2$
|
|
63 | 63 |
} |
64 | 64 |
|
65 | 65 |
Pattern test = Pattern.compile(pattern); |
TXM/trunk/bundles/org.txm.utils.core/src/org/txm/utils/io/FileCopy.java (revision 3857) | ||
---|---|---|
44 | 44 |
*/ |
45 | 45 |
public class FileCopy { |
46 | 46 |
|
47 |
private static final boolean isWindows = System.getProperty("os.name").contains("Windows"); |
|
47 |
private static final boolean isWindows = System.getProperty("os.name").contains("Windows"); //$NON-NLS-1$ //$NON-NLS-2$
|
|
48 | 48 |
|
49 | 49 |
/** |
50 | 50 |
* replace the file if it exists |
... | ... | |
254 | 254 |
// System.out.println("delete c1 "+copy1.delete()); //$NON-NLS-1$ |
255 | 255 |
// System.out.println("delete c2 "+copy2.delete()); //$NON-NLS-1$ |
256 | 256 |
|
257 |
File dir1 = new File("/home/mdecorde/TEMP/copydir"); |
|
258 |
File dir2 = new File("/home/mdecorde/TEMP/copydir3"); |
|
257 |
File dir1 = new File("/home/mdecorde/TEMP/copydir"); //$NON-NLS-1$
|
|
258 |
File dir2 = new File("/home/mdecorde/TEMP/copydir3"); //$NON-NLS-1$
|
|
259 | 259 |
FileCopy.copyFiles(dir1, dir2); |
260 | 260 |
} |
261 | 261 |
} |
Formats disponibles : Unified diff