com.hp.hpl.jena.graph.Graph.contains()方法的使用及代码示例

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

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

Graph.contains介绍

[英]Answer true iff the graph contains a triple matching (s, p, o). s/p/o may be concrete or fluid. Equivalent to find(s,p,o).hasNext, but an implementation is expected to optimise this in easy cases.
[中]如果图形包含三重匹配(s、p、o),则回答true。s/p/o可以是混凝土或流体。相当于查找(s、p、o)。hasNext,但在简单的情况下,预计会有一个实现来优化这一点。

代码示例

代码示例来源:origin: org.apache.clerezza.ext/org.apache.jena.jena-core

/** Does the graph use the node anywhere as a subject, predciate or object? */
public static boolean containsNode(Graph graph, Node node)
{
  return
    graph.contains(node, Node.ANY, Node.ANY) ||
    graph.contains(Node.ANY, Node.ANY, node) ||
    graph.contains(Node.ANY, node, Node.ANY) ;
}

代码示例来源:origin: org.apache.clerezza.ext/org.apache.jena.jena-core

@Override
  public boolean doCheck( Node n, EnhGraph g ) {
    return g.asGraph().contains( n, RDF.type.asNode(), OWL.SymmetricProperty.asNode() ) &&
        !g.asGraph().contains( n, RDF.type.asNode(), OWL.DatatypeProperty.asNode() );
  }
}

代码示例来源:origin: org.apache.clerezza.ext/org.apache.jena.jena-core

@Override
  public boolean doCheck( Node n, EnhGraph g ) {
    return g.asGraph().contains( n, RDF.type.asNode(), OWL.DatatypeProperty.asNode() );
  }
}

代码示例来源:origin: org.apache.clerezza.ext/org.apache.jena.jena-core

@Override
  public boolean doCheck( Node n, EnhGraph g ) {
    return g.asGraph().contains( n, RDF.type.asNode(), OWL.Ontology.asNode() );
  }
}

代码示例来源:origin: org.apache.clerezza.ext/org.apache.jena.jena-arq

public static boolean isContainer(Graph graph, Node container, Node containerType)
  {
//        if ( container.isLiteral() )
//            return false ;
    
    if ( containerType == null )
      return  isContainer(graph, container, BAG) ||
          isContainer(graph, container, ALT) ||
          isContainer(graph, container, SEQ) ;
    
    return graph.contains(container, RDFtype, containerType) ; 
  }

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

public static boolean isContainer(Graph graph, Node container, Node containerType)
  {
//        if ( container.isLiteral() )
//            return false ;
    
    if ( containerType == null )
      return  isContainer(graph, container, BAG) ||
          isContainer(graph, container, ALT) ||
          isContainer(graph, container, SEQ) ;
    
    return graph.contains(container, RDFtype, containerType) ; 
  }

代码示例来源:origin: org.apache.clerezza.ext/org.apache.jena.jena-core

@Override
  public boolean doCheck( Node n, EnhGraph g ) {
    return g.asGraph().contains( n, RDF.type.asNode(), OWL.DatatypeProperty.asNode() );
  }
}

代码示例来源:origin: org.apache.clerezza.ext/org.apache.jena.jena-core

@Override
  public boolean doCheck( Node n, EnhGraph g ) {
    return g.asGraph().contains( n, RDF.type.asNode(), OWL.Restriction.asNode() );
  }
}

代码示例来源:origin: org.apache.clerezza.ext/org.apache.jena.jena-core

@Override
  public boolean doCheck( Node n, EnhGraph g ) {
    return g.asGraph().contains( n, RDF.type.asNode(), OWL.AllDifferent.asNode() );
  }
}

代码示例来源:origin: org.apache.clerezza.ext/org.apache.jena.jena-core

@Override
  public boolean doCheck( Node n, EnhGraph g ) {
    return g.asGraph().contains( n, RDF.type.asNode(), OWL.InverseFunctionalProperty.asNode() ) &&
    !g.asGraph().contains( n, RDF.type.asNode(), OWL.DatatypeProperty.asNode() );
  }
}

代码示例来源:origin: org.apache.clerezza.ext/org.apache.jena.jena-core

