KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > hp > hpl > jena > shared > RandomOrderGraph


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

6 package com.hp.hpl.jena.shared;
7
8 import com.hp.hpl.jena.graph.*;
9 import com.hp.hpl.jena.rdf.model.*;
10 import com.hp.hpl.jena.util.iterator.*;
11 import com.hp.hpl.jena.graph.impl.WrappedGraph;
12
13 /**
14  * Wraps a graph and randomizes the order of find results.
15  * @author jjc
16  *
17  *
18  */

19 public class RandomOrderGraph extends WrappedGraph {
20     
21     public static Graph createDefaultGraph() {
22         return new RandomOrderGraph(Factory.createDefaultGraph());
23     }
24     public static Model createDefaultModel() {
25         return ModelFactory.createModelForGraph(createDefaultGraph());
26     }
27     final private int bufsz;
28     /**
29      * @param base
30      */

31     public RandomOrderGraph(int bufsz, Graph base) {
32         super(base);
33         this.bufsz = bufsz;
34     }
35     /**
36      * @param base
37      */

38     public RandomOrderGraph(Graph base) {
39         this(10,base);
40     }
41     
42     public ExtendedIterator find( TripleMatch m )
43     { return new RandomOrderIterator(bufsz,super.find( m ));
44     }
45
46     public ExtendedIterator find( Node s, Node p, Node o )
47     { return new RandomOrderIterator(bufsz,super.find( s, p, o ));
48     }
49     
50
51 }
52
53 /*
54  (c) Copyright 2003, 2004, 2005 Hewlett-Packard Development Company, LP
55  All rights reserved.
56
57  Redistribution and use in source and binary forms, with or without
58  modification, are permitted provided that the following conditions
59  are met:
60
61  1. Redistributions of source code must retain the above copyright
62  notice, this list of conditions and the following disclaimer.
63
64  2. Redistributions in binary form must reproduce the above copyright
65  notice, this list of conditions and the following disclaimer in the
66  documentation and/or other materials provided with the distribution.
67
68  3. The name of the author may not be used to endorse or promote products
69  derived from this software without specific prior written permission.
70
71  THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
72  IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
73  OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
74  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
75  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
76  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
77  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
78  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
79  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
80  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
81  */

82
Popular Tags