01: // This file is part of KeY - Integrated Deductive Software Design
02: // Copyright (C) 2001-2007 Universitaet Karlsruhe, Germany
03: // Universitaet Koblenz-Landau, Germany
04: // Chalmers University of Technology, Sweden
05: //
06: // The KeY system is protected by the GNU General Public License.
07: // See LICENSE.TXT for details.
08: //
09: //
10: package de.uka.ilkd.key.util.install;
11:
12: public abstract class KeYInstallerUI extends KeYInstaller {
13:
14: public KeYInstallerUI(String keyHome, String keyLib,
15: String javaHome, String keyJarPath, String os) {
16: super (keyHome, keyLib, javaHome, keyJarPath, os);
17: }
18:
19: /**
20: * returns true if the given character occurs in the list
21: */
22: public boolean containsChar(char c, char[] chars) {
23:
24: for (int i = 0; i < chars.length; i++) {
25: if (chars[i] == c) {
26: return true;
27: }
28: }
29:
30: return false;
31: }
32:
33: /**
34: * Trims String to max. nr chars per line
35: */
36: public String trim(String s, int nr) {
37: final char[] ws = new char[] { ';', ' ', ',' };
38: StringBuffer result = new StringBuffer(s);
39:
40: int column = 0;
41: int fromIndex = 0;
42: int brakePosition = -1;
43:
44: for (int i = 0; i < s.length(); i++) {
45:
46: if (s.charAt(i) == '\n') {
47: column = 0;
48: brakePosition = -1;
49: } else {
50: column++;
51: }
52:
53: if (containsChar(s.charAt(i), ws)) {
54: brakePosition = i;
55: }
56:
57: if (column >= nr - 1 && brakePosition != -1) {
58: result.insert(brakePosition + fromIndex + 1, '\n');
59: fromIndex++;
60: column = 0;
61: }
62: }
63:
64: return result.toString();
65: }
66: }
|