com.arangodb.velocypack.VPack Java Examples
The following examples show how to use
com.arangodb.velocypack.VPack.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BaseDocumentTest.java From arangodb-java-driver with Apache License 2.0 | 6 votes |
@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")); }
Example #2
Source File: ArangoDBAsync.java From arangodb-java-driver-async with Apache License 2.0 | 5 votes |
/** * Returns an instance of {@link ArangoDBAsync}. * * @return {@link ArangoDBAsync} */ public synchronized ArangoDBAsync build() { if (hosts.isEmpty()) { hosts.add(host); } final VPack vpacker = vpackBuilder.serializeNullValues(false).build(); final VPack vpackerNull = vpackBuilder.serializeNullValues(true).build(); final VPackParser vpackParser = vpackParserBuilder.build(); final ArangoSerializer serializerTemp = serializer != null ? serializer : new ArangoSerializerImpl(vpacker, vpackerNull, vpackParser); final ArangoDeserializer deserializerTemp = deserializer != null ? deserializer : new ArangoDeserializerImpl(vpackerNull, vpackParser); final DefaultArangoSerialization internal = new DefaultArangoSerialization(serializerTemp, deserializerTemp); final ArangoSerialization custom = customSerializer != null ? customSerializer : internal; final ArangoSerializationFactory util = new ArangoSerializationFactory(internal, custom); final int max = maxConnections != null ? Math.max(1, maxConnections) : ArangoDefaults.MAX_CONNECTIONS_VST_DEFAULT; final ConnectionFactory connectionFactory = new VstConnectionFactoryAsync(host, timeout, connectionTtl, useSsl, sslContext); final HostResolver hostResolver = createHostResolver(createHostList(max, connectionFactory), max, connectionFactory); final HostHandler hostHandler = createHostHandler(hostResolver); return new ArangoDBAsyncImpl(asyncBuilder(hostHandler), util, syncBuilder(hostHandler), hostResolver, new ArangoContext()); }
Example #3
Source File: InternalArangoDBBuilder.java From arangodb-java-driver with Apache License 2.0 | 5 votes |
public InternalArangoDBBuilder() { super(); vpackBuilder = new VPack.Builder(); vpackParserBuilder = new VPackParser.Builder(); vpackBuilder.registerModule(new VPackDriverModule()); vpackParserBuilder.registerModule(new VPackDriverModule()); host = new HostDescription(ArangoDefaults.DEFAULT_HOST, ArangoDefaults.DEFAULT_PORT); hosts = new ArrayList<>(); user = ArangoDefaults.DEFAULT_USER; loadProperties(ArangoDB.class.getResourceAsStream(DEFAULT_PROPERTY_FILE)); }
Example #4
Source File: BaseDocumentTest.java From arangodb-java-driver with Apache License 2.0 | 5 votes |
@Test public void serialize() throws VPackException { final BaseDocument entity = new BaseDocument(); entity.setKey("test"); entity.setRevision("test"); entity.addAttribute("a", "a"); final Builder builder = new VPack.Builder(); builder.registerModule(new VPackDriverModule()); final VPack vpacker = builder.build(); final VPackSlice vpack = vpacker.serialize(entity); assertThat(vpack, is(notNullValue())); assertThat(vpack.isObject(), is(true)); assertThat(vpack.size(), is(3)); final VPackSlice key = vpack.get("_key"); assertThat(key.isString(), is(true)); assertThat(key.getAsString(), is("test")); final VPackSlice rev = vpack.get("_rev"); assertThat(rev.isString(), is(true)); assertThat(rev.getAsString(), is("test")); final VPackSlice a = vpack.get("a"); assertThat(a.isString(), is(true)); assertThat(a.getAsString(), is("a")); }
Example #5
Source File: ArangoDeserializerImpl.java From arangodb-java-driver with Apache License 2.0 | 4 votes |
public ArangoDeserializerImpl(final VPack vpacker, final VPackParser vpackParser) { super(); this.vpacker = vpacker; this.vpackParser = vpackParser; }
Example #6
Source File: ArangoSerializerImpl.java From arangodb-java-driver with Apache License 2.0 | 4 votes |
public ArangoSerializerImpl(final VPack vpacker, final VPack vpackerNull, final VPackParser vpackParser) { super(); this.vpacker = vpacker; this.vpackerNull = vpackerNull; this.vpackParser = vpackParser; }