001: /*
002: (c) Copyright 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
003: [See end of file]
004: $Id: StatementListener.java,v 1.9 2008/01/02 12:09:39 andy_seaborne Exp $
005: */
006:
007: package com.hp.hpl.jena.rdf.listeners;
008:
009: import com.hp.hpl.jena.rdf.model.*;
010: import java.util.*;
011:
012: /**
013: A listener that filters all its listening down to the single-statement level. Users of this
014: class override <code>addedStatement(Statement)</code> and
015: <code>removedStatement(Statement)</code>.
016: @author kers
017: */
018: public class StatementListener implements ModelChangedListener {
019: /**
020: Override this to listen to all incoming added statements
021: */
022: public void addedStatement(Statement s) {
023: }
024:
025: /**
026: Override this to listen to all incoming removed statements
027: */
028: public void removedStatement(Statement s) {
029: }
030:
031: /* */
032: public void addedStatements(Statement[] statements) {
033: for (int i = 0; i < statements.length; i += 1)
034: addedStatement(statements[i]);
035: }
036:
037: public void addedStatements(List statements) {
038: for (int i = 0; i < statements.size(); i += 1)
039: addedStatement((Statement) statements.get(i));
040: }
041:
042: public void addedStatements(StmtIterator statements) {
043: while (statements.hasNext())
044: addedStatement(statements.nextStatement());
045: }
046:
047: public void addedStatements(Model m) {
048: addedStatements(m.listStatements());
049: }
050:
051: public void removedStatements(Statement[] statements) {
052: for (int i = 0; i < statements.length; i += 1)
053: removedStatement(statements[i]);
054: }
055:
056: public void removedStatements(List statements) {
057: for (int i = 0; i < statements.size(); i += 1)
058: removedStatement((Statement) statements.get(i));
059: }
060:
061: public void removedStatements(StmtIterator statements) {
062: while (statements.hasNext())
063: removedStatement(statements.nextStatement());
064: }
065:
066: public void removedStatements(Model m) {
067: removedStatements(m.listStatements());
068: }
069:
070: public void notifyEvent(Model m, Object event) {
071: }
072: }
073:
074: /*
075: (c) Copyright 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
076: All rights reserved.
077:
078: Redistribution and use in source and binary forms, with or without
079: modification, are permitted provided that the following conditions
080: are met:
081:
082: 1. Redistributions of source code must retain the above copyright
083: notice, this list of conditions and the following disclaimer.
084:
085: 2. Redistributions in binary form must reproduce the above copyright
086: notice, this list of conditions and the following disclaimer in the
087: documentation and/or other materials provided with the distribution.
088:
089: 3. The name of the author may not be used to endorse or promote products
090: derived from this software without specific prior written permission.
091:
092: THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
093: IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
094: OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
095: IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
096: INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
097: NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
098: DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
099: THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
100: (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
101: THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
102: */
|