Dieser Inhalt ist in der von Ihnen ausgewählten Sprache nicht verfügbar.
16.44. Working with Nodes
Now let's switch to working with nodes. This first example returns a map of properties (keyed by property name) for a node at a specific Path:
Path path = ... Map<Name,Property> propertiesByName = graph.getPropertiesByName().on(path);
Path path = ...
Map<Name,Property> propertiesByName = graph.getPropertiesByName().on(path);
This next example shows how the graph can be used to obtain and loop over the properties of a node:
Path path = ...
for ( Property property : graph.getProperties().on(path) ) {
...
}
Path path = ...
for ( Property property : graph.getProperties().on(path) ) {
...
}
Likewise, the next example shows how the graph can be used to obtain and loop over the children of a node:
Notice that the examples pass a Path instance to the
on(...) and of(...) methods. Many of the Graph API methods take a variety of parameter types, including String, Paths, Locations, UUID, or Property parameters. This should make it easy to use in many different situations.
Of course, changing content is more interesting and offers more interesting possibilities. Here are a few examples:
The methods shown above work immediately, as soon as each request is built. However, there is another way to use the Graph object, and that is in a batch mode. Simply create a Graph.Batch object using the
batch() method, create the requests on that batch object, and then execute all of the commands on the batch by calling its execute() method. That execute() method returns a Results interface that can be used to read the node information retrieved by the batched requests.
Method chaining works really well with the batch mode, since multiple commands can be assembled together very easily:
Of course, this section provided just a hint of the Graph API . The Graph interface is actually quite complete and offers a full-featured approach for reading and updating a graph. For more information, see the Graph JavaDocs.