@Test public void testMaps() throws IOException { try { parse("providence", "map<i64,i64>", "[]"); } catch (ParseException e) { assertThat(e.asString(), is( "Error on line 12, pos 2: Expected map start, found [\n" + " []\n" + "-^")); } assertThat(parse("providence", "map<bool,bool>", "{" + " 0: 1," + " true: false}"), is(ImmutableMap.of(false, true, true, false))); assertThat(parse("providence", "map<i8,i8>", "{" + " 1: 2," + " \"124\": 125," + " Value.SECOND: Value.THIRD," + "}"), is(ImmutableMap.of((byte)1, (byte)2, (byte)2, (byte)3, (byte)124, (byte)125))); assertThat(parse("providence", "map<i16,i16>", "{" + " 1: 2," + " \"124\": 125," + " Value.SECOND: Value.THIRD," + "}"), is(ImmutableMap.of((short)1, (short)2, (short)2, (short)3, (short)124, (short)125))); assertThat(parse("providence", "map<i32,i32>", "{" + " 1: 2," + " \"124\": 125," + " Value.SECOND: Value.THIRD," + "}"), is(ImmutableMap.of(1, 2, 2, 3, 124, 125))); assertThat(parse("providence", "map<i64,i64>", "{" + " 1: 2," + " " \"124\": 125," + " " + " Value.SECOND: Value.THIRD," + "}"), is(ImmutableMap.of(1L, 2L, 2L, 3L, 124L, 125L))); try { parse("providence", "map<i64,i64>", "{ Foo.SECOND: Value.THIRD }"); } catch (ParseException e) { assertThat(e.asString(), is( "Error on line 12, pos 29: No type named Foo.\n" + "....................... = { Foo.SECOND: Value.THIRD }\n" + "----------------------------^^^^^^^^^^")); } try { parse("providence", "map<i64,i64>", "{ OptionalFields.SECOND: Value.THIRD }"); } catch (ParseException e) { assertThat(e.asString(), is( "Error on line 12, pos 40: OptionalFields is not an enum.\n" + ".................................. = { OptionalFields.SECOND: Value.THIRD }\n" + "---------------------------------------^^^^^^^^^^^^^^^^^^^^^")); } assertThat(parse("providence", "map<double,double>", "{" + " 1.1: 2.2e+4," + "}"), is(ImmutableMap.of(1.1, 22000.0))); try { parse("providence", "map<double,double>", "{" + " \"boo\": 2.2e+4," + "}"); fail("no exception"); } catch (ParseException e) { assertThat(e.asString(), is( "Error on line 18, pos 21: Unable to parse double value\n" + ".............. = { \"boo\": 2.2e+4,}\n" + "--------------------^^^^^")); } assertThat(parse("providence", "map<string,string>", "{" + " \"a\": \"b\"," + "}"), is(ImmutableMap.of("a", "b"))); assertThat(parse("providence", "map<binary,binary>", "{" + " \"AAg\": \"AAg\"," + "}"), is(ImmutableMap.of(Binary.fromBase64("AAg="), Binary.fromBase64("AAg=")))); }
public Object parse(InputStream inputStream, PDescriptor type) throws ParseException { return parse(new Utf8StreamReader(inputStream), type); }
ConstParser { public Object parse(InputStream inputStream, PDescriptor type) throws ParseException { return parse(new Utf8StreamReader(inputStream), type); } }
ConstParser { public Object parse(InputStream inputStream, PDescriptor type) throws ParseException { return parse(new Utf8StreamReader(inputStream), type); } ConstParser(TypeRegistry registry,
                       String programContext,
                       int startLineNo,
                       int startLinePos); }
ConstParser { public Object parse(InputStream inputStream, PDescriptor type) throws ParseException { return parse(new Utf8StreamReader(inputStream), type); } ConstParser(TypeRegistry registry,
                       String programContext,
                       int startLineNo,
                       int startLinePos); Object parse(InputStream inputStream, PDescriptor type); Object parse(Reader reader, PDescriptor type); }
ConstParser { public Object parse(InputStream inputStream, PDescriptor type) throws ParseException { return parse(new Utf8StreamReader(inputStream), type); } ConstParser(TypeRegistry registry,
                       String programContext,
                       int startLineNo,
                       int startLinePos); Object parse(InputStream inputStream, PDescriptor type); Object parse(Reader reader, PDescriptor type);  }