• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java VPackBuilder类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



VPackBuilder类属于com.arangodb.velocypack包,在下文中一共展示了VPackBuilder类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: toObjectWithAttributeAdapter

import com.arangodb.velocypack.VPackBuilder; //导入依赖的package包/类
@Test
public void toObjectWithAttributeAdapter() throws IOException {
	final VPackBuilder builder = new VPackBuilder();
	{
		builder.add(ValueType.OBJECT);
		builder.add("_key", "a");
		builder.add("_rev", "b");
		builder.add("_id", "c");
		builder.add("_from", "d");
		builder.add("_to", "e");
		builder.close();
	}
	final TestEntityBaseAttributes entity = mapper.readValue(builder.slice().getBuffer(),
		TestEntityBaseAttributes.class);
	assertThat(entity, is(notNullValue()));
	assertThat(entity._key, is("a"));
	assertThat(entity._rev, is("b"));
	assertThat(entity._id, is("c"));
	assertThat(entity._from, is("d"));
	assertThat(entity._to, is("e"));
}
 
开发者ID:arangodb,项目名称:jackson-dataformat-velocypack,代码行数:22,代码来源:VPackSerializeDeserializeTest.java


示例7: toMapWithAttributeAdapter

import com.arangodb.velocypack.VPackBuilder; //导入依赖的package包/类
@Test
public void toMapWithAttributeAdapter() throws IOException {
	final VPackBuilder builder = new VPackBuilder();
	{
		builder.add(ValueType.OBJECT);
		builder.add("m1", ValueType.OBJECT);
		builder.add("_key", "a");
		builder.add("_rev", "b");
		builder.add("_id", "c");
		builder.add("_from", "d");
		builder.add("_to", "e");
		builder.close();
		builder.close();
	}
	final TestEntityMap entity = mapper.readValue(builder.slice().getBuffer(), TestEntityMap.class);
	assertThat(entity, is(notNullValue()));
	assertThat(entity.m1, is(notNullValue()));
	assertThat(entity.m1.size(), is(5));
}
 
开发者ID:arangodb,项目名称:jackson-dataformat-velocypack,代码行数:20,代码来源:VPackSerializeDeserializeTest.java


示例8: directToCollection

import com.arangodb.velocypack.VPackBuilder; //导入依赖的package包/类
@Test
public void directToCollection() throws IOException {
	final VPackBuilder builder = new VPackBuilder();
	builder.add(ValueType.ARRAY);
	builder.add(ValueType.OBJECT);
	builder.add("s", "abc");
	builder.close();
	builder.close();
	final List<TestEntityString> list = mapper.readValue(builder.slice().getBuffer(),
		new TypeReference<List<TestEntityString>>() {
		});
	assertThat(list, is(notNullValue()));
	assertThat(list.size(), is(1));
	final TestEntityString entry = list.get(0);
	assertThat(entry.s, is("abc"));
}
 
开发者ID:arangodb,项目名称:jackson-dataformat-velocypack,代码行数:17,代码来源:VPackSerializeDeserializeTest.java


示例9: directToStringMap

import com.arangodb.velocypack.VPackBuilder; //导入依赖的package包/类
@Test
public void directToStringMap() throws IOException {
	final VPackBuilder builder = new VPackBuilder();
	builder.add(ValueType.OBJECT);
	builder.add("a", ValueType.OBJECT);
	builder.add("s", "abc");
	builder.close();
	builder.close();
	final Map<String, TestEntityString> map = mapper.readValue(builder.slice().getBuffer(),
		new TypeReference<Map<String, TestEntityString>>() {
		});
	assertThat(map, is(notNullValue()));
	assertThat(map.size(), is(1));
	final TestEntityString a = map.get("a");
	assertThat(a, is(notNullValue()));
	assertThat(a.s, is("abc"));
}
 
开发者ID:arangodb,项目名称:jackson-dataformat-velocypack,代码行数:18,代码来源:VPackSerializeDeserializeTest.java


示例10: directToObjectMap

import com.arangodb.velocypack.VPackBuilder; //导入依赖的package包/类
@Test
public void directToObjectMap() throws IOException {
	final VPackBuilder builder = new VPackBuilder();
	builder.add(ValueType.ARRAY);
	builder.add(ValueType.OBJECT);
	builder.add("key", ValueType.OBJECT);
	builder.add("s", "abc");
	builder.close();
	builder.add("value", ValueType.OBJECT);
	builder.add("s", "abc");
	builder.close();
	builder.close();
	builder.close();
	final Map<TestEntityString, TestEntityString> map = mapper.readValue(builder.slice().getBuffer(),
		new TypeReference<Map<TestEntityString, TestEntityString>>() {
		});
	assertThat(map, is(notNullValue()));
	assertThat(map.size(), is(1));
	for (final Entry<TestEntityString, TestEntityString> entry : map.entrySet()) {
		assertThat(entry.getKey().s, is("abc"));
		assertThat(entry.getValue().s, is("abc"));
	}
}
 
