1 6 7 package com.hp.hpl.jena.graph.impl; 8 9 import com.hp.hpl.jena.graph.*; 10 import com.hp.hpl.jena.mem.*; 11 import com.hp.hpl.jena.shared.*; 12 import com.hp.hpl.jena.util.iterator.*; 13 import com.hp.hpl.jena.vocabulary.*; 14 15 import java.util.*; 16 17 23 24 public class SimpleGraphMaker extends BaseGraphMaker 25 { 26 30 public SimpleGraphMaker( ReificationStyle style ) 31 { super( style ); } 32 33 36 public SimpleGraphMaker() 37 { this( ReificationStyle.Minimal ); } 38 39 43 public Node getMakerClass() 44 { return JenaModelSpec.MemMakerSpec.asNode(); } 45 46 49 protected void augmentDescription( Graph d, Node self ) 50 {} 51 52 55 private Map graphs = new HashMap(); 56 57 public Graph create() 58 { return new GraphMem(); } 59 60 63 public Graph createGraph( String name, boolean strict ) 64 { 65 GraphMem already = (GraphMem) graphs.get( name ); 66 if (already == null) 67 { 68 Graph result = new GraphMem( style ); 69 graphs.put( name, result ); 70 return result; 71 } 72 else if (strict) 73 throw new AlreadyExistsException( name ); 74 else 75 return already.openAgain(); 76 } 77 78 81 public Graph openGraph( String name, boolean strict ) 82 { 83 GraphMem already = (GraphMem) graphs.get( name ); 84 if (already == null) 85 if (strict) throw new DoesNotExistException( name ); 86 else return createGraph( name, true ); 87 else 88 return already.openAgain(); 89 } 90 91 94 public void removeGraph( String name ) 95 { 96 if (!graphs.containsKey( name )) throw new DoesNotExistException( name ); 97 graphs.remove( name ); 98 } 99 100 103 public boolean hasGraph( String name ) 104 { return graphs.containsKey( name ); } 105 106 109 public void close() 110 { } 111 112 public ExtendedIterator listGraphs() 113 { return WrappedIterator.create( graphs.keySet().iterator() ); } 114 } 115 116 117 | Popular Tags |