KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > hp > hpl > jena > rdf > model > impl > IteratorFactory


1 /*
2   (c) Copyright 2003, 2004, 2005 Hewlett-Packard Development Company, LP
3   [See end of file]
4   $Id: IteratorFactory.java,v 1.11 2005/02/21 12:14:32 andy_seaborne Exp $
5 */

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 /**
21  * @author jjc
22  * Builds Jena Iterators and other things (RDFNode and Statement)
23  * needed in a Model.
24  */

25 public final class IteratorFactory {
26
27     private IteratorFactory(){}
28     
29     /**
30          @deprecated use Model::asRDFNode( Node ) instead.
31     */

32     static public RDFNode asRDFNode( Node n, Model m ) {
33         return m.asRDFNode( n );
34     }
35         
36     /**
37         @deprecated use Model::toStatement( Triple )
38     */

39     static public Statement asStatement( Triple t, ModelCom m ) {
40         return StatementImpl.toStatement( t, m );
41     }
42
43     /**
44      *
45      */

46     static public StmtIterator asStmtIterator(Iterator i, final ModelCom m) {
47         return new StmtIteratorImpl(new Map1Iterator(new Map1(){
48             public Object JavaDoc map1(Object JavaDoc o) { return m.asStatement( (Triple) o ); }
49         },i));
50     }
51
52     /**
53      *
54      */

55     static public ResIterator asResIterator(Iterator i, final ModelCom m) {
56         return new ResIteratorImpl(new Map1Iterator(new Map1(){
57             public Object JavaDoc map1(Object JavaDoc o) { return m.asRDFNode( (Node) o ); }
58         },i),null);
59     }
60
61     /**
62      *
63      */

64     static public NodeIterator asRDFNodeIterator(Iterator i, final ModelCom m) {
65         return new NodeIteratorImpl(new Map1Iterator(new Map1(){
66             public Object JavaDoc map1(Object JavaDoc 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 );
81
return (Literal) m.getNodeAs( n, Literal.class );
82     }
83     
84     static Resource asResource(Node n, Class JavaDoc cl,ModelCom m) {
85         return (Resource)m.getNodeAs(n,cl);
86     }
87 }
88
89 /*
90     (c) Copyright 2003, 2004, 2005 Hewlett-Packard Development Company, LP
91     All rights reserved.
92
93     Redistribution and use in source and binary forms, with or without
94     modification, are permitted provided that the following conditions
95     are met:
96
97     1. Redistributions of source code must retain the above copyright
98        notice, this list of conditions and the following disclaimer.
99
100     2. Redistributions in binary form must reproduce the above copyright
101        notice, this list of conditions and the following disclaimer in the
102        documentation and/or other materials provided with the distribution.
103
104     3. The name of the author may not be used to endorse or promote products
105        derived from this software without specific prior written permission.
106
107     THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
108     IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
109     OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
110     IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
111     INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
112     NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
113     DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
114     THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
115     (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
116     THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
117 */

118
Popular Tags