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.List;
22
23 public final class JavacJavaCompilerSettings extends JavaCompilerSettings {
24
25 private boolean optimize;
26 private String memMax;
27 private String memInitial;
28 private String[] customArguments;
29
30 public JavacJavaCompilerSettings() {
31 }
32
33 public JavacJavaCompilerSettings( final JavaCompilerSettings pSettings ) {
34 super(pSettings);
35 }
36
37
38 public void setCustomArguments( final String[] pCustomArguments ) {
39 customArguments = pCustomArguments;
40 }
41
42 public String[] getCustomArguments() {
43 return customArguments;
44 }
45
46
47 public void setMaxMemory( final String pMemMax ) {
48 memMax = pMemMax;
49 }
50
51 public String getMaxMemory() {
52 return memMax;
53 }
54
55
56 public void setInitialMemory( final String pMemInitial ) {
57 memInitial = pMemInitial;
58 }
59
60 public String getInitialMemory() {
61 return memInitial;
62 }
63
64
65 public boolean isOptimize() {
66 return optimize;
67 }
68
69 public void setOptimize( final boolean pOptimize ) {
70 optimize = pOptimize;
71 }
72
73
74
75
76 public List getCustomCompilerArguments() {
77 final List list = new ArrayList();
78 for (int i = 0; i < customArguments.length; i++) {
79 list.add(customArguments[i]);
80 }
81 return list;
82 }
83
84
85 public void setCustomCompilerArguments(List customCompilerArguments) {
86 customArguments = (String[]) customCompilerArguments.toArray(new String[customCompilerArguments.size()]);
87 }
88
89
90 public String getMaxmem() {
91 return memMax;
92 }
93
94
95 public void setMaxmem(String maxmem) {
96 this.memMax = maxmem;
97 }
98
99
100 public String getMeminitial() {
101 return memInitial;
102 }
103
104
105 public void setMeminitial(String meminitial) {
106 this.memInitial = meminitial;
107 }
108
109
110
111
112 String[] toNativeSettings() {
113
114 final List args = new ArrayList();
115
116 if (isOptimize()) {
117 args.add("-O");
118 }
119
120 if (isDebug()) {
121 args.add("-g");
122 }
123
124 if (isDeprecations()) {
125 args.add("-deprecation");
126 }
127
128 if (!isWarnings() && !isDeprecations()) {
129 args.add("-nowarn");
130 }
131
132 if (getMaxMemory() != null) {
133 args.add("-J-Xmx" + getMaxMemory());
134 }
135
136 if (getInitialMemory() != null) {
137 args.add("-J-Xms" + getInitialMemory());
138 }
139
140 args.add("-target");
141 args.add(getTargetVersion());
142
143 args.add("-source");
144 args.add(getSourceVersion());
145
146 args.add("-encoding");
147 args.add(getSourceEncoding());
148
149 if (customArguments != null) {
150 for (int i = 0; i < customArguments.length; i++) {
151 args.add(customArguments[i]);
152 }
153 }
154
155 return (String[])args.toArray(new String[args.size()]);
156 }
157 }