开发者ID:arangodb,项目名称:jackson-dataformat-velocypack,代码行数:24,代码来源:VPackSerializeDeserializeTest.java


示例11: fieldNamingStrategyDeserialize

import com.arangodb.velocypack.VPackBuilder; //导入依赖的package包/类
@Test
public void fieldNamingStrategyDeserialize() throws IOException {
	final VPackBuilder builder = new VPackBuilder();
	builder.add(ValueType.OBJECT);
	builder.add("bla", "test");
	builder.close();
	final ObjectMapper mapper = new VPackMapper();
	mapper.setPropertyNamingStrategy(new PropertyNamingStrategy() {
		private static final long serialVersionUID = 1L;

		@Override
		public String nameForSetterMethod(
			final MapperConfig<?> config,
			final AnnotatedMethod method,
			final String defaultName) {
			return "bla";
		}
	});
	final TestEntityA entity = mapper.readValue(builder.slice().getBuffer(), TestEntityA.class);
	assertThat(entity, is(notNullValue()));
	assertThat(entity.a, is("test"));
}
 
开发者ID:arangodb,项目名称:jackson-dataformat-velocypack,代码行数:23,代码来源:VPackSerializeDeserializeTest.java


示例12: deserializeOptional

import com.arangodb.velocypack.VPackBuilder; //导入依赖的package包/类
@Test
public void deserializeOptional() {
	final VPackBuilder builder = new VPackBuilder();
	builder.add(ValueType.OBJECT);
	builder.add("s", "hello world");
	builder.add("i", 69);
	builder.add("o", ValueType.OBJECT).close();
	builder.close();

	final OptionalTestEntity entity = vp.deserialize(builder.slice(), OptionalTestEntity.class);
	assertThat(entity, is(notNullValue()));
	assertThat(entity.s.isPresent(), is(true));
	assertThat(entity.s.get(), is("hello world"));
	assertThat(entity.i.isPresent(), is(true));
	assertThat(entity.i.get(), is(69));
	assertThat(entity.o.isPresent(), is(true));
}
 
开发者ID:arangodb,项目名称:java-velocypack-module-jdk8,代码行数:18,代码来源:VPackOptionalTest.java


示例13: deserializeOptionalNull

import com.arangodb.velocypack.VPackBuilder; //导入依赖的package包/类
@Test
public void deserializeOptionalNull() {
	final VPackBuilder builder = new VPackBuilder();
	builder.add(ValueType.OBJECT);
	builder.add("s", ValueType.NULL);
	builder.add("i", ValueType.NULL);
	builder.add("o", ValueType.NULL);
	builder.add("e", ValueType.NULL);
	builder.close();

	final OptionalTestEntity entity = vp.deserialize(builder.slice(), OptionalTestEntity.class);
	assertThat(entity, is(notNullValue()));
	assertThat(entity.s, is(notNullValue()));
	assertThat(entity.s.isPresent(), is(false));
	assertThat(entity.i, is(notNullValue()));
	assertThat(entity.i.isPresent(), is(false));
	assertThat(entity.o, is(notNullValue()));
	assertThat(entity.o.isPresent(), is(false));
	assertThat(entity.e, is(notNullValue()));
	assertThat(entity.e.isPresent(), is(false));
}
 
开发者ID:arangodb,项目名称:java-velocypack-module-jdk8,代码行数:22,代码来源:VPackOptionalTest.java


示例14: deserializeOptionalPrimitive

import com.arangodb.velocypack.VPackBuilder; //导入依赖的package包/类
@Test
public void deserializeOptionalPrimitive() {
	final VPackBuilder builder = new VPackBuilder();
	builder.add(ValueType.OBJECT);
	builder.add("d", 69.5);
	builder.add("i", 69);
	builder.add("l", 69L);
	builder.close();

	final OptionalPrimitiveTestEntity entity = vp.deserialize(builder.slice(), OptionalPrimitiveTestEntity.class);
	assertThat(entity, is(notNullValue()));
	assertThat(entity.d.isPresent(), is(true));
	assertThat(entity.d.getAsDouble(), is(69.5));
	assertThat(entity.i.isPresent(), is(true));
	assertThat(entity.i.getAsInt(), is(69));
	assertThat(entity.l.isPresent(), is(true));
	assertThat(entity.l.getAsLong(), is(69L));
}
 
开发者ID:arangodb,项目名称:java-velocypack-module-jdk8,代码行数:19,代码来源:VPackOptionalTest.java


示例15: deserializeOptionalPrimitiveNull

import com.arangodb.velocypack.VPackBuilder; //导入依赖的package包/类
@Test
public void deserializeOptionalPrimitiveNull() {
	final VPackBuilder builder = new VPackBuilder();
	builder.add(ValueType.OBJECT);
	builder.add("d", ValueType.NULL);
	builder.add("i", ValueType.NULL);
	builder.add("l", ValueType.NULL);
	builder.close();

	final OptionalPrimitiveTestEntity entity = vp.deserialize(builder.slice(), OptionalPrimitiveTestEntity.class);
	assertThat(entity, is(notNullValue()));
	assertThat(entity.d, is(notNullValue()));
	assertThat(entity.d.isPresent(), is(false));
	assertThat(entity.i, is(notNullValue()));
	assertThat(entity.i.isPresent(), is(false));
	assertThat(entity.l, is(notNullValue()));
	assertThat(entity.l.isPresent(), is(false));
}
 
