KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > avalon > excalibur > monitor > test > DirectoryTCListener


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
14  * implied.
15  *
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */

19 package org.apache.avalon.excalibur.monitor.test;
20
21 import java.beans.PropertyChangeEvent JavaDoc;
22 import java.beans.PropertyChangeListener JavaDoc;
23 import java.util.Collections JavaDoc;
24 import java.util.Set JavaDoc;
25
26 import org.apache.avalon.excalibur.monitor.DirectoryResource;
27 import org.apache.avalon.framework.logger.AbstractLogEnabled;
28
29 /**
30  * @author <a HREF="mailto:dev@avalon.apache.org">Avalon Development Team</a>
31  */

32 class DirectoryTCListener
33     extends AbstractLogEnabled
34     implements PropertyChangeListener JavaDoc
35 {
36     private int m_changeCount;
37     private Set JavaDoc m_added = Collections.EMPTY_SET;
38     private Set JavaDoc m_removed = Collections.EMPTY_SET;
39     private Set JavaDoc m_modified = Collections.EMPTY_SET;
40
41     void reset()
42     {
43         m_added = Collections.EMPTY_SET;
44         m_removed = Collections.EMPTY_SET;
45         m_modified = Collections.EMPTY_SET;
46     }
47
48     public Set JavaDoc getAdded()
49     {
50         return m_added;
51     }
52
53     public Set JavaDoc getRemoved()
54     {
55         return m_removed;
56     }
57
58     public Set JavaDoc getModified()
59     {
60         return m_modified;
61     }
62
63     public int getChangeCount()
64     {
65         return m_changeCount;
66     }
67
68     public void propertyChange( final PropertyChangeEvent JavaDoc event )
69     {
70         m_changeCount++;
71         final String JavaDoc name = event.getPropertyName();
72         final Set JavaDoc newValue = (Set JavaDoc)event.getNewValue();
73         if( name.equals( DirectoryResource.ADDED ) )
74         {
75             m_added = newValue;
76         }
77         else if( name.equals( DirectoryResource.REMOVED ) )
78         {
79             m_removed = newValue;
80         }
81         else
82         {
83             m_modified = newValue;
84         }
85     }
86 }
87
Popular Tags