@Override
  public boolean doCheck( Node n, EnhGraph g ) {
    return n.isBlank()  &&
        g.asGraph().contains( n, RDF.type.asNode(), OWL.DataRange.asNode() );
  }
}

代码示例来源:origin: org.apache.clerezza.ext/org.apache.jena.jena-core

@Override
  public boolean doCheck( Node n, EnhGraph g ) {
    return g.asGraph().contains( n, RDF.type.asNode(), OWL.Restriction.asNode() ) &&
    containsSome( g,n, OWL.someValuesFrom ) &&
    containsSome( g,n, OWL.onProperty );
  }
}

代码示例来源:origin: org.apache.clerezza.ext/org.apache.jena.jena-core

@Override
  public boolean doCheck( Node n, EnhGraph g ) {
    return g.asGraph().contains( n, RDF.type.asNode(), OWL.Restriction.asNode() ) &&
    containsSome( g, n, OWL.minCardinality ) &&
    containsSome( g, n, OWL.onProperty );
  }
}

代码示例来源:origin: org.apache.clerezza.ext/org.apache.jena.jena-core

@Override
  public boolean doCheck( Node n, EnhGraph g ) {
    return g.asGraph().contains( n, RDF.type.asNode(), OWL.Restriction.asNode() ) &&
    containsSome( g, n, OWL.maxCardinality ) &&
    containsSome( g, n, OWL.onProperty );
  }
}

代码示例来源:origin: org.apache.clerezza.ext/org.apache.jena.jena-core

@Override
  public boolean canWrap( Node node, EnhGraph eg ) {
    // node will support being an EnumeratedClass facet if it has rdf:type owl:Class and an owl:oneOf statement (or equivalents)
    Profile profile = (eg instanceof OntModel) ? ((OntModel) eg).getProfile() : null;
    return (profile != null)  &&
        profile.isSupported( node, eg, OntClass.class )  &&
        eg.asGraph().contains( node, profile.ONE_OF().asNode(), Node.ANY );
  }
};

代码示例来源:origin: org.apache.clerezza.ext/org.apache.jena.jena-core

@Override
  public boolean doCheck( Node n, EnhGraph g ) {
    return n.equals( RDF.nil.asNode() )  ||
        g.asGraph().contains( n, RDF.type.asNode(), RDF.List.asNode() );
  }
}

代码示例来源:origin: org.apache.clerezza.ext/org.apache.jena.jena-core

@Override
  public boolean canWrap( Node node, EnhGraph eg ) {
    // node will support being an ComplementClass facet if it has rdf:type owl:Class and an owl:complementOf statement (or equivalents)
    Profile profile = (eg instanceof OntModel) ? ((OntModel) eg).getProfile() : null;
    Property comp = (profile == null) ? null : profile.COMPLEMENT_OF();
    return (profile != null)  &&
        profile.isSupported( node, eg, OntClass.class )  &&
        comp != null &&
        eg.asGraph().contains( node, comp.asNode(), Node.ANY );
  }
};

代码示例来源:origin: org.apache.clerezza.ext/org.apache.jena.jena-core

@Override
  public boolean doCheck( Node n, EnhGraph g ) {
    return g.asGraph().contains( n, RDF.type.asNode(), OWL.Restriction.asNode() ) &&
    containsSome( g, n, OWL.allValuesFrom ) &&
    containsSome( g, n, OWL.onProperty );
  }
}

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

@Test public void update2()
{
  Graph g = create() ;
  g.getBulkUpdateHandler().add(new Triple[]{t1}) ;
  assertTrue(g.contains(t1)) ;
  g.getBulkUpdateHandler().removeAll() ;
  assertFalse(g.contains(t1)) ;
}

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

@Test public void update4()
{
  Dataset ds = TDBFactory.createDataset() ;
  
  ds.asDatasetGraph().getDefaultGraph().add(t1) ;
  ds.getNamedModel(graphName).getGraph().add(t1) ;
  
  Model m = ds.getNamedModel(graphName) ;
  m.removeAll() ;
  assertEquals(0, m.size()) ;
  
  // But still in the other graph
  assertTrue(ds.getDefaultModel().getGraph().contains(t1)) ;
}

相关文章