Source Code Cross Referenced for MeasureData.java in  » Profiler » JMeasurement » de » mcs » jmeasurement » 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 » JMeasurement » de.mcs.jmeasurement 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * MCS Media Computer Software Copyright (c) 2005 by MCS
003:         * -------------------------------------- Created on 23.04.2005 by w.klaas
004:         * 
005:         * Licensed under the Apache License, Version 2.0 (the "License"); you may not
006:         * use this file except in compliance with the License. You may obtain a copy of
007:         * the License at
008:         * 
009:         * http://www.apache.org/licenses/LICENSE-2.0
010:         * 
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
013:         * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
014:         * License for the specific language governing permissions and limitations under
015:         * the License.
016:         */
017:        package de.mcs.jmeasurement;
018:
019:        import java.util.Date;
020:
021:        /**
022:         * this class implements one measure data of an measure point.
023:         * 
024:         * @author w.klaas
025:         */
026:        public class MeasureData {
027:
028:            /** name of this data value. */
029:            private String name;
030:
031:            /** the value of this data. */
032:            private Object value;
033:
034:            /** the value of this data. */
035:            private String asString;
036:
037:            /** description of this data. */
038:            private String description;
039:
040:            /** the class of the value. */
041:            private Class myClass;
042:
043:            /** empty constructor not allowed. */
044:            private MeasureData() {
045:
046:            }
047:
048:            /**
049:             * creating a new Measure data object.
050:             * 
051:             * @param aName
052:             *            name of this data
053:             * @param aClass
054:             *            the value class
055:             * @param aValue
056:             *            value of this data
057:             * @param aAsString
058:             *            value as string
059:             * @param aDescription
060:             *            description
061:             */
062:            public MeasureData(final String aName, final Class aClass,
063:                    final Object aValue, final String aAsString,
064:                    final String aDescription) {
065:                this .name = aName;
066:                this .value = aValue;
067:                this .myClass = aClass;
068:                if (aAsString == null) {
069:                    this .asString = aValue.toString();
070:                } else {
071:                    this .asString = aAsString;
072:                }
073:                this .description = aDescription;
074:            }
075:
076:            /**
077:             * @return Returns the string.
078:             */
079:            public final String toString() {
080:                return "name:" + name + " valuetype:" + myClass.toString()
081:                        + " value:" + value.toString();
082:            }
083:
084:            /**
085:             * @return Returns the asString.
086:             */
087:            public final String getAsString() {
088:                return asString;
089:            }
090:
091:            /**
092:             * setting the value as String.
093:             * 
094:             * @param string
095:             *            value as string
096:             */
097:            public final void setAsString(final String string) {
098:                asString = string;
099:            }
100:
101:            /**
102:             * @return Returns the description.
103:             */
104:            public final String getDescription() {
105:                return description;
106:            }
107:
108:            /**
109:             * @return Returns the name.
110:             */
111:            public final String getName() {
112:                return name;
113:            }
114:
115:            /**
116:             * @return Returns the value.
117:             */
118:            public final Object getValue() {
119:                return value;
120:            }
121:
122:            /**
123:             * @return Returns the value.
124:             */
125:            public final Class getValueClass() {
126:                return myClass;
127:            }
128:
129:            /**
130:             * 
131:             * @return the value as long
132:             * @throws InvalidMeasureDataTypeException
133:             *             if the value couldn't be converted.
134:             */
135:            public final long getAsLong()
136:                    throws InvalidMeasureDataTypeException {
137:                if (value instanceof  Long) {
138:                    return ((Long) value).longValue();
139:                } else {
140:                    throw new InvalidMeasureDataTypeException(
141:                            "The measure data is not a Long type.");
142:                }
143:            }
144:
145:            /**
146:             * setting a data to a long value.
147:             * 
148:             * @param aValue
149:             *            value to set
150:             * @throws InvalidMeasureDataTypeException
151:             *             if the value couldn't be converted.
152:             */
153:            public final void setAsLong(final long aValue)
154:                    throws InvalidMeasureDataTypeException {
155:                if ((value == null) || (value instanceof  Long)) {
156:                    value = Long.valueOf(aValue);
157:                    setAsString(Long.toString(aValue));
158:                } else {
159:                    throw new InvalidMeasureDataTypeException(
160:                            "The measure data is not a Long type.");
161:                }
162:            }
163:
164:            /**
165:             * 
166:             * @return the value as long
167:             * @throws InvalidMeasureDataTypeException
168:             *             if the value couldn't be converted.
169:             */
170:            public final int getAsInt() throws InvalidMeasureDataTypeException {
171:                if (value instanceof  Integer) {
172:                    return ((Integer) value).intValue();
173:                } else {
174:                    throw new InvalidMeasureDataTypeException(
175:                            "The measure data is not a Integer type.");
176:                }
177:            }
178:
179:            /**
180:             * setting a data to a long value.
181:             * 
182:             * @param aValue
183:             *            value to set
184:             * @throws InvalidMeasureDataTypeException
185:             *             if the value couldn't be converted.
186:             */
187:            public final void setAsInt(final int aValue)
188:                    throws InvalidMeasureDataTypeException {
189:                if ((value == null) || (value instanceof  Integer)) {
190:                    value = Integer.valueOf(aValue);
191:                    setAsString(Integer.toString(aValue));
192:                } else {
193:                    throw new InvalidMeasureDataTypeException(
194:                            "The measure data is not a Integer type.");
195:                }
196:            }
197:
198:            /**
199:             * Getting the data as a date.
200:             * 
201:             * @return Date
202:             * @throws InvalidMeasureDataTypeException
203:             *             if the value couldn't be converted.
204:             */
205:            public final Date getAsDate()
206:                    throws InvalidMeasureDataTypeException {
207:                if (value instanceof  Date) {
208:                    return ((Date) value);
209:                } else {
210:                    throw new InvalidMeasureDataTypeException(
211:                            "The measure data is not a Date type.");
212:                }
213:            }
214:
215:            /**
216:             * setting a data to a long value.
217:             * 
218:             * @param aDate
219:             *            value to set
220:             * @throws InvalidMeasureDataTypeException
221:             *             if the value couldn't be converted.
222:             */
223:            public final void setAsDate(final Date aDate)
224:                    throws InvalidMeasureDataTypeException {
225:                value = aDate;
226:                setAsString(aDate.toString());
227:            }
228:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.