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


Java VPackBuilder.add方法代码示例

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


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

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

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

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

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

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

示例6: serialize

import com.arangodb.velocypack.VPackBuilder; //导入方法依赖的package包/类
@Override
public void serialize(
	final VPackBuilder builder,
	final String attribute,
	final Date value,
	final VPackSerializationContext context) throws VPackException {
	builder.add(attribute, DateUtil.format(value));
}
 
开发者ID:arangodb,项目名称:java-velocypack,代码行数:9,代码来源:VPackSerializers.java

示例7: toSerializedName

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

示例8: toUUID

import com.arangodb.velocypack.VPackBuilder; //导入方法依赖的package包/类
@Test
public void toUUID() throws IOException {
	final UUID uuid = UUID.randomUUID();
	final VPackBuilder builder = new VPackBuilder();
	builder.add(ValueType.OBJECT);
	builder.add("uuid", uuid.toString());
	builder.close();

	final TestEntityUUID entity = mapper.readValue(builder.slice().getBuffer(), TestEntityUUID.class);
	assertThat(entity, is(notNullValue()));
	assertThat(entity.uuid, is(uuid));
}
 
开发者ID:arangodb,项目名称:jackson-dataformat-velocypack,代码行数:13,代码来源:VPackSerializeDeserializeTest.java

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

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

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

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

示例13: toDateFromString

import com.arangodb.velocypack.VPackBuilder; //导入方法依赖的package包/类
@Test
public void toDateFromString() throws IOException {
	final VPackBuilder builder = new VPackBuilder();
	builder.add(ValueType.OBJECT);
	builder.add("utilDate", DATE_FORMAT.format(new Date(1475062216)));
	builder.add("sqlDate", DATE_FORMAT.format(new java.sql.Date(1475062216)));
	builder.add("timestamp", DATE_FORMAT.format(new java.sql.Timestamp(1475062216)));
	builder.close();

	final TestEntityDate entity = mapper.readValue(builder.slice().getBuffer(), TestEntityDate.class);
	assertThat(entity, is(notNullValue()));
	assertThat(entity.utilDate, is(new Date(1475062216)));
	assertThat(entity.sqlDate, is(new java.sql.Date(1475062216)));
	assertThat(entity.timestamp, is(new java.sql.Timestamp(1475062216)));
}
 
开发者ID:arangodb,项目名称:jackson-dataformat-velocypack,代码行数:16,代码来源:VPackSerializeDeserializeTest.java

示例14: serialize

import com.arangodb.velocypack.VPackBuilder; //导入方法依赖的package包/类
@Override
public void serialize(
        final VPackBuilder builder,
        final String attribute,
        final SafeHTMLString value,
        final VPackSerializationContext context) throws VPackException {

    builder.add(attribute, value.toString());
}
 
开发者ID:miguel-porto,项目名称:flora-on-server,代码行数:10,代码来源:SafeHTMLStringSerializer.java

示例15: serialize

import com.arangodb.velocypack.VPackBuilder; //导入方法依赖的package包/类
@Override
public void serialize(
        final VPackBuilder builder,
        final String attribute,
        final Abundance value,
        final VPackSerializationContext context) throws VPackException {

    builder.add(attribute, value.toString());
}
 
开发者ID:miguel-porto,项目名称:flora-on-server,代码行数:10,代码来源:AbundanceSerializer.java


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