KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > deployment > MethodPermissionDescriptor


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 /*
25  * MethodPermissionDescriptor.java
26  *
27  * Created on December 6, 2001, 2:32 PM
28  */

29
30 package com.sun.enterprise.deployment;
31
32 import java.util.Vector JavaDoc;
33 import java.util.Iterator JavaDoc;
34 import java.util.Collection JavaDoc;
35
36 /**
37  * This class defines a method permission information in the assembly
38  * descriptor
39  *
40  * @author Jerome Dochez
41  * @version
42  */

43 public class MethodPermissionDescriptor extends DescribableDescriptor {
44          
45     Vector JavaDoc methods = new Vector JavaDoc();
46     Vector JavaDoc mps = new Vector JavaDoc() ;
47     
48     /** Creates new MethodPermissionDescriptor */
49     public MethodPermissionDescriptor() {
50     }
51     
52     public void addMethod(MethodDescriptor aMethod) {
53         methods.add(aMethod);
54     }
55     
56     public void addMethods(Collection JavaDoc methods) {
57         this.methods.addAll(methods);
58     }
59     
60     public void addMethodPermission(MethodPermission mp) {
61         mps.add(mp);
62     }
63     
64     public MethodDescriptor[] getMethods() {
65         MethodDescriptor[] array = new MethodDescriptor[methods.size()];
66         methods.copyInto(array);
67         return array;
68     }
69     
70     public MethodPermission[] getMethodPermissions() {
71         MethodPermission[] array = new MethodPermission[mps.size()];
72         mps.copyInto(array);
73         return array;
74     }
75         
76     public void print(StringBuffer JavaDoc toStringBuffer) {
77         StringBuffer JavaDoc buffer = toStringBuffer;
78         buffer.append("Method Permission " + (getDescription()==null?"":getDescription()) );
79         buffer.append("\nFor the following Permissions ");
80         for (Iterator JavaDoc mpsIterator = mps.iterator();mpsIterator.hasNext();) {
81             MethodPermission mp = (MethodPermission) mpsIterator.next();
82             mp.print(buffer);
83             buffer.append("\n");
84         }
85         buffer.append("\nFor the following ").append(methods.size()).append(" methods\n");
86         for (Iterator JavaDoc methodsIterator = methods.iterator();methodsIterator.hasNext();) {
87             MethodDescriptor md = (MethodDescriptor) methodsIterator.next();
88             md.print(buffer);
89             buffer.append("\n");
90         }
91     }
92 }
93
Popular Tags