private static void populateSchemaFields(Schema schema, Set<BoundField> fields) { for (BoundField field: schema.fields()) { fields.add(field); if (field.def.type instanceof ArrayOf) { Type innerType = ((ArrayOf) field.def.type).type(); if (innerType instanceof Schema) populateSchemaFields((Schema) innerType, fields); } else if (field.def.type instanceof Schema) populateSchemaFields((Schema) field.def.type, fields); } }
public static void main(String[] args) { System.out.println(toHtml()); }
private static void schemaToBnfHtml(Schema schema, StringBuilder b, int indentSize) { final String indentStr = indentString(indentSize); final Map<String, Type> subTypes = new LinkedHashMap<>(); b.append(entry.getKey()); b.append(" => "); schemaToBnfHtml((Schema) entry.getValue(), b, indentSize + 2); } else {
schemaToBnfHtml(RequestHeader.SCHEMA, b, 2); b.append("</pre>\n"); schemaToFieldTableHtml(RequestHeader.SCHEMA, b); schemaToBnfHtml(ResponseHeader.SCHEMA, b, 2); b.append("</pre>\n"); schemaToFieldTableHtml(ResponseHeader.SCHEMA, b); b.append(i); b.append(") => "); schemaToBnfHtml(requests[i], b, 2); b.append("</pre>"); schemaToFieldTableHtml(requests[i], b); b.append(i); b.append(") => "); schemaToBnfHtml(responses[i], b, 2); b.append("</pre>"); schemaToFieldTableHtml(responses[i], b);
Request(ChannelHandlerContext ctx, ByteBuffer buffer) { this.requestId = buffer.getShort(); buffer.rewind(); header = RequestHeader.parse(buffer); if (header.apiKey() == ApiKeys.API_VERSIONS.id && !Protocol.apiVersionSupported(header.apiKey(), header.apiVersion())) { body = new ApiVersionsRequest(); } else { body = AbstractRequest.getRequest(header.apiKey(), header.apiVersion(), buffer); } this.clientAddress = ((InetSocketAddress) ctx.getChannel().getRemoteAddress()).getAddress(); }
private static void schemaToFieldTableHtml(Schema schema, StringBuilder b) { Set<BoundField> fields = new LinkedHashSet<>(); populateSchemaFields(schema, fields); b.append("<table class=\"data-table\"><tbody>\n"); b.append("<tr>"); b.append("<th>Field</th>\n"); b.append("<th>Description</th>\n"); b.append("</tr>"); for (BoundField field : fields) { b.append("<tr>\n"); b.append("<td>"); b.append(field.def.name); b.append("</td>"); b.append("<td>"); b.append(field.def.docString); b.append("</td>"); b.append("</tr>\n"); } b.append("</table>\n"); }