KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > hp > hpl > jena > graph > impl > WrappedBulkUpdateHandler


1 /*
2   (c) Copyright 2004, 2005 Hewlett-Packard Development Company, LP, all rights reserved.
3   [See end of file]
4   $Id: WrappedBulkUpdateHandler.java,v 1.5 2005/02/21 11:52:11 andy_seaborne Exp $
5 */

6 package com.hp.hpl.jena.graph.impl;
7
8 import java.util.*;
9
10 import com.hp.hpl.jena.graph.*;
11 import com.hp.hpl.jena.util.IteratorCollection;
12
13 /**
14     WrappedBulkUpdateHandler - a base class for wrapped bulk update handlers
15     (needed so WrappedGraph works properly with events). Each operation is
16     passed on to the base handler, and then this graph's event manager is
17     notified.
18      
19     @author kers
20 */

21 public class WrappedBulkUpdateHandler
22     implements BulkUpdateHandler
23     {
24     protected BulkUpdateHandler base;
25     protected GraphEventManager manager;
26     protected GraphWithPerform graph;
27     
28     public WrappedBulkUpdateHandler( GraphWithPerform graph, BulkUpdateHandler base )
29         {
30         this.graph = graph;
31         this.base = base;
32         this.manager = graph.getEventManager();
33         }
34
35     public void add( Triple [] triples )
36         {
37         base.add( triples );
38         manager.notifyAddArray( graph, triples );
39         }
40     
41     public void add( List triples )
42         {
43         base.add( triples );
44         manager.notifyAddList( graph, triples );
45         }
46
47     public void add( Iterator it )
48         {
49         List s = IteratorCollection.iteratorToList( it );
50         base.add( s );
51         manager.notifyAddIterator( graph, s );
52         }
53
54     public void add( Graph g, boolean withReifications )
55         {
56         base.add( g, withReifications );
57         manager.notifyAddGraph( graph, g );
58         }
59     
60     public void add( Graph g )
61         {
62         base.add( g );
63         manager.notifyAddGraph( graph, g );
64         }
65
66     public void delete( Triple[] triples )
67         {
68         base.delete( triples );
69         manager.notifyDeleteArray( graph, triples );
70         }
71
72     public void delete( List triples )
73         {
74         base.delete( triples );
75         manager.notifyDeleteList( graph, triples );
76         }
77
78     public void delete( Iterator it )
79         {
80         List s = IteratorCollection.iteratorToList( it );
81         base.delete( s );
82         manager.notifyDeleteIterator( graph, s );
83         }
84
85     public void delete( Graph g )
86         {
87         base.delete( g );
88         manager.notifyDeleteGraph( graph, g );
89         }
90
91     public void delete( Graph g, boolean withReifications )
92         {
93         base.delete( g, withReifications );
94         manager.notifyDeleteGraph( graph, g );
95         }
96
97     public void removeAll()
98         {
99         base.removeAll();
100         manager.notifyEvent( graph, GraphEvents.removeAll );
101         }
102
103     public void remove( Node s, Node p, Node o )
104         {
105         base.remove( s, p, o );
106         manager.notifyEvent( graph, GraphEvents.remove( s, p, o ) );
107         }
108
109     }
110
111
112 /*
113 (c) Copyright 2004, 2005 Hewlett-Packard Development Company, LP
114 All rights reserved.
115
116 Redistribution and use in source and binary forms, with or without
117 modification, are permitted provided that the following conditions
118 are met:
119
120 1. Redistributions of source code must retain the above copyright
121    notice, this list of conditions and the following disclaimer.
122
123 2. Redistributions in binary form must reproduce the above copyright
124    notice, this list of conditions and the following disclaimer in the
125    documentation and/or other materials provided with the distribution.
126
127 3. The name of the author may not be used to endorse or promote products
128    derived from this software without specific prior written permission.
129
130 THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
131 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
132 OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
133 IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
134 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
135 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
136 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
137 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
138 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
139 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
140 */
Popular Tags