当前位置: 首页>>代码示例>>Java>>正文


Java VPackBuilder.slice方法代码示例

本文整理汇总了Java中com.arangodb.velocypack.VPackBuilder.slice方法的典型用法代码示例。如果您正苦于以下问题:Java VPackBuilder.slice方法的具体用法?Java VPackBuilder.slice怎么用?Java VPackBuilder.slice使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.arangodb.velocypack.VPackBuilder的用法示例。


在下文中一共展示了VPackBuilder.slice方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: toBoolean

import com.arangodb.velocypack.VPackBuilder; //导入方法依赖的package包/类
@Test
public void toBoolean() throws IOException {
	final VPackBuilder builder = new VPackBuilder();
	{
		builder.add(ValueType.OBJECT);
		builder.add("a", false);
		builder.add("b", true);
		builder.add("c", Boolean.FALSE);
		builder.add("d", Boolean.TRUE);
		builder.close();
	}
	final VPackSlice vpack = builder.slice();
	final TestEntityBoolean entity = mapper.readValue(vpack.getBuffer(), TestEntityBoolean.class);
	assertThat(entity, is(notNullValue()));
	assertThat(entity.a, is(false));
	assertThat(entity.b, is(true));
	assertThat(entity.c, is(Boolean.FALSE));
	assertThat(entity.d, is(Boolean.TRUE));
}
 
开发者ID:arangodb,项目名称:jackson-dataformat-velocypack,代码行数:20,代码来源:VPackSerializeDeserializeTest.java

示例2: toStrings

import com.arangodb.velocypack.VPackBuilder; //导入方法依赖的package包/类
@Test
public void toStrings() throws IOException {
	final VPackBuilder builder = new VPackBuilder();
	{
		builder.add(ValueType.OBJECT);
		builder.add("s", "abc");
		builder.add("c1", 'd');
		builder.add("c2", 'd');
		builder.close();
	}
	final VPackSlice vpack = builder.slice();
	final TestEntityString entity = mapper.readValue(vpack.getBuffer(), TestEntityString.class);
	assertThat(entity, is(notNullValue()));
	assertThat(entity.s, is("abc"));
	assertThat(entity.c1, is(new Character('d')));
	assertThat(entity.c1, is(new Character('d')));
}
 
开发者ID:arangodb,项目名称:jackson-dataformat-velocypack,代码行数:18,代码来源:VPackSerializeDeserializeTest.java

示例3: toCollectionExtendedWithNulls

import com.arangodb.velocypack.VPackBuilder; //导入方法依赖的package包/类
@Test
public void toCollectionExtendedWithNulls() throws Exception {
	final VPackBuilder builder = new VPackBuilder();
	{
		builder.add(ValueType.OBJECT);
		{
			builder.add("a1", ValueType.ARRAY);
			builder.add("one");
			builder.add(ValueType.NULL);
			builder.add("two");
			builder.close();
		}
		builder.close();
	}

	final VPackSlice vpack = builder.slice();
	final TestEntityCollectionExtendedWithNulls entity = mapper.readValue(vpack.getBuffer(),
		TestEntityCollectionExtendedWithNulls.class);
	assertThat(entity, is(notNullValue()));
	assertThat(entity.getA1(), is(notNullValue()));
	assertThat(entity.getA1().size(), is(3));
	assertThat(entity.getA1(), contains("one", null, "two"));
}
 
开发者ID:arangodb,项目名称:jackson-dataformat-velocypack,代码行数:24,代码来源:VPackSerializeDeserializeTest.java

示例4: toObjectInArray

import com.arangodb.velocypack.VPackBuilder; //导入方法依赖的package包/类
@Test
public void toObjectInArray() throws IOException {
	final VPackBuilder builder = new VPackBuilder();
	{
		builder.add(ValueType.OBJECT);
		builder.add("a1", ValueType.ARRAY);
		{
			builder.add(ValueType.OBJECT);
			builder.add("s", "abc");
			builder.close();
		}
		builder.close();
		builder.close();
	}
	final VPackSlice vpack = builder.slice();
	final TestEntityObjectInArray entity = mapper.readValue(vpack.getBuffer(), TestEntityObjectInArray.class);
	assertThat(entity, is(notNullValue()));
	assertThat(entity.a1, is(notNullValue()));
	assertThat(entity.a1.length, is(1));
	final TestEntityString st = entity.a1[0];
	assertThat(st, is(notNullValue()));
	assertThat(st.s, is("abc"));
}
 
开发者ID:arangodb,项目名称:jackson-dataformat-velocypack,代码行数:24,代码来源:VPackSerializeDeserializeTest.java

示例5: toInterface

