Source Code Cross Referenced for Scale.java in  » 6.0-JDK-Modules-sun » tools » sun » tools » jstat » 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 » 6.0 JDK Modules sun » tools » sun.tools.jstat 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2004 Sun Microsystems, Inc.  All Rights Reserved.
003:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004:         *
005:         * This code is free software; you can redistribute it and/or modify it
006:         * under the terms of the GNU General Public License version 2 only, as
007:         * published by the Free Software Foundation.  Sun designates this
008:         * particular file as subject to the "Classpath" exception as provided
009:         * by Sun in the LICENSE file that accompanied this code.
010:         *
011:         * This code is distributed in the hope that it will be useful, but WITHOUT
012:         * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013:         * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
014:         * version 2 for more details (a copy is included in the LICENSE file that
015:         * accompanied this code).
016:         *
017:         * You should have received a copy of the GNU General Public License version
018:         * 2 along with this work; if not, write to the Free Software Foundation,
019:         * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020:         *
021:         * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022:         * CA 95054 USA or visit www.sun.com if you need additional information or
023:         * have any questions.
024:         */
025:
026:        package sun.tools.jstat;
027:
028:        import java.util.*;
029:
030:        /**
031:         * A typesafe enumeration for describing data scaling semantics
032:         *
033:         * @author Brian Doherty
034:         * @version 1.9, 05/09/07
035:         * @since 1.5
036:         */
037:        public class Scale {
038:            private static int nextOrdinal = 0;
039:            private static HashMap<String, Scale> map = new HashMap<String, Scale>();
040:
041:            private final String name;
042:            private final int ordinal = nextOrdinal++;
043:            private final double factor;
044:
045:            private Scale(String name, double factor) {
046:                this .name = name;
047:                this .factor = factor;
048:                assert !map.containsKey(name);
049:                map.put(name, this );
050:            }
051:
052:            /**
053:             * Scale representing a no scaling
054:             */
055:            public static final Scale RAW = new Scale("raw", 1);
056:
057:            /**
058:             * Scale representing a percent scaling
059:             */
060:            public static final Scale PERCENT = new Scale("percent", 1 / 100);
061:
062:            /**
063:             * Scale representing a kilo scaling
064:             */
065:            public static final Scale KILO = new Scale("K", 1024);
066:
067:            /**
068:             * Scale representing a mega scaling
069:             */
070:            public static final Scale MEGA = new Scale("M", 1024 * 1024);
071:
072:            /**
073:             * Scale representing a giga scaling
074:             */
075:            public static final Scale GIGA = new Scale("G", 1024 * 1024 * 1024);
076:
077:            /**
078:             * Scale representing a tera scaling
079:             */
080:            public static final Scale TERA = new Scale("T",
081:                    1024 * 1024 * 1024 * 1024);
082:
083:            /**
084:             * Scale representing a tera scaling
085:             */
086:            public static final Scale PETA = new Scale("P", 1024 * 1024 * 1024
087:                    * 1024 * 1024);
088:
089:            /**
090:             * Scale representing a pico scaling
091:             */
092:            public static final Scale PICO = new Scale("p", 10.0E-12);
093:
094:            /**
095:             * Scale representing a nano scaling
096:             */
097:            public static final Scale NANO = new Scale("n", 10.0E-9);
098:
099:            /**
100:             * Scale representing a micro scaling
101:             */
102:            public static final Scale MICRO = new Scale("u", 10.0E-6);
103:
104:            /**
105:             * Scale representing a milli scaling
106:             */
107:            public static final Scale MILLI = new Scale("m", 10.0E-3);
108:
109:            /**
110:             * Scale representing a picosecond scaling
111:             */
112:            public static final Scale PSEC = new Scale("ps", 10.0E-12);
113:
114:            /**
115:             * Scale representing a nanosecond scaling
116:             */
117:            public static final Scale NSEC = new Scale("ns", 10.0E-9);
118:
119:            /**
120:             * Scale representing a microsecond scaling
121:             */
122:            public static final Scale USEC = new Scale("us", 10.0E-6);
123:
124:            /**
125:             * Scale representing a millisecond scaling
126:             */
127:            public static final Scale MSEC = new Scale("ms", 10.0E-3);
128:
129:            /**
130:             * Scale representing a second scaling
131:             */
132:            public static final Scale SEC = new Scale("s", 1);
133:            public static final Scale SEC2 = new Scale("sec", 1);
134:
135:            /**
136:             * Scale representing a minutes scaling
137:             */
138:            public static final Scale MINUTES = new Scale("min", 1 / 60.0);
139:
140:            /**
141:             * Scale representing a hours scaling
142:             */
143:            public static final Scale HOUR = new Scale("h", 1 / (60.0 * 60.0));
144:            public static final Scale HOUR2 = new Scale("hour",
145:                    1 / (60.0 * 60.0));
146:
147:            /**
148:             * Returns the scaling factor of this Scale object
149:             *
150:             * @return  the scaling factor of this Scale object
151:             */
152:            public double getFactor() {
153:                return factor;
154:            }
155:
156:            /**
157:             * Returns the string representation of this Scale object.
158:             * The string representation is the name of the Scale object.
159:             *
160:             * @return  the string representation of this Scale object
161:             */
162:            public String toString() {
163:                return name;
164:            }
165:
166:            /**
167:             * Maps a string to its corresponding Scale object.
168:             *
169:             * @param   s  a string to match against Scale objects.
170:             * @return     The Scale object matching the given string.
171:             */
172:            public static Scale toScale(String s) {
173:                return map.get(s);
174:            }
175:
176:            /**
177:             * Returns an enumeration of the keys for this enumerated type
178:             *
179:             * @param   s  an string to match against Scale objects.
180:             * @return     The Scale object matching the given string.
181:             */
182:            protected static Set keySet() {
183:                return map.keySet();
184:            }
185:
186:            protected double scale(double value) {
187:                return value / factor;
188:            }
189:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.