/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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 jena3.graph.impl; import java.util.Iterator ; import jena3.NodeTuple ; import jena3.graph.Node ; import jena3.graph.Triple ; import org.apache.jena.atlas.iterator.IteratorArray ; public class QuadImpl implements Triple, NodeTuple { private final Node graph, subj, pred, obj; public QuadImpl(Node g, Node s, Node p, Node o ) { if (g == null) throw new UnsupportedOperationException( "graph cannot be null" ); if (s == null) throw new UnsupportedOperationException( "subject cannot be null" ); if (p == null) throw new UnsupportedOperationException( "predicate cannot be null" ); if (o == null) throw new UnsupportedOperationException( "object cannot be null" ); graph = g ; subj = s; pred = p; obj = o; } @Override public Node get(int i) { switch(i) { case 0: return graph ; case 1: return subj ; case 2: return pred ; case 3: return obj ; default: throw new IllegalArgumentException("Index out of range for a quad: "+i) ; } } @Override public Node getGraph() { return graph ; } @Override public Node getSubject() { return subj ; } @Override public Node getPredicate() { return pred ; } @Override public Node getObject() { return obj ; } @Override public int length() { return 4 ; } @Override public Iterator iterator() { return IteratorArray.create(new Node[]{graph, subj, pred, obj}) ; } @Override public boolean isTriple() { return false ; } @Override public boolean isQuad() { return true ; } }