KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2   (c) Copyright 2003, 2004, 2005 Hewlett-Packard Development Company, LP
3   [See end of file]
4 */

5
6 package com.hp.hpl.jena.db.impl;
7
8 import com.hp.hpl.jena.graph.*;
9 import com.hp.hpl.jena.util.iterator.*;
10 import com.hp.hpl.jena.vocabulary.DB;
11
12 /**
13  *
14  * A wrapper to assist in getting and setting DB information from
15  * a persistent store.
16  *
17  * This is written in the style of enhanced nodes - no state is
18  * stored in the DBStoreDesc, instead all state is in the
19  * underlying graph and this is just provided as a convenience.
20  *
21  * (We don't use enhanced nodes because, since we control everything
22  * in the persistent store system description, we can avoid any
23  * need to handle polymorhphism).
24  *
25  * @since Jena 2.0
26  *
27  * @author csayers
28  * @version $Revision: 1.11 $
29  */

30 public class DBPropLSet extends DBProp {
31
32     public static Node_URI lSetName = (Node_URI)DB.lSetName.getNode();
33     public static Node_URI lSetType = (Node_URI)DB.lSetType.getNode();
34     public static Node_URI lSetPSet = (Node_URI)DB.lSetPSet.getNode();
35     
36     public DBPropLSet( SpecializedGraph g, String JavaDoc name, String JavaDoc type) {
37         super( g);
38         putPropString(lSetName, name);
39         putPropString(lSetType, type);
40     }
41     
42     public DBPropLSet( SpecializedGraph g, Node n) {
43         super(g,n);
44     }
45     
46     public void setPSet( DBPropPSet pset ) {
47         putPropNode( lSetPSet, pset.getNode() );
48     }
49     
50     public String JavaDoc getName() { return self.getURI().substring(DB.getURI().length()); }
51     public String JavaDoc getType() { return getPropString( lSetType); }
52     
53     public DBPropPSet getPset() {
54         ClosableIterator matches = graph.find( self, lSetPSet, null, newComplete() );
55         if( matches.hasNext() ) {
56             try { return new DBPropPSet( graph, ((Triple) matches.next()).getObject()); }
57             finally { matches.close(); }
58         }
59         else
60             return null;
61     }
62
63     public void remove() {
64         DBPropPSet pSet = getPset();
65         if (pSet != null )
66             pSet.remove();
67         super.remove();
68     }
69
70     public ExtendedIterator listTriples() {
71         // First get all the triples that directly desrcribe this graph
72
ExtendedIterator result = DBProp.listTriples(graph, self);
73         
74         // Now get all the triples that describe the pset
75
DBPropPSet pset = getPset();
76         if( pset != null )
77             result = result.andThen( DBProp.listTriples(graph, getPset().getNode()) );
78
79         return result;
80     }
81     
82     
83 }
84
85 /*
86  * (c) Copyright 2002, 2003, 2004, 2005 Hewlett-Packard Development Company, LP
87  * All rights reserved.
88  *
89  * Redistribution and use in source and binary forms, with or without
90  * modification, are permitted provided that the following conditions
91  * are met:
92  * 1. Redistributions of source code must retain the above copyright
93  * notice, this list of conditions and the following disclaimer.
94  * 2. Redistributions in binary form must reproduce the above copyright
95  * notice, this list of conditions and the following disclaimer in the
96  * documentation and/or other materials provided with the distribution.
97  * 3. The name of the author may not be used to endorse or promote products
98  * derived from this software without specific prior written permission.
99
100  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
101  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
102  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
103  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
104  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
105  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
106  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
107  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
108  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
109  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
110  */
Popular Tags