KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > appserv > management > util > jmx > stringifier > CompositeDataStringifier


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 package com.sun.appserv.management.util.jmx.stringifier;
24
25 import java.util.Set JavaDoc;
26 import java.util.Iterator JavaDoc;
27
28 import javax.management.openmbean.CompositeData JavaDoc;
29 import javax.management.openmbean.CompositeType JavaDoc;
30
31 import com.sun.appserv.management.util.misc.StringUtil;
32 import com.sun.appserv.management.util.stringifier.Stringifier;
33 import com.sun.appserv.management.util.stringifier.SmartStringifier;
34
35
36 public class CompositeDataStringifier implements Stringifier
37 {
38     public static final CompositeDataStringifier DEFAULT = new CompositeDataStringifier();
39     
40         public
41     CompositeDataStringifier( )
42     {
43     }
44     
45         public String JavaDoc
46     stringify( Object JavaDoc o )
47     {
48         final StringBuffer JavaDoc buf = new StringBuffer JavaDoc();
49         buf.append( "Composite data:\n" );
50         
51         final CompositeData JavaDoc data = (CompositeData JavaDoc)o;
52         final CompositeType JavaDoc type = data.getCompositeType();
53         
54         final Set JavaDoc keySet = type.keySet();
55         final Iterator JavaDoc iter = keySet.iterator();
56         while ( iter.hasNext() )
57         {
58             final String JavaDoc key = (String JavaDoc)iter.next();
59             final Object JavaDoc item = data.get( key );
60             
61             final String JavaDoc s = SmartStringifier.toString( item );
62             buf.append( key + "=" + s + "\n" );
63         }
64         
65         return( buf.toString() );
66     }
67 }
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
Popular Tags