com.hp.hpl.jena.rdf.model.Model.expandPrefix()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(8.1k)|赞(0)|评价(0)|浏览(103)

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

Model.expandPrefix介绍

暂无

代码示例

代码示例来源:origin: fr.inria.eventcloud/eventcloud-api

/**
 * {@inheritDoc}
 */
@Override
public String expandPrefix(String prefixed) {
  return super.object.expandPrefix(prefixed);
}

代码示例来源:origin: epimorphics/elda

static List<Resource> modelRoots(String[] roots, Model src) {
  if (roots == null) return null;
  List<Resource> rootsR = new ArrayList<Resource>();
  for (String root : roots) {
    rootsR.add( src.createResource( src.expandPrefix(root) ) );
  }
  return rootsR;
}

代码示例来源:origin: epimorphics/elda

@Test public void addsBothTraces() {
  Model m = ModelIOUtils.modelFromTurtle( ":x :P :y. :y :Q :z. :z :R :x. :x :S :a. :a :T :b. :b :U :x." );
  Resource x = m.createResource( m.expandPrefix( ":x" ) );
  Resource y = m.createResource( m.expandPrefix( ":y" ) );
  Resource z = m.createResource( m.expandPrefix( ":z" ) );
  Resource a = m.createResource( m.expandPrefix( ":a" ) );
  Resource b = m.createResource( m.expandPrefix( ":b" ) );		
  Set<Resource> loops = CycleFinder.findCycles( x );
  assertEquals( CollectionUtils.set(x, y, z, a, b), loops );
}

代码示例来源:origin: epimorphics/elda

@Test public void testExtractsEnableForwardHeaders() {
  Model spec = ModelIOUtils.modelFromTurtle(new StringBuffer()
      .append(":s a api:API")
      .append("; api:sparqlEndpoint <http://example.com/none>")
      .append("; elda:enableForwardHeaders false")
      .append(".")
      .toString()
  );
  Resource s = spec.getResource( spec.expandPrefix( ":s" ) );
  APISpec a = SpecUtil.specFrom( s );
  assertEquals( false, a.getEnableForwardHeaders() );
}

代码示例来源:origin: epimorphics/elda

@Test  public void returnsDeferedMultiStatementCycle() {
  Model m = ModelIOUtils.modelFromTurtle( ":x :P :y. :y :Q :z. :z :R :y." );
  Resource x = m.createResource( m.expandPrefix( ":x" ) );
  Resource y = m.createResource( m.expandPrefix( ":y" ) );
  Resource z = m.createResource( m.expandPrefix( ":z" ) );
  Set<Resource> loops = CycleFinder.findCycles( x );
  assertEquals( CollectionUtils.set(y, z), loops );
}

代码示例来源:origin: epimorphics/elda

@Test  public void returnsMultiStatementCycle() {
  Model m = ModelIOUtils.modelFromTurtle( ":x :P :y. :y :Q :x." );
  Resource x = m.createResource( m.expandPrefix( ":x" ) );
  Resource y = m.createResource( m.expandPrefix( ":y" ) );
  Set<Resource> loops = CycleFinder.findCycles( x );
  assertEquals( CollectionUtils.set(x, y), loops );
}

代码示例来源:origin: epimorphics/elda

@Test public void testExtractsPropertyTimes() {
  APISpec a = SpecUtil.specFrom(s);
  Resource P = spec.getResource(spec.expandPrefix(":P"));
  Resource Q = spec.getResource(spec.expandPrefix(":Q"));
  PropertyExpiryTimes pet = PropertyExpiryTimes.buildForTests(P, 10L, Q, 20L);
  assertEquals(pet, a.getPropertyExpiryTimes());
}

代码示例来源:origin: epimorphics/elda

@Test public void testOverriddenEndpointExpiryTime() {
  Model spec = makeModel("elda:cacheExpiryTime 17", "elda:cacheExpiryTime 2000");
  Resource s = spec.getResource( spec.expandPrefix( ":s" ) );		
  Resource e = spec.getResource( spec.expandPrefix( ":e" ) );
  APISpec a = SpecUtil.specFrom( s );
  APIEndpointSpec eps = new APIEndpointSpec( a, null, e );
  assertEquals( 2000 * 1000, eps.getCacheExpiryMilliseconds() );
}

代码示例来源:origin: epimorphics/elda

@Test public void ensureApiLabelWinsOverRDFSLabel() {
  Model m = ModelIOUtils.modelFromTurtle
    ( "@prefix p: <http://example.com/ns#>."
    + "\np:a p:thing p:b; p:other p:d; p:thong p:c." 
    + "\np:thing rdfs:label 'labelled'." 
    + "\np:thing api:label 'REALLY_labelled'."
    );
  Context c = new Context( m ); 		
  Map<String, String> mm = new CompleteContext(CompleteContext.Mode.RoundTrip, c, m).Do();
  assertEquals( "REALLY_labelled", mm.get( m.expandPrefix( "p:thing" ) ) );
}

代码示例来源:origin: epimorphics/elda

@Test public void ensureConfigShortnameIsUsed() {
  Model m = ModelIOUtils.modelFromTurtle
    ( "@prefix p: <http://example.com/ns#>."
    + "\np:a p:thing p:b; p:other p:d; p:thong p:c." 
    + "\np:thing rdfs:label 'labelled'; rdfs:range p:Thing."
    );
  Context c = new Context( m ); 
  Map<String, String> mm = new CompleteContext(CompleteContext.Mode.RoundTrip, c, m).Do();
  assertEquals( "labelled", mm.get( m.expandPrefix( "p:thing" ) ) );
}

