org.apache.jena.graph.Graph.getPrefixMapping()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(5.1k)|赞(0)|评价(0)|浏览(154)

本文整理了Java中org.apache.jena.graph.Graph.getPrefixMapping()方法的一些代码示例,展示了Graph.getPrefixMapping()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Graph.getPrefixMapping()方法的具体详情如下:
包路径:org.apache.jena.graph.Graph
类名称:Graph
方法名:getPrefixMapping

Graph.getPrefixMapping介绍

[英]returns this Graph's prefix mapping. Each call on a given Graph gets the same PrefixMapping object, which is the one used by the Graph.
[中]返回此图的前缀映射。对给定图形的每次调用都会获得相同的PrefixMapping对象,即图形所使用的对象。

代码示例

代码示例来源:origin: apache/jena

public ParserOutputDataset(DatasetGraph dsg)
{ 
  this.dsg = dsg ;
  this.prefixMapping = dsg.getDefaultGraph().getPrefixMapping() ;
  // = dsg.getPrefixMapping().setNsPrefix(prefix, uri) ;
}

代码示例来源:origin: apache/jena

/**
   Inference graphs share the prefix-mapping of their underlying raw graph.
   @see org.apache.jena.graph.Graph#getPrefixMapping()
*/
@Override
public PrefixMapping getPrefixMapping()
  { return getRawGraph().getPrefixMapping(); }

代码示例来源:origin: apache/jena

private synchronized void createPrefixMapping() {
  if (prefixMapping == null) {
    prefixMapping = org.apache.jena.permissions.graph.impl.Factory
        .getInstance(this, holder.getBaseItem().getPrefixMapping());
  }
}

代码示例来源:origin: apache/jena

/** Return a SerializationContext appropriate for the graph */
public static SerializationContext sCxt(Graph graph)
{
  if ( graph != null )
    return sCxt(graph.getPrefixMapping()) ;
  return new SerializationContext() ;
}

代码示例来源:origin: apache/jena

public void testSameMapping( Graph g )
  {
  PrefixMapping pm = g.getPrefixMapping();
  assertTrue( pm == g.getPrefixMapping() );
  }
}

代码示例来源:origin: apache/jena

private static PrefixMapping modelToPrefixMapping( Model model )
  {
  return model == null 
    ? PrefixMapping.Factory.create() 
    : model.getGraph().getPrefixMapping()
    ;
  }

代码示例来源:origin: apache/jena

/** Send the triples of graph and an explicitly given prefix mapping, to a StreamRDF */
public static void sendGraphToStream(Graph graph, StreamRDF stream) {
  PrefixMap prefixMap = PrefixMapFactory.create(graph.getPrefixMapping()) ;
  sendGraphToStream(graph, stream, prefixMap) ;
}

代码示例来源:origin: apache/jena

@Override public Map<String, String> getNsPrefixMap()
  { 
  Map<String, String> result = CollectionFactory.createHashedMap();
  List<Graph> graphs = poly.getSubGraphs();
  for (int i = graphs.size(); i > 0;)
    result.putAll( graphs.get( --i ).getPrefixMapping().getNsPrefixMap() );
  result.remove( "" );
  result.putAll( getBaseMapping().getNsPrefixMap() );
  return result; 
  }

代码示例来源:origin: apache/jena

public static void write(IndentedWriter out, Graph graph)
{ 
  WriterGraph.output(out, graph, 
            new SerializationContext(graph.getPrefixMapping())) ;
  out.ensureStartOfLine() ;
}

代码示例来源:origin: apache/jena

/** Add triples into the destination (arg 1) from the source (arg 2)*/
public static void addInto(Graph dstGraph, Graph srcGraph ) {
  if ( dstGraph == srcGraph && ! dstGraph.getEventManager().listening() )
    return ;
  dstGraph.getPrefixMapping().setNsPrefixes(srcGraph.getPrefixMapping()) ;
  addIteratorWorker(dstGraph, findAll( srcGraph ));  
  dstGraph.getEventManager().notifyAddGraph( dstGraph, srcGraph );
}

代码示例来源:origin: apache/jena

/**
 * Answer a new memory-based graph with Extended prefixes.
 */
public static Graph memGraph() {
  Graph result = Factory.createGraphMem();
  result.getPrefixMapping().setNsPrefixes(PrefixMapping.Extended);
  return result;
}

代码示例来源:origin: apache/jena

@Override
  public PrefixMapping getPrefixMapping()
  {
    return ModelFactory.createDefaultModel().getGraph()
        .getPrefixMapping();
  }
}

代码示例来源:origin: apache/jena

@Test public void graphDSG_prefixes_4()
{
  // All graphs exist.
  Graph g = makeNamedGraph(baseDSG, gnNotSuchGraph)  ;
  PrefixMapping pmap = g.getPrefixMapping() ;
  assertNotNull(pmap) ;
}

代码示例来源:origin: apache/jena

public void testGraphPrefixMapping()
  { 
  Graph g = Factory.createDefaultGraph();
  AbstractTestPrefixMapping.testUseEasyPrefix
    ( "from Graph", g.getPrefixMapping() ); 
  testSameMapping( g );
  }

代码示例来源:origin: apache/jena

@Test public void graphDSG_prefixes_3()
{
  Graph g = makeDefaultGraph(baseDSG) ;
  PrefixMapping pmap = g.getPrefixMapping() ;
  assertNotNull(pmap) ;
}

代码示例来源:origin: apache/jena

public void testPolyDoesntSeeImportedDefaultPrefix()
  {
  String imported = "http://imported#";
  g1.getPrefixMapping().setNsPrefix( "", imported );
  assertEquals( null, poly.getPrefixMapping().getNsPrefixURI( "" ) );
  }

代码示例来源:origin: apache/jena

@Test
public void load_dataset_03() {
  DatasetGraphTDB dsg = fresh() ;
  TDBLoader.load(dsg, DIR + "data-3.trig", false) ;
  String uri = dsg.getDefaultGraph().getPrefixMapping().getNsPrefixURI("") ;
  assertEquals("http://example/", uri) ;
}

代码示例来源:origin: apache/jena

@Test
public void load_graph_04() {
  DatasetGraphTDB dsg = fresh() ;
  TDBLoader.load(dsg, DIR + "data-4.ttl", false) ;
  String uri = dsg.getDefaultGraph().getPrefixMapping().getNsPrefixURI("") ;
  assertEquals("http://example/", uri) ;
}

代码示例来源:origin: apache/jena

@Test
public void load_dataset_04() {
  DatasetGraph dsg = fresh() ;
  load(dsg, maker, DIR + "data-3.trig") ;
  Txn.executeRead(dsg, ()->{
    String uri = dsg.getDefaultGraph().getPrefixMapping().getNsPrefixURI("") ;
    assertEquals("http://example/", uri) ;
  });
}

代码示例来源:origin: apache/jena

@Test
public void load_graph_05() {
  DatasetGraphTDB dsg = fresh() ;
  GraphTDB graph = dsg.getDefaultGraphTDB() ;
  TDBLoader.load(graph, DIR + "data-4.ttl", false) ;
  String uri = dsg.getDefaultGraph().getPrefixMapping().getNsPrefixURI("") ;
  assertEquals("http://example/", uri) ;
}

相关文章