Source Code Cross Referenced for Measure.java in  » GIS » GeoTools-2.4.1 » org » geotools » measure » 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 » GIS » GeoTools 2.4.1 » org.geotools.measure 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *    GeoTools - OpenSource mapping toolkit
003:         *    http://geotools.org
004:         *    (C) 2003-2006, GeoTools Project Managment Committee (PMC)
005:         *    (C) 2001, Institut de Recherche pour le Développement
006:         *    (C) 1999, Fisheries and Oceans Canada
007:         *   
008:         *    This library is free software; you can redistribute it and/or
009:         *    modify it under the terms of the GNU Lesser General Public
010:         *    License as published by the Free Software Foundation;
011:         *    version 2.1 of the License.
012:         *
013:         *    This library is distributed in the hope that it will be useful,
014:         *    but WITHOUT ANY WARRANTY; without even the implied warranty of
015:         *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
016:         *    Lesser General Public License for more details.
017:         */
018:        package org.geotools.measure;
019:
020:        // Miscellaneous
021:        import javax.units.Unit;
022:
023:        import org.geotools.resources.Utilities;
024:
025:        /**
026:         * A scalar with an unit.
027:         *
028:         * @since 2.1
029:         * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/library/referencing/src/main/java/org/geotools/measure/Measure.java $
030:         * @version $Id: Measure.java 20874 2006-08-07 10:00:01Z jgarnett $
031:         * @author Martin Desruisseaux
032:         */
033:        public final class Measure extends Number {
034:            /**
035:             * For compatibility with different versions.
036:             */
037:            private static final long serialVersionUID = 6917234039472328164L;
038:
039:            /**
040:             * The scalar value.
041:             */
042:            private final double value;
043:
044:            /**
045:             * The unit.
046:             */
047:            private final Unit unit;
048:
049:            /**
050:             * Creates a new measure with the specified value and unit.
051:             */
052:            public Measure(final double value, final Unit unit) {
053:                this .value = value;
054:                this .unit = unit;
055:            }
056:
057:            /** Returns the scalar value. */
058:            public double doubleValue() {
059:                return (double) value;
060:            }
061:
062:            /** Returns the scalar value. */
063:            public float floatValue() {
064:                return (float) value;
065:            }
066:
067:            /** Returns the scalar value. */
068:            public long longValue() {
069:                return (long) value;
070:            }
071:
072:            /** Returns the scalar value. */
073:            public int intValue() {
074:                return (int) value;
075:            }
076:
077:            /** Returns the scalar value. */
078:            public short shortValue() {
079:                return (short) value;
080:            }
081:
082:            /** Returns the scalar value. */
083:            public byte byteValue() {
084:                return (byte) value;
085:            }
086:
087:            /**
088:             * Returns the unit.
089:             */
090:            public Unit getUnit() {
091:                return unit;
092:            }
093:
094:            /**
095:             * Returns a hash code value for this measure.
096:             */
097:            public int hashCode() {
098:                long code = Double.doubleToLongBits(value);
099:                return (int) code ^ (int) (code >>> 32) ^ unit.hashCode();
100:            }
101:
102:            /**
103:             * Compares this measure with the specified object for equality.
104:             */
105:            public boolean equals(final Object object) {
106:                if (object instanceof  Measure) {
107:                    final Measure that = (Measure) object;
108:                    return Double.doubleToLongBits(value) == Double
109:                            .doubleToLongBits(that.value)
110:                            && Utilities.equals(unit, that.unit);
111:                }
112:                return false;
113:            }
114:
115:            /**
116:             * Returns a string representation of this measure.
117:             */
118:            public String toString() {
119:                final StringBuffer buffer = new StringBuffer();
120:                buffer.append(value);
121:                buffer.append(' ');
122:                buffer.append(unit);
123:                return buffer.toString();
124:            }
125:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.