代码示例来源:origin: com.hp.hpl.jena/tdb

@Test public void prefix1()
{
  Dataset ds = create() ;
  Model m = ds.getDefaultModel() ;
  load1(m) ;
  String x = m.expandPrefix(":x") ;
  assertEquals(x, base1+"x") ;
}

代码示例来源:origin: com.hp.hpl.jena/tdb

@Test public void prefix2()
{
  Dataset ds = create() ;
  Model m = ds.getDefaultModel() ;
  load1(m) ;
  Model m2 = ds.getNamedModel("http://example/graph/") ;
  String x = m2.expandPrefix(":x") ;
  assertEquals(x, ":x") ;
}

代码示例来源:origin: epimorphics/elda

@Test public void testSpecEnableCountingFALSE() {
  Model m = ModelIOUtils.modelFromTurtle
    ( ":my a api:API; elda:enableCounting false; api:sparqlEndpoint :spoo" );
  Resource root = m.createResource(m.expandPrefix(":my"));
  APISpec s = SpecUtil.specFrom( root );
  assertEquals( Boolean.FALSE, s.getEnableCounting() );
}

代码示例来源:origin: epimorphics/elda

public void testVariableExtraction( String expected, String spec ) 
  {
  Model m = ModelIOUtils.modelFromTurtle( spec );
  Resource root = m.createResource( m.expandPrefix( ":my" ) );
  APISpec s = SpecUtil.specFrom( root );
  assertEqualBindings( binding( expected ), s.getBindings() );
  }

代码示例来源:origin: epimorphics/elda

@Test public void ensureRespectsDataypesByType() 
  {
  Model m = ModelIOUtils.modelFromTurtle( spec );
  m.removeAll( null, RDF.type, OWL.DatatypeProperty );
  Resource ft = m.createResource( m.expandPrefix( ":faketype" ) );
  m.add( ft, RDF.type, RDFS.Datatype );
//
  ensureRespectsDatatypes( m );
  }

代码示例来源:origin: epimorphics/elda

@Test public void testSpecEnableCountingTRUE() {
  Model m = ModelIOUtils.modelFromTurtle
    ( ":my a api:API; elda:enableCounting true; api:sparqlEndpoint :spoo" );
  Resource root = m.createResource(m.expandPrefix(":my"));
  APISpec s = SpecUtil.specFrom( root );
  assertEquals( Boolean.TRUE, s.getEnableCounting() );
}

代码示例来源:origin: epimorphics/elda

private void ensureRespectsDatatypes(Model m) {
  PrefixLogger pl = new PrefixLogger();
  Resource root = m.createResource( m.expandPrefix( ":my" ) );
  APISpec s = SpecUtil.specFrom( root );
  ValTranslator vt = new ValTranslator( vs, expressions, s.getShortnameService() );
  Info yearInf = Param.make(s.getShortnameService(), "year" ).fullParts()[0];
  Any x = vt.objectForValue( yearInf, "spoo", null );
  String eg = m.getNsPrefixURI( "" );
  assertThat( x.asSparqlTerm(pl), is( "\"spoo\"^^<" + eg + "faketype>" ) );
}

代码示例来源:origin: epimorphics/elda

@Test public void testWithAPIGraphTemplate() {
  Resource root = specWithAPIGraphTemplate.getResource( specWithAPIGraphTemplate.expandPrefix(":root"));
  APISpec a = SpecUtil.specFrom(root);
//
  APIEndpointSpec A = getEndpoint(a, "endpointA");
  assertEquals("hello/world", A.getGraphTemplate());
//
  APIEndpointSpec B = getEndpoint(a, "endpointB");
  assertEquals("api/graph/template", B.getGraphTemplate());
}

代码示例来源:origin: epimorphics/elda

@Test public void testDatatypedObject() {
  Model spec = ModelIOUtils.modelFromTurtle( ":thing api:label 'val'. :dt a rdfs:Datatype." );
  Resource root = spec.createResource( "http://example.com/root" );
  ShortnameService sns = new StandardShortnameService( root, noPrefixes, null );
//
  ValTranslator vt = new ValTranslator(absentSupply, absentFilters, sns);
  String NS = root.getModel().expandPrefix( ":" );
  Any o = vt.objectForValue( NS + "dt", "lexicalForm", null );
  assertEquals( RDFQ.literal( "lexicalForm", "", NS + "dt" ), o );		
}

代码示例来源:origin: epimorphics/elda

private void EachEndpointHasItsOwnDefaultSuffix(String expected, String protoSpec ) {
  String spec = ":my a api:API; api:sparqlEndpoint :spoo." + "\n" + protoSpec;
  Model m = ModelIOUtils.modelFromTurtle( spec );
  Resource root = m.createResource( m.expandPrefix( ":my" ) );
  APISpec s = SpecUtil.specFrom( root );
//
  for (APIEndpointSpec es : s.getEndpoints()) {
    String localName = es.getResource().getLocalName();
    String defaultSuffix = es.getBindings().getAsString("_defaultSuffix", null);
    assertEquals("suffix should be the same as the local name", localName, defaultSuffix);
  }
}

相关文章

Model类方法