01: // You can redistribute this software and/or modify it under the terms of
02: // the Ozone Core License version 1 published by ozone-db.org.
03: //
04: // The original code and portions created by SMB are
05: // Copyright (C) 1997-@year@ by SMB GmbH. All rights reserved.
06: //
07: // $Id: MethodKey.java,v 1.1 2001/12/18 10:31:30 per_nyfelt Exp $
08:
09: package org.ozoneDB.core;
10:
11: import java.io.*;
12: import java.util.*;
13: import java.lang.reflect.*;
14: import org.ozoneDB.*;
15: import org.ozoneDB.tools.OPP.*;
16: import org.ozoneDB.DxLib.*;
17: import org.ozoneDB.core.*;
18: import org.ozoneDB.util.*;
19:
20: /**
21: * Objects of this class are the keys in the method cache table of the
22: * {@link AbstractObjectContainer}. This class implements the way we map from
23: * class+methodName+sig to the actual method. This is very important for the
24: * overall peformance of ozone. Besides this class is used to sort method
25: * arrays.
26: *
27: *
28: * @author <a href="http://www.softwarebuero.de/">SMB</a>
29: * @version $Revision: 1.1 $Date: 2001/12/18 10:31:30 $
30: */
31: public final class MethodKey extends DxObject {
32:
33: protected String methodName;
34:
35: protected String sig;
36:
37: protected String className;
38:
39: protected Method method;
40:
41: public MethodKey(String _className, String _methodName, String _sig) {
42: this (_className, _methodName, _sig, null);
43: }
44:
45: public MethodKey(String _className, String _methodName,
46: String _sig, Method _method) {
47: className = _className;
48: methodName = _methodName;
49: sig = _sig;
50: method = _method;
51: }
52:
53: public Method method() {
54: return method;
55: }
56:
57: public int hashCode() {
58: return methodName.hashCode() ^ sig.hashCode();
59: }
60:
61: public boolean equals(Object obj) {
62: MethodKey rhs = (MethodKey) obj;
63: return className.equals(rhs.className) && sig.equals(rhs.sig)
64: && methodName.equals(rhs.methodName);
65: }
66:
67: public boolean isLess(DxCompatible obj) {
68: MethodKey rhs = (MethodKey) obj;
69:
70: // this method is just used to sort a method array, so it doesn't
71: // need to be that fast...
72: StringBuffer buf = new StringBuffer(className);
73: buf.append(methodName);
74: buf.append(sig);
75:
76: StringBuffer rhsBuf = new StringBuffer(rhs.className);
77: rhsBuf.append(rhs.methodName);
78: rhsBuf.append(rhs.sig);
79:
80: return buf.toString().compareTo(rhsBuf.toString()) < 0;
81: }
82:
83: public String toString() {
84: return className + "." + methodName + "(" + sig + ")";
85: }
86:
87: }
|