Search in sources :

Example 1 with LabelNotFoundKernelException

use of org.neo4j.internal.kernel.api.exceptions.LabelNotFoundKernelException in project neo4j by neo4j.

the class NodeEntity method getLabels.

public Iterable<Label> getLabels(NodeCursor nodes) {
    KernelTransaction transaction = internalTransaction.kernelTransaction();
    try {
        singleNode(transaction, nodes);
        TokenSet tokenSet = nodes.labels();
        TokenRead tokenRead = transaction.tokenRead();
        List<Label> list = new ArrayList<>(tokenSet.numberOfTokens());
        for (int i = 0; i < tokenSet.numberOfTokens(); i++) {
            list.add(label(tokenRead.nodeLabelName(tokenSet.token(i))));
        }
        return list;
    } catch (LabelNotFoundKernelException e) {
        throw new IllegalStateException("Label retrieved through kernel API should exist.", e);
    }
}
Also used : KernelTransaction(org.neo4j.kernel.api.KernelTransaction) LabelNotFoundKernelException(org.neo4j.internal.kernel.api.exceptions.LabelNotFoundKernelException) TokenSet(org.neo4j.internal.kernel.api.TokenSet) Label(org.neo4j.graphdb.Label) ArrayList(java.util.ArrayList) TokenRead(org.neo4j.internal.kernel.api.TokenRead)

Aggregations

ArrayList (java.util.ArrayList)1 Label (org.neo4j.graphdb.Label)1 TokenRead (org.neo4j.internal.kernel.api.TokenRead)1 TokenSet (org.neo4j.internal.kernel.api.TokenSet)1 LabelNotFoundKernelException (org.neo4j.internal.kernel.api.exceptions.LabelNotFoundKernelException)1 KernelTransaction (org.neo4j.kernel.api.KernelTransaction)1