KickJava   Java API By Example, From Geeks To Geeks.

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


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 uncache event that consists of a name/value pair.
20  * An example might be "table_name", "primary_key"
21  *
22  * @author Geoff Howard (ghoward@apache.org)
23  * @version $Id: NameValueEvent.java 30932 2004-07-29 17:35:38Z vgritsenko $
24  */

25 public class NameValueEvent extends Event {
26
27     private String JavaDoc m_name;
28     private String JavaDoc m_value;
29     private int m_hashcode;
30     
31     /**
32      * Constructor requires two Strings - the name/value
33      * pair which defines this Event.
34      *
35      * @param name
36      * @param value
37      */

38     public NameValueEvent(String JavaDoc name, String JavaDoc value) {
39         m_name = name;
40         m_value = value;
41         m_hashcode = (name + value).hashCode();
42     }
43     
44     /**
45      * Must return true when both name and value are
46      * equivalent Strings.
47      */

48     public boolean equals(Event e) {
49         if (e instanceof NameValueEvent) {
50             NameValueEvent nve = (NameValueEvent)e;
51             return ( m_name.equals(nve.m_name) &&
52                 m_value.equals(nve.m_value) );
53         }
54         return false;
55     }
56     
57     public int hashCode() {
58         return m_hashcode;
59     }
60     
61     public String JavaDoc toString() {
62         return "NameValueEvent[" + m_name + "," + m_value + "]";
63     }
64 }
65
Popular Tags