com.tinkerpop.rexster.gremlin.converter.SerializedResultConverter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of rexster-protocol Show documentation
Show all versions of rexster-protocol Show documentation
RexPro is a binary protocol for Rexster graph server.
package com.tinkerpop.rexster.gremlin.converter;
import com.tinkerpop.blueprints.Direction;
import com.tinkerpop.blueprints.Edge;
import com.tinkerpop.blueprints.Element;
import com.tinkerpop.pipes.util.structures.Row;
import com.tinkerpop.pipes.util.structures.Table;
import com.tinkerpop.rexster.Tokens;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* Converts graph results into a serializable format
*
* @author Blake Eggleston (bdeggleston.github.com)
*/
public class SerializedResultConverter {
static Object serializeElementId(final Element element) {
final Object id = element.getId();
if (id.getClass().isPrimitive()) {
return id;
} else {
return id.toString();
}
}
public static Object convert(Object object) {
if (object == null) {
return null;
} else if (object instanceof String || object instanceof Number || object instanceof Boolean) {
return object;
} else if (object instanceof Element) {
try {
final Element element = (Element) object;
final Set propertyKeys = element.getPropertyKeys();
final boolean isVertex = !(element instanceof Edge);
HashMap
© 2015 - 2025 Weber Informatics LLC | Privacy Policy