KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > osgi > framework > internal > core > BundleResourcePermission


1 /*******************************************************************************
2  * Copyright (c) 2003, 2004 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
12 package org.eclipse.osgi.framework.internal.core;
13
14 import java.security.Permission JavaDoc;
15
16 /**
17  * Implementation specific permission to read a bundle's resources.
18  *
19  */

20
21 final class BundleResourcePermission extends Permission JavaDoc {
22     private static final long serialVersionUID = 3256728376969867573L;
23     private long id;
24
25     BundleResourcePermission(long id) {
26         super(String.valueOf(id));
27
28         this.id = id;
29     }
30
31     BundleResourcePermission(String JavaDoc id) {
32         super(id);
33
34         this.id = Long.parseLong(id);
35     }
36
37     /**
38      * Determines if the specified permission is implied by this object.
39      *
40      * @param p The target permission to interrogate.
41      * @return <tt>true</tt> if the specified permission is implied by
42      * this object; <tt>false</tt> otherwise.
43      */

44
45     public boolean implies(Permission JavaDoc p) {
46         if (p instanceof BundleResourcePermission) {
47             BundleResourcePermission target = (BundleResourcePermission) p;
48
49             return this.id == target.id;
50         }
51
52         return false;
53     }
54
55     /**
56      * Returns the empty String.
57      */

58
59     public String JavaDoc getActions() {
60         return ""; //$NON-NLS-1$
61
}
62
63     /**
64      * Determines the equality of two <tt>BundleResourcePermission</tt> objects.
65      *
66      * @param obj The object to test for equality with this object.
67      * @return <tt>true</tt> if <tt><i>obj</i></tt> is a <tt>BundleResourcePermission</tt>, and has the
68      * same bundle id this object; <tt>false</tt> otherwise.
69      */

70     public boolean equals(Object JavaDoc obj) {
71         if (obj == this) {
72             return (true);
73         }
74
75         if (!(obj instanceof BundleResourcePermission)) {
76             return (false);
77         }
78
79         BundleResourcePermission target = (BundleResourcePermission) obj;
80
81         return this.id == target.id;
82     }
83
84     /**
85      * Returns the hash code value for this object.
86      *
87      * @return A hash code value for this object.
88      */

89
90     public int hashCode() {
91         return getName().hashCode();
92     }
93 }
94
Popular Tags