blob: 65acfc0d7e93c9f144e673f17005ab727d3cbf17 [file] [log] [blame]
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.jci.compilers;
import java.util.ArrayList;
import java.util.List;
public final class JavacJavaCompilerSettings extends JavaCompilerSettings {
private boolean optimize;
private String memMax;
private String memInitial;
private String[] customArguments;
public JavacJavaCompilerSettings() {
}
public JavacJavaCompilerSettings( final JavaCompilerSettings pSettings ) {
super(pSettings);
}
public void setCustomArguments( final String[] pCustomArguments ) {
customArguments = pCustomArguments;
}
public String[] getCustomArguments() {
return customArguments;
}
public void setMaxMemory( final String pMemMax ) {
memMax = pMemMax;
}
public String getMaxMemory() {
return memMax;
}
public void setInitialMemory( final String pMemInitial ) {
memInitial = pMemInitial;
}
public String getInitialMemory() {
return memInitial;
}
public boolean isOptimize() {
return optimize;
}
public void setOptimize( final boolean pOptimize ) {
optimize = pOptimize;
}
/** @deprecated */
public List getCustomCompilerArguments() {
final List list = new ArrayList();
for (int i = 0; i < customArguments.length; i++) {
list.add(customArguments[i]);
}
return list;
}
/** @deprecated */
public void setCustomCompilerArguments(List customCompilerArguments) {
customArguments = (String[]) customCompilerArguments.toArray(new String[customCompilerArguments.size()]);
}
/** @deprecated */
public String getMaxmem() {
return memMax;
}
/** @deprecated */
public void setMaxmem(String maxmem) {
this.memMax = maxmem;
}
/** @deprecated */
public String getMeminitial() {
return memInitial;
}
/** @deprecated */
public void setMeminitial(String meminitial) {
this.memInitial = meminitial;
}
String[] toNativeSettings() {
final List args = new ArrayList();
if (isOptimize()) {
args.add("-O");
}
if (isDebug()) {
args.add("-g");
}
if (isDeprecations()) {
args.add("-deprecation");
}
if (!isWarnings() && !isDeprecations()) {
args.add("-nowarn");
}
if (getMaxMemory() != null) {
args.add("-J-Xmx" + getMaxMemory());
}
if (getInitialMemory() != null) {
args.add("-J-Xms" + getInitialMemory());
}
args.add("-target");
args.add(getTargetVersion());
args.add("-source");
args.add(getSourceVersion());
args.add("-encoding");
args.add(getSourceEncoding());
if (customArguments != null) {
for (int i = 0; i < customArguments.length; i++) {
args.add(customArguments[i]);
}
}
return (String[])args.toArray(new String[args.size()]);
}
}