import com.arangodb.velocypack.VPackBuilder; //导入方法依赖的package包/类
@Test
public void toInterface() throws IOException {
	final VPackBuilder builder = new VPackBuilder();
	{
		builder.add(ValueType.OBJECT);
		builder.add("d", ValueType.OBJECT);
		builder.add("d", "test");
		builder.close();
		builder.close();
	}
	final VPackSlice slice = builder.slice();
	final VPack vPack = new VPack.Builder()
			.registerInstanceCreator(TestEntityD.class, new VPackInstanceCreator<TestEntityD>() {
				@Override
				public TestEntityD createInstance() {
					return new TestEntityDImpl();
				}
			}).build();
	final TestEntityC entity = vPack.deserialize(slice, TestEntityC.class);
	assertThat(entity, is(notNullValue()));
	assertThat(entity.d, is(notNullValue()));
	assertThat(entity.d.getD(), is("test"));
}
 
开发者ID:arangodb,项目名称:jackson-dataformat-velocypack,代码行数:24,代码来源:VPackSerializeDeserializeTest.java

示例6: buildObject

import com.arangodb.velocypack.VPackBuilder; //导入方法依赖的package包/类
@Test
public void buildObject() throws VPackException {
	final VPackBuilder builder = new VPackBuilder();
	builder.add(ValueType.OBJECT);// object start
	builder.add("foo", 1); // add field "foo" with value 1
	builder.add("bar", 2); // add field "bar" with value 2
	builder.close();// object end

	final VPackSlice slice = builder.slice(); // create slice
	assertThat(slice.isObject(), is(true));
	assertThat(slice.size(), is(2)); // number of fields

	final VPackSlice foo = slice.get("foo"); // get field "foo"
	assertThat(foo.isInteger(), is(true));
	assertThat(foo.getAsInt(), is(1));

	final VPackSlice bar = slice.get("bar"); // get field "bar"
	assertThat(bar.isInteger(), is(true));
	assertThat(bar.getAsInt(), is(2));

	// iterate over the fields
	for (final Iterator<Entry<String, VPackSlice>> iterator = slice.objectIterator(); iterator.hasNext();) {
		final Entry<String, VPackSlice> field = iterator.next();
		assertThat(field.getValue().isInteger(), is(true));
	}
}
 
开发者ID:arangodb,项目名称:arangodb-java-driver-async,代码行数:27,代码来源:VPackExample.java

示例7: buildObjectInObject

import com.arangodb.velocypack.VPackBuilder; //导入方法依赖的package包/类
@Test
public void buildObjectInObject() throws VPackException {
	final VPackBuilder builder = new VPackBuilder();
	builder.add(ValueType.OBJECT);// object start
	builder.add("foo", ValueType.OBJECT); // add object in field "foo"
	builder.add("bar", 2); // add field "bar" with value 2 to object "foo"
	builder.close();// object "foo" end
	builder.close();// object end

	final VPackSlice slice = builder.slice(); // create slice
	assertThat(slice.isObject(), is(true));

	final VPackSlice foo = slice.get("foo");
	assertThat(foo.isObject(), is(true));

	final VPackSlice bar = foo.get("bar"); // get field "bar" from "foo"
	assertThat(bar.isInteger(), is(true));
}
 
开发者ID:arangodb,项目名称:arangodb-java-driver-async,代码行数:19,代码来源:VPackExample.java

示例8: toInteger

import com.arangodb.velocypack.VPackBuilder; //导入方法依赖的package包/类
@Test
public void toInteger() throws IOException {
	final VPackBuilder builder = new VPackBuilder();
	{
		builder.add(ValueType.OBJECT);
		builder.add("i1", 2);
		builder.add("i2", 3);
		builder.close();
	}
	final VPackSlice vpack = builder.slice();
	final TestEntityInteger entity = mapper.readValue(vpack.getBuffer(), TestEntityInteger.class);
	assertThat(entity, is(notNullValue()));
	assertThat(entity.i1, is(2));
	assertThat(entity.i2, is(new Integer(3)));
}
 
开发者ID:arangodb,项目名称:jackson-dataformat-velocypack,代码行数:16,代码来源:VPackSerializeDeserializeTest.java

示例9: toLong

import com.arangodb.velocypack.VPackBuilder; //导入方法依赖的package包/类
@Test
public void toLong() throws IOException {
	final VPackBuilder builder = new VPackBuilder();
	{
		builder.add(ValueType.OBJECT);
		builder.add("l1", 2);
		builder.add("l2", 3);
		builder.close();
	}
	final VPackSlice vpack = builder.slice();
	final TestEntityLong entity = mapper.readValue(vpack.getBuffer(), TestEntityLong.class);
	assertThat(entity, is(notNullValue()));
	assertThat(entity.l1, is(2L));
	assertThat(entity.l2, is(new Long(3)));
}
 
开发者ID:arangodb,项目名称:jackson-dataformat-velocypack,代码行数:16,代码来源:VPackSerializeDeserializeTest.java

示例10: toFloat

