KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mr > api > jms > selector > syntax > MantaObject


1 /*
2  * Copyright 2002 by
3  * <a HREF="http://www.coridan.com">Coridan</a>
4  * <a HREF="mailto: support@coridan.com ">support@coridan.com</a>
5  *
6  * The contents of this file are subject to the Mozilla Public License Version
7  * 1.1 (the "License"); you may not use this file except in compliance with the
8  * License. You may obtain a copy of the License at
9  * http://www.mozilla.org/MPL/
10  *
11  * Software distributed under the License is distributed on an "AS IS" basis,
12  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13  * for the specific language governing rights and limitations under the
14  * License.
15  *
16  * The Original Code is "MantaRay" (TM).
17  *
18  * The Initial Developer of the Original Code is Coridan.
19  * Portions created by the Initial Developer are Copyright (C) 2006
20  * Coridan Inc. All Rights Reserved.
21  *
22  * Contributor(s): all the names of the contributors are added in the source
23  * code where applicable.
24  *
25  * Alternatively, the contents of this file may be used under the terms of the
26  * LGPL license (the "GNU LESSER GENERAL PUBLIC LICENSE"), in which case the
27  * provisions of LGPL are applicable instead of those above. If you wish to
28  * allow use of your version of this file only under the terms of the LGPL
29  * License and not to allow others to use your version of this file under
30  * the MPL, indicate your decision by deleting the provisions above and
31  * replace them with the notice and other provisions required by the LGPL.
32  * If you do not delete the provisions above, a recipient may use your version
33  * of this file under either the MPL or the GNU LESSER GENERAL PUBLIC LICENSE.
34  
35  *
36  * This library is free software; you can redistribute it and/or modify it
37  * under the terms of the MPL as stated above or under the terms of the GNU
38  * Lesser General Public License as published by the Free Software Foundation;
39  * either version 2.1 of the License, or any later version.
40  *
41  * This library is distributed in the hope that it will be useful, but WITHOUT
42  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
43  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
44  * License for more details.
45  */

46 package org.mr.api.jms.selector.syntax;
47
48
49 /**
50  * This class is the base class for classes adapting simple Java types.
51  * This is necessary to:
52  * <ul>
53  * <li>reduce the number of types that the selector has to deal with.
54  * Expressions only evaluate to boolean, numeric and string types.
55  * </li>
56  * <li>Simplify operations (comparison, type checking etc.) on these types.
57  * </li>
58  * </ul>
59  *
60
61  */

62 abstract class MantaObject {
63
64     /**
65      * Returns the underlying object
66      *
67      * @return the underlying object
68      */

69     public abstract Object JavaDoc getObject();
70
71     
72     /**
73      * Determines if this is equal to another object.
74      *
75      * @param obj the object to compare
76      * @return null if the comparison is undefined,
77      * MantaBoolean.TRUE if this = obj, otherwise
78      * MantaBoolean.FALSE if this &lt;&gt; obj
79      */

80     public MantaBoolean equal(final MantaObject obj) {
81         MantaBoolean result = MantaBoolean.FALSE;
82         if (getObject().equals(obj.getObject())) {
83             result = MantaBoolean.TRUE;
84         }
85         return result;
86     }
87
88     /**
89      * Determines if this is not equal to another object
90      *
91      * @param obj the object to compare
92      * @return null if the comparison is undefined,
93      * MantaBoolean.TRUE if this &lt;&gt; obj, otherwise
94      * MantaBoolean.FALSE if this = obj
95      */

96     public MantaBoolean notEqual(final MantaObject obj) {
97         MantaBoolean result = equal(obj);
98         if (result != null) {
99             result = result.not();
100         }
101         return result;
102     }
103
104     /**
105      * Determines if this is less than another object.
106      *
107      * @param obj the object to compare
108      * @return null if the comparison is undefined,
109      * MantaBoolean.TRUE if this &lt; obj, otherwise
110      * MantaBoolean.FALSE if this &gt;= obj
111      */

112     public MantaBoolean less(final MantaObject obj) {
113         return null;
114     }
115
116     /**
117      * Determines if this is greater than another object.
118      *
119      * @param obj the object to compare
120      * @return null if the comparison is undefined,
121      * MantaBoolean.TRUE if this &gt; obj, otherwise
122      * MantaBoolean.FALSE if this &lt;= obj
123      */

124     public MantaBoolean greater(final MantaObject obj) {
125         return null;
126     }
127
128     /**
129      * Determines if this is less than or equal to another object.
130      *
131      * @param obj the object to compare
132      * @return null if the comparison is undefined,
133      * MantaBoolean.TRUE if this &lt;= obj, otherwise
134      * MantaBoolean.FALSE if this &gt; obj
135      */

136     public MantaBoolean lessEqual(final MantaObject obj) {
137         MantaBoolean result = less(obj);
138         if (result != null && !result.value()) {
139             result = equal(obj);
140         }
141         return result;
142     }
143
144     /**
145      * Determines if this is greater than or equal to another object.
146      *
147      * @param obj the object to compare
148      * @return null if the comparison is undefined, MantaBoolean.TRUE if this &gt;= obj, otherwise
149      * MantaBoolean.FALSE if this &lt; obj
150      */

151     public MantaBoolean greaterEqual(final MantaObject obj) {
152         MantaBoolean result = greater(obj);
153        
154         if (result != null && !result.value()) {
155             result = equal(obj);
156         }//if
157
return result;
158     }//greaterEqual
159

160     
161     /**
162      * Returns a string representation of this
163      *
164      * @return a string representation of this
165      */

166     public String JavaDoc toString() {
167         return getObject().toString();
168     }//toString
169

170     
171     /**
172      * Determines the type of this
173      *
174      * @return the type of this
175      */

176     public abstract Type type();
177
178 }//MantaObject
179
Popular Tags