当前位置: 首页>>代码示例>>Java>>正文


Java Statement.getObject方法代码示例

本文整理汇总了Java中org.apache.jena.rdf.model.Statement.getObject方法的典型用法代码示例。如果您正苦于以下问题:Java Statement.getObject方法的具体用法?Java Statement.getObject怎么用?Java Statement.getObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.jena.rdf.model.Statement的用法示例。


在下文中一共展示了Statement.getObject方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: filterBinaryReferences

import org.apache.jena.rdf.model.Statement; //导入方法依赖的package包/类
/**
 * Filter out the binary resource references from the model
 * @param uri the URI for the resource
 * @param model the RDF Model of the resource
 * @return the RDF model with no binary references
 * @throws FcrepoOperationFailedException
 * @throws IOException
 */
private void filterBinaryReferences(final URI uri, final Model model) throws IOException,
        FcrepoOperationFailedException {

    final List<Statement> removeList = new ArrayList<>();
    for (final StmtIterator it = model.listStatements(); it.hasNext();) {
        final Statement s = it.nextStatement();

        final RDFNode obj = s.getObject();
        if (obj.isResource() && obj.toString().startsWith(repositoryRoot.toString())
                && !s.getPredicate().toString().equals(REPOSITORY_NAMESPACE + "hasTransactionProvider")) {
            try (final FcrepoResponse resp = client().head(URI.create(obj.toString())).disableRedirects()
                    .perform()) {
                checkValidResponse(resp, URI.create(obj.toString()), config.getUsername());
                final List<URI> linkHeaders = resp.getLinkHeaders("type");
                if (linkHeaders.contains(binaryURI)) {
                    removeList.add(s);
                }
            }
        }
    }

    model.remove(removeList);
}
 
开发者ID:fcrepo4-labs,项目名称:fcrepo-import-export,代码行数:32,代码来源:Exporter.java

示例2: mergeDescription

import org.apache.jena.rdf.model.Statement; //导入方法依赖的package包/类
private void mergeDescription(Resource ir, Resource r, boolean flagOK, Map<RDFNode,RDFNode> visited) {
	for (StmtIterator si = r.listProperties(); si.hasNext(); ) {
		Statement stmt = si.nextStatement();
		Property p = stmt.getPredicate();
		RDFNode o = stmt.getObject();
		
		if (flagOK && r.hasProperty(RDF.type, OWL.Class))
			ir.addProperty(RDF.type, infModel.getResource(Gloze.OK));
		
		if (o.isLiteral()) 
			ir.addProperty(p,o);
		
		else if (!o.isAnon())
			ir.addProperty(p,infModel.createResource(((Resource)o).getURI()));
		
		else if (o.isAnon() && visited.containsKey(o))
			ir.addProperty(p,visited.get(o));

		else { // recursively merge anonymous objects
			Resource a = infModel.createResource();
			visited.put(o,a);
			ir.addProperty(p,a);
			mergeDescription(a, (Resource)o, false, visited);
		}
	}
}
 
开发者ID:stevebattle,项目名称:Gloze,代码行数:27,代码来源:Context.java

示例3: mergeData

import org.apache.jena.rdf.model.Statement; //导入方法依赖的package包/类
public void mergeData(Model mainConferenceModel) {
	StmtIterator stmtIterator = dataModel.listStatements();
	while (stmtIterator.hasNext()) {
		Statement stmt = stmtIterator.next();
		RDFNode object = stmt.getObject();
		if (object.isLiteral()) {
			if (!mainConferenceModel.contains(stmt.getSubject(),
					stmt.getPredicate(), (RDFNode) null)) {
				mainConferenceModel.add(stmt);
			}
		} else {
			if (!mainConferenceModel.contains(stmt))
				mainConferenceModel.add(stmt);
		}
	}
}
 
开发者ID:AnLiGentile,项目名称:cLODg,代码行数:17,代码来源:DataHandler.java

示例4: getModelKeyWords

import org.apache.jena.rdf.model.Statement; //导入方法依赖的package包/类
/**
 * Extracts the key words from the model's statements.
 * This includes the Literals and the localNames of Resources and Predicates.
 * 
 * @param model Model to extract key words
 * @return List of key word strings
 */
 public List<String> getModelKeyWords(Model model) {

List<String> keyWords = new ArrayList<String>();
StmtIterator statementIter = model.listStatements();
Statement s;
Property predicate;
RDFNode object;

while (statementIter.hasNext()) {
  s = statementIter.nextStatement();
  predicate = s.getPredicate();
  object = s.getObject();
	
  keyWords.add(predicate.getLocalName());

  // local name of (non blank nodes) Resources
  if (object instanceof Resource && object.toString().contains("/")) {
	keyWords.add(object.asResource().getLocalName());
	  
  } else if (object instanceof Literal) {
	// object is a Literal
	keyWords.add(object.toString());
  }
 }
 return keyWords;
}
 
