KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > caching > validity > NamedEvent


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

16 package org.apache.cocoon.caching.validity;
17
18 /**
19  * An External cache event that consists of just a name. Examples
20  * (not necessarily useful) could include "Easter" or "Shutdown"
21  *
22  * @author Geoff Howard (ghoward@apache.org)
23  * @version $Id: NamedEvent.java 30932 2004-07-29 17:35:38Z vgritsenko $
24  */

25 public class NamedEvent extends Event {
26     
27     private String JavaDoc m_name;
28     private int m_hashcode;
29     
30     /**
31      * Constructor takes a simple String as event name.
32      *
33      * @param name name
34      */

35     public NamedEvent(String JavaDoc name) {
36         m_name = name;
37         m_hashcode = name.hashCode();
38     }
39     
40     /**
41      * Every NamedEvent where the name string is equal must
42      * return true.
43      */

44     public boolean equals(Event e) {
45         if (e instanceof NamedEvent) {
46             return m_name.equals(((NamedEvent)e).m_name);
47         }
48         return false;
49     }
50     
51     public int hashCode() {
52         return m_hashcode;
53     }
54     
55     public String JavaDoc toString() {
56         return "NamedEvent[" + m_name + "]";
57     }
58 }
59
Popular Tags