001: /*
002: (c) Copyright 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP, all rights reserved.
003: [See end of file]
004: $Id: WrappedBulkUpdateHandler.java,v 1.8 2008/01/02 12:05:20 andy_seaborne Exp $
005: */
006: package com.hp.hpl.jena.graph.impl;
007:
008: import java.util.*;
009:
010: import com.hp.hpl.jena.graph.*;
011: import com.hp.hpl.jena.util.IteratorCollection;
012:
013: /**
014: WrappedBulkUpdateHandler - a base class for wrapped bulk update handlers
015: (needed so WrappedGraph works properly with events). Each operation is
016: passed on to the base handler, and then this graph's event manager is
017: notified.
018:
019: @author kers
020: */
021: public class WrappedBulkUpdateHandler implements BulkUpdateHandler {
022: protected BulkUpdateHandler base;
023: protected GraphEventManager manager;
024: protected GraphWithPerform graph;
025:
026: public WrappedBulkUpdateHandler(GraphWithPerform graph,
027: BulkUpdateHandler base) {
028: this .graph = graph;
029: this .base = base;
030: this .manager = graph.getEventManager();
031: }
032:
033: public void add(Triple[] triples) {
034: base.add(triples);
035: manager.notifyAddArray(graph, triples);
036: }
037:
038: public void add(List triples) {
039: base.add(triples);
040: manager.notifyAddList(graph, triples);
041: }
042:
043: public void add(Iterator it) {
044: List s = IteratorCollection.iteratorToList(it);
045: base.add(s);
046: manager.notifyAddIterator(graph, s);
047: }
048:
049: public void add(Graph g, boolean withReifications) {
050: base.add(g, withReifications);
051: manager.notifyAddGraph(graph, g);
052: }
053:
054: public void add(Graph g) {
055: base.add(g);
056: manager.notifyAddGraph(graph, g);
057: }
058:
059: public void delete(Triple[] triples) {
060: base.delete(triples);
061: manager.notifyDeleteArray(graph, triples);
062: }
063:
064: public void delete(List triples) {
065: base.delete(triples);
066: manager.notifyDeleteList(graph, triples);
067: }
068:
069: public void delete(Iterator it) {
070: List s = IteratorCollection.iteratorToList(it);
071: base.delete(s);
072: manager.notifyDeleteIterator(graph, s);
073: }
074:
075: public void delete(Graph g) {
076: base.delete(g);
077: manager.notifyDeleteGraph(graph, g);
078: }
079:
080: public void delete(Graph g, boolean withReifications) {
081: base.delete(g, withReifications);
082: manager.notifyDeleteGraph(graph, g);
083: }
084:
085: public void removeAll() {
086: base.removeAll();
087: manager.notifyEvent(graph, GraphEvents.removeAll);
088: }
089:
090: public void remove(Node s, Node p, Node o) {
091: base.remove(s, p, o);
092: manager.notifyEvent(graph, GraphEvents.remove(s, p, o));
093: }
094:
095: }
096:
097: /*
098: (c) Copyright 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
099: All rights reserved.
100:
101: Redistribution and use in source and binary forms, with or without
102: modification, are permitted provided that the following conditions
103: are met:
104:
105: 1. Redistributions of source code must retain the above copyright
106: notice, this list of conditions and the following disclaimer.
107:
108: 2. Redistributions in binary form must reproduce the above copyright
109: notice, this list of conditions and the following disclaimer in the
110: documentation and/or other materials provided with the distribution.
111:
112: 3. The name of the author may not be used to endorse or promote products
113: derived from this software without specific prior written permission.
114:
115: THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
116: IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
117: OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
118: IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
119: INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
120: NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
121: DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
122: THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
123: (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
124: THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
125: */
|