Source Code Cross Referenced for MonKeyImp.java in  » Profiler » JAMon » com » jamonapi » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Profiler » JAMon » com.jamonapi 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package com.jamonapi;
002:
003:        /**
004:         * <p>A key implmentation for label, and units type monitors.
005:         * Note this could also be implemented with the following use of MonKeyBase.  This
006:         * class predates that one and would not have to use a Map for basic functions
007:         * and so MAY be more efficient (this wasn't tested).  Using label, and units
008:         * is the most common monitor that will be used in most cases.</p>
009:         * 
010:         *  <p>This could be implemented like the following.
011:         *  LinkedHashMap lm=new LinkedHashMap();<br>
012:         *  lm.put("Label", "mypakcage.myclass");<br>
013:         *  lm.put(""Units", "ms.");<br>
014:         *  MonKey mk=new MonKeyBase(lm);<br>
015:         *  
016:         *  </p>
017:         */
018:
019:        //import java.util.Collection;
020:        import java.util.List;
021:
022:        public class MonKeyImp implements  MonKey {
023:
024:            private final String summaryLabel; // pageHits for example
025:            private Object details; // The actual page name for the detail buffer.  pageHits for example
026:            private final String units; // ms. for example
027:            //      private boolean initializeDetail=true;
028:            private Object param;
029:
030:            public MonKeyImp(String summaryLabel, String units) {
031:                this (summaryLabel, summaryLabel, units);
032:            }
033:
034:            /** Object details can be an Object[], a Collection, or a Java Object.  */
035:            public MonKeyImp(String summaryLabel, Object details, String units) {
036:                this .summaryLabel = (summaryLabel == null) ? "" : summaryLabel;
037:                this .details = details;
038:                this .units = (units == null) ? "" : units;
039:            }
040:
041:            public MonKeyImp(MonKeyItem keyItem, String units) {
042:                this .summaryLabel = (keyItem == null) ? "" : keyItem.toString();
043:                ;
044:                this .units = (units == null) ? "" : units;
045:                this .details = keyItem.getDetails();
046:
047:            }
048:
049:            /** Returns the label for the monitor */
050:            public String getLabel() {
051:                return summaryLabel;
052:            }
053:
054:            /** Returns the units for the monitor */
055:            public String getUnits() {
056:                return units;
057:            }
058:
059:            public Object getDetails() {
060:                return details;
061:                //       return details;
062:                //  		if (initializeDetail) {
063:                //  			initializeDetail=false;
064:                //  			detailLabel+=", "+units;
065:                //            (detailLabel==null) ? "" : detailLabel
066:                //  		}
067:                //  		
068:                //	     return detailLabel;
069:            }
070:
071:            //    
072:            //    public List getDetails(List list) {
073:            //        Misc.addTo(list, details);
074:            //        return list;
075:            //    }
076:
077:            public void setDetails(Object details) {
078:                this .details = details;
079:
080:            }
081:
082:            /** Returns any object that has a named key.  In this keys case
083:             * 'label' and 'units' makes sense, but any values are acceptible.
084:             */
085:            public Object getValue(String key) {
086:                if (LABEL_HEADER.equalsIgnoreCase(key))
087:                    return getLabel();
088:                else if (UNITS_HEADER.equalsIgnoreCase(key))
089:                    return getUnits();
090:                else if ("param".equalsIgnoreCase(key))
091:                    return getParam();
092:                else if ("details".equalsIgnoreCase(key))
093:                    return getDetails();
094:                else
095:                    return null;
096:
097:            }
098:
099:            /** Used to get any arbitrary Object into the key.  It will not be used as part of the key, however it can be retrieved later for example
100:             * in the JAMonBufferListener.
101:             * @return
102:             */
103:            public Object getParam() {
104:                return param;
105:            }
106:
107:            /** Used to set any arbitrary Object into the key.  It will not be used as part of the key, however it can be retrieved later for example
108:             * in the JAMonBufferListener.
109:             * @return
110:             */
111:            public void setParam(Object param) {
112:                this .param = param;
113:            }
114:
115:            /**
116:             This method is called automatically by a HashMap when this class is used as a HashMap key.  A Coordinate is
117:             considered equal if its x and y variables have the same value.
118:             */
119:
120:            public boolean equals(Object compareKey) {
121:
122:                return (compareKey instanceof  MonKeyImp
123:                        && summaryLabel
124:                                .equals(((MonKeyImp) compareKey).summaryLabel) && units
125:                        .equals(((MonKeyImp) compareKey).units));
126:
127:            }
128:
129:            /** Used when key is put into a Map to look up the monitor */
130:            public int hashCode() {
131:                return (summaryLabel.hashCode() + units.hashCode());
132:            }
133:
134:            public List getBasicHeader(List header) {
135:                header.add(LABEL_HEADER);
136:                return header;
137:            }
138:
139:            public List getDisplayHeader(List header) {
140:                return getHeader(header);
141:            }
142:
143:            public List getHeader(List header) {
144:                header.add(LABEL_HEADER);
145:                header.add(UNITS_HEADER);
146:                return header;
147:            }
148:
149:            public List getBasicRowData(List rowData) {
150:                rowData.add(getLabel() + ", " + getUnits());
151:                return rowData;
152:            }
153:
154:            public List getRowData(List rowData) {
155:                rowData.add(getLabel());
156:                rowData.add(getUnits());
157:
158:                return rowData;
159:            }
160:
161:            public List getRowDisplayData(List rowData) {
162:                return getRowData(rowData);
163:            }
164:
165:            public String toString() {
166:                return new StringBuffer().append("JAMon Label=").append(
167:                        getLabel()).append(", Units=").append(getUnits())
168:                        .toString();
169:
170:            }
171:
172:            public String getRangeKey() {
173:                return getUnits();
174:            }
175:
176:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.