1 6 7 package com.hp.hpl.jena.rdf.model.impl; 8 9 10 import java.util.*; 11 12 13 14 import com.hp.hpl.jena.rdf.model.*; 15 import com.hp.hpl.jena.util.iterator.*; 16 17 import com.hp.hpl.jena.graph.*; 18 19 20 25 public final class IteratorFactory { 26 27 private IteratorFactory(){} 28 29 32 static public RDFNode asRDFNode( Node n, Model m ) { 33 return m.asRDFNode( n ); 34 } 35 36 39 static public Statement asStatement( Triple t, ModelCom m ) { 40 return StatementImpl.toStatement( t, m ); 41 } 42 43 46 static public StmtIterator asStmtIterator(Iterator i, final ModelCom m) { 47 return new StmtIteratorImpl(new Map1Iterator(new Map1(){ 48 public Object map1(Object o) { return m.asStatement( (Triple) o ); } 49 },i)); 50 } 51 52 55 static public ResIterator asResIterator(Iterator i, final ModelCom m) { 56 return new ResIteratorImpl(new Map1Iterator(new Map1(){ 57 public Object map1(Object o) { return m.asRDFNode( (Node) o ); } 58 },i),null); 59 } 60 61 64 static public NodeIterator asRDFNodeIterator(Iterator i, final ModelCom m) { 65 return new NodeIteratorImpl(new Map1Iterator(new Map1(){ 66 public Object map1(Object o) { return m.asRDFNode( (Node) o ); } 67 },i),null); 68 } 69 70 static Resource asResource(Node n,ModelCom m) { 71 return asResource(n,Resource.class,m); 72 73 } 74 75 static Property asProperty(Node n,ModelCom m) { 76 return (Property)asResource(n,Property.class,m); 77 } 78 79 static Literal asLiteral(Node n,ModelCom m) { 80 return (Literal) m.getNodeAs( n, Literal.class ); 82 } 83 84 static Resource asResource(Node n, Class cl,ModelCom m) { 85 return (Resource)m.getNodeAs(n,cl); 86 } 87 } 88 89 118 | Popular Tags |