Source Code Cross Referenced for TransformedUnit.java in  » Science » jscience-4.3.1 » javax » measure » unit » 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 » Science » jscience 4.3.1 » javax.measure.unit 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * JScience - Java(TM) Tools and Libraries for the Advancement of Sciences.
003:         * Copyright (C) 2006 - JScience (http://jscience.org/)
004:         * All rights reserved.
005:         * 
006:         * Permission to use, copy, modify, and distribute this software is
007:         * freely granted, provided that this notice is preserved.
008:         */
009:        package javax.measure.unit;
010:
011:        import javax.measure.converter.UnitConverter;
012:        import javax.measure.quantity.Quantity;
013:
014:        /**
015:         * <p> This class represents the units derived from other units using
016:         *     {@link UnitConverter converters}.</p>
017:         *     
018:         * <p> Examples of transformed units:[code]
019:         *         CELSIUS = KELVIN.add(273.15);
020:         *         FOOT = METER.multiply(0.3048);
021:         *         MILLISECOND = MILLI(SECOND); 
022:         *     [/code]</p>
023:         *     
024:         * <p> Transformed units have no label. But like any other units,
025:         *     they may have labels attached to them:[code]
026:         *         UnitFormat.getStandardInstance().label(FOOT, "ft");
027:         *     [/code]
028:         *     or aliases: [code]
029:         *         UnitFormat.getStandardInstance().alias(CENTI(METER)), "centimeter");
030:         *         UnitFormat.getStandardInstance().alias(CENTI(METER)), "centimetre");
031:         *     [/code]</p>
032:         *
033:         * @author  <a href="mailto:jean-marie@dautelle.com">Jean-Marie Dautelle</a>
034:         * @version 3.1, April 22, 2006
035:         * @see     Unit#plus(double)
036:         * @see     Unit#times(double)
037:         * @see     Unit#transform(UnitConverter)
038:         * @see     UnitFormat
039:         */
040:        public final class TransformedUnit<Q extends Quantity> extends
041:                DerivedUnit<Q> {
042:
043:            /**
044:             * Holds the parent unit (not a transformed unit).
045:             */
046:            private final Unit<Q> _parentUnit;
047:
048:            /**
049:             * Holds the converter to the parent unit.
050:             */
051:            private final UnitConverter _toParentUnit;
052:
053:            /**
054:             * Creates a transformed unit from the specified parent unit.
055:             *
056:             * @param parentUnit the untransformed unit from which this unit is 
057:             *        derived.
058:             * @param  toParentUnit the converter to the parent units.
059:             * @throws IllegalArgumentException if <code>toParentUnit == 
060:             *         {@link UnitConverter#IDENTITY UnitConverter.IDENTITY}</code>
061:             */
062:            TransformedUnit(Unit<Q> parentUnit, UnitConverter toParentUnit) {
063:                if (toParentUnit == UnitConverter.IDENTITY)
064:                    throw new IllegalArgumentException("Identity not allowed");
065:                _parentUnit = parentUnit;
066:                _toParentUnit = toParentUnit;
067:            }
068:
069:            /**
070:             * Returns the parent unit for this unit. The parent unit is the 
071:             * untransformed unit from which this unit is derived.
072:             *
073:             * @return the untransformed unit from which this unit is derived.
074:             */
075:            public Unit<Q> getParentUnit() {
076:                return _parentUnit;
077:            }
078:
079:            /**
080:             * Returns the converter to the parent unit.
081:             *
082:             * @return the converter to the parent unit.
083:             */
084:            public UnitConverter toParentUnit() {
085:                return _toParentUnit;
086:            }
087:
088:            /**
089:             * Indicates if this transformed unit is considered equals to the specified 
090:             * object (both are transformed units with equal parent unit and equal
091:             * converter to parent unit).
092:             *
093:             * @param  that the object to compare for equality.
094:             * @return <code>true</code> if <code>this</code> and <code>that</code>
095:             *         are considered equals; <code>false</code>otherwise. 
096:             */
097:            public boolean equals(Object that) {
098:                if (this  == that)
099:                    return true;
100:                if (!(that instanceof  TransformedUnit))
101:                    return false;
102:                TransformedUnit<?> thatUnit = (TransformedUnit<?>) that;
103:                return this ._parentUnit.equals(thatUnit._parentUnit)
104:                        && this ._toParentUnit.equals(thatUnit._toParentUnit);
105:            }
106:
107:            // Implements abstract method.
108:            public int hashCode() {
109:                return _parentUnit.hashCode() + _toParentUnit.hashCode();
110:            }
111:
112:            // Implements abstract method.
113:            public Unit<? super  Q> getStandardUnit() {
114:                return _parentUnit.getStandardUnit();
115:            }
116:
117:            // Implements abstract method.
118:            public UnitConverter toStandardUnit() {
119:                return _parentUnit.toStandardUnit().concatenate(_toParentUnit);
120:            }
121:
122:            private static final long serialVersionUID = 1L;
123:
124:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.