开发者ID:thingweb,项目名称:thingweb-directory,代码行数:34,代码来源:ThingDescriptionUtils.java

示例5: getProperty

import org.apache.jena.rdf.model.Statement; //导入方法依赖的package包/类
public static RDFNode getProperty(Resource subject, Property predicate) {
	Statement s = subject.getProperty(predicate);
	if(s != null) {
		return s.getObject();
	}
	else {
		return null;
	}
}
 
开发者ID:TopQuadrant,项目名称:shacl,代码行数:10,代码来源:JenaUtil.java

示例6: getLocalParameters

import org.apache.jena.rdf.model.Statement; //导入方法依赖的package包/类
@Override
public Map<Property, Parameter> getLocalParameters()
{
    Map<Property, Parameter> args = new HashMap<>();
    
    StmtIterator it = listProperties(LDT.param);
    try
    {
        while(it.hasNext())
        {
            Statement stmt = it.next();
            if (!stmt.getObject().canAs(Parameter.class))
            {
                if (log.isErrorEnabled()) log.error("Unsupported Argument '{}' for Template '{}' (rdf:type ldt:Parameter missing)", stmt.getObject(), getURI());
                throw new OntologyException("Unsupported Argument '" + stmt.getObject() + "' for Template '" + getURI() + "' (rdf:type ldt:Parameter missing)");
            }

            Parameter arg = stmt.getObject().as(Parameter.class);
            if (args.containsKey(arg.getPredicate()))
            {
                if (log.isErrorEnabled()) log.error("Multiple Arguments with the same predicate '{}' for Template '{}' ", arg.getPredicate(), getURI());
                throw new OntologyException("Multiple Arguments with the same predicate '" + arg.getPredicate() + "' for Template '" + getURI() + "'");
            }
            
            args.put(arg.getPredicate(), arg);
        }
    }
    finally
    {
        it.close();
    }
    
    return args;
}
 
开发者ID:AtomGraph,项目名称:Processor,代码行数:35,代码来源:TemplateImpl.java

示例7: createIndividual

import org.apache.jena.rdf.model.Statement; //导入方法依赖的package包/类
private Model createIndividual(VirtualEntity virtualEntity) {
        // some definitions
        String personURI = "http://somewhere/JohnSmith";
        String givenName = "John";
        String familyName = "Smith";
        String fullName = givenName + " " + familyName;

// create an empty Model
        Model model = ModelFactory.createDefaultModel();

// create the resource
//   and add the properties cascading style
        Resource johnSmith
                = model.createResource(personURI)
                        .addProperty(VCARD.FN, fullName)
                        .addProperty(VCARD.N,
                                model.createResource()
                                        .addProperty(VCARD.Given, givenName)
                                        .addProperty(VCARD.Family, familyName));

        // list the statements in the Model
        StmtIterator iter = model.listStatements();

// print out the predicate, subject and object of each statement
        while (iter.hasNext()) {
            Statement stmt = iter.nextStatement();  // get next statement
            Resource subject = stmt.getSubject();     // get the subject
            Property predicate = stmt.getPredicate();   // get the predicate
            RDFNode object = stmt.getObject();      // get the object

            System.out.print(subject.toString());
            System.out.print(" " + predicate.toString() + " ");
            if (object instanceof Resource) {
                System.out.print(object.toString());
            } else {
                // object is a literal
                System.out.print(" \"" + object.toString() + "\"");
            }

            System.out.println(" .");
        }

        return model;
    }
 
开发者ID:nailtonvieira,项目名称:cloudsemanticwot,代码行数:45,代码来源:DataConnectorImpl.java

示例8: toXML

import org.apache.jena.rdf.model.Statement; //导入方法依赖的package包/类
public boolean toXML(Element e, RDFNode rdf, Set<Statement> pending, Context ctx) {
	if (rdf instanceof Resource) {
		Resource r = ((Resource)rdf);
		// add simple content encoded as rdf:value
		Statement s = r.getProperty(RDF.value);
		if (extension!=null) extension.toXML(e,r,pending,ctx);
		else if (restriction!=null) restriction.toXML(e,r,pending,ctx);
		else if (s!=null && s.getObject() instanceof Literal) {
			Literal l = (Literal) s.getObject();
			e.appendChild(e.getOwnerDocument().createTextNode(l.getString()));
		}
		return true;
	}
	return false;
}
 
