@Override public final Incidence getNextIncidenceAtVertex(Graph traversalContext, Direction direction) { Incidence i; try { i = localGraphDatabase.getIncidenceObject( storingGraphDatabase.getNextIncidenceIdAtVertexId(id)); } catch (RemoteException e) { throw new RuntimeException(e); } if (traversalContext == null) { while (((i != null) && (direction != null) && (direction != Direction.BOTH) && (direction != i.getDirection()))) { i = i.getNextIncidenceAtVertex(); } } else { if ((direction != null) && (direction != Direction.BOTH)) { while ((i != null) && ((!traversalContext.containsEdge(i.getEdge())) || (direction != i.getDirection()))) { i = i.getNextIncidenceAtVertex(); } } else { while ((i != null) && (!traversalContext.containsEdge(i.getEdge()))) { i = i.getNextIncidenceAtVertex(); } } } return i; }
@Override public Vertex getThat(Graph traversalContext) { Edge incidentEdge; try { incidentEdge = localGraphDatabase.getEdgeObject(storingGraphDatabase.getEdgeIdAtIncidenceId(id)); } catch (RemoteException e) { throw new RuntimeException(e); } if (!incidentEdge.isBinary()) { throw new UnsupportedOperationException("This method is only supported by binary Edges."); } Vertex vertex = null; if (getDirection() == Direction.VERTEX_TO_EDGE) { vertex = ((BinaryEdge) incidentEdge).getOmega(); } else { vertex = ((BinaryEdge) incidentEdge).getAlpha(); } if (getGraph().getTraversalContext() == null || getGraph().getTraversalContext().containsVertex(vertex)) { return vertex; } else { return null; } }
@Override public Edge getEdge() { try { return localGraphDatabase.getEdgeObject(storingGraphDatabase.getEdgeIdAtIncidenceId(id)); } catch (RemoteException e) { throw new RuntimeException(e); } }
@Override public void putBeforeAtEdge(Incidence i) { try { storingGraphDatabase.putIncidenceIdBeforeAtEdgeId(id, i.getGlobalId()); } catch (RemoteException e) { throw new RuntimeException(e); } }
@Override public void putAfterAtVertex(Incidence i) { try { storingGraphDatabase.putIncidenceIdAfterAtVertexId(id, i.getGlobalId()); } catch (RemoteException e) { throw new RuntimeException(e); } }
@Override public Incidence getPreviousIncidenceAtVertex(Graph traversalContext) { Incidence currentIncidence; try { currentIncidence = localGraphDatabase.getIncidenceObject( storingGraphDatabase.getPreviousIncidenceIdAtVertexId( storingGraphDatabase.getVertexIdAtIncidenceId(id))); } catch (RemoteException e) { throw new RuntimeException(e); } while ((traversalContext != null) && (currentIncidence != null) && (!traversalContext.containsEdge(currentIncidence.getEdge()))) { currentIncidence = currentIncidence.getPreviousIncidenceAtVertex(); } return currentIncidence; }
@Override public Iterable<Vertex> getThoseVertices(Graph traversalContext) { Edge edge; try { edge = localGraphDatabase.getEdgeObject(storingGraphDatabase.getEdgeIdAtIncidenceId(id)); } catch (RemoteException e) { throw new RuntimeException(e); } assert getGraph().getTraversalContext() == null || getGraph().getTraversalContext().containsEdge(edge); return edge.getIncidentVertices(traversalContext, getDirection().getOppositeDirection()); }
@Override public Vertex getThis(Graph traversalContext) { try { if (!localGraphDatabase .getEdgeObject(storingGraphDatabase.getEdgeIdAtIncidenceId(id)) .isBinary()) { throw new UnsupportedOperationException("This method is only supported by binary Edges."); } else { Vertex vertex = localGraphDatabase.getVertexObject(storingGraphDatabase.getVertexIdAtIncidenceId(id)); if (getGraph().getTraversalContext() == null || getGraph().getTraversalContext().containsVertex(vertex)) { return vertex; } else { return null; } } } catch (RemoteException e) { throw new RuntimeException(e); } }
@Override public Incidence getNextIncidenceAtEdge() { if (getGraph().getTraversalContext() == null) { try { return localGraphDatabase.getIncidenceObject( storingGraphDatabase.getNextIncidenceIdAtEdgeId(id)); } catch (RemoteException e) { throw new RuntimeException(e); } } else { return getNextIncidenceAtEdge(getGraph().getTraversalContext()); } }
@Override public Iterable<Edge> getThoseEdges(Graph traversalContext) { Vertex vertex; try { vertex = localGraphDatabase.getVertexObject(storingGraphDatabase.getVertexIdAtIncidenceId(id)); } catch (RemoteException e) { throw new RuntimeException(e); } assert getGraph().getTraversalContext() == null || getGraph().getTraversalContext().containsVertex(vertex); return vertex.getIncidentEdges(traversalContext, getDirection().getOppositeDirection()); }
@Override public final Incidence getNextIncidenceAtVertex(Direction direction) { if (getGraph().getTraversalContext() == null) { Incidence i; try { i = localGraphDatabase.getIncidenceObject( storingGraphDatabase.getNextIncidenceIdAtVertexId(id)); } catch (RemoteException e) { throw new RuntimeException(e); } if ((direction != null) && (direction != Direction.BOTH)) { while ((i != null) && (direction != i.getDirection())) { i = i.getNextIncidenceAtVertex(); } } return i; } else { return getNextIncidenceAtVertex(getGraph().getTraversalContext(), direction); } }