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

x33g5p2x  于2022-01-28 转载在 其他  
字(8.6k)|赞(0)|评价(0)|浏览(119)

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

Resource.equals介绍

[英]Determine whether two objects represent the same resource.

A resource can only be equal to another resource. If both resources are not anonymous, then they are equal if the URI's are equal. If both resources are anonymous, they are equal only if there Id's are the same. If one resource is anonymous and the other is not, then they are not equal.
[中]确定两个对象是否代表同一资源。
一个资源只能与另一个资源相等。如果两个资源都不是匿名的,那么如果URI相等,它们就相等。如果两个资源都是匿名的,则只有当Id相同时,它们才是相等的。如果一个资源是匿名的,而另一个不是匿名的,那么它们是不相等的。

代码示例

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

protected boolean same( Frame other )
  { 
  return root.equals( other.root )
    && type.equals( other.type )
    && assembler.equals( other.assembler )
    ; 
  }

代码示例来源:origin: org.openscience.cdk/cdk-iordf

/**
 * Converts a {@link Resource} object into the matching {@link Order}.
 *
 * @param rdfOrder Resource for which the matching {@link Order} should be given.
 * @return the matching {@link Order}.
 */
public static Order resource2Order(Resource rdfOrder) {
  if (rdfOrder.equals(CDK.SINGLEBOND)) {
    return Order.SINGLE;
  } else if (rdfOrder.equals(CDK.DOUBLEBOND)) {
    return Order.DOUBLE;
  } else if (rdfOrder.equals(CDK.TRIPLEBOND)) {
    return Order.TRIPLE;
  } else if (rdfOrder.equals(CDK.QUADRUPLEBOND)) {
    return Order.QUADRUPLE;
  }
  return null;
}

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

@Override
protected void blockRule(Resource r) {
  if (r.equals(RDFSyntax.sectionReification)) sReification=true;
  // else if (r.equals(RDFSyntax.resourcePropertyElt)) sResourcePropertyElt=true;
  else if (r.equals(RDFSyntax.sectionListExpand)) sListExpand=true;
  else if (r.equals(RDFSyntax.parseTypeLiteralPropertyElt)) sParseTypeLiteralPropertyElt=true;
  else if (r.equals(RDFSyntax.parseTypeResourcePropertyElt)) sParseTypeResourcePropertyElt=true;
  else if (r.equals(RDFSyntax.parseTypeCollectionPropertyElt)) sParseTypeCollectionPropertyElt=true;
  else if (r.equals(RDFSyntax.idAttr)) {
    sIdAttr=true;
    sReification = true;
  }
  else if (r.equals(RDFSyntax.propertyAttr)) sPropertyAttr=true;
  //else if (r.equals(DAML_OIL.collection)) sDamlCollection=true;
  else {
    logger.warn("Cannot block rule <"+r.getURI()+">");
  }
}
@Override

代码示例来源:origin: org.smartdeveloperhub.curator/sdh-curator-connector

private void addPendingResource(Resource resource) {
  if(!this.resource.equals(resource) && !this.pendingResources.contains(resource) && !this.parsedResources.contains(resource)) {
    LOGGER.trace("    + Added pending resource {}",resource);
    this.pendingResources.add(resource);
  }
}

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

public static Mode decode( Resource root, Mode defaultMode ) {
    if (root == null) return defaultMode;
    Statement s = root.getProperty( ELDA_API.shortnameMode );
    if (s == null) return defaultMode;
    Resource mode = s.getResource();
    return
      mode.equals(ELDA_API.preferPrefixes) ? CompleteContext.Mode.PreferPrefixes
      : mode.equals(ELDA_API.preferLocalnames) ? CompleteContext.Mode.PreferLocalnames
      : mode.equals(ELDA_API.roundTrip) ? CompleteContext.Mode.RoundTrip
      : defaultMode
      ;
  }
}

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

private static boolean hasNoCompetingSubclass( List<RDFNode> types, Resource candidate )
  {
  for (int j = 0; j < types.size(); j += 1)
    {
    Resource other = (Resource) types.get( j );
    if (other.hasProperty( RDFS.subClassOf, candidate ) && !candidate.equals( other )) return false;
    }
  return true;
  }

代码示例来源:origin: DSpace/DSpace

protected String parseResourceGenerator(Resource resourceGenerator,
                    String value, String dsoIRI) {
  if (resourceGenerator.isURIResource()
    && resourceGenerator.equals(DMRM.DSpaceObjectIRI)) {
    return dsoIRI;
  }
  return parseValueProcessor(resourceGenerator, value);
}

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

/**
  sameAs - is this statement equal to the statement o? We can't assume
  o is a StatementImpl
*/
private final boolean sameAs( Statement o )
  { 
  return subject.equals( o.getSubject() ) 
    && predicate.equals( o.getPredicate() )
    && object.equals( o.getObject() );
  }

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

@Override protected void blockRule( Resource r ) {
  if (r.equals( RDFSyntax.parseTypeLiteralPropertyElt )) {
 //       System.err.println("Blocking");
    blockLiterals = true;
  } else
    logger.warn("Cannot block rule <"+r.getURI()+">");
}

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