开发者ID:stevebattle,项目名称:Gloze,代码行数:16,代码来源:simpleContent.java

示例9: holdsRole

import org.apache.jena.rdf.model.Statement; //导入方法依赖的package包/类
public Set<Role> holdsRole(){
	Set<Role> roles = new HashSet<Role>();
	StmtIterator iterator = resource.listProperties(ModelFactory.createDefaultModel().createProperty("http://data.semanticweb.org/ns/swc/ontology#holdsRole"));
	while(iterator.hasNext()){
		Statement stmt = iterator.next();
		Resource roleResource = ((Resource)stmt.getObject());
		roles.add(new Role(roleResource));
	}
	
	return roles;
}
 
开发者ID:AnLiGentile,项目名称:cLODg,代码行数:12,代码来源:Person.java

示例10: swdfAffiliations

import org.apache.jena.rdf.model.Statement; //导入方法依赖的package包/类
public Set<Organisation> swdfAffiliations(){
	Set<Organisation> orgs = new HashSet<Organisation>();
	StmtIterator iterator = resource.listProperties(ModelFactory.createDefaultModel().createProperty("http://swrc.ontoware.org/ontology#affiliation"));
	while(iterator.hasNext()){
		Statement stmt = iterator.next();
		Resource organisationResource = ((Resource)stmt.getObject());
		orgs.add(new Organisation(organisationResource));
	}
	
	return orgs;
}
 
开发者ID:AnLiGentile,项目名称:cLODg,代码行数:12,代码来源:Person.java

示例11: printSPARQLStatement

import org.apache.jena.rdf.model.Statement; //导入方法依赖的package包/类
/**
 * @param stmt
 */
public static void printSPARQLStatement(Statement stmt, OutputStreamWriter osw) {

  if (logger.isDebugEnabled()) {
    logger.debug("printSPARQLStatement: stmt: {}", stmt);
  }

  StringBuffer buf = new StringBuffer();
  buf.append("  <");
  buf.append(stmt.getSubject().getURI());
  buf.append("> <");
  buf.append(stmt.getPredicate().getURI());
  buf.append("> ");
  RDFNode objNode = stmt.getObject();
  if (objNode.isURIResource())
    buf.append("<").append(objNode.asResource().getURI()).append(">");
  else {
    RDFDatatype dt = objNode.asLiteral().getDatatype();
    if ( logger.isDebugEnabled()) {
      logger.debug("printSPARQLStatement: literal datatype URI: {}, java class: {}", dt.getURI(), dt.getJavaClass());
    }

    if (dt.getURI().equals(XSDDatatype.XSDstring.getURI())) {
      buf.append("\"").append(sparqlEscape(objNode.asLiteral().getString())).append("\"");
      if (StringUtils.isNotEmpty(objNode.asLiteral().getLanguage()))
        buf.append("@").append(objNode.asLiteral().getLanguage());
    } else if (dt.getURI().equals(RDF.langString.getURI())) {
      buf.append("\"").append(sparqlEscape(objNode.asLiteral().getString())).append("\"");
      if (StringUtils.isNotEmpty(objNode.asLiteral().getLanguage()))
        buf.append("@").append(objNode.asLiteral().getLanguage());
    } else if (dt.getURI().equals(XSDDatatype.XSDboolean.getURI())) {
      buf.append(objNode.asLiteral().getBoolean());
    } else if (dt.getURI().equals(XSDDatatype.XSDint.getURI()) ||
        dt.getURI().equals(XSDDatatype.XSDinteger.getURI())) {
      buf.append(objNode.asLiteral().getInt());
    } else if (dt.getURI().equals(XSDDatatype.XSDlong.getURI())) {
      buf.append(objNode.asLiteral().getLong());
    } else if (dt.getURI().equals(XSDDatatype.XSDanyURI.getURI())) {
      buf.append("\"").append(objNode.asLiteral().getString()).append("\"^^<").append(XSDDatatype.XSDanyURI.getURI()).append(">");
    } else if (dt.getURI().equals(XSDDatatype.XSDdate.getURI())) {
      buf.append("\"").append(objNode.asLiteral().getLexicalForm()).append("\"^^<").append(XSDDatatype.XSDdate.getURI()).append(">");
    } else if (dt.getJavaClass() != null && dt.getJavaClass().getName() != null &&
        dt.getJavaClass().getName().equals("java.util.Date")) {
      buf.append("\"").append(dtfmt.format(objNode.asLiteral().getValue())).append("\"^^<").append(XSDDatatype.XSDdate.getURI()).append(">");
    } else {
      logger.warn("printSPARQLStatement: unrecognized literal datatype: {}", dt.getURI());
      buf.append("\"").append(sparqlEscape(objNode.asLiteral().getString())).append("\"");
    }
  }

  try {
    osw.append(buf.toString() + " .").append("\n");
  } catch (IOException ioe) {
    logger.error("failed to write statement for SPARQL", ioe);
  }
}
 
