本文整理汇总了Java中com.arangodb.velocypack.VPackBuilder.close方法的典型用法代码示例。如果您正苦于以下问题:Java VPackBuilder.close方法的具体用法?Java VPackBuilder.close怎么用?Java VPackBuilder.close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.arangodb.velocypack.VPackBuilder
的用法示例。
在下文中一共展示了VPackBuilder.close方法的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));
}
示例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')));
}
示例3: 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"));
}
示例4: 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"));
}
示例5: 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())));
}
示例6: 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));
}
示例7: 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));
}
示例8: 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"));
}
示例9: 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"));
}
}
示例10: 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));
}
示例11: 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));
}
}
示例12: 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));
}
示例13: 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"));
}
示例14: 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)));
}
示例15: 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)));
}