44 * |
44 * |
45 * @param source source code of the class as String. |
45 * @param source source code of the class as String. |
46 * @return true, if compilation succeeded, false otherwise. |
46 * @return true, if compilation succeeded, false otherwise. |
47 */ |
47 */ |
48 public boolean compile(String source) { |
48 public boolean compile(String source) { |
|
49 return compile(source, true); |
|
50 } |
|
51 |
|
52 /** |
|
53 * Compiles classes in given source. The resulting .class files are added |
|
54 * to an internal list which can be later retrieved by getClassFiles() - |
|
55 * but only if @param generate is true. |
|
56 * |
|
57 * @param source source code of the class as String. |
|
58 * @param generate if false, .class files are not generated (used to check source for errors) |
|
59 * @return true, if compilation succeeded, false otherwise. |
|
60 */ |
|
61 public boolean compile(String source, boolean generate) { |
49 ICompilerRequestor requestor = this; |
62 ICompilerRequestor requestor = this; |
50 IErrorHandlingPolicy policy = DefaultErrorHandlingPolicies.exitAfterAllProblems(); |
63 IErrorHandlingPolicy policy = DefaultErrorHandlingPolicies.exitAfterAllProblems(); |
51 IProblemFactory problemFactory = new DefaultProblemFactory(Locale.getDefault()); |
64 IProblemFactory problemFactory = new DefaultProblemFactory(Locale.getDefault()); |
52 Source[] units = new Source[1]; |
65 Source[] units = new Source[1]; |
53 units[0] = new Source(source); |
66 units[0] = new Source(source); |