本文整理汇总了Java中com.hp.hpl.jena.rdf.model.NodeIterator类的典型用法代码示例。如果您正苦于以下问题:Java NodeIterator类的具体用法?Java NodeIterator怎么用?Java NodeIterator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
NodeIterator类属于com.hp.hpl.jena.rdf.model包,在下文中一共展示了NodeIterator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getName
import com.hp.hpl.jena.rdf.model.NodeIterator; //导入依赖的package包/类
@Override
public String getName() {
NodeIterator ni;
try {
ni = KBObjectImpl.getBaseContextModel().listObjectsOfProperty(
((Individual)((VariableImpl)this).getCore()),
(OntProperty)((KBPredicateImpl)Constants.getInstance().RIF_VARNAME_PRED).getCore());
if (ni.hasNext()) {
return ni.next().asLiteral().getString();
}
} catch (Exception ex) {
Logger.getLogger(VariableImpl.class.getName()).log(Level.SEVERE, null, ex);
}
return "";
}
示例2: getScope
import com.hp.hpl.jena.rdf.model.NodeIterator; //导入依赖的package包/类
/**
* Finds all RTM_IN_SCOPE properties for this property and returns a
* collection containing the RDF URIs of the values as URILocators.
*/
private Collection getScope(RDFNode rdfprop, Model model)
throws JenaException, MalformedURLException {
Resource subject = (Resource) rdfprop;
Property prop = model.getProperty(RTM_IN_SCOPE);
NodeIterator it = model.listObjectsOfProperty(subject, prop);
ArrayList scope = new ArrayList();
while (it.hasNext()) {
Object o = it.next();
if (!(o instanceof Resource))
throw new RDFMappingException("Scoping topic must be specified by a resource, not by " + o);
Resource obj = (Resource) o;
LocatorIF loc = new URILocator(obj.getURI());
scope.add(loc);
}
return scope;
}
示例3: getType
import com.hp.hpl.jena.rdf.model.NodeIterator; //导入依赖的package包/类
private TopicIF getType(RDFNode rdfprop, Model model)
throws JenaException, MalformedURLException {
Resource subject = (Resource) rdfprop;
Property prop = model.getProperty(RTM_TYPE);
NodeIterator it = model.listObjectsOfProperty(subject, prop);
while (it.hasNext()) {
Resource obj = (Resource) it.next();
LocatorIF loc = new URILocator(obj.getURI());
TopicIF topic = topicmap.getTopicBySubjectIdentifier(loc);
if (topic == null) {
topic = builder.makeTopic();
topic.addSubjectIdentifier(loc);
}
return topic;
}
return null;
}
示例4: createSubjectMaps
import com.hp.hpl.jena.rdf.model.NodeIterator; //导入依赖的package包/类
private List<Resource> createSubjectMaps(Resource mappingResource, KR2RMLMapping kr2rmlMapping) throws JSONException {
List<Resource> subjectMapResources = new ArrayList<Resource>();
Property hasTrMapUri = model.getProperty(Uris.KM_HAS_TRIPLES_MAP_URI);
// Get all the triple maps
NodeIterator trMapsResItr = model.listObjectsOfProperty(mappingResource, hasTrMapUri);
while (trMapsResItr.hasNext()) {
Resource trMapRes = trMapsResItr.next().asResource();
SubjectMap subjMap = addSubjectMapForTripleMap(trMapRes, kr2rmlMapping, subjectMapResources);
// Add the Triples map
TriplesMap trMap = new TriplesMap(trMapRes.getURI(), subjMap);
kr2rmlMapping.getTriplesMapIndex().put(trMapRes.getURI(), trMap);
kr2rmlMapping.addTriplesMap(trMap);
kr2rmlMapping.getAuxInfo().getTriplesMapGraph().addTriplesMap(trMap);
}
return subjectMapResources;
}
示例5: getVariables
import com.hp.hpl.jena.rdf.model.NodeIterator; //导入依赖的package包/类
private List<String> getVariables(Model model, Resource service_resource) {
Property has_variable_property = model.getProperty(Namespaces.KARMA + "hasVariable");
List<String> variables = new ArrayList<String>();
NodeIterator nodeIterator = null;
RDFNode node = null;
// hasAttribute
nodeIterator = model.listObjectsOfProperty(service_resource, has_variable_property);
while ( nodeIterator.hasNext()) {
node = nodeIterator.next();
if (!node.isResource()) {
logger.info("object of the hasAttribute property is not a resource.");
continue;
}
variables.add(node.asResource().getLocalName());
}
return variables;
}
示例6: test_buildTblToTM_1
import com.hp.hpl.jena.rdf.model.NodeIterator; //导入依赖的package包/类
@Test
public void test_buildTblToTM_1() {
Model r2rml = readR2RML(r2rml1);
R2RMLSpec spec = new R2RMLSpec(r2rml);
Resource expectedTMSubject = ResourceFactory.createResource(prefix + "TriplesMap1");
NodeIterator tmpRes = r2rml.listObjectsOfProperty(expectedTMSubject, RR.logicalTable);
Resource expectedTblSubject = tmpRes.next().asResource();
LogicalTable logTbl = new LogicalTable(r2rml, expectedTblSubject);
Pair<LogicalTable, TriplesMap> expectedLtTm =
new Pair<LogicalTable, TriplesMap>(
logTbl, new TriplesMap(r2rml, expectedTMSubject));
int expectedNumLtTmEntries = 1;
Map<LogicalTable, Collection<TriplesMap>> tableToTMs =
R2RML2SMLConverter.buildTblToTM(spec);
assertEquals(expectedNumLtTmEntries, tableToTMs.size());
assertEquals(expectedNumLtTmEntries, tableToTMs.keySet().size());
Set<LogicalTable> tbls = tableToTMs.keySet();
assertTrue(tbls.contains(expectedLtTm.first));
Collection<TriplesMap> triplesMaps = tableToTMs.get(logTbl);
assertTrue(triplesMaps.contains(expectedLtTm.second));
}
示例7: generateQuadQualityProblem
import com.hp.hpl.jena.rdf.model.NodeIterator; //导入依赖的package包/类
@Test
public void generateQuadQualityProblem(){
qr = new QualityReport();
String qualityProblemURI = qr.createQualityProblem(metricURI, quadProblemList);
Model qualityProblem = qr.getProblemReportFromTBD(qualityProblemURI);
// checks if model contains appropriate data
assertEquals(14, qualityProblem.size());
assertTrue(qualityProblem.listStatements(null, RDF.type, QPRO.QualityProblem).hasNext());
assertTrue(qualityProblem.listStatements(null, QPRO.isDescribedBy, metricURI).hasNext());
NodeIterator objects = qualityProblem.listObjectsOfProperty(QPRO.problematicThing);
assertTrue(objects.hasNext());
RDFNode _node = objects.next();
assertTrue(_node.asNode().isBlank());
assertTrue(qualityProblem.listStatements(_node.asResource(), RDF.type, RDF.Statement).hasNext());
assertTrue(qualityProblem.listStatements(_node.asResource(), RDF.subject, (RDFNode) null).hasNext());
assertTrue(qualityProblem.listStatements(_node.asResource(), RDF.predicate, RDFS.label).hasNext());
assertTrue(qualityProblem.listStatements(_node.asResource(), RDF.object, (RDFNode) null).hasNext());
qr.flush();
}
示例8: NetworkingAdapter
import com.hp.hpl.jena.rdf.model.NodeIterator; //导入依赖的package包/类
public NetworkingAdapter(Model adapterModel, Resource adapterABox) {
this.uuid = UUID.randomUUID().toString();
this.adapterTBox = adapterModel;
this.adapterABox = adapterABox;
Resource adapterType =getAdapterClass();
this.adapterABox.addProperty(RDF.type,adapterType);
this.adapterABox.addProperty(RDFS.label, this.adapterABox.getLocalName());
this.adapterABox.addProperty(RDFS.comment, "A networking adapter that can create virtual link among resources.");
NodeIterator resourceIterator = this.adapterTBox.listObjectsOfProperty(Omn_lifecycle.implements_);
if (resourceIterator.hasNext()) {
Resource resource = resourceIterator.next().asResource();
this.adapterABox.addProperty(Omn_lifecycle.canImplement, resource);
this.adapterABox.getModel().add(resource.getModel());
ResIterator propertiesIterator = adapterTBox.listSubjectsWithProperty(RDFS.domain, resource);
while (propertiesIterator.hasNext()) {
Property p = adapterTBox.getProperty(propertiesIterator.next().getURI());
networkingControlProperties.add(p);
}
}
}
示例9: createInstances
import com.hp.hpl.jena.rdf.model.NodeIterator; //导入依赖的package包/类
@Override
public Model createInstances(Model model) throws ProcessingException, InvalidRequestException {
Model createdInstancesModel = super.createInstances(model);
LOGGER.warning("createInstances override method.");
String topologyUri = null;
NodeIterator objects = model.listObjectsOfProperty(Omn.isResourceOf);
if (objects.hasNext()) {
RDFNode object = objects.next();
topologyUri = object.asResource().getURI();
}
return createdInstancesModel;
}
示例10: setValue
import com.hp.hpl.jena.rdf.model.NodeIterator; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public <T> void setValue(T value, Type valueType)
{
if (_statement != null)
{
if (valueType instanceof Class<?>)
setValue(_statement, value, (Class<T>) valueType);
else if (valueType instanceof ParameterizedType)
{
ParameterizedType parameterizedType = (ParameterizedType) valueType;
if (parameterizedType.getRawType().equals(List.class) && (parameterizedType.getActualTypeArguments().length == 1))
{
Type actualTypeArgument = parameterizedType.getActualTypeArguments()[0];
List<Object> list = new LinkedList<Object>();
NodeIterator bagIterator = _statement.getBag().iterator();
// TODO
// while (bagIterator.hasNext())
// setValue(bagIterator.next(), (Class<?>) actualTypeArgument));
}
}
}
}
示例11: getAllTypes
import com.hp.hpl.jena.rdf.model.NodeIterator; //导入依赖的package包/类
public static Set<String> getAllTypes(Model model, String typePrefix) {
Resource rootResource = model.createResource(typePrefix);
com.hp.hpl.jena.rdf.model.Property classProperty = model.createProperty("http://dblab.cs.toronto.edu/project/xcurator/0.1#classes");
Bag classBag = model.createBag("http://dblab.cs.toronto.edu/project/xcurator/0.1#classBag");
model.add(rootResource, classProperty, classBag);
Set<String> ret = new HashSet<String>();
NodeIterator iterator = classBag.iterator();
while (iterator.hasNext()) {
Resource resource = (Resource) iterator.next();
ret.add(resource.getURI());
}
return ret;
}
示例12: checkPrecedence
import com.hp.hpl.jena.rdf.model.NodeIterator; //导入依赖的package包/类
public static boolean checkPrecedence(CompanyModel c) {
StmtIterator stmtit = c.getModel().listStatements(
new SimpleSelector(null, c.DEPTS, (RDFNode) null));
List<Resource> depts = new LinkedList<Resource>();
while (stmtit.hasNext()) {
NodeIterator subDeptsIt = stmtit.next().getBag().iterator();
while (subDeptsIt.hasNext())
depts.add(subDeptsIt.next().asResource());
}
for (Resource dept : depts) {
// get manager's salary
double managerSalary = dept.getProperty(c.MANAGER).getProperty(
c.SALARY).getDouble();
NodeIterator employeeIt = dept.getProperty(c.EMPLOYEES).getBag()
.iterator();
while (employeeIt.hasNext())
if (!(employeeIt.next().asResource().getProperty(c.SALARY)
.getDouble() < managerSalary))
return false;
}
return true;
}
示例13: getAllExcludes
import com.hp.hpl.jena.rdf.model.NodeIterator; //导入依赖的package包/类
/**
* exclude these words when enhancing.
*
* @param ocls
* @param additionalExcludes
* @return
*/
public List<String> getAllExcludes(OntClass ocls, String... additionalExcludes) {
List<String> excludeList = new ArrayList<String>(5);
AnnotationProperty apExclude = model.getAnnotationProperty(NS + "synExcludes"); //to add synExcludes to list
AnnotationProperty apSyn = model.getAnnotationProperty(NS + SynSuggestion.TYPE_SynInclude);// to add slreeady added synIncludes
AnnotationProperty apAsso = PO.AP_ASSOCIATON;
//add all additionalExcludes
if (additionalExcludes != null) {
for (int i = 0; i < additionalExcludes.length; i++) {
additionalExcludes[i] = additionalExcludes[i].toLowerCase();
}
Collections.addAll(excludeList, additionalExcludes);
}
// add syn excludes
NodeIterator itrExcludes = ocls.listPropertyValues(apExclude);
while (itrExcludes.hasNext()) {
String synExs = itrExcludes.next().asLiteral().getLexicalForm();
String synEx[] = synExs.split(",");
for (int i = 0; i < synEx.length; i++) {
synEx[i] = synEx[i].trim();
}
Collections.addAll(excludeList, synEx);
}
// add synIncludes
NodeIterator itrSyn = ocls.listPropertyValues(apSyn); // add to exclude list, already added synonyms also
while (itrSyn.hasNext()) {
excludeList.add(itrSyn.next().asLiteral().getLexicalForm());
}
//add association
NodeIterator itrAsso = ocls.listPropertyValues(apAsso);
while (itrAsso.hasNext()) {
excludeList.add(itrAsso.next().asLiteral().getLexicalForm());
}
logger.debug("exclude list:" + excludeList);
return excludeList;
}
示例14: getAssociations
import com.hp.hpl.jena.rdf.model.NodeIterator; //导入依赖的package包/类
public List<String> getAssociations() {
List<String> associations = associations = new ArrayList<String>(4);
AnnotationProperty associationAnn =PO.AP_ASSOCIATON;
NodeIterator itrAssociation = f.listPropertyValues(associationAnn);
while (itrAssociation.hasNext()) {
String asso = itrAssociation.next().asLiteral().getLexicalForm();
associations.add(asso);
}
return associations;
}
示例15: buildNotesTree
import com.hp.hpl.jena.rdf.model.NodeIterator; //导入依赖的package包/类
private void buildNotesTree(
Model model,
String parentResourceUri,
String notebookUri,
ConceptTreeNode parentNode,
AnnotationTransformer annotationTransformer) throws Exception {
String conceptUri;
ConceptResource concept;
RDFNode statement;
Seq seq = model.getSeq(parentResourceUri);
NodeIterator i = seq.iterator();
cat.debug("<-> concept tree builder - got root: " + parentResourceUri);
ConceptTreeNode child;
while (i.hasNext()) {
statement = i.nextNode();
// add children to parent node
conceptUri = statement.toString();
cat.debug(" <-> concept tree builder - child '" + conceptUri + "'");
concept = MindRaider.noteCustodian.get(notebookUri, conceptUri);
child = new ConceptTreeNode();
// TODO create resource clone to avoid changing of annotations
if (annotationTransformer != null) {
concept.setAnnotation(annotationTransformer.transform(concept.getAnnotation()));
}
child.setConcept(concept.resource);
parentNode.getChildren().add(child);
// now dive recursively for each existing node...
buildNotesTree(model, conceptUri, notebookUri, child, annotationTransformer);
}
}