Source Code Cross Referenced for DoubleThing.java in  » Scripting » hecl » org » hecl » 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 » Scripting » hecl » org.hecl 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* Copyright 2006 Wolfgang S. Kechel
002:
003:        Licensed under the Apache License, Version 2.0 (the "License");
004:        you may not use this file except in compliance with the License.
005:        You may obtain a copy of the License at
006:
007:        http://www.apache.org/licenses/LICENSE-2.0
008:
009:        Unless required by applicable law or agreed to in writing, software
010:        distributed under the License is distributed on an "AS IS" BASIS,
011:        WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
012:        See the License for the specific language governing permissions and
013:        limitations under the License.
014:         */
015:
016:        package org.hecl;
017:
018:        /**
019:         * The <code>DoubleThing</code> class represents a Thing that contains
020:         * a double value.
021:         */
022:        public//#if cldc == 1.0
023:        abstract//#endif
024:        class DoubleThing extends FractionalThing {
025:            public String thingclass() {
026:                return "double";
027:            }
028:
029:            /**
030:             * Creates a new <code>DoubleThing</code> instance equal to 0.
031:             *
032:             */
033:            //#if javaversion >= 1.5 || cldc > 1.0
034:            public DoubleThing() {
035:                set(0.0);
036:            }
037:
038:            /**
039:             * Creates a new <code>DoubleThing</code> instance with value i.
040:             * 
041:             * @param d
042:             *            a <code>double</code> value
043:             */
044:            public DoubleThing(double d) {
045:                set(d);
046:            }
047:
048:            /**
049:             * Creates a new <code>DoubleThing</code> instance from boolean b where true
050:             * is 1 and false is 0.
051:             *
052:             * @param b
053:             *            a <code>boolean</code> value
054:             */
055:            public DoubleThing(boolean b) {
056:                set(b == true ? 1.0 : 0.0);
057:            }
058:
059:            /**
060:             * Creates a new <code>DoubleThing</code> instance from string s.
061:             * 
062:             * @param s
063:             *            a <code>String</code> value
064:             */
065:            public DoubleThing(String s) {
066:                set(Double.parseDouble(s));
067:            }
068:
069:            /**
070:             * The <code>create</code> method creates and returns a newly allocated
071:             * Thing with a DoubleThing internal representation.
072:             * 
073:             * @param d
074:             *            a <code>double</code> value
075:             * @return a <code>Thing</code> value
076:             */
077:            public static Thing create(double d) {
078:                return new Thing(new DoubleThing(d));
079:            }
080:
081:            /**
082:             * The <code>create</code> method creates and returns a newly allocated
083:             * Thing with a DoubleThing internal representation.
084:             * 
085:             * @param b
086:             *            an <code>boolean</code> value
087:             * @return a <code>Thing</code> value
088:             */
089:            public static Thing create(boolean b) {
090:                return new Thing(new DoubleThing(b));
091:            }
092:
093:            /**
094:             * <code>set</code> transforms the given Thing into a DoubleThing,
095:             * internally.
096:             * 
097:             * @param thing
098:             *            a <code>Thing</code> value
099:             * @exception HeclException
100:             *                if an error occurs
101:             */
102:            private static void set(Thing thing) throws HeclException {
103:                RealThing realthing = thing.getVal();
104:
105:                if (realthing instanceof  DoubleThing)
106:                    return;
107:
108:                if (NumberThing.isNumber(realthing)) {
109:                    // It's already a number
110:                    thing.setVal(new DoubleThing(((NumberThing) realthing)
111:                            .doubleValue()));
112:                } else {
113:                    /* Otherwise, try and parse the string representation. */
114:                    thing.setVal(new DoubleThing(thing.toString()));
115:                }
116:            }
117:
118:            /**
119:             * <code>get</code> attempts to fetch a double value from a Thing.
120:             *
121:             * @param thing
122:             *            a <code>Thing</code> value
123:             * @return a <code>double</code> value
124:             * @exception HeclException
125:             *                if an error occurs
126:             */
127:            public static double get(Thing thing) throws HeclException {
128:                set(thing);
129:                return ((DoubleThing) thing.getVal()).doubleValue();
130:            }
131:
132:            public byte byteValue() {
133:                return (byte) val;
134:            }
135:
136:            public short shortValue() {
137:                return (short) val;
138:            }
139:
140:            public int intValue() {
141:                return (int) val;
142:            }
143:
144:            public long longValue() {
145:                return (long) val;
146:            }
147:
148:            public float floatValue() {
149:                return (float) val;
150:            }
151:
152:            public double doubleValue() {
153:                return (double) val;
154:            }
155:
156:            /**
157:             * <code>set</code> sets the internal value of a DoubleThing to i.
158:             * 
159:             * @param d
160:             *            a <code>double</code> value
161:             */
162:            public void set(double d) {
163:                val = d;
164:            }
165:
166:            /**
167:             * <code>deepcopy</code> makes a copy.
168:             * 
169:             * @return a <code>RealThing</code> value
170:             */
171:            public RealThing deepcopy() {
172:                return new DoubleThing(val);
173:            }
174:
175:            /**
176:             * <code>getStringRep</code> creates a string representation of the
177:             * DoubleThing.
178:             * 
179:             * @return a <code>String</code> value
180:             */
181:            public String getStringRep() {
182:                return Double.toString(val);
183:            }
184:
185:            private double val;
186:            //#endif
187:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.