/*
 * 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 org.apache.jena.sparql.core;

import org.apache.jena.graph.Graph ;
import org.apache.jena.graph.GraphUtil ;
import org.apache.jena.graph.Node ;

/** A DatasetGraph base class for triples+quads storage.     
 */
public abstract class DatasetGraphTriplesQuads extends DatasetGraphBaseFind
{
    @Override
    final public void add(Quad quad) {
        add(quad.getGraph(), quad.getSubject(), quad.getPredicate(), quad.getObject()) ;
    }

    @Override
    final public void delete(Quad quad) {
        delete(quad.getGraph(), quad.getSubject(), quad.getPredicate(), quad.getObject()) ;
    }

    @Override
    public void add(Node g, Node s, Node p, Node o) {
        if ( Quad.isDefaultGraph(g) )
            addToDftGraph(s, p, o) ;
        else
            addToNamedGraph(g, s, p, o) ;
    }

    @Override
    public void delete(Node g, Node s, Node p, Node o) {
        if ( Quad.isDefaultGraph(g) )
            deleteFromDftGraph(s, p, o) ;
        else
            deleteFromNamedGraph(g, s, p, o) ;
    }
    
    protected abstract void addToDftGraph(Node s, Node p, Node o) ;
    protected abstract void addToNamedGraph(Node g, Node s, Node p, Node o) ;
    protected abstract void deleteFromDftGraph(Node s, Node p, Node o) ;
    protected abstract void deleteFromNamedGraph(Node g, Node s, Node p, Node o) ;
    
    // Default implementations - copy based.
    
    @Override
    public void setDefaultGraph(Graph graph) { 
        GraphUtil.addInto(getDefaultGraph(), graph) ;
    }
    
    @Override
    public void addGraph(Node graphName, Graph graph) {
        GraphUtil.addInto(getGraph(graphName), graph) ;
    }
    
    @Override
    public void removeGraph(Node graphName) {
        deleteAny(graphName, Node.ANY, Node.ANY, Node.ANY) ;
    }
}

@@ -1411,32 +1411,38 @@
   @Override%0A    
+final 
 public void add(
@@ -1467,32 +1467,32 @@
 de p, Node o) %7B%0A
-
         if ( Qua
@@ -1622,32 +1622,38 @@
   @Override%0A    
+final 
 public void dele
@@ -2143,24 +2143,312 @@
 e o) ;%0A    %0A
+//    // Ensure we loop back here%0A//    @Override%0A//    public Graph getDefaultGraph() %7B%0A//        return GraphView.createDefaultGraph(this) ;%0A//    %7D%0A//%0A//    @Override%0A//    public Graph getGraph(Node graphNode) %7B%0A//        return GraphView.createNamedGraph(this, graphNode) ;%0A//    %7D%0A%0A
     // Defau
@@ -2480,24 +2480,26 @@
  based.%0A    
+  
 %0A    @Overri

Make add/delete final: they route the operations to addToNamedGraph &c.