KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > cli > util > stringifier > MBeanOperationInfoStringifier


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  * $Header: /cvs/glassfish/admin-cli/cli-api/src/java/com/sun/cli/util/stringifier/MBeanOperationInfoStringifier.java,v 1.3 2005/12/25 03:46:05 tcfujii Exp $
26  * $Revision: 1.3 $
27  * $Date: 2005/12/25 03:46:05 $
28  */

29  
30
31 package com.sun.cli.util.stringifier;
32
33 import java.lang.reflect.Array JavaDoc;
34 import javax.management.*;
35
36 public class MBeanOperationInfoStringifier
37     extends MBeanFeatureInfoStringifier implements Stringifier
38 {
39     public static MBeanOperationInfoStringifier DEFAULT = new MBeanOperationInfoStringifier( );
40     
41         public
42     MBeanOperationInfoStringifier( )
43     {
44         super( );
45     }
46     
47         public
48     MBeanOperationInfoStringifier( MBeanFeatureInfoStringifierOptions options )
49     {
50         super( options );
51     }
52     
53         public String JavaDoc
54     stringify( Object JavaDoc o )
55     {
56         assert( o != null );
57
58         final MBeanOperationInfo op = (MBeanOperationInfo)o;
59         
60         String JavaDoc result = getPresentationTypeString( op.getReturnType() ) + " " + op.getName() + "(";
61         
62         // create the signature string
63
result = result + ParamsToString( op.getSignature(), mOptions) + ")";
64                     
65         String JavaDoc impactStr = "";
66         switch( op.getImpact() )
67         {
68             default: impactStr = "unknown"; break;
69             case MBeanOperationInfo.INFO: impactStr = "info"; break;
70             case MBeanOperationInfo.ACTION: impactStr = "action"; break;
71             case MBeanOperationInfo.ACTION_INFO: impactStr = "action-info";break;
72         }
73         
74         result = result + sOperationDelimiter + "impact=" +impactStr;
75             
76         if ( mOptions.mIncludeDescription )
77         {
78             result = result + sOperationDelimiter + "\"" + op.getDescription() + "\"";
79         }
80         
81         return( result );
82     }
83 }
Popular Tags