1 19 20 package com.hp.hpl.jena.graph.compose; 23 24 25 import com.hp.hpl.jena.graph.*; 28 import com.hp.hpl.jena.graph.impl.SimpleEventManager; 29 import com.hp.hpl.jena.shared.JenaException; 30 import com.hp.hpl.jena.util.CollectionFactory; 31 import com.hp.hpl.jena.util.iterator.*; 32 33 import java.util.*; 34 35 36 46 public class MultiUnion 47 extends Polyadic 48 { 49 52 53 56 57 60 61 64 69 public MultiUnion() { 70 super(); 71 } 72 73 74 81 public MultiUnion( Graph[] graphs) { 82 super( graphs ); 83 } 84 85 86 94 public MultiUnion( Iterator graphs ) { 95 super( graphs ); 96 } 97 98 99 102 105 public Reifier getReifier() 106 { Graph base = getBaseGraph(); 107 return base == null ? super.getReifier() : base.getReifier(); } 108 109 118 public void performAdd( Triple t ) { 119 try { 120 getBaseGraph().add( t ); 121 } 122 catch (NullPointerException e) { 123 throw new JenaException( "Tried to add to a union graph that has no component graphs." ); 124 } 125 } 126 127 136 public void performDelete( Triple t ) { 137 try { 138 getBaseGraph().delete( t ); 139 } 140 catch (NullPointerException e) { 141 throw new JenaException( "Tried to delete from a union graph that has no component graphs." ); 142 } 143 } 144 145 146 154 public boolean graphBaseContains( Triple t ) { 155 for (Iterator i = m_subGraphs.iterator(); i.hasNext(); ) { 156 if (((Graph) i.next()).contains( t )) { 157 return true; 158 } 159 } 160 161 return false; 162 } 163 164 165 175 public ExtendedIterator graphBaseFind( final TripleMatch t ) { 176 Set seen = CollectionFactory.createHashedSet(); 177 ExtendedIterator i = NullIterator.instance; 178 179 for (Iterator graphs = m_subGraphs.iterator(); graphs.hasNext(); ) { 181 ExtendedIterator newTriples = recording( rejecting( ((Graph) graphs.next()).find( t ), seen ), seen ); 182 i = i.andThen( newTriples ); 183 } 184 185 return SimpleEventManager.notifyingRemove( MultiUnion.this, i ); 187 } 188 189 190 198 public void addGraph( Graph graph ) { 199 if (!m_subGraphs.contains( graph )) { 200 m_subGraphs.add( graph ); 201 } 202 } 203 204 } 205 206 207 236 237 | Popular Tags |