org.apache.avro.Protocol.getDoc()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(4.1k)|赞(0)|评价(0)|浏览(108)

本文整理了Java中org.apache.avro.Protocol.getDoc()方法的一些代码示例,展示了Protocol.getDoc()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Protocol.getDoc()方法的具体详情如下:
包路径:org.apache.avro.Protocol
类名称:Protocol
方法名:getDoc

Protocol.getDoc介绍

[英]Doc string for this protocol.
[中]此协议的文档字符串。

代码示例

代码示例来源:origin: apache/avro

/**
 * Constructs a similar Protocol instance with the same {@code name}, {@code doc}, and {@code namespace} as {code p}
 * has. It also copies all the {@code props}.
 */
public Protocol(Protocol p) {
 this(p.getName(), p.getDoc(), p.getNamespace());
 putAll(p);
}

代码示例来源:origin: apache/avro

private Protocol addStringType(Protocol p) {
 if (stringType != StringType.String)
  return p;
 Protocol newP = new Protocol(p.getName(), p.getDoc(), p.getNamespace());
 Map<Schema,Schema> types = new LinkedHashMap<>();
 for (Map.Entry<String, Object> a : p.getObjectProps().entrySet()) {
  newP.addProp(a.getKey(), a.getValue());
 }
 // annotate types
 Collection<Schema> namedTypes = new LinkedHashSet<>();
 for (Schema s : p.getTypes())
  namedTypes.add(addStringType(s, types));
 newP.setTypes(namedTypes);
 // annotate messages
 Map<String,Message> newM = newP.getMessages();
 for (Message m : p.getMessages().values())
  newM.put(m.getName(), m.isOneWay()
       ? newP.createMessage(m,
                 addStringType(m.getRequest(), types))
       : newP.createMessage(m,
                 addStringType(m.getRequest(), types),
                 addStringType(m.getResponse(), types),
                 addStringType(m.getErrors(), types)));
 return newP;
}

代码示例来源:origin: apache/avro

@Test
public void testParsing() throws IOException {
 Protocol protocol = getSimpleProtocol();
 assertEquals(protocol.getDoc(), "Protocol used for testing.");
 assertEquals(6, protocol.getMessages().size());
 assertEquals("Pretend you're in a cave!", protocol.getMessages().get("echo").getDoc());
}

代码示例来源:origin: apache/avro

Protocol result = new Protocol(protocol.getName(), protocol.getDoc(), protocol.getNamespace());
final Collection<Schema> types = protocol.getTypes();

代码示例来源:origin: org.apache.hadoop/avro

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;
}

代码示例来源:origin: org.apache.cassandra.deps/avro

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;
}

相关文章