KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ejbca > core > model > approval > ApprovalOveradableClassName


1 /*************************************************************************
2  * *
3  * EJBCA: The OpenSource Certificate Authority *
4  * *
5  * This software is free software; you can redistribute it and/or *
6  * modify it under the terms of the GNU Lesser General Public *
7  * License as published by the Free Software Foundation; either *
8  * version 2.1 of the License, or any later version. *
9  * *
10  * See terms of license at gnu.org. *
11  * *
12  *************************************************************************/

13 package org.ejbca.core.model.approval;
14
15 import org.apache.log4j.Logger;
16
17 /**
18  * Class used in constants for approvalable methods indicating calling classes/methods
19  * that don't need to go through approvals
20  *
21  * Contains the full classpath and method na,e
22  *
23  * @author Philip Vendil
24  * $Id: ApprovalOveradableClassName.java,v 1.2 2006/08/12 17:14:50 anatom Exp $
25  */

26 public class ApprovalOveradableClassName {
27     
28     private static final Logger log = Logger.getLogger(ApprovalOveradableClassName.class);
29     
30     String JavaDoc className = null;
31     String JavaDoc methodName = null;
32     
33     /**
34      *
35      * @param className The full name with packages
36      * @param methodName the method name/ can be null indicating all methods
37      */

38     public ApprovalOveradableClassName(String JavaDoc className, String JavaDoc methodName) {
39         super();
40         this.className = className;
41         this.methodName = methodName;
42     }
43
44     /**
45      * @return The full name with packages
46      */

47     
48     public String JavaDoc getClassName() {
49         return className;
50     }
51
52     public String JavaDoc getMethodName() {
53         return methodName;
54     }
55     
56     /**
57      * Method that checks if the current classname / method is in the stacktrace
58      * @param traces
59      * @return if the class.method exists in trace
60      */

61     public boolean isInStackTrace(StackTraceElement JavaDoc[] traces){
62         
63         boolean retval = false;
64         for(int i=0;i<traces.length;i++){
65             if (log.isDebugEnabled()) {
66                 log.debug("Compare " + className + "." + methodName + " with " + traces[i].getClassName() + "." +traces[i].getMethodName() );
67             }
68             if(traces[i].getClassName().equals(className)){
69                 if(methodName != null){
70                     retval = traces[i].getMethodName().equals(methodName);
71                     if(retval == true){
72                         break;
73                     }
74                 }else{
75                     retval = true;
76                     break;
77                 }
78             }
79         }
80         
81         
82         if (log.isDebugEnabled()) {
83             log.debug("Result " + retval);
84         }
85         
86         return retval;
87     }
88
89 }
90
Popular Tags