/** * Return true if a given graph is an inference graph * @param g A graph * @return True if the graph is an inference graph, or is a union with an inference * base graph */ public boolean isInferenceGraph( Graph g ) { return (g instanceof InfGraph) || (g instanceof Polyadic && ((Polyadic) g).getBaseGraph() instanceof InfGraph); } }
/** * Return true if a given graph is an inference graph * @param g A graph * @return True if the graph is an inference graph, or is a union with an inference * base graph */ public boolean isInferenceGraph( Graph g ) { return (g instanceof InfGraph) || (g instanceof Polyadic && ((Polyadic) g).getBaseGraph() instanceof InfGraph); } }
/** * <p> * Answer a list of the graphs other than the updateable (base) graph * </p> * * @return A list of all of the sub-graphs, excluding the base graph. */ public List<Graph> getSubGraphs() { List<Graph> sg = new ArrayList<>( m_subGraphs ); if (getBaseGraph() != null) { sg.remove( getBaseGraph() ); } return sg; }
/** * <p> * Answer a list of the graphs other than the updateable (base) graph * </p> * * @return A list of all of the sub-graphs, excluding the base graph. */ public List<Graph> getSubGraphs() { List<Graph> sg = new ArrayList<>( m_subGraphs ); if (getBaseGraph() != null) { sg.remove( getBaseGraph() ); } return sg; }
@Override public TransactionHandler getTransactionHandler() { return (getBaseGraph() == null) ? super.getTransactionHandler() : getBaseGraph().getTransactionHandler(); }
private PrefixMapping getBaseMapping() { Graph base = poly.getBaseGraph(); return base == null ? pending : base.getPrefixMapping(); }
private PrefixMapping getBaseMapping() { Graph base = poly.getBaseGraph(); return base == null ? pending : base.getPrefixMapping(); }
@Override public Capabilities getCapabilities() { return (getBaseGraph() == null) ? super.getCapabilities() : getBaseGraph().getCapabilities(); }
@Override public Capabilities getCapabilities() { return (getBaseGraph() == null) ? super.getCapabilities() : getBaseGraph().getCapabilities(); }
@Override public TransactionHandler getTransactionHandler() { return (getBaseGraph() == null) ? super.getTransactionHandler() : getBaseGraph().getTransactionHandler(); }
/** * <p> * Answer the distinguished graph for the composition, which will be the graph * that receives triple adds and deletes. If no base graph is defined, throw * a {@link JenaException}. * </p> * * @return The distinguished updateable graph, or null if there are no graphs * in this composition */ public Graph getRequiredBaseGraph() { Graph base = getBaseGraph(); if (base == null) { throw new JenaException( "This polyadic graph should have a base graph, but none is defined" ); } else { return base; } }
/** * <p> * Answer the distinguished graph for the composition, which will be the graph * that receives triple adds and deletes. If no base graph is defined, throw * a {@link JenaException}. * </p> * * @return The distinguished updateable graph, or null if there are no graphs * in this composition */ public Graph getRequiredBaseGraph() { Graph base = getBaseGraph(); if (base == null) { throw new JenaException( "This polyadic graph should have a base graph, but none is defined" ); } else { return base; } }
private static String polyadicGraphToString(Polyadic poly) { Graph baseGraph = poly.getBaseGraph(); List<Graph> subGraphs = poly.getSubGraphs(); return simpleName(poly) + "[" + hashHex(poly) + ", base=" + graphToString(baseGraph) + ", subgraphs=" + subGraphsToString(subGraphs, baseGraph) + "]"; }
private void collectLeafGraphs(final Graph graph, final Set<Graph> prevLeaves) { if (graph instanceof Polyadic) { final Polyadic union = (Polyadic) graph; if (union.getBaseGraph() != null) collectLeafGraphs(union.getBaseGraph(), prevLeaves); for (final Graph graph2 : union.getSubGraphs()) collectLeafGraphs(graph2, prevLeaves); } else if (graph instanceof Dyadic) { final Dyadic dyadic = (Dyadic) graph; if (dyadic.getL() instanceof Graph) collectLeafGraphs((Graph) dyadic.getL(), prevLeaves); if (dyadic.getR() instanceof Graph) collectLeafGraphs((Graph) dyadic.getR(), prevLeaves); } else if (graph instanceof InfGraph) collectLeafGraphs(((InfGraph) graph).getRawGraph(), prevLeaves); else if (_leafGraphs.add(graph) && !prevLeaves.contains(graph)) { _changedGraphs.add(graph); graph.getEventManager().register(this); } }
private void collectLeafGraphs(final Graph graph, final Set<Graph> prevLeaves) { if (graph instanceof Polyadic) { final Polyadic union = (Polyadic) graph; if (union.getBaseGraph() != null) collectLeafGraphs(union.getBaseGraph(), prevLeaves); for (final Graph graph2 : union.getSubGraphs()) collectLeafGraphs(graph2, prevLeaves); } else if (graph instanceof Dyadic) { final Dyadic dyadic = (Dyadic) graph; if (dyadic.getL() instanceof Graph) collectLeafGraphs((Graph) dyadic.getL(), prevLeaves); if (dyadic.getR() instanceof Graph) collectLeafGraphs((Graph) dyadic.getR(), prevLeaves); } else if (graph instanceof InfGraph) collectLeafGraphs(((InfGraph) graph).getRawGraph(), prevLeaves); else if (_leafGraphs.add(graph) && !prevLeaves.contains(graph)) { _changedGraphs.add(graph); graph.getEventManager().register(this); } }
private void collectLeafGraphs(final Graph graph, final Set<Graph> prevLeaves) { if (graph instanceof Polyadic) { final Polyadic union = (Polyadic) graph; if (union.getBaseGraph() != null) collectLeafGraphs(union.getBaseGraph(), prevLeaves); for (final Graph graph2 : union.getSubGraphs()) collectLeafGraphs(graph2, prevLeaves); } else if (graph instanceof Dyadic) { final Dyadic dyadic = (Dyadic) graph; if (dyadic.getL() instanceof Graph) collectLeafGraphs((Graph) dyadic.getL(), prevLeaves); if (dyadic.getR() instanceof Graph) collectLeafGraphs((Graph) dyadic.getR(), prevLeaves); } else if (graph instanceof InfGraph) collectLeafGraphs(((InfGraph) graph).getRawGraph(), prevLeaves); else if (_leafGraphs.add(graph) && !prevLeaves.contains(graph)) { _changedGraphs.add(graph); graph.getEventManager().register(this); } }
private static void syncGraph(Graph graph) { // "Temporary" hack. Graph ought to implement sync and casade it down. if ( graph instanceof InfGraph ) syncGraph(((InfGraph)graph).getRawGraph()) ; else if ( graph instanceof Polyadic ) // MultiUnion // Only the base graph is updatable. syncGraph(((Polyadic)graph).getBaseGraph()) ; else if ( graph instanceof GraphWrapper ) syncGraph(((GraphWrapper)graph).get()) ; else if ( graph instanceof WrappedGraph ) syncGraph(((WrappedGraph)graph).getWrapped()) ; else syncObject(graph) ; }