001: /*
002: (c) Copyright 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
003: [See end of file]
004: */
005:
006: package com.hp.hpl.jena.db.impl;
007:
008: import com.hp.hpl.jena.graph.*;
009: import com.hp.hpl.jena.util.iterator.*;
010: import com.hp.hpl.jena.vocabulary.DB;
011:
012: /**
013: *
014: * A wrapper to assist in getting and setting DB information from
015: * a persistent store.
016: *
017: * This is written in the style of enhanced nodes - no state is
018: * stored in the DBStoreDesc, instead all state is in the
019: * underlying graph and this is just provided as a convenience.
020: *
021: * (We don't use enhanced nodes because, since we control everything
022: * in the persistent store system description, we can avoid any
023: * need to handle polymorhphism).
024: *
025: * @since Jena 2.0
026: *
027: * @author csayers
028: * @version $Revision: 1.15 $
029: */
030: public class DBPropLSet extends DBProp {
031:
032: public static Node_URI lSetName = (Node_URI) DB.lSetName.asNode();
033: public static Node_URI lSetType = (Node_URI) DB.lSetType.asNode();
034: public static Node_URI lSetPSet = (Node_URI) DB.lSetPSet.asNode();
035:
036: public DBPropLSet(SpecializedGraph g, String name, String type) {
037: super (g);
038: putPropString(lSetName, name);
039: putPropString(lSetType, type);
040: }
041:
042: public DBPropLSet(SpecializedGraph g, Node n) {
043: super (g, n);
044: }
045:
046: public void setPSet(DBPropPSet pset) {
047: putPropNode(lSetPSet, pset.getNode());
048: }
049:
050: public String getName() {
051: return self.getURI().substring(DB.getURI().length());
052: }
053:
054: public String getType() {
055: return getPropString(lSetType);
056: }
057:
058: public DBPropPSet getPset() {
059: ClosableIterator matches = graph.find(self, lSetPSet, null,
060: newComplete());
061: if (matches.hasNext()) {
062: try {
063: return new DBPropPSet(graph, ((Triple) matches.next())
064: .getObject());
065: } finally {
066: matches.close();
067: }
068: } else
069: return null;
070: }
071:
072: public void remove() {
073: DBPropPSet pSet = getPset();
074: if (pSet != null)
075: pSet.remove();
076: super .remove();
077: }
078:
079: public ExtendedIterator listTriples() {
080: // First get all the triples that directly desrcribe this graph
081: ExtendedIterator result = DBProp.listTriples(graph, self);
082:
083: // Now get all the triples that describe the pset
084: DBPropPSet pset = getPset();
085: if (pset != null)
086: result = result.andThen(DBProp.listTriples(graph, getPset()
087: .getNode()));
088:
089: return result;
090: }
091:
092: }
093:
094: /*
095: * (c) Copyright 2002, 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
096: * All rights reserved.
097: *
098: * Redistribution and use in source and binary forms, with or without
099: * modification, are permitted provided that the following conditions
100: * are met:
101: * 1. Redistributions of source code must retain the above copyright
102: * notice, this list of conditions and the following disclaimer.
103: * 2. Redistributions in binary form must reproduce the above copyright
104: * notice, this list of conditions and the following disclaimer in the
105: * documentation and/or other materials provided with the distribution.
106: * 3. The name of the author may not be used to endorse or promote products
107: * derived from this software without specific prior written permission.
108:
109: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
110: * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
111: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
112: * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
113: * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
114: * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
115: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
116: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
117: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
118: * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
119: */
|