本文整理汇总了Java中com.arangodb.velocypack.exception.VPackException类的典型用法代码示例。如果您正苦于以下问题:Java VPackException类的具体用法?Java VPackException怎么用?Java VPackException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
VPackException类属于com.arangodb.velocypack.exception包,在下文中一共展示了VPackException类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: compactObject
import com.arangodb.velocypack.exception.VPackException; //导入依赖的package包/类
@Test
public void compactObject() throws VPackException {
// {"a": 12, "b": true, "c": "xyz"}
final VPackBuilder builder = new VPackBuilder();
builder.add(ValueType.OBJECT, true);
builder.add("a", 12);
builder.add("b", true);
builder.add("c", "xyz");
builder.close();
final VPackSlice slice = builder.slice();
assertThat(slice.isObject(), is(true));
assertThat(slice.getLength(), is(3));
assertThat(slice.get("a").getAsLong(), is(12L));
assertThat(slice.get("b").getAsBoolean(), is(true));
assertThat(slice.get("c").getAsString(), is("xyz"));
}
开发者ID:arangodb,项目名称:java-velocypack,代码行数:18,代码来源:VPackBuilderTest.java
示例2: deserializeObject
import com.arangodb.velocypack.exception.VPackException; //导入依赖的package包/类
private <T> T deserializeObject(
final VPackSlice parent,
final VPackSlice vpack,
final Type type,
final String fieldName) throws InstantiationException, IllegalAccessException, NoSuchMethodException,
InvocationTargetException, VPackException {
final T entity;
final VPackDeserializer<?> deserializer = getDeserializer(fieldName, type);
if (deserializer != null) {
if (VPackDeserializerParameterizedType.class.isAssignableFrom(deserializer.getClass())
&& ParameterizedType.class.isAssignableFrom(type.getClass())) {
entity = ((VPackDeserializerParameterizedType<T>) deserializer).deserialize(parent, vpack,
deserializationContext, ParameterizedType.class.cast(type));
} else {
entity = ((VPackDeserializer<T>) deserializer).deserialize(parent, vpack, deserializationContext);
}
} else if (type == Object.class) {
entity = (T) getValue(parent, vpack, getType(vpack), fieldName);
} else {
entity = createInstance(type);
deserializeFields(entity, vpack);
}
return entity;
}
开发者ID:arangodb,项目名称:java-velocypack,代码行数:25,代码来源:VPack.java
示例3: serializeObject
import com.arangodb.velocypack.exception.VPackException; //导入依赖的package包/类
private void serializeObject(
final String name,
final Object entity,
final VPackBuilder builder,
final Map<String, Object> additionalFields)
throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, VPackException {
final VPackSerializer<?> serializer = getSerializer(entity.getClass());
if (serializer != null) {
((VPackSerializer<Object>) serializer).serialize(builder, name, entity, serializationContext);
} else {
builder.add(name, ValueType.OBJECT);
serializeFields(entity, builder, additionalFields);
if (!additionalFields.isEmpty()) {
additionalFields.clear();
builder.close(true);
} else {
builder.close(false);
}
}
}
开发者ID:arangodb,项目名称:java-velocypack,代码行数:22,代码来源:VPack.java
示例4: customDeserializerByNameWrongType
import com.arangodb.velocypack.exception.VPackException; //导入依赖的package包/类
@Test
public void customDeserializerByNameWrongType() throws VPackException {
final VPackBuilder builder = new VPackBuilder();
builder.add(ValueType.OBJECT);
builder.add("s", "test");
builder.close();
final TestEntityString entity = new VPack.Builder()
.registerDeserializer("s", Integer.class, new VPackDeserializer<String>() {
@Override
public String deserialize(
final VPackSlice parent,
final VPackSlice vpack,
final VPackDeserializationContext context) throws VPackException {
return "fail";
}
}).build().deserialize(builder.slice(), TestEntityString.class);
assertThat(entity, is(notNullValue()));
assertThat(entity.s, is(notNullValue()));
assertThat(entity.s, is("test"));
}
开发者ID:arangodb,项目名称:java-velocypack,代码行数:21,代码来源:VPackSerializeDeserializeTest.java
示例5: directFromMapWithinMap
import com.arangodb.velocypack.exception.VPackException; //导入依赖的package包/类
@Test
public void directFromMapWithinMap() throws VPackException {
final Map<String, Object> map = new HashMap<String, Object>();
final Map<String, Object> map2 = new HashMap<String, Object>();
map2.put("b", "test");
map.put("a", map2);
final VPackSlice vpack = new VPack.Builder().build().serialize(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"));
}
开发者ID:arangodb,项目名称:java-velocypack,代码行数:18,代码来源:VPackSerializeDeserializeTest.java
示例6: getSmallInt
import com.arangodb.velocypack.exception.VPackException; //导入依赖的package包/类
@Test
public void getSmallInt() throws VPackException {
checkSmallInt(0, new byte[] { 0x30 });
checkSmallInt(1, new byte[] { 0x31 });
checkSmallInt(2, new byte[] { 0x32 });
checkSmallInt(3, new byte[] { 0x33 });
checkSmallInt(4, new byte[] { 0x34 });
checkSmallInt(5, new byte[] { 0x35 });
checkSmallInt(6, new byte[] { 0x36 });
checkSmallInt(7, new byte[] { 0x37 });
checkSmallInt(8, new byte[] { 0x38 });
checkSmallInt(9, new byte[] { 0x39 });
checkSmallInt(-6, new byte[] { 0x3a });
checkSmallInt(-5, new byte[] { 0x3b });
checkSmallInt(-4, new byte[] { 0x3c });
checkSmallInt(-3, new byte[] { 0x3d });
checkSmallInt(-2, new byte[] { 0x3e });
checkSmallInt(-1, new byte[] { 0x3f });
}
开发者ID:arangodb,项目名称:java-velocypack,代码行数:20,代码来源:VPackSliceTest.java
示例7: deserialize
import com.arangodb.velocypack.exception.VPackException; //导入依赖的package包/类
@Override
public Date deserialize(
final VPackSlice parent,
final VPackSlice vpack,
final VPackDeserializationContext context) throws VPackException {
final Date date;
if (vpack.isString()) {
try {
date = DateUtil.parse(vpack.getAsString());
} catch (final ParseException e) {
throw new VPackParserException(e);
}
} else {
date = vpack.getAsDate();
}
return date;
}
开发者ID:arangodb,项目名称:java-velocypack,代码行数:18,代码来源:VPackDeserializers.java
示例8: emptyArray
import com.arangodb.velocypack.exception.VPackException; //导入依赖的package包/类
@Test
public void emptyArray() throws VPackException {
final VPackBuilder builder = new VPackBuilder();
builder.add(ValueType.ARRAY);
builder.close();
final VPackSlice slice = builder.slice();
assertThat(slice.isArray(), is(true));
assertThat(slice.getLength(), is(0));
try {
slice.get(0);
fail();
} catch (final IndexOutOfBoundsException e) {
}
}
开发者ID:arangodb,项目名称:java-velocypack,代码行数:17,代码来源:VPackBuilderTest.java
示例9: fromBoolean
import com.arangodb.velocypack.exception.VPackException; //导入依赖的package包/类
@Test
public void fromBoolean() throws VPackException {
final VPackSlice vpack = new VPack.Builder().build().serialize(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));
}
}
开发者ID:arangodb,项目名称:java-velocypack,代码行数:27,代码来源:VPackSerializeDeserializeTest.java
示例10: indexedArray4ByteLength
import com.arangodb.velocypack.exception.VPackException; //导入依赖的package包/类
@Test
public void indexedArray4ByteLength() throws VPackException {
final int valueCount = 200;
final VPackBuilder builder = new VPackBuilder();
builder.add(ValueType.ARRAY);
for (long i = 0; i < valueCount; i++) {
builder.add(
"Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium. Integer tincidunt. Cras dapibus. Vivamus elementum semper nisi. Aenean vulputate eleifend tellus.");
}
builder.close();
final VPackSlice slice = builder.slice();
assertThat(slice.head(), is((byte) 0x04));
assertThat(slice.isArray(), is(true));
assertThat(slice.getLength(), is(valueCount));
}
开发者ID:arangodb,项目名称:java-velocypack,代码行数:17,代码来源:VPackBuilderTest.java
示例11: toMapWithAttributeAdapter
import com.arangodb.velocypack.exception.VPackException; //导入依赖的package包/类
@Test
public void toMapWithAttributeAdapter() throws VPackException {
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 = new VPack.Builder().build().deserialize(builder.slice(), TestEntityMap.class);
assertThat(entity, is(notNullValue()));
assertThat(entity.m1, is(notNullValue()));
assertThat(entity.m1.size(), is(5));
}
开发者ID:arangodb,项目名称:java-velocypack,代码行数:20,代码来源:VPackSerializeDeserializeTest.java
示例12: fromInheritance
import com.arangodb.velocypack.exception.VPackException; //导入依赖的package包/类
@Test
public void fromInheritance() throws VPackException {
final VPackSlice vpack = new VPack.Builder().build().serialize(new TestEntityB());
assertThat(vpack, is(notNullValue()));
assertThat(vpack.isObject(), is(true));
assertThat(vpack.getLength(), is(2));
{
final VPackSlice a = vpack.get("a");
assertThat(a.isString(), is(true));
assertThat(a.getAsString(), is("a"));
}
{
final VPackSlice b = vpack.get("b");
assertThat(b.isString(), is(true));
assertThat(b.getAsString(), is("b"));
}
}
开发者ID:arangodb,项目名称:java-velocypack,代码行数:18,代码来源:VPackSerializeDeserializeTest.java
示例13: fromDouble
import com.arangodb.velocypack.exception.VPackException; //导入依赖的package包/类
@Test
public void fromDouble() throws VPackException {
final VPackSlice vpack = new VPack.Builder().build().serialize(new TestEntityDouble());
assertThat(vpack, is(notNullValue()));
assertThat(vpack.isObject(), is(true));
{
final VPackSlice d1 = vpack.get("d1");
assertThat(d1.isDouble(), is(true));
assertThat(d1.getAsDouble(), is(1.5));
}
{
final VPackSlice d2 = vpack.get("d2");
assertThat(d2.isDouble(), is(true));
assertThat(d2.getAsDouble(), is(1.5));
}
}
开发者ID:arangodb,项目名称:java-velocypack,代码行数:17,代码来源:VPackSerializeDeserializeTest.java
示例14: fromJsonObjectInArray
import com.arangodb.velocypack.exception.VPackException; //导入依赖的package包/类
@Test
public void fromJsonObjectInArray() throws VPackException {
final VPackSlice vpack = new VPackParser.Builder().build().fromJson("[{\"a\":\"test\"},{\"a\":\"test\"}]");
assertThat(vpack.isArray(), is(true));
assertThat(vpack.size(), is(2));
final VPackSlice z = vpack.get(0);
assertThat(z.isObject(), is(true));
assertThat(z.size(), is(1));
final VPackSlice za = z.get("a");
assertThat(za.isString(), is(true));
assertThat(za.getAsString(), is("test"));
final VPackSlice o = vpack.get(1);
assertThat(o.isObject(), is(true));
assertThat(o.size(), is(1));
final VPackSlice oa = o.get("a");
assertThat(oa.isString(), is(true));
assertThat(oa.getAsString(), is("test"));
}
开发者ID:arangodb,项目名称:java-velocypack,代码行数:19,代码来源:VPackParserTest.java
示例15: parse
import com.arangodb.velocypack.exception.VPackException; //导入依赖的package包/类
private void parse(
final VPackSlice parent,
final String attribute,
final VPackSlice value,
final StringBuilder json,
final boolean includeNullValues) throws VPackException {
VPackJsonDeserializer deserializer = null;
if (attribute != null) {
appendField(attribute, json);
deserializer = getDeserializer(attribute, value.getType());
}
if (deserializer != null) {
deserializer.deserialize(parent, attribute, value, json);
} else {
if (value.isObject()) {
parseObject(value, json, includeNullValues);
} else if (value.isArray()) {
parseArray(value, json, includeNullValues);
} else if (value.isBoolean()) {
json.append(value.getAsBoolean());
} else if (value.isString()) {
json.append(JSONValue.toJSONString(value.getAsString()));
} else if (value.isDouble()) {
json.append(value.getAsDouble());
} else if (value.isInt()) {
json.append(value.getAsLong());
} else if (value.isNumber()) {
json.append(value.getAsNumber());
} else if (value.isDate()) {
json.append(JSONValue.toJSONString(DateUtil.format(value.getAsDate())));
} else if (value.isNull()) {
json.append(NULL);
} else {
json.append(JSONValue.toJSONString(NON_REPRESENTABLE_TYPE));
}
}
}
开发者ID:arangodb,项目名称:java-velocypack,代码行数:39,代码来源:VPackParser.java
示例16: addLongAsInt
import com.arangodb.velocypack.exception.VPackException; //导入依赖的package包/类
@Test
public void addLongAsInt() throws VPackException {
final VPackBuilder builder = new VPackBuilder();
final long value = Long.MAX_VALUE;
builder.add(value, ValueType.INT);
final VPackSlice slice = builder.slice();
assertThat(slice.isInt(), is(true));
assertThat(slice.getAsLong(), is(value));
}
开发者ID:arangodb,项目名称:java-velocypack,代码行数:11,代码来源:VPackBuilderTest.java
示例17: parseArray
import com.arangodb.velocypack.exception.VPackException; //导入依赖的package包/类
private void parseArray(final VPackSlice value, final StringBuilder json, final boolean includeNullValues)
throws VPackException {
json.append(ARRAY_OPEN);
int added = 0;
for (int i = 0; i < value.getLength(); i++) {
final VPackSlice valueAt = value.get(i);
if (!valueAt.isNull() || includeNullValues) {
if (added++ > 0) {
json.append(SEPARATOR);
}
parse(value, null, valueAt, json, includeNullValues);
}
}
json.append(ARRAY_CLOSE);
}
开发者ID:arangodb,项目名称:java-velocypack,代码行数:16,代码来源:VPackParser.java
示例18: fromEmptyMap
import com.arangodb.velocypack.exception.VPackException; //导入依赖的package包/类
@Test
public void fromEmptyMap() throws VPackException {
final TestEntityEmptyMap entity = new TestEntityEmptyMap();
entity.setM(new HashMap<String, Object>());
final VPackSlice vpack = new VPack.Builder().build().serialize(entity);
assertThat(vpack, is(notNullValue()));
assertThat(vpack.isObject(), is(true));
assertThat(vpack.getLength(), is(1));
final VPackSlice m = vpack.get("m");
assertThat(m.isObject(), is(true));
assertThat(m.getLength(), is(0));
}
开发者ID:arangodb,项目名称:java-velocypack,代码行数:13,代码来源:VPackSerializeDeserializeTest.java
示例19: objectLength
import com.arangodb.velocypack.exception.VPackException; //导入依赖的package包/类
@Test
public void objectLength() throws VPackException {
// {"a": 12, "b": true, "c": "xyz"}
final int expected = 3;
checkLength(expected, new byte[] { 0x0b, 0x13, 0x03, 0x41, 0x62, 0x1a, 0x41, 0x61, 0x28, 0x0c, 0x41, 0x63, 0x43,
0x78, 0x79, 0x7a, 0x06, 0x03, 0x0a });
checkLength(expected,
new byte[] { 0x0d, 0x22, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x41, 0x62, 0x03, 0x41, 0x61, 0x28, 0x0c,
0x41, 0x63, 0x43, 0x78, 0x79, 0x7a, 0x0c, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x10, 0x00,
0x00, 0x00 });
checkLength(expected, new byte[] { 0x0f, 0x13, 0x03, 0x41, 0x62, 0x03, 0x41, 0x61, 0x28, 0x0c, 0x41, 0x63, 0x43,
0x78, 0x79, 0x7a, 0x03, 0x06, 0x0a });
}
开发者ID:arangodb,项目名称:java-velocypack,代码行数:14,代码来源:VPackSliceTest.java
示例20: toString
import com.arangodb.velocypack.exception.VPackException; //导入依赖的package包/类
@Override
public String toString() {
try {
return new VPackParser.Builder().build().toJson(this, true);
} catch (final VPackException e) {
return super.toString();
}
}
开发者ID:arangodb,项目名称:java-velocypack,代码行数:9,代码来源:VPackSlice.java
注:本文中的com.arangodb.velocypack.exception.VPackException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论