/** Create a graph and record it with the given name in the local map. */ @Override public Graph createGraph( String name, boolean strict ) { GraphMemBase already = (GraphMemBase) graphs.get( name ); if (already == null) { Graph result = Factory.createGraphMem( ); graphs.put( name, result ); return result; } else if (strict) throw new AlreadyExistsException( name ); else return already.openAgain(); }
/** Construct a new FileGraph who's name is given by the specified File, If create is true, this is a new file, and any existing file will be destroyed; if create is false, this is an existing file, and its current contents will be loaded. The language code for the file is supplied. @param f the File naming the associated file-system file @param lang the language string for the file @param create true to create a new one, false to read an existing one @param strict true to throw exceptions for create: existing, open: not found @param style the reification style for the graph */ public FileGraph( NotifyOnClose notify, File f, String lang, boolean create, boolean strict ) { this.name = f; this.notify = notify; this.model = new ModelCom( this ); this.lang = lang; if (create) { if (f.exists() && strict) throw new AlreadyExistsException( f.toString() ); } else readModel( this.model, strict ); }
@Override public Graph createGraph( String name, boolean strict ) { File f = withRoot( name ); FileGraph already = created.get( f ); if (already == null) return remember( f, new FileGraph( this, f, true, strict ) ); else { if (strict) throw new AlreadyExistsException( name ); else return already.openAgain(); } }