KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > cli > commands > DisplayErrorStatisticsCommand


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 package com.sun.enterprise.cli.commands;
25
26 import com.sun.enterprise.cli.framework.*;
27 import java.util.Map JavaDoc;
28 import java.text.DateFormat JavaDoc;
29 import java.util.Vector JavaDoc;
30 import com.sun.appserv.management.ext.logging.LogAnalyzer;
31
32 public class DisplayErrorStatisticsCommand extends GenericCommand
33 {
34     protected void handleReturnValue(Object JavaDoc retVal)
35     {
36         final Map JavaDoc[] errorInfo = (Map JavaDoc[])retVal;
37         
38         if (errorInfo.length > 0)
39         {
40             String JavaDoc sTitle = String.format("%1$-39s %2$-9s %3$-8s",
41                                           getLocalizedString("Timestamp"),
42                                           getLocalizedString("Severity"),
43                                           getLocalizedString("Warning"));
44             
45             CLILogger.getInstance().printDetailMessage(sTitle);
46             
47             CLILogger.getInstance().printDetailMessage("---------------------------------------------------------");
48         }
49         for (Map JavaDoc errorRecord : errorInfo)
50         {
51             final Long JavaDoc timeStamp = (Long JavaDoc) errorRecord.get(LogAnalyzer.TIMESTAMP_KEY);
52             final java.util.Date JavaDoc date = new java.util.Date JavaDoc(timeStamp);
53
54             final Integer JavaDoc severeCount =
55                     (Integer JavaDoc) errorRecord.get(LogAnalyzer.SEVERE_COUNT_KEY);
56             final Integer JavaDoc warningCount =
57                     (Integer JavaDoc) errorRecord.get(LogAnalyzer.WARNING_COUNT_KEY);
58
59             final String JavaDoc sDate = (getBooleanOption(TERSE))?timeStamp.toString():
60                                  timeStamp.toString()+
61                                  "("+DateFormat.getDateTimeInstance().format(date)+")";
62
63             final String JavaDoc sErrorRecord = String.format("%1$-43s %2$-8s %3$-8s",
64                                                       sDate, severeCount, warningCount);
65             CLILogger.getInstance().printMessage(sErrorRecord);
66         }
67         if (errorInfo.length > 0)
68         {
69             CLILogger.getInstance().printDetailMessage("---------------------------------------------------------");
70         }
71     }
72 }
73
Popular Tags