public ArrayIterator(final VPackSlice slice) throws VPackValueTypeException { super(slice); if (!slice.isArray()) { throw new VPackValueTypeException(ValueType.ARRAY); } }
/** * @return array value at the specified index * @throws VPackValueTypeException */ public VPackSlice get(final int index) { if (!isArray()) { throw new VPackValueTypeException(ValueType.ARRAY); } return getNth(index); }
public Iterator<VPackSlice> arrayIterator() { if (isArray()) { return new ArrayIterator(this); } else { throw new VPackValueTypeException(ValueType.ARRAY); } }
private Object readArray(final TypeInformation<?> type, final VPackSlice source) { if (!source.isArray()) { throw new MappingException( String.format("Can't read array type %s from VPack type %s!", type, source.getType())); } final TypeInformation<?> componentType = getNonNullComponentType(type); final int length = source.getLength(); final Object array = Array.newInstance(componentType.getType(), length); for (int i = 0; i < length; ++i) { Array.set(array, i, readInternal(componentType, source.get(i))); } return array; }
private Object readArray(final TypeInformation<?> type, final VPackSlice source) { if (!source.isArray()) { throw new MappingException( String.format("Can't read array type %s from VPack type %s!", type, source.getType())); } final TypeInformation<?> componentType = getNonNullComponentType(type); final int length = source.getLength(); final Object array = Array.newInstance(componentType.getType(), length); for (int i = 0; i < length; ++i) { Array.set(array, i, readInternal(componentType, source.get(i))); } return array; }
private Object readCollection(final TypeInformation<?> type, final VPackSlice source) { if (!source.isArray()) { throw new MappingException( String.format("Can't read collection type %s from VPack type %s!", type, source.getType())); } final TypeInformation<?> componentType = getNonNullComponentType(type); final Class<?> collectionType = Iterable.class.equals(type.getType()) ? Collection.class : type.getType(); final Collection<Object> collection = CollectionFactory.createCollection(collectionType, componentType.getType(), source.getLength()); final Iterator<VPackSlice> iterator = source.arrayIterator(); while (iterator.hasNext()) { final VPackSlice elem = iterator.next(); collection.add(readInternal(componentType, elem)); } return collection; }
private Object readCollection(final TypeInformation<?> type, final VPackSlice source) { if (!source.isArray()) { throw new MappingException( String.format("Can't read collection type %s from VPack type %s!", type, source.getType())); } final TypeInformation<?> componentType = getNonNullComponentType(type); final Class<?> collectionType = Iterable.class.equals(type.getType()) ? Collection.class : type.getType(); final Collection<Object> collection = CollectionFactory.createCollection(collectionType, componentType.getType(), source.getLength()); final Iterator<VPackSlice> iterator = source.arrayIterator(); while (iterator.hasNext()) { final VPackSlice elem = iterator.next(); collection.add(readInternal(componentType, elem)); } return collection; }
public Alias readAliasFrom(final VPackSlice source) { if (source.isArray()) { return Alias.NONE; } if (source.isObject()) { final VPackSlice typeKey = source.get(this.typeKey); return Alias.ofNullable(typeKey.isString() ? typeKey.getAsString() : null); } throw new IllegalArgumentException("Cannot read alias from VPack type " + source.getType()); }
@Override public VPackSlice deserialize(final JsonParser p, final DeserializationContext ctxt) throws IOException, JsonProcessingException { if (p instanceof VPackParser) { final VPackSlice vpack = ((VPackParser) p).getVPack(); // consume each element if (vpack.isArray() || vpack.isObject()) { for (int i = 0; i < vpack.size() + 1; i++) { p.nextToken(); } } return vpack; } return new VPackSlice(p.getBinaryValue()); } };
public Alias readAliasFrom(final VPackSlice source) { if (source.isArray()) { return Alias.NONE; } if (source.isObject()) { final VPackSlice typeKey = source.get(this.typeKey); return Alias.ofNullable(typeKey.isString() ? typeKey.getAsString() : null); } throw new IllegalArgumentException("Cannot read alias from VPack type " + source.getType()); }
@Override public Collection<AqlFunctionEntity> deserialize(final Response response) throws VPackException { final VPackSlice body = response.getBody(); // compatibility with ArangoDB < 3.4 // https://docs.arangodb.com/devel/Manual/ReleaseNotes/UpgradingChanges34.html final VPackSlice result = body.isArray() ? body : body.get(ArangoResponseField.RESULT); return util().deserialize(result, new Type<Collection<AqlFunctionEntity>>() { }.getType()); } };
final Collection<Object> documentsAndErrors = new ArrayList<Object>(); final VPackSlice body = response.getBody(); if (body.isArray()) { for (final Iterator<VPackSlice> iterator = body.arrayIterator(); iterator.hasNext();) { final VPackSlice next = iterator.next();
final Collection<Object> documentsAndErrors = new ArrayList<Object>(); final VPackSlice body = response.getBody(); if (body.isArray()) { for (final Iterator<VPackSlice> iterator = body.arrayIterator(); iterator.hasNext();) { final VPackSlice next = iterator.next();
final Collection<Object> documentsAndErrors = new ArrayList<Object>(); final VPackSlice body = response.getBody(); if (body.isArray()) { for (final Iterator<VPackSlice> iterator = body.arrayIterator(); iterator.hasNext();) { final VPackSlice next = iterator.next();
if (value.isObject()) { parseObject(value, json, includeNullValues); } else if (value.isArray()) { parseArray(value, json, includeNullValues); } else if (value.isBoolean()) {
final FieldLink link = FieldLink.on(field.getKey()); final VPackSlice analyzers = value.get("analyzers"); if (analyzers.isArray()) { final Iterator<VPackSlice> analyzerIterator = analyzers.arrayIterator(); for (; analyzerIterator.hasNext();) {
private Type getType(final VPackSlice vpack) { final Type type; if (vpack.isObject()) { type = Map.class; } else if (vpack.isString()) { type = String.class; } else if (vpack.isBoolean()) { type = Boolean.class; } else if (vpack.isArray()) { type = Collection.class; } else if (vpack.isDate()) { type = Date.class; } else if (vpack.isDouble()) { type = Double.class; } else if (vpack.isNumber()) { type = Number.class; } else if (vpack.isCustom()) { type = String.class; } else { type = null; } return type; }
if (isString()) { length = getStringLength(); } else if (!isArray() && !isObject()) { throw new VPackValueTypeException(ValueType.ARRAY, ValueType.OBJECT, ValueType.STRING); } else {