|
1 | 1 | package org.linkeddatafragments.fragments.tpf;
|
2 | 2 |
|
| 3 | +import java.util.NoSuchElementException; |
| 4 | + |
3 | 5 | import org.linkeddatafragments.fragments.LinkedDataFragmentBase;
|
4 | 6 | import org.linkeddatafragments.util.CommonResources;
|
5 | 7 |
|
6 | 8 | import com.hp.hpl.jena.datatypes.xsd.XSDDatatype;
|
7 | 9 | import com.hp.hpl.jena.rdf.model.Literal;
|
8 | 10 | import com.hp.hpl.jena.rdf.model.Model;
|
9 |
| -import com.hp.hpl.jena.rdf.model.ModelFactory; |
10 | 11 | import com.hp.hpl.jena.rdf.model.Resource;
|
| 12 | +import com.hp.hpl.jena.rdf.model.Statement; |
11 | 13 | import com.hp.hpl.jena.rdf.model.StmtIterator;
|
| 14 | +import com.hp.hpl.jena.util.iterator.NiceIterator; |
12 | 15 |
|
13 | 16 | /**
|
14 | 17 | * Implementation of {@link TriplePatternFragment}.
|
@@ -52,13 +55,16 @@ public TriplePatternFragmentImpl( Model triples,
|
52 | 55 | final long pageNumber,
|
53 | 56 | final boolean isLastPage ) {
|
54 | 57 | super( fragmentURL, datasetURL, pageNumber, isLastPage );
|
55 |
| - this.triples = triples == null ? ModelFactory.createDefaultModel() : triples; |
| 58 | + this.triples = triples; |
56 | 59 | this.totalSize = totalSize < 0 ? 0 : totalSize;
|
57 | 60 | }
|
58 | 61 |
|
59 | 62 | @Override
|
60 | 63 | public StmtIterator getTriples() {
|
61 |
| - return triples.listStatements(); |
| 64 | + if ( triples != null ) |
| 65 | + return triples.listStatements(); |
| 66 | + else |
| 67 | + return emptyStmtIterator; |
62 | 68 | }
|
63 | 69 |
|
64 | 70 | @Override
|
@@ -119,4 +125,14 @@ public String getTemplate() {
|
119 | 125 | TriplePatternFragmentRequest.PARAMETERNAME_OBJ + "}";
|
120 | 126 | }
|
121 | 127 |
|
| 128 | + |
| 129 | + public static final StmtIterator emptyStmtIterator = new EmptyStmtIterator(); |
| 130 | + |
| 131 | + public static class EmptyStmtIterator |
| 132 | + extends NiceIterator<Statement> |
| 133 | + implements StmtIterator |
| 134 | + { |
| 135 | + public Statement nextStatement() { throw new NoSuchElementException(); } |
| 136 | + } |
| 137 | + |
122 | 138 | }
|
0 commit comments