01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * 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 implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package org.apache.cocoon.caching.validity;
18:
19: /**
20: * An external uncache event that consists of a name/value pair.
21: * An example might be "table_name", "primary_key"
22: *
23: * @author Geoff Howard (ghoward@apache.org)
24: * @version $Id: NameValueEvent.java 433543 2006-08-22 06:22:54Z crossley $
25: */
26: public class NameValueEvent extends Event {
27:
28: private String m_name;
29: private String m_value;
30: private int m_hashcode;
31:
32: /**
33: * Constructor requires two Strings - the name/value
34: * pair which defines this Event.
35: *
36: * @param name
37: * @param value
38: */
39: public NameValueEvent(String name, String value) {
40: m_name = name;
41: m_value = value;
42: m_hashcode = (name + value).hashCode();
43: }
44:
45: /**
46: * Must return true when both name and value are
47: * equivalent Strings.
48: */
49: public boolean equals(Event e) {
50: if (e instanceof NameValueEvent) {
51: NameValueEvent nve = (NameValueEvent) e;
52: return (m_name.equals(nve.m_name) && m_value
53: .equals(nve.m_value));
54: }
55: return false;
56: }
57:
58: public int hashCode() {
59: return m_hashcode;
60: }
61:
62: public String toString() {
63: return "NameValueEvent[" + m_name + "," + m_value + "]";
64: }
65: }
|