![JAR search and dependency download from the Maven repository](/logo.png)
iot.jcypher.query.api.pattern.Node Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jcypher Show documentation
Show all versions of jcypher Show documentation
Provides seamlessly integrated Java access to graph databases (Neo4J)
at different levels of abstraction.
/************************************************************************
* Copyright (c) 2014-2015 IoT-Solutions e.U.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
************************************************************************/
package iot.jcypher.query.api.pattern;
import java.util.List;
import iot.jcypher.domain.internal.CurrentDomain;
import iot.jcypher.query.ast.pattern.PatternExpression;
import iot.jcypher.query.ast.pattern.PatternNode;
import iot.jcypher.query.ast.pattern.PatternRelation;
import iot.jcypher.query.values.JcRelation;
public class Node extends Element {
Node(PatternExpression expression) {
super(expression);
}
/**
* JCYPHER
* match or create (depends on the clause) relations connected to the node
* e.g. MATCH.node(n).relation()
*
*/
public Relation relation() {
return relation(null);
}
/**
* JCYPHER
* match or create (depends on the clause) relations connected to the node,
*
make them accessible by a JcRelation element later on in the query
* e.g. MATCH.node(n).relation(r)
*
*/
public Relation relation(JcRelation relation) {
PatternExpression px = (PatternExpression)this.astNode;
PatternRelation pr = new PatternRelation(relation);
px.addElement(pr);
Relation ret = new Relation(px);
return ret;
}
/**
* JCYPHER
* set a label to match or create nodes with that label
* e.g. MATCH.node(n).label("Movie")
*
*/
public Node label(String label) {
PatternExpression px = (PatternExpression)this.astNode;
List labels = ((PatternNode)px.getLastElement()).getLabels();
labels.add(label);
String dLab = CurrentDomain.label.get();
if (dLab != null && !labels.contains(dLab))
labels.add(dLab);
return this;
}
/**
* JCYPHER
* set a label to match or create nodes with that label
* using enum label
* e.g. MATCH.node(n).label(MyLabels.Movie)
*
*/
public Node label(Enum> label) {
return label(label.name());
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy