Package org.apache.avro

Examples of org.apache.avro.Protocol$Message


/**
* The input to Idl is a CompilationUnit, which is currently
* just a single Protocol.
*/
  final public Protocol CompilationUnit() throws ParseException {
  Protocol p;
    p = ProtocolDeclaration();
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case 65:
      jj_consume_token(65);
      break;
View Full Code Here


    throw new Error("Missing return statement in function");
  }

  final public Protocol ProtocolDeclaration() throws ParseException {
  String name;
  Protocol p;
  Map<String, JsonNode> props = new LinkedHashMap<String, JsonNode>();
    label_2:
    while (true) {
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case AT:
        ;
        break;
      default:
        jj_la1[4] = jj_gen;
        break label_2;
      }
      SchemaProperty(props);
    }
    if (props.containsKey("namespace"))
      namespace = getTextProp("namespace", props, token);
    jj_consume_token(PROTOCOL);
    name = Identifier();
   p = new Protocol(name, getDoc(), namespace);
   for (String key : props.keySet())
     if ("namespace".equals(key)) {               // already handled: ignore
     } else if (props.get(key).isTextual()) {     // ignore other non-textual
       p.addProp(key, getTextProp(key, props, token));
     }
    ProtocolBody(p);
   {if (true) return p;}
    throw new Error("Missing return statement in function");
  }
View Full Code Here

  }

  final public void ProtocolBody(Protocol p) throws ParseException {
  Schema schema;
  Message message;
  Protocol importProtocol;
  Map<String, JsonNode> props = new LinkedHashMap<String, JsonNode>();
    jj_consume_token(LBRACE);
    label_4:
    while (true) {
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case ARRAY:
      case BOOLEAN:
      case DOUBLE:
      case ENUM:
      case ERROR:
      case FIXED:
      case FLOAT:
      case IMPORT:
      case INT:
      case LONG:
      case MAP:
      case BYTES:
      case STRING:
      case NULL:
      case RECORD:
      case UNION:
      case VOID:
      case IDENTIFIER:
      case AT:
      case TICK:
        ;
        break;
      default:
        jj_la1[6] = jj_gen;
        break label_4;
      }
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case IMPORT:
        jj_consume_token(IMPORT);
        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
        case IDL:
        case PROTOCOL:
          switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
          case IDL:
            importProtocol = ImportIdl();
            break;
          case PROTOCOL:
            importProtocol = ImportProtocol();
            break;
          default:
            jj_la1[7] = jj_gen;
            jj_consume_token(-1);
            throw new ParseException();
          }
       for (Schema s : importProtocol.getTypes())
         names.put(s.getFullName(), s);
       p.getMessages().putAll(importProtocol.getMessages());
          break;
        case SCHEMA:
          schema = ImportSchema();
          break;
        default:
View Full Code Here

/**
* The input to Idl is a CompilationUnit, which is currently
* just a single Protocol.
*/
  final public Protocol CompilationUnit() throws ParseException {
  Protocol p;
    p = ProtocolDeclaration();
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case 65:
      jj_consume_token(65);
      break;
View Full Code Here

    throw new Error("Missing return statement in function");
  }

  final public Protocol ProtocolDeclaration() throws ParseException {
  String name;
  Protocol p;
  Map<String, JsonNode> props = new LinkedHashMap<String, JsonNode>();
    label_2:
    while (true) {
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case AT:
        ;
        break;
      default:
        jj_la1[4] = jj_gen;
        break label_2;
      }
      SchemaProperty(props);
    }
    if (props.containsKey("namespace"))
      namespace = getTextProp("namespace", props, token);
    jj_consume_token(PROTOCOL);
    name = Identifier();
   p = new Protocol(name, getDoc(), namespace);
   for (String key : props.keySet())
     if ("namespace".equals(key)) {               // already handled: ignore
     } else if (props.get(key).isTextual()) {     // ignore other non-textual
       p.addProp(key, getTextProp(key, props, token));
     }
    ProtocolBody(p);
   {if (true) return p;}
    throw new Error("Missing return statement in function");
  }
