Source Code Cross Referenced for BinaryOpValueExp.java in  » EJB-Server-JBoss-4.2.1 » jmx » 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 » EJB Server JBoss 4.2.1 » jmx » javax.management 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * JBoss, Home of Professional Open Source.
003:         * Copyright 2006, Red Hat Middleware LLC, and individual contributors
004:         * as indicated by the @author tags. See the copyright.txt file in the
005:         * distribution for a full listing of individual contributors.
006:         *
007:         * This is free software; you can redistribute it and/or modify it
008:         * under the terms of the GNU Lesser General Public License as
009:         * published by the Free Software Foundation; either version 2.1 of
010:         * the License, or (at your option) any later version.
011:         *
012:         * This software is distributed in the hope that it will be useful,
013:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
014:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015:         * Lesser General Public License for more details.
016:         *
017:         * You should have received a copy of the GNU Lesser General Public
018:         * License along with this software; if not, write to the Free
019:         * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020:         * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
021:         */
022:        package javax.management;
023:
024:        /**
025:         * A Binary Operation that is an arguement to a query.
026:         *
027:         * <p><b>Revisions:</b>
028:         * <p><b>20020314 Adrian Brock:</b>
029:         * <ul>
030:         * <li>Added human readable string representation.            
031:         * </ul>
032:         * <p><b>20020317 Adrian Brock:</b>
033:         * <ul>
034:         * <li>Make queries thread safe
035:         * </ul>
036:         * 
037:         * @author  <a href="mailto:Adrian.Brock@HappeningTimes.com">Adrian Brock</a>.
038:         * @version $Revision: 57200 $
039:         */
040:        class BinaryOpValueExp extends QueryEval implements  ValueExp {
041:            // Constants ---------------------------------------------------
042:
043:            private static final long serialVersionUID = 1216286847881456786L;
044:
045:            // Attributes --------------------------------------------------
046:
047:            /**
048:             * The operation
049:             */
050:            private int op;
051:
052:            /**
053:             * The first expression
054:             */
055:            private ValueExp exp1;
056:
057:            /**
058:             * The second expression
059:             */
060:            private ValueExp exp2;
061:
062:            // Constructors ------------------------------------------------
063:
064:            public BinaryOpValueExp() {
065:            }
066:
067:            /**
068:             * Construct a binary operation value
069:             *
070:             * @param operation the operation as defined in Query
071:             * @param first the first expression in the operation
072:             * @param second the second expression in the operation
073:             */
074:            public BinaryOpValueExp(int operation, ValueExp first,
075:                    ValueExp second) {
076:                this .op = operation;
077:                this .exp1 = first;
078:                this .exp2 = second;
079:            }
080:
081:            // Public ------------------------------------------------------
082:
083:            // Value Exp Implementation ------------------------------------
084:
085:            public ValueExp apply(ObjectName name)
086:                    throws BadStringOperationException,
087:                    BadBinaryOpValueExpException,
088:                    BadAttributeValueExpException, InvalidApplicationException {
089:                ValueExp testFirst = exp1.apply(name);
090:                ValueExp testSecond = exp2.apply(name);
091:
092:                if (testFirst instanceof  NumericValueExp
093:                        && testSecond instanceof  NumericValueExp) {
094:                    if (((NumericValueExp) testFirst).isInteger()) {
095:                        switch (op) {
096:                        case Query.PLUS:
097:                            return Query.value(((NumericValueExp) testFirst)
098:                                    .getLongValue()
099:                                    + ((NumericValueExp) testSecond)
100:                                            .getLongValue());
101:                        case Query.MINUS:
102:                            return Query.value(((NumericValueExp) testFirst)
103:                                    .getLongValue()
104:                                    - ((NumericValueExp) testSecond)
105:                                            .getLongValue());
106:                        case Query.TIMES:
107:                            return Query.value(((NumericValueExp) testFirst)
108:                                    .getLongValue()
109:                                    * ((NumericValueExp) testSecond)
110:                                            .getLongValue());
111:                        case Query.DIV:
112:                            return Query.value(((NumericValueExp) testFirst)
113:                                    .getLongValue()
114:                                    / ((NumericValueExp) testSecond)
115:                                            .getLongValue());
116:                        }
117:                    } else {
118:                        switch (op) {
119:                        case Query.PLUS:
120:                            return Query.value(((NumericValueExp) testFirst)
121:                                    .getDoubleValue()
122:                                    + ((NumericValueExp) testSecond)
123:                                            .getDoubleValue());
124:                        case Query.MINUS:
125:                            return Query.value(((NumericValueExp) testFirst)
126:                                    .getDoubleValue()
127:                                    - ((NumericValueExp) testSecond)
128:                                            .getDoubleValue());
129:                        case Query.TIMES:
130:                            return Query.value(((NumericValueExp) testFirst)
131:                                    .getDoubleValue()
132:                                    * ((NumericValueExp) testSecond)
133:                                            .getDoubleValue());
134:                        case Query.DIV:
135:                            return Query.value(((NumericValueExp) testFirst)
136:                                    .getDoubleValue()
137:                                    / ((NumericValueExp) testSecond)
138:                                            .getDoubleValue());
139:                        }
140:                    }
141:                } else if (testFirst instanceof  StringValueExp
142:                        && testSecond instanceof  StringValueExp) {
143:                    switch (op) {
144:                    case Query.PLUS:
145:                        return Query.value(new String(testFirst.toString()
146:                                + testSecond.toString()));
147:                    }
148:                    throw new BadStringOperationException("TODO");
149:                }
150:                // Review What happens now?
151:                throw new BadBinaryOpValueExpException(testFirst);
152:            }
153:
154:            // Object overrides --------------------------------------------
155:
156:            public String toString() {
157:                StringBuffer buffer = new StringBuffer();
158:                buffer.append("(");
159:                buffer.append(exp1);
160:                buffer.append(")");
161:                switch (op) {
162:                case Query.PLUS:
163:                    buffer.append(" + ");
164:                    break;
165:                case Query.MINUS:
166:                    buffer.append(" - ");
167:                    break;
168:                case Query.TIMES:
169:                    buffer.append(" * ");
170:                    break;
171:                case Query.DIV:
172:                    buffer.append(" / ");
173:                }
174:                buffer.append("(");
175:                buffer.append(exp2);
176:                buffer.append(")");
177:                return buffer.toString();
178:            }
179:
180:            // Protected ---------------------------------------------------
181:
182:            // Package Private ---------------------------------------------
183:
184:            // Private -----------------------------------------------------
185:
186:            // Inner Classes -----------------------------------------------
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.