1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.commons.jci.compilers;
19
20 import java.util.ArrayList;
21 import java.util.Collection;
22 import org.apache.commons.jci.problems.CompilationProblem;
23
24
25
26
27
28
29
30
31
32 public final class CompilationResult {
33
34 private final CompilationProblem[] errors;
35 private final CompilationProblem[] warnings;
36
37 public CompilationResult( final CompilationProblem[] pProblems ) {
38 final Collection<CompilationProblem> errorsColl = new ArrayList<CompilationProblem>();
39 final Collection<CompilationProblem> warningsColl = new ArrayList<CompilationProblem>();
40
41 for (CompilationProblem problem : pProblems) {
42 if (problem.isError()) {
43 errorsColl.add(problem);
44 } else {
45 warningsColl.add(problem);
46 }
47 }
48
49 errors = new CompilationProblem[errorsColl.size()];
50 errorsColl.toArray(errors);
51
52 warnings = new CompilationProblem[warningsColl.size()];
53 warningsColl.toArray(warnings);
54 }
55
56 public CompilationProblem[] getErrors() {
57 final CompilationProblem[] res = new CompilationProblem[errors.length];
58 System.arraycopy(errors, 0, res, 0, res.length);
59 return res;
60 }
61
62 public CompilationProblem[] getWarnings() {
63 final CompilationProblem[] res = new CompilationProblem[warnings.length];
64 System.arraycopy(warnings, 0, res, 0, res.length);
65 return res;
66 }
67 }