KickJava   Java API By Example, From Geeks To Geeks.

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


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/MBeanAttributeInfoStringifier.java,v 1.3 2005/12/25 03:46:04 tcfujii Exp $
26  * $Revision: 1.3 $
27  * $Date: 2005/12/25 03:46:04 $
28  */

29  
30 package com.sun.cli.util.stringifier;
31
32 import java.lang.reflect.Array JavaDoc;
33 import javax.management.*;
34
35 public class MBeanAttributeInfoStringifier extends MBeanFeatureInfoStringifier implements Stringifier
36 {
37     public final static MBeanAttributeInfoStringifier DEFAULT =
38                     new MBeanAttributeInfoStringifier( );
39     
40         public
41     MBeanAttributeInfoStringifier( )
42     {
43         super( );
44     }
45     
46         public
47     MBeanAttributeInfoStringifier( MBeanFeatureInfoStringifierOptions options )
48     {
49         super( options );
50     }
51     
52         public String JavaDoc
53     stringify( Object JavaDoc o )
54     {
55         MBeanAttributeInfo attr = (MBeanAttributeInfo)o;
56         String JavaDoc result = attr.getName() + ":";
57         if ( attr.isReadable() )
58             result = result + "r";
59         if ( attr.isWritable() )
60             result = result + "w";
61         result = result + mOptions.mArrayDelimiter + getPresentationTypeString( attr.getType() );
62         
63         if ( mOptions.mIncludeDescription )
64         {
65             result = result + ",\"" + attr.getDescription() + "\"";
66         }
67         
68         return( result );
69     }
70 }
Popular Tags