1 6 package com.hp.hpl.jena.mem; 7 8 import java.util.Set ; 9 10 import com.hp.hpl.jena.graph.*; 11 import com.hp.hpl.jena.graph.impl.SimpleEventManager; 12 import com.hp.hpl.jena.shared.ReificationStyle; 13 import com.hp.hpl.jena.util.CollectionFactory; 14 import com.hp.hpl.jena.util.iterator.ExtendedIterator; 15 16 23 24 public class SmallGraphMem extends GraphMemBase 25 { 26 protected Set triples = CollectionFactory.createHashedSet(); 27 28 public SmallGraphMem() 29 { this( ReificationStyle.Minimal ); } 30 31 public SmallGraphMem( ReificationStyle style ) 32 { super( style ); } 33 34 public void performAdd( Triple t ) 35 { if (!getReifier().handledAdd( t )) triples.add( t ); } 36 37 public void performDelete( Triple t ) 38 { if (!getReifier().handledRemove( t )) triples.remove( t ); } 39 40 public int graphBaseSize() 41 { return triples.size(); } 42 43 48 public boolean graphBaseContains( Triple t ) 49 { return t.isConcrete() ? triples.contains( t ) : containsByFind( t ); } 50 51 protected void destroy() 52 { triples = null; } 53 54 public BulkUpdateHandler getBulkUpdateHandler() 55 { 56 if (bulkHandler == null) bulkHandler = new GraphMemBulkUpdateHandler( this ) 57 { 58 protected void clearComponents() 59 { 60 SmallGraphMem g = (SmallGraphMem) graph; 61 g.triples.clear(); 62 } 63 }; 64 return bulkHandler; 65 } 66 67 public ExtendedIterator graphBaseFind( TripleMatch m ) 68 { 69 return 70 SimpleEventManager.notifyingRemove( this, triples.iterator() ) 71 .filterKeep ( new TripleMatchFilter( m.asTriple() ) ); 72 } 73 } 74 75 | Popular Tags |