Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package com.tinkerpop.blueprints.impls.neo4j2;
 
 
 

Author(s):
Marko A. Rodriguez (http://markorodriguez.com)
public class Neo4j2EdgeIterable<T extends Edgeimplements CloseableIterable<Neo4j2Edge> {
    private final Iterable<Relationshiprelationships;
    private final Neo4j2Graph graph;
    private final boolean checkTransaction;
    public Neo4j2EdgeIterable(final Iterable<Relationshiprelationshipsfinal Neo4j2Graph graphfinal boolean checkTransaction) {
        this. = relationships;
        this. = graph;
        this. = checkTransaction;
    }
    public Neo4j2EdgeIterable(final Iterable<Relationshiprelationshipsfinal Neo4j2Graph graph) {
        this(relationshipsgraphfalse);
    }
    public Iterator<Neo4j2Edgeiterator() {
        return new Iterator<Neo4j2Edge>() {
            private final Iterator<Relationshipitty = .iterator();
            private Relationship nextRelationship = null;
            public void remove() {
                .autoStartTransaction(true);
                this..remove();
            }
            public Neo4j2Edge next() {
                .autoStartTransaction(false);
                if (!) {
                    return new Neo4j2Edge(this..next(), );
                } else {
                    if (null != this.) {
                        final Relationship temp = this.;
                        this. = null;
                        return new Neo4j2Edge(temp);
                    } else {
                        while (true) {
                            final Relationship relationship = this..next();
                            try {
                                if (!.relationshipIsDeleted(relationship.getId())) {
                                    return new Neo4j2Edge(relationship);
                                }
                            } catch (final IllegalStateException e) {
                                // tried to access a relationship not available to the transaction
                            }
                        }
                    }
                }
            }
            public boolean hasNext() {
                .autoStartTransaction(false);
                if (!)
                    return this..hasNext();
                else {
                    if (null != this.)
                        return true;
                    else {
                        while (this..hasNext()) {
                            final Relationship relationship = this..next();
                            try {
                                if (!.relationshipIsDeleted(relationship.getId())) {
                                    this. = relationship;
                                    return true;
                                }
                            } catch (final IllegalStateException e) {
                            }
                        }
                        return false;
                    }
                }
            }
        };
    }
    public void close() {
        if (this. instanceof IndexHits) {
            ((IndexHitsthis.).close();
        }
    }
New to GrepCode? Check out our FAQ X