private OutputFile compile(Schema schema) { OutputFile outputFile = new OutputFile(); String name = mangle(schema.getName()); outputFile.path = makePath(name, schema.getNamespace());
private void compileToDestination(File src, File dst) throws IOException { for (Schema schema : queue) { OutputFile o = compile(schema); File outputFile = new File(dst, o.path); o.writeToDestination(src, dst); } if (protocol != null) { compileInterface(protocol).writeToDestination(src, dst); } }
private OutputFile compile(Schema schema) { OutputFile outputFile = new OutputFile(); String name = mangle(schema.getName()); outputFile.path = makePath(name, schema.getNamespace());
private OutputFile compileInterface(Protocol protocol) { OutputFile outputFile = new OutputFile(); String mangledName = mangle(protocol.getName()); outputFile.path = makePath(mangledName, protocol.getNamespace()); StringBuilder out = new StringBuilder(); header(out, protocol.getNamespace()); doc(out, 1, protocol.getDoc()); line(out, 0, "public interface " + mangledName + " {"); line(out, 1, "public static final org.apache.avro.Protocol PROTOCOL = org.apache.avro.Protocol.parse(\"" +esc(protocol)+"\");"); for (Map.Entry<String,Message> e : protocol.getMessages().entrySet()) { String name = e.getKey(); Message message = e.getValue(); Schema request = message.getRequest(); String response = message.isOneWay() ? "void" : unbox(message.getResponse()); doc(out, 1, e.getValue().getDoc()); line(out, 1, response+" "+ mangle(name)+"("+params(request)+")" + (message.isOneWay() ? "" : (" throws org.apache.avro.ipc.AvroRemoteException" +errors(message.getErrors()))) +";"); } line(out, 0, "}"); outputFile.contents = out.toString(); return outputFile; }
private OutputFile compileInterface(Protocol protocol) { OutputFile outputFile = new OutputFile(); String mangledName = mangle(protocol.getName()); outputFile.path = makePath(mangledName, protocol.getNamespace()); StringBuilder out = new StringBuilder(); header(out, protocol.getNamespace()); doc(out, 1, protocol.getDoc()); line(out, 0, "public interface " + mangledName + " {"); line(out, 1, "public static final org.apache.avro.Protocol PROTOCOL = org.apache.avro.Protocol.parse(\"" +esc(protocol)+"\");"); for (Map.Entry<String,Message> e : protocol.getMessages().entrySet()) { String name = e.getKey(); Message message = e.getValue(); Schema request = message.getRequest(); Schema response = message.getResponse(); doc(out, 1, e.getValue().getDoc()); line(out, 1, unbox(response)+" "+ mangle(name)+"("+params(request)+")"); line(out, 2,"throws org.apache.avro.ipc.AvroRemoteException"+errors(message.getErrors())+";"); } line(out, 0, "}"); outputFile.contents = out.toString(); return outputFile; }
private void compileToDestination(File dst) throws IOException { for (Schema schema : queue) { OutputFile o = compile(schema); o.writeToDestination(dst); } if (protocol != null) { compileInterface(protocol).writeToDestination(dst); } }