本文整理了Java中org.apache.avro.Protocol.toString()
方法的一些代码示例,展示了Protocol.toString()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Protocol.toString()
方法的具体详情如下:
包路径:org.apache.avro.Protocol
类名称:Protocol
方法名:toString
[英]Render this as JSON.
[中]将其呈现为JSON。
代码示例来源:origin: apache/avro
/** Render this as <a href="http://json.org/">JSON</a>.*/
@Override
public String toString() { return toString(false); }
代码示例来源:origin: org.apache.avro/avro
/** Render this as <a href="http://json.org/">JSON</a>.*/
@Override
public String toString() { return toString(false); }
代码示例来源:origin: org.apache.avro/avro
/** Return the MD5 hash of the text of this protocol. */
public byte[] getMD5() {
if (md5 == null)
try {
md5 = MessageDigest.getInstance("MD5")
.digest(this.toString().getBytes("UTF-8"));
} catch (Exception e) {
throw new AvroRuntimeException(e);
}
return md5;
}
代码示例来源:origin: apache/avro
/** Return the MD5 hash of the text of this protocol. */
public byte[] getMD5() {
if (md5 == null)
try {
md5 = MessageDigest.getInstance("MD5")
.digest(this.toString().getBytes("UTF-8"));
} catch (Exception e) {
throw new AvroRuntimeException(e);
}
return md5;
}
代码示例来源:origin: org.apache.avro/avro
/** Return the protocol for a Java interface. */
public Protocol getProtocol(Class iface) {
try {
Protocol p = (Protocol)(iface.getDeclaredField("PROTOCOL").get(null));
if (!p.getNamespace().equals(iface.getPackage().getName()))
// HACK: protocol mismatches iface. maven shade plugin? try replacing.
p = Protocol.parse(p.toString().replace(p.getNamespace(),
iface.getPackage().getName()));
return p;
} catch (NoSuchFieldException e) {
throw new AvroRuntimeException("Not a Specific protocol: "+iface);
} catch (IllegalAccessException e) {
throw new AvroRuntimeException(e);
}
}
代码示例来源:origin: apache/avro
/** Return the protocol for a Java interface. */
public Protocol getProtocol(Class iface) {
try {
Protocol p = (Protocol)(iface.getDeclaredField("PROTOCOL").get(null));
if (!p.getNamespace().equals(iface.getPackage().getName()))
// HACK: protocol mismatches iface. maven shade plugin? try replacing.
p = Protocol.parse(p.toString().replace(p.getNamespace(),
iface.getPackage().getName()));
return p;
} catch (NoSuchFieldException e) {
throw new AvroRuntimeException("Not a Specific protocol: "+iface);
} catch (IllegalAccessException e) {
throw new AvroRuntimeException(e);
}
}
代码示例来源:origin: apache/avro
parseOut.print(p.toString(true));
} finally {
if (parseOut != out) // Close only the newly created FileOutputStream
代码示例来源:origin: apache/avro
System.out.println(ReflectData.get().getProtocol(klass).toString(true));
} else {
System.out.println(ReflectData.get().getSchema(klass).toString(true));
代码示例来源:origin: apache/avro
public void execute() throws MojoExecutionException {
ClassLoader classLoader = getClassLoader();
for(File inputFile : sourceDirectory.listFiles()) {
String className = parseClassName(inputFile.getPath());
Class<?> klass = loadClass(classLoader, className);
String fileName = outputDirectory.getPath() + "/" + parseFileName(klass);
File outputFile = new File(fileName);
outputFile.getParentFile().mkdirs();
try {
PrintWriter writer = new PrintWriter(fileName, "UTF-8");
if(klass.isInterface()) {
writer.println(ReflectData.get().getProtocol(klass).toString(true));
} else {
writer.println(ReflectData.get().getSchema(klass).toString(true));
}
writer.close();
} catch(Exception e) {
e.printStackTrace();
}
}
}
代码示例来源:origin: apache/avro
String json = p.toString(true);
Protocol protocol = Protocol.parse(json);
SpecificCompiler compiler = new SpecificCompiler(protocol, getDateTimeLogicalTypeImplementation());
代码示例来源:origin: apache/avro
@Test
public void testSplitProtocolBuild() {
Protocol p = new Protocol("P", null, "foo");
p.addProp("property", "some value");
String protocolString = p.toString();
final int mid = protocolString.length() / 2;
String[] parts = {
protocolString.substring(0, mid),
protocolString.substring(mid),
};
Protocol parsedStringProtocol = org.apache.avro.Protocol.parse(protocolString);
Protocol parsedArrayOfStringProtocol =
org.apache.avro.Protocol.parse(protocolString.substring(0, mid),
protocolString.substring(mid));
assertNotNull(parsedStringProtocol);
assertNotNull(parsedArrayOfStringProtocol);
assertEquals(parsedStringProtocol.toString(), parsedArrayOfStringProtocol.toString());
}
}
代码示例来源:origin: apache/avro
out.println(p.toString(true));
代码示例来源:origin: apache/avro
response.serverProtocol = local.toString();
response.serverHash = localHash;
代码示例来源:origin: apache/avro
private void writeHandshake(Encoder out) throws IOException {
if (getTransceiver().isConnected()) return;
MD5 localHash = new MD5();
localHash.bytes(local.getMD5());
String remoteName = transceiver.getRemoteName();
MD5 remoteHash = REMOTE_HASHES.get(remoteName);
if (remoteHash == null) { // guess remote is local
remoteHash = localHash;
remote = local;
} else {
remote = REMOTE_PROTOCOLS.get(remoteHash);
}
HandshakeRequest handshake = new HandshakeRequest();
handshake.clientHash = localHash;
handshake.serverHash = remoteHash;
if (sendLocalText)
handshake.clientProtocol = local.toString();
RPCContext context = new RPCContext();
context.setHandshakeRequest(handshake);
for (RPCPlugin plugin : rpcMetaPlugins) {
plugin.clientStartConnect(context);
}
handshake.meta = context.requestHandshakeMeta();
HANDSHAKE_WRITER.write(handshake, out);
}
代码示例来源:origin: apache/avro
@Test
public void testForwardReference() {
ReflectData data = ReflectData.get();
Protocol reflected = data.getProtocol(C.class);
Protocol reparsed = Protocol.parse(reflected.toString());
assertEquals(reflected, reparsed);
assert(reparsed.getTypes().contains(data.getSchema(A.class)));
assert(reparsed.getTypes().contains(data.getSchema(B1.class)));
assert(reparsed.getTypes().contains(data.getSchema(B2.class)));
assert(reparsed.getTypes().contains(data.getSchema(X.class)));
}
代码示例来源:origin: com.facebook.presto.hive/hive-apache
/** Render this as <a href="http://json.org/">JSON</a>.*/
@Override
public String toString() { return toString(false); }
代码示例来源:origin: org.apache.hadoop/avro
/** Return the MD5 hash of the text of this protocol. */
public byte[] getMD5() {
if (md5 == null)
try {
md5 = MessageDigest.getInstance("MD5")
.digest(this.toString().getBytes("UTF-8"));
} catch (Exception e) {
throw new AvroRuntimeException(e);
}
return md5;
}
代码示例来源:origin: com.facebook.presto.hive/hive-apache
/** Return the MD5 hash of the text of this protocol. */
public byte[] getMD5() {
if (md5 == null)
try {
md5 = MessageDigest.getInstance("MD5")
.digest(this.toString().getBytes("UTF-8"));
} catch (Exception e) {
throw new AvroRuntimeException(e);
}
return md5;
}
代码示例来源:origin: org.apache.cassandra.deps/avro
/** Return the MD5 hash of the text of this protocol. */
public byte[] getMD5() {
if (md5 == null)
try {
md5 = MessageDigest.getInstance("MD5")
.digest(this.toString().getBytes("UTF-8"));
} catch (Exception e) {
throw new AvroRuntimeException(e);
}
return md5;
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.avro
/** Return the MD5 hash of the text of this protocol. */
public byte[] getMD5() {
if (md5 == null)
try {
md5 = MessageDigest.getInstance("MD5")
.digest(this.toString().getBytes("UTF-8"));
} catch (Exception e) {
throw new AvroRuntimeException(e);
}
return md5;
}
内容来源于网络,如有侵权,请联系作者删除!