001: /*
002: (c) Copyright 2007, 2008 Hewlett-Packard Development Company, LP
003: All rights reserved.
004: $Id: BasicFBReifier.java,v 1.6 2008/01/02 12:07:46 andy_seaborne Exp $
005: */
006:
007: package com.hp.hpl.jena.reasoner.rulesys;
008:
009: import com.hp.hpl.jena.graph.*;
010: import com.hp.hpl.jena.shared.*;
011: import com.hp.hpl.jena.util.iterator.ExtendedIterator;
012:
013: public class BasicFBReifier implements Reifier {
014: protected final GetReifier deductions;
015: protected final Graph parent;
016: protected final Reifier base;
017:
018: public BasicFBReifier(BasicForwardRuleInfGraph parent,
019: Reifier base, GetReifier deductions, ReificationStyle style) {
020: this .deductions = deductions;
021: this .parent = parent;
022: this .base = base;
023: }
024:
025: interface GetReifier {
026: Reifier getReifier();
027: }
028:
029: public ExtendedIterator allNodes() {
030: return base.allNodes().andThen(
031: deductions.getReifier().allNodes());
032: }
033:
034: public ExtendedIterator allNodes(Triple t) {
035: return base.allNodes(t).andThen(
036: deductions.getReifier().allNodes());
037: }
038:
039: public void close() {
040: base.close();
041: }
042:
043: public ExtendedIterator find(TripleMatch m) {
044: return base.find(m).andThen(deductions.getReifier().find(m));
045: }
046:
047: public ExtendedIterator findEither(TripleMatch m, boolean showHidden) {
048: return base.findEither(m, showHidden).andThen(
049: deductions.getReifier().findEither(m, showHidden));
050: }
051:
052: public ExtendedIterator findExposed(TripleMatch m) {
053: return base.findExposed(m).andThen(
054: deductions.getReifier().findExposed(m));
055: }
056:
057: public Graph getParentGraph() {
058: return parent;
059: }
060:
061: public ReificationStyle getStyle() {
062: return base.getStyle();
063: }
064:
065: public boolean handledAdd(Triple t) {
066: return base.handledAdd(t);
067: }
068:
069: public boolean handledRemove(Triple t) {
070: return base.handledRemove(t);
071: }
072:
073: public boolean hasTriple(Node n) {
074: return base.hasTriple(n)
075: || deductions.getReifier().hasTriple(n);
076: }
077:
078: public boolean hasTriple(Triple t) {
079: return base.hasTriple(t)
080: || deductions.getReifier().hasTriple(t);
081: }
082:
083: public Node reifyAs(Node n, Triple t) {
084: return base.reifyAs(n, t);
085: }
086:
087: public void remove(Node n, Triple t) {
088: base.remove(n, t);
089: }
090:
091: public void remove(Triple t) {
092: base.remove(t);
093: }
094:
095: public int size() {
096: return deductions.getReifier().size();
097: }
098:
099: public Triple getTriple(Node n) {
100: Triple a = base.getTriple(n);
101: Triple b = deductions.getReifier().getTriple(n);
102: if (a != null && b != null)
103: throw new JenaException(
104: "TODO: have multiple answers for getTrple, viz "
105: + a + " and " + b);
106: return a == null ? b : a;
107: }
108: }
109:
110: /*
111: (c) Copyright 2007, 2008 Hewlett-Packard Development Company, LP
112: All rights reserved.
113:
114: Redistribution and use in source and binary forms, with or without
115: modification, are permitted provided that the following conditions
116: are met:
117:
118: 1. Redistributions of source code must retain the above copyright
119: notice, this list of conditions and the following disclaimer.
120:
121: 2. Redistributions in binary form must reproduce the above copyright
122: notice, this list of conditions and the following disclaimer in the
123: documentation and/or other materials provided with the distribution.
124:
125: 3. The name of the author may not be used to endorse or promote products
126: derived from this software without specific prior written permission.
127:
128: THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
129: IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
130: OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
131: IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
132: INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
133: NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
134: DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
135: THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
136: (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
137: THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
138: */
|