Source Code Cross Referenced for OpenType.java in  » JMX » mx4j » javax » management » openmbean » 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 » JMX » mx4j » javax.management.openmbean 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * Copyright (C) The MX4J Contributors.
003:         * All rights reserved.
004:         *
005:         * This software is distributed under the terms of the MX4J License version 1.0.
006:         * See the terms of the MX4J License in the documentation provided with this software.
007:         */package javax.management.openmbean;
008:
009:        import java.io.IOException;
010:        import java.io.ObjectInputStream;
011:        import java.io.Serializable;
012:        import java.io.StreamCorruptedException;
013:
014:        import mx4j.util.Utils;
015:
016:        /**
017:         * @version $Revision: 1.12 $
018:         */
019:        public abstract class OpenType implements  Serializable {
020:            private static final long serialVersionUID = -9195195325186646468L;
021:
022:            public static final String[] ALLOWED_CLASSNAMES = {
023:                    "java.lang.Void", "java.lang.Boolean", "java.lang.Byte",
024:                    "java.lang.Character", "java.lang.Short",
025:                    "java.lang.Integer", "java.lang.Long", "java.lang.Float",
026:                    "java.lang.Double", "java.lang.String",
027:                    "java.math.BigDecimal", "java.math.BigInteger",
028:                    "java.util.Date", "javax.management.ObjectName",
029:                    CompositeData.class.getName(), TabularData.class.getName() };
030:
031:            private String className = null;
032:            private String typeName = null;
033:            private String description = null;
034:
035:            protected OpenType(String className, String typeName,
036:                    String description) throws OpenDataException {
037:                initialize(className, typeName, description);
038:            }
039:
040:            /**
041:             * private convenience method for the readObject method to call so that code is not being duplicated in the constructor and the readObject methods
042:             */
043:            private void initialize(String className, String typeName,
044:                    String description) throws OpenDataException {
045:                if (className == null)
046:                    throw new IllegalArgumentException(
047:                            "null className is invalid");
048:                if (typeName == null)
049:                    throw new IllegalArgumentException(
050:                            "null typeName is invalid");
051:                if (description == null)
052:                    throw new IllegalArgumentException(
053:                            "null description is invalid");
054:                if (!(validateClass(className)))
055:                    throw new OpenDataException(
056:                            "Class does not represent one of the allowed className types");
057:                this .className = className;
058:                this .typeName = typeName;
059:                this .description = description;
060:            }
061:
062:            /**
063:             * private validate method just to do some type checking with regards to that the entered className matches the array of allowed types
064:             */
065:            private boolean validateClass(String className) {
066:                /** test we do not have an array if it is it is allowed but it is not listed in the allowed types (be too long) so remove the array
067:                 *  indicator [[[[[L etc and the ; at the end to test if the array type is of the correct class listed above.
068:                 */
069:                if (className.startsWith("["))
070:                    className = className.substring(className.indexOf("L") + 1,
071:                            (className.length() - 1));
072:
073:                for (int i = 0; i < ALLOWED_CLASSNAMES.length; i++) {
074:                    if (className.equals(ALLOWED_CLASSNAMES[i]))
075:                        return true;
076:                }
077:                return false;
078:            }
079:
080:            /**
081:             * Retrieve the className
082:             *
083:             * @return the name of the class
084:             */
085:            public String getClassName() {
086:                return className;
087:            }
088:
089:            /**
090:             * Retrieve the description
091:             *
092:             * @return description
093:             */
094:            public String getDescription() {
095:                return description;
096:            }
097:
098:            /**
099:             * Retrieve the typeName
100:             *
101:             * @return typeName
102:             */
103:            public String getTypeName() {
104:                return typeName;
105:            }
106:
107:            /**
108:             * check if this instance represents an array or not
109:             *
110:             * @return true if the class represents an array, false otherwise
111:             */
112:            public boolean isArray() {
113:                Class c = null;
114:                try {
115:                    c = Utils.loadClass(Thread.currentThread()
116:                            .getContextClassLoader(), className);
117:                } catch (ClassNotFoundException e) {
118:                    return false;
119:                }
120:                return c.isArray();
121:            }
122:
123:            /**
124:             * read out object, validate it using the same methods the constructor uses to validate its' invariants
125:             */
126:            private void readObject(ObjectInputStream inputStream)
127:                    throws IOException, ClassNotFoundException {
128:                inputStream.defaultReadObject();
129:                try {
130:                    initialize(className, typeName, description);
131:                } catch (OpenDataException e) {
132:                    throw new StreamCorruptedException(
133:                            "The object read from the ObjectInputStream during deserialization is not valid");
134:                }
135:            }
136:
137:            public abstract boolean isValue(Object object);
138:
139:            public abstract boolean equals(Object object);
140:
141:            public abstract int hashCode();
142:
143:            public abstract String toString();
144:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.