本文整理汇总了Java中javax.json.stream.JsonParser.Event.VALUE_NUMBER属性的典型用法代码示例。如果您正苦于以下问题:Java Event.VALUE_NUMBER属性的具体用法?Java Event.VALUE_NUMBER怎么用?Java Event.VALUE_NUMBER使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类javax.json.stream.JsonParser.Event
的用法示例。
在下文中一共展示了Event.VALUE_NUMBER属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testGetLong
@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));
}
示例2: testGetBigInteger
@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));
}
示例3: testGetDecimal
@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));
}
示例4: testGetInt
@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);
}
示例5: testGetInt_2
@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);
}
示例6: testGetLong
@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);
}
示例7: testGetLong_2
@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);
}
示例8: testGetDecimal
@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);
}
示例9: testGetInt
@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);
}
示例10: testGetInt_2
@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);
}
示例11: testGetLong
@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);
}
示例12: testGetLong_2
@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);
}
示例13: testGetDecimal
@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);
}
示例14: testGetInt
@Test
public void testGetInt () throws IOException
{
File file = new File ("../tests/data/types.bson".replace ('/', File.separatorChar));
JsonParser p = new BsonParser (new FileInputStream (file));
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, 2147483647, 12345, 1234, 1942892530, 2147483647, 12345, 1 }, ints);
}
示例15: testGetLong
@Test
public void testGetLong () throws IOException
{
File file = new File ("../tests/data/types.bson".replace ('/', File.separatorChar));
JsonParser p = new BsonParser (new FileInputStream (file));
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, 9223372036854775807L, 12345, 1234, 12345678901234L, 9223372036854775807L, 12345, 1 }, longs);
}