View Full Code Here

  }

  final public void ProtocolBody(Protocol p) throws ParseException {
  Schema schema;
  Message message;
  Protocol importProtocol;
  Map<String, JsonNode> props = new LinkedHashMap<String, JsonNode>();
    jj_consume_token(LBRACE);
    label_4:
    while (true) {
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case ARRAY:
      case BOOLEAN:
      case DOUBLE:
      case ENUM:
      case ERROR:
      case FIXED:
      case FLOAT:
      case IMPORT:
      case INT:
      case LONG:
      case MAP:
      case BYTES:
      case STRING:
      case NULL:
      case RECORD:
      case UNION:
      case VOID:
      case IDENTIFIER:
      case AT:
      case TICK:
        ;
        break;
      default:
        jj_la1[6] = jj_gen;
        break label_4;
      }
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case IMPORT:
        jj_consume_token(IMPORT);
        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
        case IDL:
        case PROTOCOL:
          switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
          case IDL:
            importProtocol = ImportIdl();
            break;
          case PROTOCOL:
            importProtocol = ImportProtocol();
            break;
          default:
            jj_la1[7] = jj_gen;
            jj_consume_token(-1);
            throw new ParseException();
          }
       for (Schema s : importProtocol.getTypes())
         names.put(s.getFullName(), s);
       p.getMessages().putAll(importProtocol.getMessages());
          break;
        case SCHEMA:
          schema = ImportSchema();
          break;
        default:
View Full Code Here

    @Union({Void.class,String.class})
      String foo(@Union({Void.class,String.class}) String s);
  }

  @Test public void testP0() throws Exception {
    Protocol p0 = ReflectData.get().getProtocol(P0.class);
    Protocol.Message message = p0.getMessages().get("foo");
    // check response schema is union
    Schema response = message.getResponse();
    assertEquals(Schema.Type.UNION, response.getType());
    assertEquals(Schema.Type.NULL, response.getTypes().get(0).getType());
    assertEquals(Schema.Type.STRING, response.getTypes().get(1).getType());
View Full Code Here

  public static interface P1 {
    @Nullable String foo(@Nullable String s);
  }

  @Test public void testP1() throws Exception {
    Protocol p1 = ReflectData.get().getProtocol(P1.class);
    Protocol.Message message = p1.getMessages().get("foo");
    // check response schema is union
    Schema response = message.getResponse();
    assertEquals(Schema.Type.UNION, response.getType());
    assertEquals(Schema.Type.NULL, response.getTypes().get(0).getType());
    assertEquals(Schema.Type.STRING, response.getTypes().get(1).getType());
View Full Code Here

    @AvroSchema("\"int\"")                        // message value
    Object foo(@AvroSchema("\"int\"")Object x);   // message param
  }

  @Test public void testP4() throws Exception {
    Protocol p = ReflectData.get().getProtocol(P4.class);
    Protocol.Message message = p.getMessages().get("foo");
    assertEquals(Schema.Type.INT, message.getResponse().getType());
    Field field = message.getRequest().getField("x");
    assertEquals(Schema.Type.INT, field.schema().getType());
  }
View Full Code Here

    Schema messageSchema = message.schema();
    assertEquals(Schema.Type.UNION, messageSchema.getType());
    assertEquals(Schema.Type.NULL, messageSchema.getTypes().get(0).getType());
    assertEquals(Schema.Type.STRING, messageSchema.getTypes().get(1).getType());

    Protocol p2 = ReflectData.get().getProtocol(P2.class);
    Protocol.Message m = p2.getMessages().get("error");
    // check error schema is union
    Schema response = m.getErrors();
    assertEquals(Schema.Type.UNION, response.getType());
    assertEquals(Schema.Type.STRING, response.getTypes().get(0).getType());
    assertEquals(e1, response.getTypes().get(1));
View Full Code Here

TOP

Related Classes of org.apache.avro.Protocol$Message

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.