开发者ID:Smartlogic-Semaphore-Limited,项目名称:Java-APIs,代码行数:59,代码来源:JenaUtil.java

示例12: getEdgeTarget

import org.apache.jena.rdf.model.Statement; //导入方法依赖的package包/类
@Override
public RDFNode getEdgeTarget(Statement e) {
    return e.getObject();
}
 
开发者ID:SmartDataAnalytics,项目名称:SubgraphIsomorphismIndex,代码行数:5,代码来源:PseudoGraphJenaModel.java

示例13: createEdgePalette

import org.apache.jena.rdf.model.Statement; //导入方法依赖的package包/类
protected ColourPalette createEdgePalette(Model model) {
    RDFNode node;
    Resource resource1, resource2;
    StmtIterator sIterator = model.listStatements(null, RDFS.subPropertyOf, (RDFNode) null);
    Statement statement;
    HierarchyNode hNode1, hNode2;
    // Iterate over the class hierarchy triples
    while (sIterator.hasNext()) {
        statement = sIterator.next();
        resource1 = statement.getSubject();
        node = statement.getObject();
        if (node.isResource()) {
            resource2 = node.asResource();
            if (properties.containsKey(resource1)) {
                hNode1 = properties.get(resource1);
            } else {
                // this property is not known, add it
                hNode1 = new HierarchyNode();
                properties.put(resource1, hNode1);
            }
            if (properties.containsKey(resource2)) {
                hNode2 = properties.get(resource2);
            } else {
                // this property is not known, add it
                hNode2 = new HierarchyNode();
                properties.put(resource2, hNode2);
            }
            // add the hierarchy information
            // if there is no list of child nodes
            if (hNode1.childNodes == null) {
                hNode1.childNodes = new Resource[] { resource2 };
            } else {
                hNode1.childNodes = Arrays.copyOf(hNode1.childNodes, hNode1.childNodes.length + 1);
                hNode1.childNodes[hNode1.childNodes.length - 1] = resource2;
            }
            // if there is no list of parent nodes
            if (hNode2.parentNodes == null) {
                hNode2.parentNodes = new Resource[] { resource1 };
            } else {
                hNode2.parentNodes = Arrays.copyOf(hNode2.parentNodes, hNode2.parentNodes.length + 1);
                hNode2.parentNodes[hNode2.parentNodes.length - 1] = resource1;
            }
        }
    }

    // All properties have been collected
    // The colours can be defined
    for (int i = 0; i < properties.allocated.length; ++i) {
        if (properties.allocated[i]) {
            edgePalette.addColour(((Resource) ((Object[]) properties.keys)[i]).getURI());
        }
    }

    // The hierarchy can be used to create colour mixtures that contain the
    // hierarchy
    // Search for all root nodes that have child nodes
    for (int i = 0; i < properties.allocated.length; ++i) {
        if (properties.allocated[i]) {
            hNode1 = (HierarchyNode) ((Object[]) properties.values)[i];
            if ((hNode1.childNodes != null) && (hNode1.parentNodes == null)) {
                mixColours((Resource) ((Object[]) properties.keys)[i], hNode1, properties, edgePalette);
            }
        }
    }

    return edgePalette;
}
 
开发者ID:dice-group,项目名称:Lemming,代码行数:68,代码来源:GraphCreator.java

示例14: getSubject

import org.apache.jena.rdf.model.Statement; //导入方法依赖的package包/类
@Override
public RDFNode getSubject() {
	Statement s = getProperty(SH.subject);
	return s != null ? s.getObject() : null;
}
 
开发者ID:TopQuadrant,项目名称:shacl,代码行数:6,代码来源:SHRuleImpl.java

示例15: getObject

import org.apache.jena.rdf.model.Statement; //导入方法依赖的package包/类
@Override
public RDFNode getObject() {
	Statement s = getProperty(SH.object);
	return s != null ? s.getObject() : null;
}
 
开发者ID:TopQuadrant,项目名称:shacl,代码行数:6,代码来源:SHRuleImpl.java


注:本文中的org.apache.jena.rdf.model.Statement.getObject方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。