File output = new File(dir, getClassname() + ".java");
WriteStream os = null;
try {
os = Vfs.openWrite(output.toString());
JavaWriter out = new JavaWriter(os);
out.println("package " + pkg + ";");
out.println();
out.println("import java.math.BigDecimal;");
out.println("import java.math.BigInteger;");
out.println("import java.util.List;");
out.println("import javax.xml.bind.annotation.*;");
out.println();
out.print("@XmlType(name=\"" + getName() + "\"");
if (_schema != null && _schema.getTargetNamespace() != null)
out.print(", namespace=\"" + _schema.getTargetNamespace() + "\"");
out.println(")");
out.println("public class " + getClassname() + " {");
out.pushDepth();
if (_contents != null) {
for (int i = 0; i < _contents.size(); i++) {
if (_contents.get(i) instanceof Sequence) {
Sequence sequence = (Sequence) _contents.get(i);
for (Object o : sequence.getContents()) {
if (o instanceof Element) {
((Element) o).generateJavaField(out);
out.println();
}
}
}
}
}
out.popDepth();
out.println("}");
}
finally {
if (os != null)
os.close();
}
if (_emitFaultWrapper) {
os = null;
output = new File(dir, getFaultWrapperClassname() + ".java");
try {
os = Vfs.openWrite(output.toString());
JavaWriter out = new JavaWriter(os);
out.println("package " + pkg + ";");
out.println();
out.println("import java.math.BigDecimal;");
out.println("import java.math.BigInteger;");
out.println("import java.util.List;");
out.println();
out.println("public class " + getFaultWrapperClassname());
out.pushDepth();
out.println("extends Exception {");
out.println();
out.println("private " + getClassname() + " _faultInfo;");
out.println();
out.print("public " + getFaultWrapperClassname() + "(String message, ");
out.println(getClassname() + " faultInfo)");
out.println("{");
out.pushDepth();
out.println("super(message);");
out.println("_faultInfo = faultInfo;");
out.popDepth();
out.println("}");
out.println();
out.print("public " + getFaultWrapperClassname() + "(String message, ");
out.println(getClassname() + " faultInfo, Throwable cause)");
out.println("{");
out.pushDepth();
out.println("super(message, cause);");
out.println("_faultInfo = faultInfo;");
out.popDepth();
out.println("}");
out.println();
out.println("public " + getClassname() + " getFaultInfo()");
out.println("{");
out.pushDepth();
out.println("return _faultInfo;");
out.popDepth();
out.println("}");
out.popDepth();
out.println("}");
}
finally {
if (os != null)
os.close();
}