private boolean isFitForRendering(Set<Resource> itemSet, Map.Entry<Resource, JSONLDComposer.Int> e, Resource i) {
  return e.getValue().value() > 1 
  && !itemSet.contains(i) 
  && i.listProperties().hasNext()
  && !i.equals(root);
}

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

/** @return The index of the child node with the given property, or -1 if not found */
protected int indexOfChildProperty( Property prop ) {
  int index = -1;
  for (int i = 0; index < 0 && i < children().size(); i++) {
    DisplayHierarchyNode child = children().get( i );
    if (child.terminalLink().asResource().equals(  prop )) {
      index = i;
    }
  }
  return index;
}

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

/** Test whether a statement should be included in a selection.  This method
 * tests whether the supplied statement satisfies the subject, predicate and
 * object constraints of the selector and then tests whether it matches the
 * application provided <CODE>selects</CODE> method.
 * @param s the statement to be tested
 * @return true if the statement satisfies the subject, object
 * and predicate constraints and the selects constraint.
 */
@Override
public boolean test(Statement s) {
  return (subject == null || subject.equals(s.getSubject()))
    && (predicate == null || predicate.equals(s.getPredicate()))
    && (object == null || object.equals(s.getObject()))
    && selects(s);
}

代码示例来源:origin: org.renci.ahab/libndl

private boolean isType(Resource r, Resource resourceClass){
  
  //Test for type of subject (if any)
  Resource candidateResourceClass = r.getProperty(new PropertyImpl("http://www.w3.org/1999/02/22-rdf-syntax-ns#type")).getResource();

  if(candidateResourceClass != null && candidateResourceClass.equals(resourceClass)){
    return true;
  }
  return false;
  
}

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

/**
  Answer true if <code>v</code> is a list, which here is defined to
  be "a resource which is nil or has an rdf:first or is of type rdf:List". 
*/
public static boolean isList(RDFNode l) {
  if (l.isLiteral()) return false;    	
  Resource r = (Resource) l;
  return 
    r.equals( RDF.nil )
    || r.hasProperty( RDF.first )
    || r.hasProperty( RDF.type, RDF.List ) 
    ;   
}

代码示例来源:origin: culturecommunication/ginco

public boolean selects(Statement s) {
    if (s.getObject().isResource()) {
      return s.getObject().asResource()
          .equals(SKOS.CONCEPTSCHEME);
    } else {
      return false;
    }
  }
};

代码示例来源:origin: culturecommunication/ginco

public boolean selects(Statement s) {
    if (s.getObject().isResource()) {
      Resource res = s.getObject().asResource();
      return res.equals(FOAF.Organization);
    } else {
      return false;
    }
  }
};

代码示例来源:origin: net.sourceforge.owlapi/pellet-jena-ignazio1977

private ATermList createList(Resource r) {
  if(r.equals(RDF.nil))
    return ATermUtils.EMPTY_LIST;
  else if(!rawModel.contains(r, RDF.first)) {
    System.err.println("Invalid list structure: List " + r
        + " does not have a rdf:first property. Ignoring rest of the list.");
    return ATermUtils.EMPTY_LIST;
  }
  ATerm first = node2term(rawModel.getProperty(r, RDF.first).getObject());
  Resource rest = rawModel.getProperty(r, RDF.rest).getResource();
  return ATermUtils.makeList(first, createList(rest));
} // createList

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

protected Iterator<RDFNode> rdfListIterator(Resource r)
{
  List<RDFNode> list = new ArrayList<RDFNode>() ;
  for ( ; ! r.equals(RDF.nil); )
  {
    StmtIterator sIter = r.getModel().listStatements(r, RDF.first, (RDFNode)null) ;
    list.add(sIter.nextStatement().getObject()) ;
    if ( sIter.hasNext() )
      // @@ need to cope with this (unusual) case
      throw new JenaException("N3: Multi valued list item") ;
    sIter = r.getModel().listStatements(r, RDF.rest, (RDFNode)null) ;
    r = (Resource)sIter.nextStatement().getObject() ;
    if ( sIter.hasNext() )
      throw new JenaException("N3: List has two tails") ;
  }
  return list.iterator() ;
}

代码示例来源:origin: culturecommunication/ginco

public boolean selects(Statement s) {
    if (s.getObject().isResource()
        && !s.getSubject().hasProperty(RDF.type, OWL.Class)
        && !s.getSubject().hasProperty(RDF.type,
        OWL.ObjectProperty)
        && !s.getSubject().hasProperty(RDF.type,
        OWL.DatatypeProperty)) {
      return s.getObject().asResource().equals(resource);
    } else {
      return false;
    }
  }
};

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

@Test
public void testTermBindings() {
  List<Binding<Resource>> bindings = page.termBindings();
  boolean found = false;
  for (Binding<Resource> b: bindings) {
    if (b.label().equals( "playTimeMinutes")) {
      assertTrue( b.value().equals( ResourceFactory.createResource( "http://epimorphics.com/public/vocabulary/games.ttl#playTimeMinutes" ) ));
      found = true;
    }
  }
  assertTrue( found );
}

相关文章