KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > core > internal > expressions > Property


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.core.internal.expressions;
12
13 import org.eclipse.core.runtime.Assert;
14
15 import org.eclipse.core.expressions.IPropertyTester;
16
17 public class Property {
18     
19     private Class JavaDoc fType;
20     private String JavaDoc fNamespace;
21     private String JavaDoc fName;
22     
23     private IPropertyTester fTester;
24
25     /* package */ Property(Class JavaDoc type, String JavaDoc namespace, String JavaDoc name) {
26         Assert.isNotNull(type);
27         Assert.isNotNull(namespace);
28         Assert.isNotNull(name);
29         
30         fType= type;
31         fNamespace= namespace;
32         fName= name;
33     }
34     
35     /* package */ void setPropertyTester(IPropertyTester tester) {
36         Assert.isNotNull(tester);
37         fTester= tester;
38     }
39     
40     public boolean isInstantiated() {
41         return fTester.isInstantiated();
42     }
43     
44     public boolean isDeclaringPluginActive() {
45         return fTester.isDeclaringPluginActive();
46     }
47     
48     public boolean isValidCacheEntry(boolean forcePluginActivation) {
49         if (forcePluginActivation) {
50             return isInstantiated() && isDeclaringPluginActive();
51         } else {
52             return (isInstantiated() && isDeclaringPluginActive()) ||
53                     (!isInstantiated() && !isDeclaringPluginActive());
54         }
55     }
56     
57     public boolean test(Object JavaDoc receiver, Object JavaDoc[] args, Object JavaDoc expectedValue) {
58         return fTester.test(receiver, fName, args, expectedValue);
59     }
60     
61     public boolean equals(Object JavaDoc obj) {
62         if (!(obj instanceof Property))
63             return false;
64         Property other= (Property)obj;
65         return fType.equals(other.fType) && fNamespace.equals(other.fNamespace) && fName.equals(other.fName);
66     }
67     
68     public int hashCode() {
69         return (fType.hashCode() << 16) | fNamespace.hashCode() << 8 | fName.hashCode();
70     }
71 }
72
Popular Tags