本文整理汇总了Java中com.arangodb.velocypack.VPackSlice.get方法的典型用法代码示例。如果您正苦于以下问题:Java VPackSlice.get方法的具体用法?Java VPackSlice.get怎么用?Java VPackSlice.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.arangodb.velocypack.VPackSlice
的用法示例。
在下文中一共展示了VPackSlice.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fromBoolean
import com.arangodb.velocypack.VPackSlice; //导入方法依赖的package包/类
@Test
public void fromBoolean() throws IOException {
final VPackSlice vpack = new VPackSlice(mapper.writeValueAsBytes(new TestEntityBoolean()));
assertThat(vpack, is(notNullValue()));
assertThat(vpack.isObject(), is(true));
{
final VPackSlice a = vpack.get("a");
assertThat(a.isBoolean(), is(true));
assertThat(a.getAsBoolean(), is(true));
}
{
final VPackSlice b = vpack.get("b");
assertThat(b.isBoolean(), is(true));
assertThat(b.getAsBoolean(), is(false));
}
{
final VPackSlice c = vpack.get("c");
assertThat(c.isBoolean(), is(true));
assertThat(c.getAsBoolean(), is(true));
}
{
final VPackSlice d = vpack.get("d");
assertThat(d.isBoolean(), is(true));
assertThat(d.getAsBoolean(), is(false));
}
}
示例2: fromStrings
import com.arangodb.velocypack.VPackSlice; //导入方法依赖的package包/类
@Test
public void fromStrings() throws IOException {
final VPackSlice vpack = new VPackSlice(mapper.writeValueAsBytes(new TestEntityString()));
assertThat(vpack, is(notNullValue()));
assertThat(vpack.isObject(), is(true));
{
final VPackSlice s = vpack.get("s");
assertThat(s.isString(), is(true));
assertThat(s.getAsString(), is("test"));
}
{
final VPackSlice c1 = vpack.get("c1");
assertThat(c1.isString(), is(true));
assertThat(c1.getAsChar(), is('t'));
}
{
final VPackSlice c2 = vpack.get("c2");
assertThat(c2.isString(), is(true));
assertThat(c2.getAsChar(), is('t'));
}
}
示例3: fromInteger
import com.arangodb.velocypack.VPackSlice; //导入方法依赖的package包/类
@Test
public void fromInteger() throws IOException {
final VPackSlice vpack = new VPackSlice(mapper.writeValueAsBytes(new TestEntityInteger()));
assertThat(vpack, is(notNullValue()));
assertThat(vpack.isObject(), is(true));
{
final VPackSlice i1 = vpack.get("i1");
assertThat(i1.isInteger(), is(true));
assertThat(i1.getAsInt(), is(1));
}
{
final VPackSlice i2 = vpack.get("i2");
assertThat(i2.isInteger(), is(true));
assertThat(i2.getAsInt(), is(1));
}
}
示例4: directFromObjectMap
import com.arangodb.velocypack.VPackSlice; //导入方法依赖的package包/类
@Test
public void directFromObjectMap() throws IOException {
final Map<TestEntityString, TestEntityString> map = new HashMap<>();
map.put(new TestEntityString(), new TestEntityString());
map.put(new TestEntityString(), new TestEntityString());
// final VPackSlice vpack = new VPack.Builder().build().serialize(map,
// new SerializeOptions().type(new Type<Map<TestEntityString, TestEntityString>>() {
// }.getType()));
final VPackSlice vpack = new VPackSlice(mapper.writeValueAsBytes(map));
assertThat(vpack, is(notNullValue()));
assertThat(vpack.isArray(), is(true));
assertThat(vpack.getLength(), is(map.size()));
for (int i = 0; i < map.size(); i++) {
final VPackSlice entry = vpack.get(i);
final VPackSlice key = entry.get("key");
checkStringEntity(key);
final VPackSlice value = entry.get("value");
checkStringEntity(value);
}
}
示例5: fromFloat
import com.arangodb.velocypack.VPackSlice; //导入方法依赖的package包/类
@Test
public void fromFloat() throws IOException {
final VPackSlice vpack = new VPackSlice(mapper.writeValueAsBytes(new TestEntityFloat()));
assertThat(vpack, is(notNullValue()));
assertThat(vpack.isObject(), is(true));
{
final VPackSlice f1 = vpack.get("f1");
assertThat(f1.isDouble(), is(true));
assertThat(f1.getAsFloat(), is(1.0F));
}
{
final VPackSlice f2 = vpack.get("f2");
assertThat(f2.isDouble(), is(true));
assertThat(f2.getAsFloat(), is(1.0F));
}
}
示例6: fromShort
import com.arangodb.velocypack.VPackSlice; //导入方法依赖的package包/类
@Test
public void fromShort() throws IOException {
final VPackSlice vpack = new VPackSlice(mapper.writeValueAsBytes(new TestEntityShort()));
assertThat(vpack, is(notNullValue()));
assertThat(vpack.isObject(), is(true));
{
final VPackSlice s1 = vpack.get("s1");
assertThat(s1.isInteger(), is(true));
assertThat(s1.getAsShort(), is((short) 1));
}
{
final VPackSlice s2 = vpack.get("s2");
assertThat(s2.isInteger(), is(true));
assertThat(s2.getAsShort(), is((short) 1));
}
}
示例7: directFromMapWithinMap
import com.arangodb.velocypack.VPackSlice; //导入方法依赖的package包/类
@Test
public void directFromMapWithinMap() throws IOException {
final Map<String, Object> map = new HashMap<>();
final Map<String, Object> map2 = new HashMap<>();
map2.put("b", "test");
map.put("a", map2);
final VPackSlice vpack = new VPackSlice(mapper.writeValueAsBytes(map));
assertThat(vpack, is(notNullValue()));
assertThat(vpack.isObject(), is(true));
assertThat(vpack.size(), is(1));
final VPackSlice a = vpack.get("a");
assertThat(a.isObject(), is(true));
assertThat(a.size(), is(1));
final VPackSlice b = a.get("b");
assertThat(b.isString(), is(true));
assertThat(b.getAsString(), is("test"));
}
示例8: fieldNamingStrategySerialize
import com.arangodb.velocypack.VPackSlice; //导入方法依赖的package包/类
@Test
public void fieldNamingStrategySerialize() throws IOException {
final ObjectMapper mapper = new VPackMapper();
mapper.setPropertyNamingStrategy(new PropertyNamingStrategy() {
private static final long serialVersionUID = 1L;
@Override
public String nameForGetterMethod(
final MapperConfig<?> config,
final AnnotatedMethod method,
final String defaultName) {
return "bla";
}
});
final VPackSlice vpack = new VPackSlice(mapper.writeValueAsBytes(new TestEntityA()));
assertThat(vpack, is(notNullValue()));
assertThat(vpack.isObject(), is(true));
final VPackSlice bla = vpack.get("bla");
assertThat(bla.isString(), is(true));
assertThat(bla.getAsString(), is("a"));
}
示例9: buildObject
import com.arangodb.velocypack.VPackSlice; //导入方法依赖的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));
}
}
示例10: buildObjectInObject
import com.arangodb.velocypack.VPackSlice; //导入方法依赖的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));
}
示例11: insertDocumentResponseDeserializer
import com.arangodb.velocypack.VPackSlice; //导入方法依赖的package包/类
protected <T> ResponseDeserializer<DocumentCreateEntity<T>> insertDocumentResponseDeserializer(final T value) {
return new ResponseDeserializer<DocumentCreateEntity<T>>() {
@SuppressWarnings("unchecked")
@Override
public DocumentCreateEntity<T> deserialize(final Response response) throws VPackException {
final VPackSlice body = response.getBody();
final DocumentCreateEntity<T> doc = util().deserialize(body, DocumentCreateEntity.class);
final VPackSlice newDoc = body.get(ArangoDBConstants.NEW);
if (newDoc.isObject()) {
doc.setNew((T) util().deserialize(newDoc, value.getClass()));
}
final Map<DocumentField.Type, String> values = new HashMap<DocumentField.Type, String>();
values.put(DocumentField.Type.ID, doc.getId());
values.put(DocumentField.Type.KEY, doc.getKey());
values.put(DocumentField.Type.REV, doc.getRev());
executor.documentCache().setValues(value, values);
return doc;
}
};
}
示例12: replaceDocumentResponseDeserializer
import com.arangodb.velocypack.VPackSlice; //导入方法依赖的package包/类
protected <T> ResponseDeserializer<DocumentUpdateEntity<T>> replaceDocumentResponseDeserializer(final T value) {
return new ResponseDeserializer<DocumentUpdateEntity<T>>() {
@SuppressWarnings("unchecked")
@Override
public DocumentUpdateEntity<T> deserialize(final Response response) throws VPackException {
final VPackSlice body = response.getBody();
final DocumentUpdateEntity<T> doc = util().deserialize(body, DocumentUpdateEntity.class);
final VPackSlice newDoc = body.get(ArangoDBConstants.NEW);
if (newDoc.isObject()) {
doc.setNew((T) util().deserialize(newDoc, value.getClass()));
}
final VPackSlice oldDoc = body.get(ArangoDBConstants.OLD);
if (oldDoc.isObject()) {
doc.setOld((T) util().deserialize(oldDoc, value.getClass()));
}
final Map<DocumentField.Type, String> values = new HashMap<DocumentField.Type, String>();
values.put(DocumentField.Type.REV, doc.getRev());
executor.documentCache().setValues(value, values);
return doc;
}
};
}
示例13: updateDocumentResponseDeserializer
import com.arangodb.velocypack.VPackSlice; //导入方法依赖的package包/类
protected <T> ResponseDeserializer<DocumentUpdateEntity<T>> updateDocumentResponseDeserializer(final T value) {
return new ResponseDeserializer<DocumentUpdateEntity<T>>() {
@SuppressWarnings("unchecked")
@Override
public DocumentUpdateEntity<T> deserialize(final Response response) throws VPackException {
final VPackSlice body = response.getBody();
final DocumentUpdateEntity<T> doc = util().deserialize(body, DocumentUpdateEntity.class);
final VPackSlice newDoc = body.get(ArangoDBConstants.NEW);
if (newDoc.isObject()) {
doc.setNew((T) util().deserialize(newDoc, value.getClass()));
}
final VPackSlice oldDoc = body.get(ArangoDBConstants.OLD);
if (oldDoc.isObject()) {
doc.setOld((T) util().deserialize(oldDoc, value.getClass()));
}
final Map<DocumentField.Type, String> values = new HashMap<DocumentField.Type, String>();
values.put(DocumentField.Type.REV, doc.getRev());
executor.documentCache().setValues(value, values);
return doc;
}
};
}
示例14: deleteDocumentResponseDeserializer
import com.arangodb.velocypack.VPackSlice; //导入方法依赖的package包/类
protected <T> ResponseDeserializer<DocumentDeleteEntity<T>> deleteDocumentResponseDeserializer(
final Class<T> type) {
return new ResponseDeserializer<DocumentDeleteEntity<T>>() {
@SuppressWarnings("unchecked")
@Override
public DocumentDeleteEntity<T> deserialize(final Response response) throws VPackException {
final VPackSlice body = response.getBody();
final DocumentDeleteEntity<T> doc = util().deserialize(body, DocumentDeleteEntity.class);
final VPackSlice oldDoc = body.get(ArangoDBConstants.OLD);
if (oldDoc.isObject()) {
doc.setOld((T) util().deserialize(oldDoc, type));
}
return doc;
}
};
}
示例15: dontSerializeNullValues
import com.arangodb.velocypack.VPackSlice; //导入方法依赖的package包/类
@Test
public void dontSerializeNullValues() throws IOException {
final TestEntityString entity = new TestEntityString();
entity.setS(null);
final ObjectMapper mapper = new VPackMapper();
mapper.setSerializationInclusion(Include.NON_NULL);
final VPackSlice vpack = new VPackSlice(mapper.writeValueAsBytes(entity));
assertThat(vpack, is(notNullValue()));
assertThat(vpack.isObject(), is(true));
final VPackSlice s = vpack.get("s");
assertThat(s.isNone(), is(true));
}