KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > hp > hpl > jena > db > impl > SpecializedGraph_TripleStore_RDB


1 /*
2  * (c) Copyright 2002, 2003, 2004, 2005 Hewlett-Packard Development Company, LP
3  * All rights reserved.
4  *
5  */

6 package com.hp.hpl.jena.db.impl;
7
8 import com.hp.hpl.jena.db.GraphRDB;
9 import com.hp.hpl.jena.graph.*;
10 import com.hp.hpl.jena.vocabulary.RDF;
11
12 /**
13  *
14  * @author hkuno based on GraphMem.java, v 1.4 by Chris Dollin (chris-dollin)
15  * @version
16  *
17  * TripleStoreGraph_RDB is a table-specific, database-independent
18  * implementation of TripleStoreGraph.
19  */

20
21 public class SpecializedGraph_TripleStore_RDB extends SpecializedGraph_TripleStore {
22     
23     /**
24      * Constructor.
25      *
26      * Create a new instance of a TripleStore graph, taking an IPSet
27      * as an argument. Used for bootstrapping, when we don't have a
28      * DBPropLSet yet.
29      */

30     public SpecializedGraph_TripleStore_RDB(IPSet pSet, Integer JavaDoc dbGraphId) {
31         super(pSet, dbGraphId);
32     }
33     
34     /*
35      * (non-Javadoc)
36      * @see com.hp.hpl.jena.db.impl.SpecializedGraph#subsumes(com.hp.hpl.jena.graph.Triple, int)
37      *
38      * determine if the default graph has any triples of the given pattern.
39      * the table below indicates the return value for each reif style for
40      * the various types of patterns.
41      * note: "conc" means the node in the pattern is not a concrete node.
42      *
43      * Pattern Minimal Conv Standard
44      * ANY rdf:subj ANY all none none
45      * ANY rdf:pred ANY all none none
46      * ANY rdf:obj ANY all none none
47      * ANY rdf:type rdf:stmt all none none
48      * ANY rdf:type conc all all all
49      * ANY rdf:type !conc all all some
50      * ANY !conc ANY all all some
51      * else all all all
52      */

53     
54     public char subsumes ( Triple pattern, int reifBehavior ) {
55         // we assume that other sg's have been called first
56
char res = allTriplesForPattern;
57         if ( reifBehavior == GraphRDB.OPTIMIZE_AND_HIDE_ONLY_FULL_REIFICATIONS )
58             return res;
59         Node pred = pattern.getPredicate();
60         boolean isReifPred = pred.equals(RDF.Nodes.subject) ||
61             pred.equals(RDF.Nodes.predicate) ||
62             pred.equals(RDF.Nodes.object);
63         boolean isPredType = pred.equals(RDF.Nodes.type);
64         Node obj = pattern.getObject();
65         boolean isObjStmt = obj.equals(RDF.Nodes.Statement);
66         if ( reifBehavior == GraphRDB.OPTIMIZE_ALL_REIFICATIONS_AND_HIDE_NOTHING ) {
67             if ( isReifPred ) res = noTriplesForPattern;
68             else if ( isPredType ) {
69                 if ( isObjStmt ) res = noTriplesForPattern;
70                 else if ( !obj.isConcrete() ) res = someTriplesForPattern;
71             } if ( !pred.isConcrete() ) res = someTriplesForPattern;
72         } else {
73             // reifBehavior == OPTIMIZE_AND_HIDE_FULL_AND_PARTIAL_REIFICATIONS
74
if ( isReifPred || (isPredType && isObjStmt) )
75                 res = noTriplesForPattern;
76         }
77             return res;
78         }
79 }
80
81 /*
82  * (c) Copyright 2002, 2003, 2004, 2005 Hewlett-Packard Development Company, LP
83  * All rights reserved.
84  *
85  * Redistribution and use in source and binary forms, with or without
86  * modification, are permitted provided that the following conditions
87  * are met:
88  * 1. Redistributions of source code must retain the above copyright
89  * notice, this list of conditions and the following disclaimer.
90  * 2. Redistributions in binary form must reproduce the above copyright
91  * notice, this list of conditions and the following disclaimer in the
92  * documentation and/or other materials provided with the distribution.
93  * 3. The name of the author may not be used to endorse or promote products
94  * derived from this software without specific prior written permission.
95
96  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
97  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
98  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
99  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
100  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
101  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
102  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
103  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
104  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
105  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
106  */

107
Popular Tags