本文整理匯總了Java中com.hp.hpl.jena.rdf.model.StmtIterator.hasNext方法的典型用法代碼示例。如果您正苦於以下問題:Java StmtIterator.hasNext方法的具體用法?Java StmtIterator.hasNext怎麽用?Java StmtIterator.hasNext使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.hp.hpl.jena.rdf.model.StmtIterator
的用法示例。
在下文中一共展示了StmtIterator.hasNext方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: main
import com.hp.hpl.jena.rdf.model.StmtIterator; //導入方法依賴的package包/類
public static void main(String[] args) {
// Set up the ModelD2RQ using a mapping file
ModelD2RQ m = new ModelD2RQ("file:doc/example/mapping-iswc.ttl");
// Find anything with an rdf:type of iswc:InProceedings
StmtIterator paperIt = m.listStatements(null, RDF.type, ISWC.InProceedings);
// List found papers and print their titles
while (paperIt.hasNext()) {
Resource paper = paperIt.nextStatement().getSubject();
System.out.println("Paper: " + paper.getProperty(DC.title).getString());
// List authors of the paper and print their names
StmtIterator authorIt = paper.listProperties(DC.creator);
while (authorIt.hasNext()) {
Resource author = authorIt.nextStatement().getResource();
System.out.println("Author: " + author.getProperty(FOAF.name).getString());
}
System.out.println();
}
m.close();
}
示例2: getUndefinedResources
import com.hp.hpl.jena.rdf.model.StmtIterator; //導入方法依賴的package包/類
public Collection<Resource> getUndefinedResources(Model model) {
Set<Resource> result = new HashSet<Resource>();
StmtIterator it = model.listStatements();
while (it.hasNext()) {
Statement stmt = it.nextStatement();
if (stmt.getSubject().isURIResource()
&& stmt.getSubject().getURI().startsWith(namespace)
&& !resources.contains(stmt.getSubject())) {
result.add(stmt.getSubject());
}
if (stmt.getPredicate().equals(RDF.type)) continue;
if (stmt.getObject().isURIResource()
&& stmt.getResource().getURI().startsWith(namespace)
&& !resources.contains(stmt.getResource())) {
result.add(stmt.getResource());
}
}
return result;
}
示例3: parseDownloadMap
import com.hp.hpl.jena.rdf.model.StmtIterator; //導入方法依賴的package包/類
private void parseDownloadMap(DownloadMap dm, Resource r) {
StmtIterator stmts;
stmts = r.listProperties(D2RQ.dataStorage);
while (stmts.hasNext()) {
dm.setDatabase(mapping.database(
stmts.nextStatement().getResource()));
}
stmts = r.listProperties(D2RQ.belongsToClassMap);
while (stmts.hasNext()) {
dm.setBelongsToClassMap(mapping.classMap(
stmts.nextStatement().getResource()));
}
stmts = r.listProperties(D2RQ.contentDownloadColumn);
while (stmts.hasNext()) {
dm.setContentDownloadColumn(stmts.nextStatement().getString());
}
stmts = r.listProperties(D2RQ.mediaType);
while (stmts.hasNext()) {
dm.setMediaType(stmts.nextStatement().getString());
}
}
示例4: parseConfiguration
import com.hp.hpl.jena.rdf.model.StmtIterator; //導入方法依賴的package包/類
private void parseConfiguration() {
Iterator<Individual> it = this.model.listIndividuals(D2RQ.Configuration);
if (it.hasNext()) {
Resource configResource = it.next();
Configuration configuration = new Configuration(configResource);
StmtIterator stmts = configResource.listProperties(D2RQ.serveVocabulary);
while (stmts.hasNext()) {
configuration.setServeVocabulary(stmts.nextStatement().getBoolean());
}
stmts = configResource.listProperties(D2RQ.useAllOptimizations);
while (stmts.hasNext()) {
configuration.setUseAllOptimizations(stmts.nextStatement().getBoolean());
}
this.mapping.setConfiguration(configuration);
if (it.hasNext())
throw new D2RQException("Only one configuration block is allowed");
}
}
示例5: getNumberOfLinks
import com.hp.hpl.jena.rdf.model.StmtIterator; //導入方法依賴的package包/類
private Integer getNumberOfLinks(String nif) {
Model model = ModelFactory.createDefaultModel();
model.read(new ByteArrayInputStream(nif.getBytes()), null, "TTL");
StmtIterator iter = model.listStatements();
Integer result = 0;
while (iter.hasNext()) {
Statement stm = iter.nextStatement();
if (NIF21Format.RDF_PROPERTY_IDENTREF.equals(stm.getPredicate().toString())) {
result += 1;
}
}
return result;
}
示例6: getSourceValue
import com.hp.hpl.jena.rdf.model.StmtIterator; //導入方法依賴的package包/類
public String getSourceValue()
{
String rsrc = getSourceURL();
String val = _result.getValue();
Property prop = _source.getProperty(getSourcePropertyURI());
StmtIterator iter = _source.getResource(rsrc).listProperties(prop);
while ( iter.hasNext() )
{
Statement stmt = iter.next();
if ( !stmt.getObject().isLiteral() ) { continue; }
String str = stmt.getString();
if ( str.contains(val) ) { return str; }
}
return "";
}
示例7: getAllNoteDescriptors
import com.hp.hpl.jena.rdf.model.StmtIterator; //導入方法依賴的package包/類
public ResourceDescriptor[] getAllNoteDescriptors(String outlineUri) {
Model outlineModel;
try {
outlineModel = MindRaider.outlineCustodian.getModel(outlineUri);
Property property = RDF.type;
String literal = MindRaiderConstants.MR_OWL_CLASS_CONCEPT;
StmtIterator i = outlineModel.listStatements((com.hp.hpl.jena.rdf.model.Resource)null,property,outlineModel.getResource(literal));
ArrayList<String> noteUris=new ArrayList<String>();
while(i.hasNext()) {
Statement s=i.nextStatement();
noteUris.add(s.getSubject().getURI());
}
return getDescriptorsForNoteUris(true, outlineModel, noteUris.toArray(new String[noteUris.size()]));
} catch (Exception e) {
logger.debug("Unable to get resource descriptors",e); // {{debug}}
}
return null;
}
示例8: fetchLabels
import com.hp.hpl.jena.rdf.model.StmtIterator; //導入方法依賴的package包/類
private void fetchLabels(Model m)
{
Map<String,String> map = new HashMap();
Property p = m.getProperty(SKOS_PREF_LABEL);
ResIterator rIter = m.listResourcesWithProperty(m.getProperty(RDF_TYPE));
while ( rIter.hasNext() )
{
Resource r = rIter.next();
fetchAlternatives(map, r);
StmtIterator sIter = r.listProperties(p);
while ( sIter.hasNext() )
{
Statement stmt = sIter.next();
put(stmt.getSubject(), getKey(stmt.getString(), map));
}
map.clear();
}
}
示例9: checkPrecedence
import com.hp.hpl.jena.rdf.model.StmtIterator; //導入方法依賴的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;
}
示例10: getDefaultCortexSupport
import com.hp.hpl.jena.rdf.model.StmtIterator; //導入方法依賴的package包/類
/**
* Retrieve the dhus system supported items for file scanning processing.
* Is considered supported all classes having
* <code>http://www.gael.fr/dhus#metadataExtractor</code> property
* connection.
* @return the list of supported class names.
*/
public static synchronized String[] getDefaultCortexSupport ()
{
DrbCortexModel model;
try
{
model = DrbCortexModel.getDefaultModel ();
}
catch (IOException e)
{
throw new UnsupportedOperationException (
"Drb cortex not properly initialized.");
}
ExtendedIterator it=model.getCortexModel ().getOntModel ().listClasses ();
List<String>list = new ArrayList<String> ();
while (it.hasNext ())
{
OntClass cl = (OntClass)it.next ();
OntProperty metadata_extractor_p = cl.getOntModel().getOntProperty(
"http://www.gael.fr/dhus#support");
StmtIterator properties = cl.listProperties (metadata_extractor_p);
while (properties.hasNext ())
{
Statement stmt = properties.nextStatement ();
LOGGER.debug ("Scanner Support Added for " +
stmt.getSubject ().toString ());
list.add (stmt.getSubject ().toString ());
}
}
return list.toArray (new String[list.size ()]);
}
示例11: testListStatements
import com.hp.hpl.jena.rdf.model.StmtIterator; //導入方法依賴的package包/類
public void testListStatements() {
StmtIterator iter = this.model.listStatements();
int count = 0;
while (iter.hasNext()) {
Statement stmt = iter.nextStatement();
stmt.toString();
// dumpStatement(stmt);
count++;
}
assertEquals(322, count);
}
示例12: getUndefinedClasses
import com.hp.hpl.jena.rdf.model.StmtIterator; //導入方法依賴的package包/類
public Collection<Resource> getUndefinedClasses(Model model) {
Set<Resource> result = new HashSet<Resource>();
StmtIterator it = model.listStatements(null, RDF.type, (RDFNode) null);
while (it.hasNext()) {
Statement stmt = it.nextStatement();
if (stmt.getObject().isURIResource()
&& stmt.getResource().getURI().startsWith(namespace)
&& !classes.contains(stmt.getObject())) {
result.add(stmt.getResource());
}
}
return result;
}
示例13: getUndefinedProperties
import com.hp.hpl.jena.rdf.model.StmtIterator; //導入方法依賴的package包/類
public Collection<Property> getUndefinedProperties(Model model) {
Set<Property> result = new HashSet<Property>();
StmtIterator it = model.listStatements();
while (it.hasNext()) {
Statement stmt = it.nextStatement();
if (stmt.getPredicate().getURI().startsWith(namespace)
&& !properties.contains(stmt.getPredicate())) {
result.add(stmt.getPredicate());
}
}
return result;
}
示例14: printIndividual
import com.hp.hpl.jena.rdf.model.StmtIterator; //導入方法依賴的package包/類
protected static String printIndividual(Individual individual) {
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("Individual: " + individual.getLocalName() + "\n");
StmtIterator properties = individual.listProperties();
while (properties.hasNext()) {
Statement s = properties.next();
stringBuilder.append(" " + s.getPredicate().getLocalName() + " : " + s.getObject().toString() + "\n");
}
properties.close();
stringBuilder.append("\n");
stringBuilder.append(StringUtils.repeat("-", 70));
return stringBuilder.toString();
}
示例15: triplesInvolvingVocabulary
import com.hp.hpl.jena.rdf.model.StmtIterator; //導入方法依賴的package包/類
public Model triplesInvolvingVocabulary(Model model) {
Model result = ModelFactory.createDefaultModel();
result.getNsPrefixMap().putAll(model.getNsPrefixMap());
StmtIterator it = model.listStatements();
while (it.hasNext()) {
Statement stmt = it.next();
if (properties.contains(stmt.getPredicate())
|| (stmt.getPredicate().equals(RDF.type) && classes.contains(stmt.getObject()))) {
result.add(stmt);
}
}
return result;
}