Ejemplo n.º 1
0
            /// <exception cref="VPackException"/>
            public Response deserialize(VPackSlice
                                        parent, VPackSlice vpack, VPackDeserializationContext
                                        context)
            {
                Response response = new Response
                                        ();

                response.setVersion(vpack.get(0).getAsInt());
                response.setType(vpack.get(1).getAsInt());
                response.setResponseCode(vpack.get(2).getAsInt());
                return(response);
            }
Ejemplo n.º 2
0
            /// <exception cref="VPackException"/>
            public string deserialize(VPackSlice parent, VPackSlice
                                      vpack, VPackDeserializationContext context)
            {
                string id;

                if (vpack.isCustom())
                {
                    long idLong = NumberUtil.toLong(vpack.getBuffer
                                                        (), vpack.getStart() + 1, vpack.getByteSize() - 1);
                    string collectionName = this.cache.getCollectionName(idLong);
                    if (collectionName != null)
                    {
                        VPackSlice key = parent.get("_key");
                        id = string.format("%s/%s", collectionName, key.getAsString());
                    }
                    else
                    {
                        id = null;
                    }
                }
                else
                {
                    id = vpack.getAsString();
                }
                return(id);
            }
Ejemplo n.º 3
0
            /// <exception cref="VPackException"/>
            public T Deserialize(Response response)
            {
                VPackSlice body = response.getBody();

                if (body != null)
                {
                    VPackSlice result = body.get(ArangoDBConstants
                                                 .RESULT);
                    if (!result.isNone())
                    {
                        return(this._enclosing.executor.Deserialize(result, this.type));
                    }
                }
                return(null);
            }
Ejemplo n.º 4
0
            /// <exception cref="VPackException"/>
            public void deserialize(VPackSlice parent, string attribute
                                    , VPackSlice vpack, java.lang.StringBuilder json)
            {
                string id;
                long   idLong = NumberUtil.toLong(vpack.getBuffer
                                                      (), vpack.getStart() + 1, vpack.getByteSize() - 1);
                string collectionName = this.cache.getCollectionName(idLong);

                if (collectionName != null)
                {
                    VPackSlice key = parent.get("_key");
                    id = string.format("%s/%s", collectionName, key.getAsString());
                }
                else
                {
                    id = null;
                }
                json.Append(org.json.simple.JSONValue.toJSONString(id));
            }
            /// <exception cref="VPackException"/>
            public DocumentCreateEntity <T> Deserialize(Response
                                                        response)
            {
                VPackSlice body = response.getBody();
                DocumentCreateEntity <T> doc = this._enclosing.executor.Deserialize
                                                   (body, typeof(com.arangodb.entity.DocumentCreateEntity
                                                                 ));
                VPackSlice newDoc = body.get(ArangoDBConstants
                                             .NEW);

                if (newDoc.isObject())
                {
                    doc.setNew((T)this._enclosing.executor.Deserialize(newDoc, Sharpen.Runtime.getClassForObject
                                                                           (this.value)));
                }
                System.Collections.Generic.IDictionary <com.arangodb.entity.DocumentFieldAttribute.Type, string
                                                        > values = new System.Collections.Generic.Dictionary <com.arangodb.entity.DocumentFieldAttribute.Type
                                                                                                              , string>();
                values[com.arangodb.entity.DocumentFieldAttribute.Type.ID]  = doc.getId();
                values[com.arangodb.entity.DocumentFieldAttribute.Type.KEY] = doc.getKey();
                values[com.arangodb.entity.DocumentFieldAttribute.Type.REV] = doc.getRev();
                this._enclosing.executor.documentCache().setValues(this.value, values);
                return(doc);
            }