@Override public boolean run(Outline outline, Options opt, ErrorHandler errorHandler) { for (final PackageOutline packageOutline : outline .getAllPackageContexts()) { final StringBuilder sb = new StringBuilder(); for (final ClassOutline classOutline : packageOutline.getClasses()) { sb.append(CodeModelUtils.getLocalClassName(classOutline.ref)); sb.append("\n"); } final JTextFile indexFile = new JTextFile("jaxb.index"); indexFile.setContents(sb.toString()); packageOutline._package().addResourceFile(indexFile); } return true; }
private void outputSchema(JPackage avroPackage, List<NamedAvroType> types) { // set up the correct format for leading zeros (ensures proper order in filesystem) StringBuilder digits = new StringBuilder(); for (int i=0; i < Integer.toString(types.size()).length(); ++i) { digits.append("0"); } DecimalFormat format = new java.text.DecimalFormat(digits.toString()); AtomicInteger counter = new AtomicInteger(1); for (NamedAvroType type : types) { String id = format.format(counter.getAndIncrement()); JTextFile avroSchema = new JTextFile("avroSchema-"+ id +"_"+ type.name +".txt"); avroSchema.setContents(getJson(type)); avroPackage.addResourceFile(avroSchema); } }
private JTextFile createTextFile(String fileName, JSProgram... programs) throws IOException { Validate.notNull(fileName); final JTextFile textFile = new JTextFile(fileName); final StringWriter stringWriter = new StringWriter(); final CodeWriter codeWriter = new CodeWriter(stringWriter); for (JSProgram program : programs) { codeWriter.program(program); codeWriter.lineTerminator(); } textFile.setContents(stringWriter.toString()); return textFile; }
private JTextFile createTextFile(String fileName, JsonStructure jsonStructure) throws IOException { Validate.notNull(fileName); final JTextFile textFile = new JTextFile(fileName); final StringWriter stringWriter = new StringWriter(); final JsonWriter jsonWriter = provider.createWriterFactory( Collections.singletonMap(JsonGenerator.PRETTY_PRINTING, Boolean.TRUE)).createWriter(stringWriter); jsonWriter.write(jsonStructure); textFile.setContents(stringWriter.toString()); return textFile; }
public void marshallPersistence(JCodeModel codeModel, Persistence persistence) throws Exception { // final JPackage defaultPackage = codeModel._package(""); final JPackage metaInfPackage = codeModel._package("META-INF"); final JTextFile persistenceXmlFile = new JTextFile("persistence.xml"); metaInfPackage.addResourceFile(persistenceXmlFile); final Writer writer = new StringWriter(); getMarshaller().marshal(persistence, writer); persistenceXmlFile.setContents(writer.toString()); }