本文整理汇总了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())));
}
示例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"));
}
示例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));
}
}
示例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));
}
示例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"));
}
示例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));
}
示例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"));
}
示例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));
}
示例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)));
}
示例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));
}
示例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)));
}
示例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));
}
示例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)));
}
示例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());
}
示例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());
}