Package org.apache.avro

Examples of org.apache.avro.Protocol


  public static interface C { void foo(A a); }

  @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)));
  }
View Full Code Here


        + "putOnClassPath" + File.separator;
      URL[] newPathURL = new URL[]{new URL(newPath)};
      URLClassLoader ucl = new URLClassLoader(newPathURL, cl);

      Idl parser = new Idl(in, ucl);
      Protocol p = parser.CompilationUnit();
      parser.close();
      return p.toString();
    }
View Full Code Here

    assertEquals(3, count);
  }
 
  @Test
  public void testProtocolWithDocs() throws IOException {
    Protocol protocol = TestProtocolParsing.getSimpleProtocol();
    Collection<OutputFile> out = new SpecificCompiler(protocol).compile();
    assertEquals(6, out.size());
    int count = 0;
    for (OutputFile o : out) {
      if (o.path.endsWith("Simple.java")) {
View Full Code Here

    assertEquals(3, count);
  }
 
  @Test
  public void testProtocolWithDocs() throws IOException {
    Protocol protocol = TestProtocolParsing.getSimpleProtocol();
    Collection<OutputFile> out = new SpecificCompiler(protocol).compile();
    assertEquals(6, out.size());
    int count = 0;
    for (OutputFile o : out) {
      if (o.path.endsWith("Simple.java")) {
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_3:
    while (true) {
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case AT:
        ;
        break;
      default:
        jj_la1[5] = jj_gen;
        break label_3;
      }
      SchemaProperty(props);
    }
    if (props.containsKey("namespace"))
      namespace = getTextProp("namespace", props, token);
    jj_consume_token(PROTOCOL);
    name = Identifier();
   p = new Protocol(name, getDoc(), namespace);
    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;
    jj_consume_token(LBRACE);
    label_5:
    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[7] = jj_gen;
        break label_5;
      }
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case ENUM:
      case ERROR:
      case FIXED:
      case RECORD:
      case AT:
        schema = NamedSchemaDeclaration();
        break;
      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[8] = 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_3:
    while (true) {
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case AT:
        ;
        break;
      default:
        jj_la1[5] = jj_gen;
        break label_3;
      }
      SchemaProperty(props);
    }
    if (props.containsKey("namespace"))
      namespace = getTextProp("namespace", props, token);
    jj_consume_token(PROTOCOL);
    name = Identifier();
   p = new Protocol(name, getDoc(), namespace);
    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;
    jj_consume_token(LBRACE);
    label_5:
    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[7] = jj_gen;
        break label_5;
      }
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case ENUM:
      case ERROR:
      case FIXED:
      case RECORD:
      case AT:
        schema = NamedSchemaDeclaration();
        break;
      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[8] = 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

TOP

Related Classes of org.apache.avro.Protocol

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.