private String mapToJson(Map<String, ByteIterator> values) { VPackBuilder builder = new VPackBuilder().add(ValueType.OBJECT); for (Map.Entry<String, ByteIterator> entry : values.entrySet()) { builder.add(entry.getKey(), byteIteratorToString(entry.getValue())); } builder.close(); return arangoDB.util().deserialize(builder.slice(), String.class); }
for (Iterator<Entry<String, VPackSlice>> iterator = document.objectIterator(); iterator.hasNext();) { Entry<String, VPackSlice> next = iterator.next(); VPackSlice value = next.getValue(); if (value.isString()) { resultMap.put(next.getKey(), stringToByteIterator(value.getAsString())); } else if (!value.isCustom()) { logger.error("Error! Not the format expected! Actually is {}", value.getClass().getName()); VPackSlice value = document.get(field); if (value.isString()) { resultMap.put(field, stringToByteIterator(value.getAsString())); } else if (!value.isCustom()) { logger.error("Error! Not the format expected! Actually is {}", value.getClass().getName());
while (cursor.hasNext()) { VPackSlice aDocument = cursor.next(); HashMap<String, ByteIterator> aMap = new HashMap<String, ByteIterator>(aDocument.size()); if (!this.fillMap(aMap, aDocument)) { return Status.ERROR;
@Override public void serialize( final VPackBuilder builder, final String attribute, final Boolean value, final VPackSerializationContext context) throws VPackException { builder.add(attribute, value); } };
/** * translates an integer key into a string, without checks */ protected VPackSlice translateUnchecked() { final VPackSlice result = attributeTranslator.translate(getAsInt()); return result != null ? result : new VPackSlice(); }
@Override public Float deserialize( final VPackSlice parent, final VPackSlice vpack, final VPackDeserializationContext context) throws VPackException { return vpack.getAsFloat(); } };
@Override public <T> T deserialize(final VPackSlice vpack, final Type type) throws VPackParserException { return VPack.this.deserialize(vpack, type); } };
@Override public Builder registerModules(final VPackModule... modules) { for (final VPackModule module : modules) { registerModule(module); } return this; }
@Override public Byte deserialize( final VPackSlice parent, final VPackSlice vpack, final VPackDeserializationContext context) { return vpack.getAsByte(); } };
private long getSmallInt() { final byte head = head(); final long smallInt; if (head >= 0x30 && head <= 0x39) { smallInt = head - 0x30; } else /* if (head >= 0x3a && head <= 0x3f) */ { smallInt = head - 0x3a - 6; } return smallInt; }
@Override public Character deserialize( final VPackSlice parent, final VPackSlice vpack, final VPackDeserializationContext context) throws VPackException { return vpack.getAsChar(); } };
@Override public Builder registerModule(final VPackModule module) { module.setup(VPack.Builder.this); return this; }
@Override public void append(final VPackBuilder builder, final Integer value) throws VPackBuilderException { if (value <= 9 && value >= -6) { builder.appendSmallInt(value); } else { builder.add((byte) 0x23); builder.append(value, INTEGER_BYTES); } } };
@Override public void append(final VPackBuilder builder, final Byte value) { if (value <= 9 && value >= -6) { builder.appendSmallInt(value); } else { builder.add((byte) 0x23); builder.append(value, INTEGER_BYTES); } } };
@Override public void serialize( final VPackBuilder builder, final String attribute, final Double value, final VPackSerializationContext context) throws VPackException { builder.add(attribute, value); } };
@Override public void serialize( final VPackBuilder builder, final String attribute, final Character value, final VPackSerializationContext context) throws VPackException { builder.add(attribute, value); } };
@Override public void serialize( final VPackBuilder builder, final String attribute, final VPackSlice value, final VPackSerializationContext context) throws VPackException { builder.add(attribute, value); } };
@Override public void serialize( final VPackBuilder builder, final String attribute, final Integer value, final VPackSerializationContext context) throws VPackException { builder.add(attribute, value); } };
@Override public void serialize( final VPackBuilder builder, final String attribute, final Short value, final VPackSerializationContext context) throws VPackException { builder.add(attribute, value); } };
@Override public void serialize( final VPackBuilder builder, final String attribute, final BigDecimal value, final VPackSerializationContext context) throws VPackException { builder.add(attribute, value); } };