OpenConcerto

Dépôt officiel du code source de l'ERP OpenConcerto
sonarqube

svn://code.openconcerto.org/openconcerto

Rev

Rev 21 | Rev 28 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 21 Rev 25
Line 220... Line 220...
220
        StringBuffer result = new StringBuffer();
220
        StringBuffer result = new StringBuffer();
221
        for (int i = 0; i < s.length(); i++) {
221
        for (int i = 0; i < s.length(); i++) {
222
 
222
 
223
            if (lastString.length() == nbCharMaxLine) {
223
            if (lastString.length() == nbCharMaxLine) {
224
                int esp = lastString.lastIndexOf(" ");
224
                int esp = lastString.lastIndexOf(" ");
225
                if (result.length() > 0) {
225
                if (result.length() > 0 && result.charAt(result.length() - 1) != '\n') {
226
                    result.append("\n");
226
                    result.append("\n");
227
                }
227
                }
228
                if (esp > 0) {
228
                if (esp > 0) {
229
                    result.append(lastString.substring(0, esp).toString().trim());
229
                    result.append(lastString.substring(0, esp).toString().trim());
230
                    lastString = new StringBuffer(lastString.substring(esp, lastString.length()));
230
                    lastString = new StringBuffer(lastString.substring(esp, lastString.length()));
231
                } else {
231
                } else {
232
                    result.append(lastString.toString().trim());
232
                    result.append(lastString.toString().trim());
233
                    lastString = new StringBuffer();
233
                    lastString = new StringBuffer();
234
                }
234
                }
-
 
235
                result.append("\n");
235
            }
236
            }
236
 
237
 
237
            char charAt = s.charAt(i);
238
            char charAt = s.charAt(i);
238
            if (charAt == '\n') {
239
            if (charAt == '\n') {
239
                lastString.append(charAt);
240
                lastString.append(charAt);
240
                result.append(lastString);
241
                result.append(lastString);
241
                lastString = new StringBuffer();
242
                lastString = new StringBuffer();
242
            } else {
243
            } else {
243
 
-
 
244
                lastString.append(charAt);
244
                lastString.append(charAt);
245
            }
245
            }
246
        }
246
        }
247
 
247
 
248
        if (result.length() > 0) {
248
        if (result.length() > 0 && result.charAt(result.length() - 1) != '\n') {
249
            result.append("\n");
249
            result.append("\n");
250
        }
250
        }
251
 
251
 
252
        result.append(lastString.toString().trim());
252
        result.append(lastString.toString().trim());
253
 
253
 
Line 336... Line 336...
336
        public int hashCode() {
336
        public int hashCode() {
337
            return this.esc + this.substitution.hashCode();
337
            return this.esc + this.substitution.hashCode();
338
        }
338
        }
339
    }
339
    }
340
 
340
 
-
 
341
    public static String rightAlign(String s, int width) {
-
 
342
        String r = s;
-
 
343
        int n = width - s.length();
-
 
344
        for (int i = 0; i < n; i++) {
-
 
345
            r = ' ' + r;
-
 
346
        }
-
 
347
        return r;
-
 
348
    }
-
 
349
 
-
 
350
    public static String leftAlign(String s, int width) {
-
 
351
        String r = s;
-
 
352
        int n = width - s.length();
-
 
353
        for (int i = 0; i < n; i++) {
-
 
354
            r += ' ';
-
 
355
        }
-
 
356
        return r;
-
 
357
    }
341
}
358
}