KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ozoneDB > tools > OPP > message > CompositeOPPMessageListener


1 // You can redistribute this software and/or modify it under the terms of
2
// the Ozone Library License version 1 published by ozone-db.org.
3
//
4
// The original code and portions created by SMB are
5
// Copyright (C) 1997-@year@ by SMB GmbH. All rights reserved.
6
//
7
// $Id: $
8
package org.ozoneDB.tools.OPP.message;
9
10 import org.ozoneDB.tools.OPP.message.MessageWriter;
11
12 import java.util.Set JavaDoc;
13 import java.util.HashSet JavaDoc;
14 import java.util.Iterator JavaDoc;
15
16 public class CompositeOPPMessageListener implements MessageWriter {
17     Set JavaDoc listeners = new HashSet JavaDoc();
18
19     public void startGeneration(String JavaDoc object) {
20         for (Iterator JavaDoc iter = listeners.iterator(); iter.hasNext();) {
21             ((MessageWriter) iter.next()).startGeneration(object);
22         }
23     }
24
25     public void error(String JavaDoc message) {
26         for (Iterator JavaDoc iter = listeners.iterator(); iter.hasNext();) {
27             ((MessageWriter) iter.next()).error(message);
28         }
29     }
30
31     public void warning(String JavaDoc message) {
32         for (Iterator JavaDoc iter = listeners.iterator(); iter.hasNext();) {
33             ((MessageWriter) iter.next()).warning(message);
34         }
35     }
36
37     public void warning(String JavaDoc filename, int row, String JavaDoc message) {
38         for (Iterator JavaDoc iter = listeners.iterator(); iter.hasNext();) {
39             ((MessageWriter) iter.next()).warning(filename, row, message);
40         }
41     }
42
43     public void info(String JavaDoc message) {
44         for (Iterator JavaDoc iter = listeners.iterator(); iter.hasNext();) {
45             ((MessageWriter) iter.next()).info(message);
46         }
47     }
48
49     public void debug(String JavaDoc message) {
50         for (Iterator JavaDoc iter = listeners.iterator(); iter.hasNext();) {
51             ((MessageWriter) iter.next()).debug(message);
52         }
53     }
54
55     public void endGeneration() {
56         for (Iterator JavaDoc iter = listeners.iterator(); iter.hasNext();) {
57             ((MessageWriter) iter.next()).endGeneration();
58         }
59     }
60
61     public void addListener(MessageWriter listener) {
62         listeners.add(listener);
63     }
64
65     public void removeListener(MessageWriter listener) {
66         listeners.remove(listener);
67     }
68 }
69
Popular Tags