开发者ID:arangodb,项目名称:java-velocypack-module-jdk8,代码行数:19,代码来源:VPackOptionalTest.java


示例16: deserializeDate

import com.arangodb.velocypack.VPackBuilder; //导入依赖的package包/类
@SuppressWarnings("deprecation")
@Test
public void deserializeDate() {
	final VPackBuilder builder = new VPackBuilder();
	builder.add(ValueType.OBJECT);
	builder.add("instant", new Date(1475062216));
	builder.add("localDate", new Date(70, 0, 18));
	builder.add("localDateTime", new Date(1475062216));
	builder.add("zonedDateTime", new Date(1475062216));
	builder.add("offsetDateTime", new Date(1475062216));
	builder.close();

	final TestEntityDate entity = vp.deserialize(builder.slice(), TestEntityDate.class);
	assertThat(entity, is(notNullValue()));
	assertThat(entity.instant, is(Instant.ofEpochMilli(1475062216)));
	assertThat(entity.localDate, is(Instant.ofEpochMilli(1475062216).atZone(ZoneId.systemDefault()).toLocalDate()));
	assertThat(entity.localDateTime,
		is(LocalDateTime.ofInstant(Instant.ofEpochMilli(1475062216), ZoneId.systemDefault())));
	assertThat(entity.zonedDateTime,
		is(ZonedDateTime.ofInstant(Instant.ofEpochMilli(1475062216), ZoneId.systemDefault())));
}
 
开发者ID:arangodb,项目名称:java-velocypack-module-jdk8,代码行数:22,代码来源:VPackTimeTest.java


示例17: deserializeDateFromString

import com.arangodb.velocypack.VPackBuilder; //导入依赖的package包/类
@SuppressWarnings("deprecation")
@Test
public void deserializeDateFromString() {
	final VPackBuilder builder = new VPackBuilder();
	builder.add(ValueType.OBJECT);
	builder.add("instant", DATE_FORMAT.format(new Date(1475062216)));
	builder.add("localDate", DATE_FORMAT.format(new Date(70, 0, 18)));
	builder.add("localDateTime", DATE_FORMAT.format(new Date(1475062216)));
	builder.add("zonedDateTime", DATE_FORMAT.format(new Date(1475062216)));
	builder.close();

	final TestEntityDate entity = vp.deserialize(builder.slice(), TestEntityDate.class);
	assertThat(entity, is(notNullValue()));
	assertThat(entity.instant, is(Instant.ofEpochMilli(1475062216)));
	assertThat(entity.localDate, is(Instant.ofEpochMilli(1475062216).atZone(ZoneId.systemDefault()).toLocalDate()));
	assertThat(entity.localDateTime,
		is(LocalDateTime.ofInstant(Instant.ofEpochMilli(1475062216), ZoneId.systemDefault())));
	assertThat(entity.zonedDateTime,
		is(ZonedDateTime.ofInstant(Instant.ofEpochMilli(1475062216), ZoneId.systemDefault())));
}
 
开发者ID:arangodb,项目名称:java-velocypack-module-jdk8,代码行数:21,代码来源:VPackTimeTest.java


示例18: 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


示例19: 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


示例20: deserialize

import com.arangodb.velocypack.VPackBuilder; //导入依赖的package包/类
@Test
public void deserialize() throws VPackException {
	final VPackBuilder builder = new VPackBuilder();
	builder.add(ValueType.OBJECT);
	builder.add("_id", "test/test");
	builder.add("_key", "test");
	builder.add("_rev", "test");
	builder.add("a", "a");
	builder.close();

	final VPack.Builder vbuilder = new VPack.Builder();
	vbuilder.registerModule(new VPackDriverModule());
	final VPack vpacker = vbuilder.build();

	final BaseDocument entity = vpacker.deserialize(builder.slice(), BaseDocument.class);
	assertThat(entity.getId(), is(notNullValue()));
	assertThat(entity.getId(), is("test/test"));
	assertThat(entity.getKey(), is(notNullValue()));
	assertThat(entity.getKey(), is("test"));
	assertThat(entity.getRevision(), is(notNullValue()));
	assertThat(entity.getRevision(), is("test"));
	assertThat(entity.getProperties().size(), is(1));
	assertThat(String.valueOf(entity.getAttribute("a")), is("a"));
}
 
开发者ID:arangodb,项目名称:arangodb-java-driver,代码行数:25,代码来源:BaseDocumentTest.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java MavenExecution类代码示例发布时间:2022-05-22
下一篇:
Java AddUndoPositionInterface类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap