當前位置: 首頁>>代碼示例>>Java>>正文


Java Property類代碼示例

本文整理匯總了Java中org.apache.jena.rdf.model.Property的典型用法代碼示例。如果您正苦於以下問題:Java Property類的具體用法?Java Property怎麽用?Java Property使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Property類屬於org.apache.jena.rdf.model包,在下文中一共展示了Property類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: print

import org.apache.jena.rdf.model.Property; //導入依賴的package包/類
public void print(PrintStream ps, boolean printChildren) {
  Property nameProperty = model.getProperty("http://example.com/owl/csvtupler/map2sparql#","name");
  Statement nameStatement = resource.getProperty(nameProperty);

  Property rootProperty = model.getProperty("http://example.com/owl/csvtupler/map2sparql#","root");
  Statement rootStatement = resource.getProperty(rootProperty);
  if (rootStatement != null) {
    ps.print("Root node:\t");
  }
  ps.print("Node: "+name+"\n");

  if (printChildren) {
    Iterator iter = getChildren().iterator();
    while (iter.hasNext()) {
      ps.print("\t");
      ((Node)iter.next()).print(ps,printChildren);
    }
  }
}
 
開發者ID:tag42git,項目名稱:CsvTupler,代碼行數:20,代碼來源:Node.java

示例2: testConceptGroupedDiff

import org.apache.jena.rdf.model.Property; //導入依賴的package包/類
@Test
public void testConceptGroupedDiff() throws IOException {

  Model model2 = hydrateAndModifySecondModel();

  List<Property> chaseProperties = Lists.newArrayList();
  chaseProperties.add(SKOSXL.prefLabel);
  chaseProperties.add(SKOSXL.altLabel);
  Collection<RDFSubjectDifference> diffs = RDFDifferenceBuilder.buildSubjectBatches(
      RDFDifferenceBuilder.buildDifference(model, model2), chaseProperties);

  for (RDFSubjectDifference subjDiff : diffs) {
    String sparql = DiffToSparqlInsertUpdateBuilder.buildSparqlInsertUpdate(subjDiff);
    System.out.println("Batch for subject: " + subjDiff.subject.toString());
    System.out.println(sparql);
  }
}
 
開發者ID:Smartlogic-Semaphore-Limited,項目名稱:Java-APIs,代碼行數:18,代碼來源:DiffToSparqlInsertUpdateBuilderTests.java

示例3: fillTrie

import org.apache.jena.rdf.model.Property; //導入依賴的package包/類
@Override
protected void fillTrie(Logger logger, Trie<Resource> trie, Corpus corpus) throws IOException, ModuleException {
	Model model = createModel(logger);
	Property typeProp = model.getProperty("http://www.w3.org/1999/02/22-rdf-syntax-ns#type");
	Property[] labelPropertyProps = getProperties(model, labelURIs);
	int nEntries = 0;
	for (String resourceTypeURI : resourceTypeURIs) {
		Property resourceType = model.getProperty(model.expandPrefix(resourceTypeURI));
		for (Resource res : Iterators.loop(model.listSubjectsWithProperty(typeProp , resourceType))) {
			if (res.isAnon()) {
				continue;
			}
			for (Property prop : labelPropertyProps) {
				for (RDFNode node : Iterators.loop(model.listObjectsOfProperty(res, prop))) {
					String label = getNodeValue(node);
					trie.addEntry(label, res);
					nEntries++;
				}
			}
		}
	}
	logger.info("Entries: " + nEntries);
}
 
開發者ID:Bibliome,項目名稱:alvisnlp,代碼行數:24,代碼來源:RDFProjector.java

示例4: getJenaModel

import org.apache.jena.rdf.model.Property; //導入依賴的package包/類
private Model getJenaModel(@NonNull org.eclipse.rdf4j.model.Model model) {
  Model jenaModel = ModelFactory.createDefaultModel();
  java.util.Iterator<org.eclipse.rdf4j.model.Statement> iterator = model.iterator();

  while (iterator.hasNext()) {
    org.eclipse.rdf4j.model.Statement rdf4jStatement = iterator.next();

    // create resource / subject
    Resource resource = rdf4jResourceToJenaResource(jenaModel, rdf4jStatement.getSubject());
    // create property / predicate
    Property property =
        rdf4jPropertyToJenaProperty(jenaModel, (SimpleIRI) rdf4jStatement.getPredicate());
    // create rdfnode / object
    RDFNode node = rdf4jValueToJenaRdfNode(jenaModel, rdf4jStatement.getObject());

    Statement statement = ResourceFactory.createStatement(resource, property, node);
    jenaModel.add(statement);
  }
  return jenaModel;
}
 
開發者ID:dotwebstack,項目名稱:dotwebstack-framework,代碼行數:21,代碼來源:ShaclValidator.java

示例5: addTriple

import org.apache.jena.rdf.model.Property; //導入依賴的package包/類
@Override
public void addTriple(CrawleableUri uri, Triple triple) {
    String uriString = uri.getUri().toString();
    if (rdfData.containsKey(uriString)) {
        Model model = rdfData.get(uriString);
        Resource s;
        Node n = triple.getSubject();
        if (n.isBlank()) {
            s = model.createResource(new AnonId(triple.getSubject().getBlankNodeId()));
        } else {
            s = model.createResource(triple.getSubject().getURI());
        }
        Property p = model.createProperty(triple.getPredicate().getURI());
        if (triple.getObject().isURI()) {
            model.add(s, p, model.createResource(triple.getObject().getURI()));
        } else if (triple.getObject().isBlank()) {
            model.add(s, p, model.createResource(new AnonId(triple.getObject().getBlankNodeId())));
        } else {
            model.add(s, p, triple.getObject().getLiteralValue().toString());
        }
    } else {
        LOGGER.error("Called to add a triple to the URI \"" + uriString + "\" which has never been opened.");
        healthyness = false;
    }
}
 
開發者ID:dice-group,項目名稱:Squirrel,代碼行數:26,代碼來源:InMemorySink.java

示例6: makeSampleModel

import org.apache.jena.rdf.model.Property; //導入依賴的package包/類
private static Model makeSampleModel() {
	String BASE = "http://example/";
	
	Model model = ModelFactory.createDefaultModel();
	model.setNsPrefix("", BASE);
	Resource r1 = model.createResource(BASE + "r1");
	Resource r2 = model.createResource(BASE + "r2");
	Property p1 = model.createProperty(BASE + "p");
	Property p2 = model.createProperty(BASE + "p2");
	RDFNode v1 = model.createTypedLiteral("1", XSDDatatype.XSDinteger);
	RDFNode v2 = model.createTypedLiteral("2", XSDDatatype.XSDinteger);

	r1.addProperty(p1, v1).addProperty(p1, v2);
	r1.addProperty(p2, v1).addProperty(p2, v2);
	r2.addProperty(p1, v1).addProperty(p1, v2);

	return model;
}
 
開發者ID:iotoasis,項目名稱:SDA,代碼行數:19,代碼來源:SDADatasetAccessor.java

示例7: GraphCreator

import org.apache.jena.rdf.model.Property; //導入依賴的package包/類
public GraphCreator() {
    // Initialize the classes
    classes = new ObjectObjectOpenHashMap<Resource, HierarchyNode>();
    classes.put(RDFS.Class, new HierarchyNode());
    classes.put(OWL.Class, new HierarchyNode());
    classes.put(RDF.Property, new HierarchyNode());
    vertexPalette = new InMemoryPalette();
    vertexPalette.addColour(RDFS.Class.getURI());
    vertexPalette.setColour(OWL.Class.getURI(), vertexPalette.getColour(RDFS.Class.getURI()));
    vertexPalette.addColour(RDF.Property.getURI());
    // Initialize the properties
    properties = new ObjectObjectOpenHashMap<Resource, HierarchyNode>();
    properties.put(RDF.type, new HierarchyNode());
    edgePalette = new InMemoryPalette();
    edgePalette.addColour(RDF.type.getURI());
}
 
開發者ID:dice-group,項目名稱:Lemming,代碼行數:17,代碼來源:GraphCreator.java

示例8: createParamValueBeans

import org.apache.jena.rdf.model.Property; //導入依賴的package包/類
private static void createParamValueBeans(Model model, Resource taskResource, NodeIterator parameterIterator,
        Map<String, ConfigurationParamValueBean> parameters) {
    RDFNode node;
    Resource parameter;
    Property paraProp;
    String parameterUri;
    while (parameterIterator.hasNext()) {
        node = parameterIterator.next();
        if (node.isResource()) {
            parameter = node.asResource();
            parameterUri = parameter.getURI();
            paraProp = model.getProperty(parameterUri);
            if (model.contains(taskResource, paraProp) && !parameters.containsKey(parameterUri)) {
                ConfigurationParamValueBean paramBean = new ConfigurationParamValueBean();
                paramBean.setId(parameterUri);
                paramBean.setValue(RdfHelper.getStringValue(model, taskResource, paraProp));
                parameters.put(parameterUri, paramBean);
            }
        }
    }
}
 
開發者ID:hobbit-project,項目名稱:platform,代碼行數:22,代碼來源:RdfModelHelper.java

示例9: getTriples

import org.apache.jena.rdf.model.Property; //導入依賴的package包/類
/**
 * Gets all triples for resource r and property p. If outgoing is true it
 * returns all triples with <r,p,o>, else <s,p,r>
 *
 * @param r
 *            the resource
 * @param p
 *            the property
 * @param outgoing
 *            whether to get outgoing or ingoing triples
 * @return A set of triples
 */
public Set<Triple> getTriples(Resource r, Property p, boolean outgoing) {
	Set<Triple> result = new HashSet<Triple>();
	try {
		String q;
		if (outgoing) {
			q = "SELECT ?o where { <" + r.getURI() + "> <" + p.getURI() + "> ?o." + "?o rdfs:label []}";
		} else {
			q = "SELECT ?o where { ?o <" + p.getURI() + "> <" + r.getURI() + ">." + "?o rdfs:label []}";
		}
		q += " LIMIT " + maxShownValuesPerProperty + 1;
		QueryExecution qe = qef.createQueryExecution(q);
		ResultSet results = qe.execSelect();
		if (results.hasNext()) {
			while (results.hasNext()) {
				RDFNode n = results.next().get("o");
				result.add(Triple.create(r.asNode(), p.asNode(), n.asNode()));
			}
		}
		qe.close();
	} catch (Exception e) {
		e.printStackTrace();
	}
	return result;
}
 
開發者ID:dice-group,項目名稱:BENGAL,代碼行數:37,代碼來源:Verbalizer.java

示例10: rdfModelFor

import org.apache.jena.rdf.model.Property; //導入依賴的package包/類
protected Model rdfModelFor(Entry entry, boolean includeKey) {
    Model model = ModelFactory.createDefaultModel();
    Property entryNumberProperty = model.createProperty(SPEC_PREFIX + "entry-number-field");
    Property entryTimestampProperty = model.createProperty(SPEC_PREFIX + "entry-timestamp-field");
    Property itemProperty = model.createProperty(SPEC_PREFIX + "item-resource");

    String entryNumber = Integer.toString(entry.getEntryNumber());
    Resource resource = model.createResource(entryUri(entryNumber).toString())
            .addProperty(entryNumberProperty, entryNumber)
            .addProperty(entryTimestampProperty, entry.getTimestampAsISOFormat())
            .addProperty(itemProperty, model.createResource(itemUri(entry.getItemHashes().get(0).encode()).toString()));

    if (includeKey) {
        Property keyProperty = model.createProperty(SPEC_PREFIX + "key-field");
        resource.addProperty(keyProperty, entry.getKey());
    }

    model.setNsPrefix("register-metadata", SPEC_PREFIX);
    return model;
}
 
開發者ID:openregister,項目名稱:openregister-java,代碼行數:21,代碼來源:EntryTurtleWriter.java

示例11: addAllValuesFrom

import org.apache.jena.rdf.model.Property; //導入依賴的package包/類
/**
 * @param cls
 *            class for which a all-values-from restriction is created
 * @param pi
 *            property
 * @param p
 *            ontology representation of the property
 */
protected void addAllValuesFrom(OntClass cls, PropertyInfo pi, Property p) {

	if (pi.matches(
			OWLISO19150.RULE_OWL_PROP_RANGE_LOCAL_UNIVERSAL_QUANTIFICATION)) {

		Resource range = this.rangeByPropertyInfo.get(pi);

		if (range != null) {

			OntClass restriction = ontmodel
					.createAllValuesFromRestriction(null, p, range);
			cls.addSuperClass(restriction);

		} else {
			/*
			 * The restriction is not created because the range is unknown
			 */
			MessageContext mc = result.addWarning(this, 35, pi.name());
			if (mc != null) {
				mc.addDetail(this, 10001, pi.fullName());
			}
		}
	}
}
 
開發者ID:ShapeChange,項目名稱:ShapeChange,代碼行數:33,代碼來源:OntologyModel.java

示例12: mapProperty

import org.apache.jena.rdf.model.Property; //導入依賴的package包/類
/**
 * Creates an ontology property (in the internal {@link #refmodel} - unless
 * it already exists in the refmodel), with namespace identified by looking
 * up the prefix of the QName in the configuration of namespaces. Also
 * creates an import of that namespace.
 * 
 * @param qname
 *            identifies a property
 * @return property identified by the qname
 */
private Property mapProperty(String qname) {

	String[] qnamePars = qname.split(":");
	String prefix = qnamePars[0];
	String propertyName = qnamePars[1];

	// identify rdf namespace based upon prefix and standard namespaces
	String rdfNs = config.fullNamespace(prefix);
	String location = config.locationOfNamespace(rdfNs);

	String uri = rdfNs + propertyName;
	Property p = refmodel.getProperty(uri);
	if (p == null)
		p = refmodel.createProperty(uri);

	// also add import for the namespace
	addImport(rdfNs, location);

	// return correct element definition
	return p;
}
 
開發者ID:ShapeChange,項目名稱:ShapeChange,代碼行數:32,代碼來源:OntologyModel.java

示例13: addProperties

import org.apache.jena.rdf.model.Property; //導入依賴的package包/類
public void addProperties(List<UDTValue> properties) {
  if (properties != null && !properties.isEmpty()) {
    for (UDTValue value : properties) {
      Property property = ResourceFactory.createProperty(value.getString("property"));
      RDFNode propertyValue;
      if (value.isNull("datatype")) {
        propertyValue = ResourceFactory.createResource(value.getString("value"));
      } else {
        propertyValue = ResourceFactory.createTypedLiteral(value.getString("value"),
            TypeMapper.getInstance().getSafeTypeByName(value.getString("datatype")));
      }

      addProperty(property, propertyValue);
    }
  }
}
 
開發者ID:semiotproject,項目名稱:semiot-platform,代碼行數:17,代碼來源:CommandResult.java

示例14: toRDF

import org.apache.jena.rdf.model.Property; //導入依賴的package包/類
public boolean toRDF(Resource subject, Property prop, Node node, String value, Seq seq, Set<restriction> restrictions, Context ctx) 
throws Exception {
	schema xs = (schema) this.get_owner();
	String type = null;
	if (name!=null) type = createURI(name,subject.getModel(),ctx);
	
	if (_list!=null) 
		return _list.toRDF(subject, prop, seq, node, value, restrictions,ctx);
	else if (restriction != null) 
		return restriction.toRDF(subject, node, value, prop, seq, restrictions,ctx);
	else if (union!=null)
		return union.toRDF(subject,prop,node,value,seq, restrictions,ctx);

	if (value !=null && ctx.isPreserved()) value = value.trim();	
	return xs.toRDF(node,subject,prop,value,type,seq,restrictions,ctx);
}
 
開發者ID:stevebattle,項目名稱:Gloze,代碼行數:17,代碼來源:simpleType.java

示例15: activate

import org.apache.jena.rdf.model.Property; //導入依賴的package包/類
@Override
public void activate(final Collection<JenaPosLengthMatch> matches) throws IOException {
	final Model model = driver.getModel();
	final Property lengthProperty = model.getProperty(BASE_PREFIX + LENGTH);

	for (final JenaPosLengthMatch match : matches) {
		final Resource segment = match.getSegment();
		final int length = match.getLength().getInt();
		final int newLength = -length + 1;

		final Selector selector = new SimpleSelector(segment, lengthProperty, (RDFNode) null);
		final StmtIterator statementsToRemove = model.listStatements(selector);
		if (statementsToRemove.hasNext()) {
			final Statement oldStatement = statementsToRemove.next();
			model.remove(oldStatement);
		}
		
		final Statement newStatement = model.createLiteralStatement(segment, lengthProperty, newLength);
		model.add(newStatement);
	}
}
 
開發者ID:FTSRG,項目名稱:trainbenchmark,代碼行數:22,代碼來源:JenaTransformationRepairPosLength.java


注:本文中的org.apache.jena.rdf.model.Property類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。