import com.arangodb.velocypack.VPackBuilder; //导入方法依赖的package包/类
@Test
public void toFloat() throws IOException {
	final VPackBuilder builder = new VPackBuilder();
	{
		builder.add(ValueType.OBJECT);
		builder.add("f1", 2F);
		builder.add("f2", 3F);
		builder.close();
	}
	final VPackSlice vpack = builder.slice();
	final TestEntityFloat entity = mapper.readValue(vpack.getBuffer(), TestEntityFloat.class);
	assertThat(entity, is(notNullValue()));
	assertThat(entity.f1, is(2F));
	assertThat(entity.f2, is(new Float(3)));
}
 
开发者ID:arangodb,项目名称:jackson-dataformat-velocypack,代码行数:16,代码来源:VPackSerializeDeserializeTest.java

示例11: toShort

import com.arangodb.velocypack.VPackBuilder; //导入方法依赖的package包/类
@Test
public void toShort() throws IOException {
	final VPackBuilder builder = new VPackBuilder();
	{
		builder.add(ValueType.OBJECT);
		builder.add("s1", 2);
		builder.add("s2", 3);
		builder.close();
	}
	final VPackSlice vpack = builder.slice();
	final TestEntityShort entity = mapper.readValue(vpack.getBuffer(), TestEntityShort.class);
	assertThat(entity, is(notNullValue()));
	assertThat(entity.s1, is((short) 2));
	assertThat(entity.s2, is(new Short((short) 3)));
}
 
开发者ID:arangodb,项目名称:jackson-dataformat-velocypack,代码行数:16,代码来源:VPackSerializeDeserializeTest.java

示例12: toByte

import com.arangodb.velocypack.VPackBuilder; //导入方法依赖的package包/类
@Test
public void toByte() throws IOException {
	final VPackBuilder builder = new VPackBuilder();
	{
		builder.add(ValueType.OBJECT);
		builder.add("b1", 30); // integer path
		builder.add("b2", 4); // short integer path
		builder.close();
	}
	final VPackSlice vpack = builder.slice();
	final TestEntityByte entity = mapper.readValue(vpack.getBuffer(), TestEntityByte.class);
	assertThat(entity, is(notNullValue()));
	assertThat(entity.b1, is((byte) 30));
	assertThat(entity.b2, is(new Byte((byte) 4)));
}
 
开发者ID:arangodb,项目名称:jackson-dataformat-velocypack,代码行数:16,代码来源:VPackSerializeDeserializeTest.java

示例13: toDouble

import com.arangodb.velocypack.VPackBuilder; //导入方法依赖的package包/类
@Test
public void toDouble() throws IOException {
	final VPackBuilder builder = new VPackBuilder();
	{
		builder.add(ValueType.OBJECT);
		builder.add("d1", 2.25);
		builder.add("d2", 3.75);
		builder.close();
	}
	final VPackSlice vpack = builder.slice();
	final TestEntityDouble entity = mapper.readValue(vpack.getBuffer(), TestEntityDouble.class);
	assertThat(entity, is(notNullValue()));
	assertThat(entity.d1, is(2.25));
	assertThat(entity.d2, is(3.75));
}
 
开发者ID:arangodb,项目名称:jackson-dataformat-velocypack,代码行数:16,代码来源:VPackSerializeDeserializeTest.java

示例14: toBigNumbers

import com.arangodb.velocypack.VPackBuilder; //导入方法依赖的package包/类
@Test
public void toBigNumbers() throws IOException {
	final VPackBuilder builder = new VPackBuilder();
	{
		builder.add(ValueType.OBJECT);
		builder.add("bi", BigInteger.valueOf(2));
		builder.add("bd", BigDecimal.valueOf(3.75));
		builder.close();
	}
	final VPackSlice vpack = builder.slice();
	final TestEntityBigNumber entity = mapper.readValue(vpack.getBuffer(), TestEntityBigNumber.class);
	assertThat(entity, is(notNullValue()));
	assertThat(entity.bi, is(BigInteger.valueOf(2)));
	assertThat(entity.bd, is(BigDecimal.valueOf(3.75)));
}
 
开发者ID:arangodb,项目名称:jackson-dataformat-velocypack,代码行数:16,代码来源:VPackSerializeDeserializeTest.java

示例15: toEnum

import com.arangodb.velocypack.VPackBuilder; //导入方法依赖的package包/类
@Test
public void toEnum() throws IOException {
	final VPackBuilder builder = new VPackBuilder();
	{
		builder.add(ValueType.OBJECT);
		builder.add("e1", TestEnum.B.name());
		builder.close();
	}
	final VPackSlice vpack = builder.slice();
	final TestEntityEnum entity = mapper.readValue(vpack.getBuffer(), TestEntityEnum.class);
	assertThat(entity, is(notNullValue()));
	assertThat(entity.e1, is(TestEnum.B));
}
 
开发者ID:arangodb,项目名称:jackson-dataformat-velocypack,代码行数:14,代码来源:VPackSerializeDeserializeTest.java


注:本文中的com.arangodb.velocypack.VPackBuilder.slice方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。