KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > cli > jmx > support > InspectResultStringifier


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/jmx/support/InspectResultStringifier.java,v 1.3 2005/12/25 03:45:47 tcfujii Exp $
26  * $Revision: 1.3 $
27  * $Date: 2005/12/25 03:45:47 $
28  */

29  
30
31
32 package com.sun.cli.jmx.support;
33
34 import com.sun.cli.util.stringifier.*;
35 import com.sun.cli.jmx.support.*;
36
37 import java.lang.reflect.Array JavaDoc;
38 import javax.management.*;
39
40
41 public final class InspectResultStringifier implements Stringifier
42 {
43         public
44     InspectResultStringifier( )
45     {
46     }
47     
48     
49
50         private String JavaDoc
51     stringifyArray( Object JavaDoc [] a, Stringifier stringifier)
52     {
53         String JavaDoc temp = "";
54         
55         if ( Array.getLength( a ) != 0 )
56         {
57             temp = "\n" + ArrayStringifier.stringify( a, "\n", stringifier);
58         }
59         return( temp );
60     }
61
62         public String JavaDoc
63     stringify( Object JavaDoc o)
64     {
65         String JavaDoc result = "";
66         final InspectResult r = (InspectResult)o;
67     
68         final MBeanFeatureInfoStringifierOptions options = new MBeanFeatureInfoStringifierOptions( r.includeDescription, ",");
69         
70         result = result + "--- " + r.objectInstance.getObjectName().toString() + " ---";
71
72         if ( r.summary != null )
73         {
74             if ( result.length() != 0 )
75             {
76                 result = result + "\n";
77             }
78
79             result = result + r.summary;
80         }
81         
82         // Do formal terms like "Attributes" need to be I18n? Probabably not as they are part of a specification.
83
if ( r.attrInfo != null )
84         {
85             result = result + "\n\n- Attributes -" +
86                         stringifyArray( r.attrInfo, new MBeanAttributeInfoStringifier(options) );
87         }
88         
89         if ( r.operationsInfo != null )
90         {
91             result = result + "\n\n- Operations -" +
92                         stringifyArray( r.operationsInfo, new MBeanOperationInfoStringifier(options) );
93         }
94         
95         if ( r.constructorsInfo != null )
96         {
97             result = result + "\n\n- Constructors -" +
98                         stringifyArray( r.constructorsInfo, new MBeanConstructorInfoStringifier(options) );
99         }
100         
101         if ( r.notificationsInfo != null )
102         {
103             result = result + "\n\n- Notifications -" +
104                         stringifyArray( r.notificationsInfo, new MBeanNotificationInfoStringifier(options) );
105         }
106         
107         return( result );
108             
109     }
110 }
111
112
113
114
Popular Tags