KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mc4j > console > connection > NumericIntrospectorAction


1 /*
2  * Copyright 2002-2004 Greg Hinkle
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.mc4j.console.connection;
18
19 import org.mc4j.ems.connection.bean.EmsBean;
20 import org.mc4j.ems.connection.bean.attribute.EmsAttribute;
21 import org.openide.nodes.Node;
22 import org.openide.util.HelpCtx;
23 import org.openide.util.actions.NodeAction;
24 import org.openide.windows.IOProvider;
25 import org.openide.windows.OutputWriter;
26
27 import java.math.BigDecimal JavaDoc;
28 import java.math.BigInteger JavaDoc;
29 import java.util.HashSet JavaDoc;
30 import java.util.Set JavaDoc;
31
32 /**
33  *
34  * @author Greg Hinkle (ghinkle@users.sourceforge.net), August 2002
35  * @version $Revision: 570 $($Author: ghinkl $ / $Date: 2006-04-12 15:14:16 -0400 (Wed, 12 Apr 2006) $)
36  */

37 public class NumericIntrospectorAction extends NodeAction {
38
39     protected void performAction(Node[] nodes) {
40         ConnectionNode node = (ConnectionNode)nodes[0];
41
42         OutputWriter w = IOProvider.getDefault().getIO("Stats Output", true).getOut();
43
44         for (EmsBean emsBean : node.getEmsConnection().getBeans()) {
45             boolean beanOutput = false;
46
47             for (EmsAttribute attribute : emsBean.getAttributes()) {
48
49                 if (!attribute.isWritable() && STATS_TYPES.contains(attribute.getType())) {
50
51                     if (!beanOutput) {
52                         w.println(emsBean.getBeanName().getCanonicalName());
53                         beanOutput = true;
54                     }
55
56                     w.println("\t" + attribute.getName() + "[" + attribute.getType() + "]");
57                 }
58
59             }
60         }
61     }
62
63     static Set JavaDoc STATS_TYPES = new HashSet JavaDoc();
64     static {
65         STATS_TYPES.add(Short.TYPE.getName());
66         STATS_TYPES.add(Short JavaDoc.class.getName());
67         STATS_TYPES.add(Integer.TYPE.getName());
68         STATS_TYPES.add(Integer JavaDoc.class.getName());
69         STATS_TYPES.add(Long.TYPE.getName());
70         STATS_TYPES.add(Long JavaDoc.class.getName());
71         STATS_TYPES.add(Float.TYPE.getName());
72         STATS_TYPES.add(Float JavaDoc.class.getName());
73         STATS_TYPES.add(Double.TYPE.getName());
74         STATS_TYPES.add(Double JavaDoc.class.getName());
75         STATS_TYPES.add(BigInteger JavaDoc.class.getName());
76         STATS_TYPES.add(BigDecimal JavaDoc.class.getName());
77     }
78
79
80     protected boolean enable(Node[] nodes) {
81         return ((nodes.length == 1) &&
82             (nodes[0] instanceof ConnectionNode) &&
83             (((ConnectionNode)nodes[0]).isConnected()));
84     }
85
86     public String JavaDoc getName() {
87         return "Print numeric info";
88     }
89
90     protected String JavaDoc iconResource() {
91         return null;
92     }
93
94     public HelpCtx getHelpCtx() {
95         return HelpCtx.DEFAULT_HELP;
96         // If you will provide context help then use:
97
// return new HelpCtx(DisconnectAction.class);
98
}
99
100 }
101
Popular Tags