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.vocabulary.*; 13 14 20 public abstract class BaseGraphMaker implements GraphMaker 21 { 22 26 public BaseGraphMaker( ReificationStyle style ) 27 { this.style = style; } 28 29 private int counter = 0; 30 protected ReificationStyle style; 31 32 35 public ReificationStyle getReificationStyle() 36 { return style; } 37 38 42 public Graph getGraph() 43 { 44 if (defaultGraph == null) defaultGraph = createGraph(); 45 return defaultGraph; 46 } 47 48 private Graph defaultGraph; 49 50 53 public Graph createGraph() 54 { return createGraph( "anon_" + counter++ + "", false ); } 55 56 60 public Graph createGraph(String name) 61 { return createGraph( name, false ); } 62 63 67 public Graph openGraph( String name ) 68 { return openGraph( name, false ); } 69 70 71 77 public Graph getDescription() 78 { return getDescription( Node.createAnon() ); } 79 80 public Graph getDescription( Node root ) 81 { 82 Graph result = new GraphMem(); 83 addDescription( result, root ); 84 return result; 85 } 86 87 public Graph addDescription( Graph desc, Node self ) 88 { 89 Node mode = JenaModelSpec.styleAsJMS( style ); 90 desc.add( Triple.create( self, JenaModelSpec.reificationMode.asNode(), mode ) ); 91 desc.add( Triple.create( self, RDF.Nodes.type, getMakerClass() ) ); 92 augmentDescription( desc, self ); 93 return desc; 94 } 95 96 101 protected abstract void augmentDescription( Graph d, Node self ); 102 103 108 public abstract Node getMakerClass(); 109 } 110 111 112 | Popular Tags |