|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
public interface Relationship
Represents a relationship between two nodes in the network. A relationship has a start node, an end node and a type. You can attach properties to relationships with the exact same API as with nodes.
Relationships are created by invoking the Node.createRelationshipTo() method on a node as follows:
Relationship rel = node.createRelationshipTo( otherNode, MyRels.REL_TYPE );
The fact that the relationship API gives meaning to start and end nodes implicitly means that all
relationships have a direction. In the example above, rel would
be directed from node to otherNode.
A relationship's start node and end node and their relation to
Direction.OUTGOING and Direction.INCOMING are defined so that
the assertions in the following code are true:
Furthermore, Neo guarantees that a relationship is never "hanging freely,"
i.e.
Node a = neo.createNode(), b = neo.createNode();
Relationship rel = a.createRelationshipTo( b, MyRels.REL_TYPE );
// Now we have: (a) --- REL_TYPE ---> (b)
assert rel.getStartNode().equals( a );
assert rel.getEndNode().equals( b );
assert rel.getNodes()[0].equals( a ) && rel.getNodes()[1].equals( b );
rel = b.getSingleRelationship( MyRels.REL_TYPE, Direction.INCOMING ) ;
assert rel.getStartNode().equals( b );
assert rel.getEndNode().equals( a );
assert rel.getNodes()[0].equals( b ) && rel.getNodes()[1].equals( a );
getStartNode(), getEndNode(), getOtherNode(Node)
and getNodes() are guaranteed to always return valid, non-null
nodes.
| Method Summary | |
|---|---|
void |
delete()
Deletes this relationship. |
Node |
getEndNode()
Returns the end node of this relationship. |
long |
getId()
|
Node[] |
getNodes()
Returns the two nodes that are attached to this relationship. |
Node |
getOtherNode(Node node)
A convenience operation that, given a node that is attached to this relationship, returns the other node. |
Object |
getProperty(String key)
See Node.getProperty(String) |
Object |
getProperty(String key,
Object defaultValue)
See Node.getProperty(String, Object) |
Iterable<String> |
getPropertyKeys()
See Node.getPropertyKeys() |
Iterable<Object> |
getPropertyValues()
See Node.getPropertyValues() |
Node |
getStartNode()
Returns the start node of this relationship. |
RelationshipType |
getType()
Returns the type of this relationship. |
boolean |
hasProperty(String key)
See Node.hasProperty(String) |
Object |
removeProperty(String key)
See Node.removeProperty(String) |
void |
setProperty(String key,
Object value)
See Node.setProperty(String, Object) |
| Method Detail |
|---|
long getId()
void delete()
delete() has returned is invalid and will lead to
unspecified behavior.
Node getStartNode()
directions as arguments to the
relationship accessors in Node, see the
class documentation of Relationship.
Node getEndNode()
directions as arguments to the
relationship accessors in Node, see the
class documentation of Relationship.
Node getOtherNode(Node node)
node
is a start node, the end node will be returned, and vice versa. This
is a very convenient operation when you're manually traversing the
node space by invoking one of the getRelationships() operations on node. For example, to get the node
"at the other end" of a relationship, use the following:
Node endNode = node.getSingleRelationship( MyRels.REL_TYPE ).getOtherNode ( node );
This operation will throw a runtime exception if node is
neither this relationship's start node nor its end node.
node - the start or end node of this relationship
RuntimeException - if the given node is neither the start nor
end node of this relationshipNode[] getNodes()
RelationshipType getType()
creation. It will always be one of
the elements of the RelationshipType enumeration
passed in to EmbeddedNeo at startup.
boolean hasProperty(String key)
Node.hasProperty(String)
Object getProperty(String key)
Node.getProperty(String)
Object getProperty(String key,
Object defaultValue)
Node.getProperty(String, Object)
void setProperty(String key,
Object value)
Node.setProperty(String, Object)
Object removeProperty(String key)
Node.removeProperty(String)
Iterable<String> getPropertyKeys()
Node.getPropertyKeys()
Iterable<Object> getPropertyValues()
Node.getPropertyValues()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||