KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > hp > hpl > jena > rdf > listeners > ChangedListener


1 /*
2   (c) Copyright 2003, 2004, 2005 Hewlett-Packard Development Company, LP
3   [See end of file]
4   $Id: ChangedListener.java,v 1.6 2005/02/21 12:13:23 andy_seaborne Exp $
5 */

6
7 package com.hp.hpl.jena.rdf.listeners;
8
9 import com.hp.hpl.jena.rdf.model.*;
10
11 import java.util.*;
12
13 /**
14     Class that merely notes that a change has occurred. The only method its user
15     should be interested in is <code>hasChanged()</code>.
16     
17     @author kers
18 */

19 public class ChangedListener implements ModelChangedListener
20     {
21     /**
22         True iff a change has occurred since the last check
23     */

24     private boolean changed = false;
25     /**
26         Record that a change has occurred by setting <code>changed</code> true.
27     */

28     protected void setChanged() { changed = true; }
29     /**
30         Answer true iff a change has occurred since the last hasChanged and set changed
31         false.
32         @return true iff a change has occurred since the last call to hasChanged
33     */

34     public boolean hasChanged() { try { return changed; } finally { changed = false; } }
35     public void addedStatement( Statement s ) { setChanged(); }
36     public void addedStatements( Statement [] statements ) { setChanged(); }
37     public void addedStatements( List statements ) { setChanged(); }
38     public void addedStatements( StmtIterator statements ) { setChanged(); }
39     public void addedStatements( Model m ) { setChanged(); }
40     public void removedStatement( Statement s ) { setChanged(); }
41     public void removedStatements( Statement [] statements ) { setChanged(); }
42     public void removedStatements( List statements ) { setChanged(); }
43     public void removedStatements( StmtIterator statements ) { setChanged(); }
44     public void removedStatements( Model m ) { setChanged(); }
45     public void notifyEvent( Model m, Object JavaDoc event ) {}
46     }
47
48
49 /*
50     (c) Copyright 2003, 2004, 2005 Hewlett-Packard Development Company, LP
51     All rights reserved.
52
53     Redistribution and use in source and binary forms, with or without
54     modification, are permitted provided that the following conditions
55     are met:
56
57     1. Redistributions of source code must retain the above copyright
58        notice, this list of conditions and the following disclaimer.
59
60     2. Redistributions in binary form must reproduce the above copyright
61        notice, this list of conditions and the following disclaimer in the
62        documentation and/or other materials provided with the distribution.
63
64     3. The name of the author may not be used to endorse or promote products
65        derived from this software without specific prior written permission.
66
67     THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
68     IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
69     OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
70     IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
71     INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
72     NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
73     DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
74     THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
75     (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
76     THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
77 */
Popular Tags