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


001:        /**
002:         * The XMOJO Project 5
003:         * Copyright © 2003 XMOJO.org. All rights reserved.
004:
005:         * NO WARRANTY
006:
007:         * BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR
008:         * THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
009:         * OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
010:         * PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
011:         * OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
012:         * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
013:         * TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE
014:         * LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
015:         * REPAIR OR CORRECTION.
016:
017:         * IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL
018:         * ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE
019:         * THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
020:         * GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
021:         * USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF
022:         * DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
023:         * PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE),
024:         * EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
025:         * SUCH DAMAGES.
026:         **/package javax.management;
027:
028:        /**
029:         * This Query class supports construction of query object constraints.
030:         * The static methods provided return query expressions that may be used in
031:         * listing and enumerating MBeans. Individual constraint constructing methods
032:         * allow only appropriate types as arguments. Composition of calls can
033:         * construct arbitrary nestings of constraints, as the following
034:         * example illustrates:
035:         * QueryExp exp = Query.and(Query.gt(Query.attr("age"),Query.value(5)),
036:         * 					Query.match(Query.attr("name"), Query.value("John")));
037:         */
038:        public class Query {
039:            public static final int DIV = 1;
040:
041:            public static final int EQ = 2;
042:
043:            public static final int GE = 3;
044:
045:            public static final int GT = 4;
046:
047:            public static final int LE = 5;
048:
049:            public static final int LT = 6;
050:
051:            public static final int MINUS = 7;
052:
053:            public static final int PLUS = 8;
054:
055:            public static final int TIMES = 9;
056:
057:            static final int MATCH = 10;
058:
059:            static final int AND = 11;
060:
061:            static final int OR = 12;
062:
063:            static final int BET = 13;
064:
065:            static final int NOT = 14;
066:
067:            static final int IN = 15;
068:
069:            static final int INITIAL = 16;
070:
071:            static final int ANY = 17;
072:
073:            static final int FINAL = 18;
074:
075:            /**
076:             * Constructs a query object.
077:             */
078:            public Query() {
079:            }
080:
081:            /**
082:             * Returns a new attribute expression.
083:             *
084:             * @param name - The name of the attribute.
085:             *
086:             * @return An attribute expression for the attribute named name.
087:             */
088:            public static AttributeValueExp attr(String name) {
089:                return new AttributeValueExp(name);
090:            }
091:
092:            /**
093:             * Returns a new qualified attribute expression.
094:             *
095:             * @param className - The name of the class possessing the attribute
096:             *
097:             * @param name - The name of the attribute
098:             *
099:             * @return An attribute expression for the attribute named name.
100:             */
101:            public static AttributeValueExp attr(String className, String name) {
102:                return new AttributeValueExp(className, name);
103:            }
104:
105:            /**
106:             * Returns a new class attribute expression which can be used in any
107:             * Query call that expects a ValueExp.
108:             *
109:             * @return A class attribute expression.
110:             */
111:            public static AttributeValueExp classattr() {
112:                return new AttributeValueExp();
113:            }
114:
115:            /**
116:             * Returns a numeric value expression that can be used in any Query
117:             * call that expects a ValueExp.
118:             *
119:             * @param val - An int value
120:             *
121:             * @return A ValueExp object containing the argument.
122:             */
123:            public static ValueExp value(int val) {
124:                return new AttributeValueExp(null, new Integer(val));
125:            }
126:
127:            /**
128:             * Returns a numeric value expression that can be used in any Query
129:             * call that expects a ValueExp.
130:             *
131:             * @param val - A long value
132:             *
133:             * @return A ValueExp object containing the argument.
134:             */
135:            public static ValueExp value(long val) {
136:                return new AttributeValueExp(null, new Long(val));
137:            }
138:
139:            /**
140:             * Returns a numeric value expression that can be used in any Query
141:             * call that expects a ValueExp.
142:             *
143:             * @param val - A float value
144:             *
145:             * @return A ValueExp object containing the argument.
146:             */
147:            public static ValueExp value(float val) {
148:                return new AttributeValueExp(null, new Float(val));
149:            }
150:
151:            /**
152:             * Returns a numeric value expression that can be used in any Query
153:             * call that expects a ValueExp.
154:             *
155:             * @param val - A double value
156:             *
157:             * @return A ValueExp object containing the argument.
158:             */
159:            public static ValueExp value(double val) {
160:                return new AttributeValueExp(null, new Double(val));
161:            }
162:
163:            /**
164:             * Returns a boolean value expression that can be used in any Query
165:             * call that expects a ValueExp.
166:             *
167:             * @param val - A boolean value
168:             *
169:             * @return A ValueExp object containing the argument.
170:             */
171:            public static ValueExp value(boolean val) {
172:                return new AttributeValueExp(null, new Boolean(val));
173:            }
174:
175:            /**
176:             * Returns a numeric value expression that can be used in any Query
177:             * call that expects a ValueExp.
178:             *
179:             * @param val - An instance of Number
180:             *
181:             * @return A ValueExp object containing the argument.
182:             */
183:            public static ValueExp value(Number val) {
184:                return new AttributeValueExp(null, val);
185:            }
186:
187:            /**
188:             * Returns a new string expression.
189:             *
190:             * @param val - The string value
191:             *
192:             * @return A ValueExp object containing the string argument.
193:             */
194:            public static StringValueExp value(String val) {
195:                return new StringValueExp(val);
196:            }
197:
198:            /**
199:             * Returns a binary expression representing the sum of two numeric values
200:             * or the concatenation of two string values.
201:             *
202:             * @param v1 - The first '+' operand.
203:             *
204:             * @param v2 - The second '+' operand.
205:             *
206:             * @return A ValueExp representing the sum or concatenation of the two arguments
207:             */
208:            public static ValueExp plus(ValueExp v1, ValueExp v2) {
209:                if (v1 instanceof  AttributeValueExp
210:                        && v2 instanceof  AttributeValueExp)
211:                    return new AttributeValueExp((AttributeValueExp) v1,
212:                            (AttributeValueExp) v2, PLUS);
213:
214:                if (v1 instanceof  StringValueExp
215:                        && v2 instanceof  StringValueExp)
216:                    return new StringValueExp((StringValueExp) v1,
217:                            (StringValueExp) v2, PLUS);
218:
219:                return null;
220:            }
221:
222:            /**
223:             * Returns a binary expression representing the difference of two
224:             * numeric values.
225:             *
226:             * @param v1 - The first '-' operand.
227:             *
228:             * @param v2 - The second '-' operand.
229:             *
230:             * @return A ValueExp representing the difference of two arguments.
231:             */
232:            public static ValueExp minus(ValueExp v1, ValueExp v2) {
233:                if (v1 instanceof  AttributeValueExp
234:                        && v2 instanceof  AttributeValueExp)
235:                    return new AttributeValueExp((AttributeValueExp) v1,
236:                            (AttributeValueExp) v2, MINUS);
237:
238:                return null;
239:            }
240:
241:            /**
242:             * Returns a binary expression representing the product of two numeric values.
243:             *
244:             * @param v1 - The first '*' operand.
245:             *
246:             * @param v2 - The second '*' operand.
247:             *
248:             * @return A ValueExp representing the product.
249:             */
250:            public static ValueExp times(ValueExp v1, ValueExp v2) {
251:                if (v1 instanceof  AttributeValueExp
252:                        && v2 instanceof  AttributeValueExp)
253:                    return new AttributeValueExp((AttributeValueExp) v1,
254:                            (AttributeValueExp) v2, TIMES);
255:
256:                return null;
257:            }
258:
259:            /**
260:             * Returns a binary expression representing the quotient of two numeric values.
261:             *
262:             * @param v1 - The first '/' operand.
263:             *
264:             * @param v2 - The second '/' operand.
265:             *
266:             * @return A ValueExp representing the quotient of two arguments.
267:             */
268:            public static ValueExp div(ValueExp v1, ValueExp v2) {
269:                if (v1 instanceof  AttributeValueExp
270:                        && v2 instanceof  AttributeValueExp)
271:                    return new AttributeValueExp((AttributeValueExp) v1,
272:                            (AttributeValueExp) v2, DIV);
273:
274:                return null;
275:            }
276:
277:            /**
278:             * Returns a query expression that represents a "greater than" constraint
279:             * on two values.
280:             *
281:             * @param v1 - A value expression
282:             *
283:             * @param v2 - Another value expression
284:             *
285:             * @return A "greater than" constraint on the arguments.
286:             */
287:            public static QueryExp gt(ValueExp v1, ValueExp v2) {
288:                return new QueryExpSupport(v1, v2, GT);
289:            }
290:
291:            /**
292:             * Returns a query expression that represents a matching constraint on a
293:             * string argument. The matching syntax is consistent with file globbing:
294:             * Supports "?", "*", "[", each of which may be escaped with "\";
295:             * Character classes may use "!" for negation and "-" for range.
296:             * (* for any character sequence ? for a single arbitrary character [...]
297:             * for a character sequence). For example: a*b?c would match a string
298:             * starting with the character a, followed by any number of characters,
299:             * followed by a b, any single character, and a c.
300:             *
301:             * @param a - An attribute expression
302:             *
303:             * @param s - A string value expression representing a matching constraint
304:             *
305:             * @return A query expression that represents the matching constraint
306:             * 				on the string argument.
307:             */
308:            public static QueryExp match(AttributeValueExp a, StringValueExp s) {
309:                return new QueryExpSupport(a, s, MATCH);
310:            }
311:
312:            /**
313:             * Returns a query expression that represents a "greater than or equal to"
314:             * constraint on two values.
315:             *
316:             * @param v1 - A value expression
317:             *
318:             * @param v2 - Another value expression
319:             *
320:             * @return A "greater than or equal to" constraint on the arguments.
321:             */
322:            public static QueryExp geq(ValueExp v1, ValueExp v2) {
323:                return new QueryExpSupport(v1, v2, GE);
324:            }
325:
326:            /**
327:             * Returns a query expression that represents a "less than or equal to"
328:             * constraint on two values.
329:             *
330:             * @param  v1 - A value expression
331:             *
332:             * @param  v2 - Another value expression
333:             *
334:             * @return A "less than or equal to" constraint on the arguments.
335:             */
336:            public static QueryExp leq(ValueExp v1, ValueExp v2) {
337:                return new QueryExpSupport(v1, v2, LE);
338:            }
339:
340:            /**
341:             * Returns a query expression that represents a "less than" constraint
342:             * on two values.
343:             *
344:             * @param v1 - A value expression
345:             *
346:             * @param v2 - Another value expression
347:             *
348:             * @return A "less than" constraint on the arguments.
349:             */
350:            public static QueryExp lt(ValueExp v1, ValueExp v2) {
351:                return new QueryExpSupport(v1, v2, LT);
352:            }
353:
354:            /**
355:             * Returns a query expression that represents an equality constraint
356:             * on two values.
357:             *
358:             * @param v1 - A value expression
359:             * @param v2 - Another value expression
360:             *
361:             * @return A "equal to" constraint on the arguments.
362:             */
363:            public static QueryExp eq(ValueExp v1, ValueExp v2) {
364:                return new QueryExpSupport(v1, v2, EQ);
365:            }
366:
367:            /**
368:             * Returns a query expression that represents the constraint that one
369:             * value is between two other values.
370:             *
371:             * @param v1 - A value expression that is "between" v2 and v3
372:             *
373:             * @param v2 - Value expression that represents a boundary of the constraint
374:             *
375:             * @param v3 - Value expression that represents a boundary of the constraint
376:             *
377:             * @return The constraint that v1 lies between v2 and v3.
378:             */
379:            public static QueryExp between(ValueExp v1, ValueExp v2, ValueExp v3) {
380:                return new QueryExpSupport(v1, v2, v3, BET);
381:            }
382:
383:            /**
384:             * Returns an expression constraining a value to be one of an explicit list.
385:             *
386:             * @param val - A value to be constrained
387:             *
388:             * @param valueList - An array of ValueExps
389:             *
390:             * @return A QueryExp that represents the constraint.
391:             */
392:            public static QueryExp in(ValueExp va1, ValueExp[] valueList) {
393:                return new QueryExpSupport(va1, valueList, IN);
394:            }
395:
396:            /**
397:             * Returns a query expression that represents a matching constraint on a
398:             * string argument. The value must start with the given string value.
399:             *
400:             * @param a - An attribute expression
401:             *
402:             * @param s - A string value expression representing the beginning
403:             * 				of the string value
404:             *
405:             * @return The constraint that a matches s.
406:             */
407:            public static QueryExp initialSubString(AttributeValueExp a,
408:                    StringValueExp s) {
409:                return new QueryExpSupport(a, s, INITIAL);
410:            }
411:
412:            /**
413:             * Returns a query expression that represents a matching constraint on a
414:             * string argument. The value must contain the given string value.
415:             *
416:             * @param a - An attribute expression
417:             *
418:             * @param s - A string value expression representing the substring.
419:             *
420:             * @return The constraint that a matches s.
421:             */
422:            public static QueryExp anySubString(AttributeValueExp a,
423:                    StringValueExp s) {
424:                return new QueryExpSupport(a, s, ANY);
425:            }
426:
427:            /**
428:             * Returns a query expression that represents a matching constraint on a
429:             * string argument. The value must contain the given string value.
430:             *
431:             * @param a - An attribute expression
432:             *
433:             * @param s - A string value expression representing the end of the string value
434:             *
435:             * @return The constraint that a matches s.
436:             */
437:            public static QueryExp finalSubString(AttributeValueExp a,
438:                    StringValueExp s) {
439:                return new QueryExpSupport(a, s, FINAL);
440:            }
441:
442:            /**
443:             * Returns a query expression that is the conjunction of two other query
444:             * expressions.
445:             *
446:             * @param q1 - A query expression
447:             *
448:             * @param q2 - Another query expression
449:             *
450:             * @return The conjunction of the two arguments.
451:             */
452:            public static QueryExp and(QueryExp q1, QueryExp q2) {
453:                return new QueryExpSupport(q1, q2, AND);
454:            }
455:
456:            /**
457:             * Returns a query expression that is the disjunction of two other
458:             * query expressions.
459:             *
460:             * @param q1 - A query expression
461:             *
462:             * @param q2 - Another query expression
463:             *
464:             * @return The disjunction of the two arguments.
465:             */
466:            public static QueryExp or(QueryExp q1, QueryExp q2) {
467:                return new QueryExpSupport(q1, q2, OR);
468:            }
469:
470:            /**
471:             * Returns a constraint that is the negation of its argument.
472:             *
473:             * @param queryExp - The constraint to negate
474:             *
475:             * @return A negated constraint.
476:             */
477:            public static QueryExp not(QueryExp queryExp) {
478:                return new QueryExpSupport(queryExp, NOT);
479:            }
480:        }//End of class Query
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.