本文整理汇总了Java中javax.json.stream.JsonParser.Event类的典型用法代码示例。如果您正苦于以下问题:Java Event类的具体用法?Java Event怎么用?Java Event使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Event类属于javax.json.stream.JsonParser包,在下文中一共展示了Event类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: perfTest
import javax.json.stream.JsonParser.Event; //导入依赖的package包/类
private void perfTest (JsonParser p)
{
try
{
for (;;)
{
Event e = p.next ();
switch (e)
{
case KEY_NAME:
case VALUE_NUMBER:
case VALUE_STRING:
p.getString ();
break;
default:
break;
}
}
}
catch (NoSuchElementException ex)
{
}
}
示例2: testBinary
import javax.json.stream.JsonParser.Event; //导入依赖的package包/类
@Test
public void testBinary () throws IOException
{
File file = new File ("../tests/data/binary.bson".replace ('/', File.separatorChar));
CookJsonProvider provider = new CookJsonProvider ();
HashMap<String, Object> config = new HashMap<String, Object> ();
config.put (CookJsonProvider.FORMAT, CookJsonProvider.FORMAT_BSON);
config.put (CookJsonProvider.BINARY_FORMAT, CookJsonProvider.BINARY_FORMAT_HEX);
JsonReader r = provider.createReaderFactory (config).createReader (new FileInputStream (file));
JsonStructure v = r.read ();
r.close ();
CookJsonParser p = new JsonStructureParser (v);
while (p.hasNext ())
{
if (p.next () == Event.VALUE_STRING)
{
if (p.isBinary ())
{
Assert.assertEquals (p.getString (), Hex.encodeHexString (p.getBytes ()));
}
}
}
p.close ();
}
示例3: testGetLong
import javax.json.stream.JsonParser.Event; //导入依赖的package包/类
@Test
public void testGetLong () throws IOException
{
File file = new File ("../tests/data/types.json".replace ('/', File.separatorChar));
CookJsonProvider provider = new CookJsonProvider ();
JsonReader r = provider.createReader (new FileInputStream (file));
JsonStructure v = r.read ();
r.close ();
CookJsonParser p = new JsonStructureParser (v);
long[] longs = new long[9];
int count = 0;
while (p.hasNext ())
{
if (p.next () == Event.VALUE_NUMBER)
{
Assert.assertTrue (p.getValue () instanceof JsonNumber);
longs[count++] = p.getLong ();
}
}
p.close ();
Assert.assertEquals (sum (new long[]{ 1234, 12345678901234L, 7888426545362939890L, 12345, 1234, 12345678901234L, 7888426545362939890L, 12345, 1 }), sum (longs));
}
示例4: testGetBigInteger
import javax.json.stream.JsonParser.Event; //导入依赖的package包/类
@Test
public void testGetBigInteger () throws IOException
{
File file = new File ("../tests/data/types.json".replace ('/', File.separatorChar));
CookJsonParser p = getJsonParser (file);
BigInteger[] bigints = new BigInteger[9];
int count = 0;
while (p.hasNext ())
{
if (p.next () == Event.VALUE_NUMBER)
{
Assert.assertTrue (p.getValue () instanceof JsonNumber);
bigints[count++] = p.getBigDecimal ().toBigInteger ();
}
}
p.close ();
Assert.assertEquals (sum (new BigInteger[]{ new BigInteger ("1234"), new BigInteger ("12345678901234"), new BigInteger ("1234567890123412345678901234"), new BigInteger ("12345"), new BigInteger ("1234"), new BigInteger ("12345678901234"), new BigInteger ("1234567890123412345678901234"), new BigInteger ("12345"), new BigInteger ("1") }), sum (bigints));
}
示例5: testGetDecimal
import javax.json.stream.JsonParser.Event; //导入依赖的package包/类
@Test
public void testGetDecimal () throws IOException
{
File file = new File ("../tests/data/types.json".replace ('/', File.separatorChar));
CookJsonProvider provider = new CookJsonProvider ();
JsonReader r = provider.createReader (new FileInputStream (file));
JsonStructure v = r.read ();
r.close ();
CookJsonParser p = new JsonStructureParser (v);
BigDecimal[] decimals = new BigDecimal[9];
int count = 0;
while (p.hasNext ())
{
if (p.next () == Event.VALUE_NUMBER)
{
Assert.assertTrue (p.getValue () instanceof JsonNumber);
decimals[count++] = p.getBigDecimal ();
}
}
p.close ();
Assert.assertEquals (sum (new BigDecimal[]{ new BigDecimal (1234), new BigDecimal (12345678901234L), new BigDecimal ("1234567890123412345678901234"), new BigDecimal (12345.5), new BigDecimal (1234), new BigDecimal (12345678901234L), new BigDecimal ("1234567890123412345678901234"), new BigDecimal (12345.5), new BigDecimal (1) }), sum (decimals));
}
示例6: testGetInt
import javax.json.stream.JsonParser.Event; //导入依赖的package包/类
@Test
public void testGetInt () throws IOException
{
File file = new File ("../tests/data/types.json".replace ('/', File.separatorChar));
JsonParser p = getJsonParser (file, 0);
int[] ints = new int[9];
int count = 0;
while (p.hasNext ())
{
if (p.next () == Event.VALUE_NUMBER)
{
ints[count++] = p.getInt ();
}
}
p.close ();
Assert.assertArrayEquals (new int[]
{ 1234, 1942892530, -115429390, 12345, 1234, 1942892530, -115429390, 12345, 1 }, ints);
}
示例7: testGetInt_2
import javax.json.stream.JsonParser.Event; //导入依赖的package包/类
@Test
public void testGetInt_2 () throws IOException
{
File file = new File ("../tests/data/types.json".replace ('/', File.separatorChar));
JsonParser p = getJsonParser (file, 1);
int[] ints = new int[9];
int count = 0;
while (p.hasNext ())
{
if (p.next () == Event.VALUE_NUMBER)
{
ints[count++] = p.getInt ();
}
}
p.close ();
Assert.assertArrayEquals (new int[]
{ 1234, 1942892530, -115429390, 12345, 1234, 1942892530, -115429390, 12345, 1 }, ints);
}
示例8: testGetLong
import javax.json.stream.JsonParser.Event; //导入依赖的package包/类
@Test
public void testGetLong () throws IOException
{
File file = new File ("../tests/data/types.json".replace ('/', File.separatorChar));
JsonParser p = getJsonParser (file, 0);
long[] longs = new long[9];
int count = 0;
while (p.hasNext ())
{
if (p.next () == Event.VALUE_NUMBER)
{
longs[count++] = p.getLong ();
}
}
p.close ();
Assert.assertArrayEquals (new long[]
{ 1234, 12345678901234L, 7888426545362939890L, 12345, 1234, 12345678901234L, 7888426545362939890L, 12345, 1 },
longs);
}
示例9: testGetLong_2
import javax.json.stream.JsonParser.Event; //导入依赖的package包/类
@Test
public void testGetLong_2 () throws IOException
{
File file = new File ("../tests/data/types.json".replace ('/', File.separatorChar));
JsonParser p = getJsonParser (file, 1);
long[] longs = new long[9];
int count = 0;
while (p.hasNext ())
{
if (p.next () == Event.VALUE_NUMBER)
{
longs[count++] = p.getLong ();
}
}
p.close ();
Assert.assertArrayEquals (new long[]
{ 1234, 12345678901234L, 7888426545362939890L, 12345, 1234, 12345678901234L, 7888426545362939890L, 12345, 1 },
longs);
}
示例10: testGetDecimal
import javax.json.stream.JsonParser.Event; //导入依赖的package包/类
@Test
public void testGetDecimal () throws IOException
{
File file = new File ("../tests/data/types.json".replace ('/', File.separatorChar));
JsonParser p = getJsonParser (file, 0);
BigDecimal[] decimals = new BigDecimal[9];
int count = 0;
while (p.hasNext ())
{
if (p.next () == Event.VALUE_NUMBER)
{
decimals[count++] = p.getBigDecimal ();
}
}
p.close ();
Assert.assertArrayEquals (new BigDecimal[]
{ new BigDecimal (1234), new BigDecimal (12345678901234L), new BigDecimal ("1234567890123412345678901234"),
new BigDecimal (12345.5), new BigDecimal (1234), new BigDecimal (12345678901234L),
new BigDecimal ("1234567890123412345678901234"), new BigDecimal (12345.5), new BigDecimal (1) },
decimals);
}
示例11: testGetInt
import javax.json.stream.JsonParser.Event; //导入依赖的package包/类
@Test
public void testGetInt () throws IOException
{
File file = new File ("../tests/data/types.json".replace ('/', File.separatorChar));
JsonParser p = getJsonParser (file, 0);
int[] ints = new int[9];
int count = 0;
while (p.hasNext ())
{
if (p.next () == Event.VALUE_NUMBER)
{
ints[count++] = p.getInt ();
}
}
p.close ();
Assert.assertArrayEquals (new int[]{ 1234, 1942892530, -115429390, 12345, 1234, 1942892530, -115429390, 12345, 1 }, ints);
}
示例12: testGetInt_2
import javax.json.stream.JsonParser.Event; //导入依赖的package包/类
@Test
public void testGetInt_2 () throws IOException
{
File file = new File ("../tests/data/types.json".replace ('/', File.separatorChar));
JsonParser p = getJsonParser (file, 1);
int[] ints = new int[9];
int count = 0;
while (p.hasNext ())
{
if (p.next () == Event.VALUE_NUMBER)
{
ints[count++] = p.getInt ();
}
}
p.close ();
Assert.assertArrayEquals (new int[]{ 1234, 1942892530, -115429390, 12345, 1234, 1942892530, -115429390, 12345, 1 }, ints);
}
示例13: testGetLong
import javax.json.stream.JsonParser.Event; //导入依赖的package包/类
@Test
public void testGetLong () throws IOException
{
File file = new File ("../tests/data/types.json".replace ('/', File.separatorChar));
JsonParser p = getJsonParser (file, 0);
long[] longs = new long[9];
int count = 0;
while (p.hasNext ())
{
if (p.next () == Event.VALUE_NUMBER)
{
longs[count++] = p.getLong ();
}
}
p.close ();
Assert.assertArrayEquals (new long[]{ 1234, 12345678901234L, 7888426545362939890L, 12345, 1234, 12345678901234L, 7888426545362939890L, 12345, 1 }, longs);
}
示例14: testGetLong_2
import javax.json.stream.JsonParser.Event; //导入依赖的package包/类
@Test
public void testGetLong_2 () throws IOException
{
File file = new File ("../tests/data/types.json".replace ('/', File.separatorChar));
JsonParser p = getJsonParser (file, 1);
long[] longs = new long[9];
int count = 0;
while (p.hasNext ())
{
if (p.next () == Event.VALUE_NUMBER)
{
longs[count++] = p.getLong ();
}
}
p.close ();
Assert.assertArrayEquals (new long[]{ 1234, 12345678901234L, 7888426545362939890L, 12345, 1234, 12345678901234L, 7888426545362939890L, 12345, 1 }, longs);
}
示例15: testGetDecimal
import javax.json.stream.JsonParser.Event; //导入依赖的package包/类
@Test
public void testGetDecimal () throws IOException
{
File file = new File ("../tests/data/types.json".replace ('/', File.separatorChar));
JsonParser p = getJsonParser (file, 0);
BigDecimal[] decimals = new BigDecimal[9];
int count = 0;
while (p.hasNext ())
{
if (p.next () == Event.VALUE_NUMBER)
{
decimals[count++] = p.getBigDecimal ();
}
}
p.close ();
Assert.assertArrayEquals (new BigDecimal[]{ new BigDecimal (1234), new BigDecimal (12345678901234L), new BigDecimal ("1234567890123412345678901234"), new BigDecimal (12345.5), new BigDecimal (1234), new BigDecimal (12345678901234L), new BigDecimal ("1234567890123412345678901234"), new BigDecimal (12345.5), new BigDecimal (1) }, decimals);
}