Source Code Cross Referenced for BetweenQueryExp.java in  » JMX » mx4j » javax » management » 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 
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:         */
008:
009:        package javax.management;
010:
011:        /**
012:         * @version $Revision: 1.7 $
013:         * @serial include
014:         */
015:        class BetweenQueryExp extends QueryEval implements  QueryExp {
016:            private static final long serialVersionUID = -2933597532866307444L;
017:
018:            /**
019:             * @serial The lower value
020:             */
021:            private final ValueExp exp1;
022:            /**
023:             * @serial The value to test
024:             */
025:            private final ValueExp exp2;
026:            /**
027:             * The upper value
028:             */
029:            private final ValueExp exp3;
030:
031:            BetweenQueryExp(ValueExp exp1, ValueExp exp2, ValueExp exp3) {
032:                this .exp1 = exp1;
033:                this .exp2 = exp2;
034:                this .exp3 = exp3;
035:            }
036:
037:            public void setMBeanServer(MBeanServer server) {
038:                super .setMBeanServer(server);
039:                if (exp1 != null)
040:                    exp1.setMBeanServer(server);
041:                if (exp2 != null)
042:                    exp2.setMBeanServer(server);
043:                if (exp3 != null)
044:                    exp3.setMBeanServer(server);
045:            }
046:
047:            public boolean apply(ObjectName name)
048:                    throws BadStringOperationException,
049:                    BadBinaryOpValueExpException,
050:                    BadAttributeValueExpException, InvalidApplicationException {
051:                if (exp1 != null && exp2 != null && exp3 != null) {
052:                    ValueExp val1 = exp1.apply(name);
053:                    ValueExp val2 = exp2.apply(name);
054:                    ValueExp val3 = exp3.apply(name);
055:
056:                    if (val1 instanceof  NumericValueExp
057:                            && val2 instanceof  NumericValueExp
058:                            && val3 instanceof  NumericValueExp) {
059:                        NumericValueExp num1 = (NumericValueExp) val1;
060:                        NumericValueExp num2 = (NumericValueExp) val2;
061:                        NumericValueExp num3 = (NumericValueExp) val3;
062:
063:                        if (num1.isDouble() || num2.isDouble()
064:                                || num3.isDouble()) {
065:                            return isBetween(new Double(num1.doubleValue()),
066:                                    new Double(num2.doubleValue()), new Double(
067:                                            num3.doubleValue()));
068:                        } else {
069:                            return isBetween(new Long(num1.longValue()),
070:                                    new Long(num2.longValue()), new Long(num3
071:                                            .longValue()));
072:                        }
073:                    }
074:                    /*
075:                     else if (val1 instanceof StringValueExp && val2 instanceof StringValueExp && val3 instanceof StringValueExp)
076:                     {
077:                     String s1 = ((StringValueExp)val1).getValue();
078:                     String s2 = ((StringValueExp)val2).getValue();
079:                     String s3 = ((StringValueExp)val3).getValue();
080:                     return isBetween(s1, s2, s3);
081:                     }
082:                     */
083:                    else {
084:                        throw new InvalidApplicationException(
085:                                "Values are not numeric");
086:                    }
087:                }
088:
089:                return false;
090:            }
091:
092:            private boolean isBetween(Comparable c1, Comparable c2,
093:                    Comparable c3) {
094:                if (c1 == null && c2 == null && c3 == null)
095:                    return true;
096:                if (c1 == null && (c2 == null || c3 == null))
097:                    return true;
098:                if (c1 == null)
099:                    return false;
100:                if (c1 != null && (c2 == null || c3 == null))
101:                    return false;
102:                return c1.compareTo(c2) >= 0 && c1.compareTo(c3) <= 0;
103:            }
104:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.