OSDN Git Service

original
[gb-231r1-is01/Gingerbread_2.3.3_r1_IS01.git] / libcore / dom / src / test / java / org / w3c / domts / UserDataMonitor.java
1 /*
2  * Copyright (c) 2004 World Wide Web Consortium, (Massachusetts Institute of
3  * Technology, Institut National de Recherche en Informatique et en
4  * Automatique, Keio University). All Rights Reserved. This program is
5  * distributed under the W3C's Software Intellectual Property License. This
6  * program is distributed in the hope that it will be useful, but WITHOUT ANY
7  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
8  * FOR A PARTICULAR PURPOSE. See W3C License
9  * http://www.w3.org/Consortium/Legal/ for more details.
10  */
11
12 package org.w3c.domts;
13
14 import java.util.ArrayList;
15 import java.util.List;
16
17 import org.w3c.dom.Node;
18 import org.w3c.dom.UserDataHandler;
19
20 /**
21  * This is a utility implementation of UserDataHandler that captures all
22  * notifications
23  */
24 public class UserDataMonitor
25     implements UserDataHandler {
26   private final List notifications = new ArrayList();
27
28   /**
29    * Public constructor
30    *
31    */
32   public UserDataMonitor() {
33   }
34
35   /**
36    * Implementation of UserDataHandler.handle. Creates a UserDataNotification
37    * for later testing
38    *
39    * @param operation
40    *            See org.w3c.dom.UserDataHandler
41    * @param key
42    *            See org.w3c.dom.UserDataHandler
43    * @param data
44    *            See org.w3c.dom.UserDataHandler
45    * @param src
46    *            See org.w3c.dom.UserDataHandler
47    * @param dst
48    *            See org.w3c.dom.UserDataHandler
49    */
50   public void handle(
51       short operation,
52       String key,
53       Object data,
54       Node src,
55       Node dst) {
56     notifications.add(
57         new UserDataNotification(operation, key, data, src, dst));
58   }
59
60   /**
61    * Gets list of notifications
62    *
63    * @return List of notifications, may not be null.
64    */
65   public final List getAllNotifications() {
66     return new ArrayList(notifications);
67   }
68
69 }