KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > caucho > jmx > query > AbstractValueExp


1 /*
2  * Copyright (c) 1998-2003 Caucho Technology -- all rights reserved
3  *
4  * This file is part of Resin(R) Open Source
5  *
6  * Each copy or derived work must preserve the copyright notice and this
7  * notice unmodified.
8  *
9  * Resin Open Source is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * Resin Open Source is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
17  * of NON-INFRINGEMENT. See the GNU General Public License for more
18  * details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with Resin Open Source; if not, write to the
22  * Free SoftwareFoundation, Inc.
23  * 59 Temple Place, Suite 330
24  * Boston, MA 02111-1307 USA
25  *
26  * @author Scott Ferguson
27  */

28
29 package com.caucho.jmx.query;
30
31 import javax.management.*;
32
33 /**
34  * Implementation of a less-than query
35  */

36 abstract public class AbstractValueExp extends QueryEval implements ValueExp {
37   /**
38    * Returns a value expression the value expression matches the name.
39    */

40   public ValueExp apply(ObjectName name)
41     throws BadStringOperationException,
42     BadBinaryOpValueExpException,
43     BadAttributeValueExpException,
44     InvalidApplicationException
45   {
46     return this;
47   }
48   
49   /**
50    * Returns the value as a string.
51    */

52   public String getString()
53   {
54     throw new UnsupportedOperationException();
55   }
56   
57   /**
58    * Returns the value as a boolean.
59    */

60   public boolean getBoolean()
61   {
62     String value = getString();
63     
64     return value != null && value.equals("true");
65   }
66   
67   /**
68    * Returns the value as a long
69    */

70   public long getLong()
71   {
72     String value = getString();
73
74     if (value == null)
75       return 0;
76     else
77       return Long.parseLong(value);
78   }
79   
80   /**
81    * Returns the value as a double
82    */

83   public double getDouble()
84   {
85     String value = getString();
86
87     if (value == null)
88       return 0;
89     else
90       return Double.parseDouble(value);
91   }
92   
93   /**
94    * Converts to a string value.
95    */

96   public static String toString(ValueExp exp)
97     throws BadBinaryOpValueExpException
98   {
99     return AbstractExp.toString(exp);
100   }
101   
102   /**
103    * Converts to a long value.
104    */

105   public static long toLong(ValueExp exp)
106     throws BadBinaryOpValueExpException
107   {
108     return AbstractExp.toLong(exp);
109   }
110   
111   /**
112    * Converts to a long value.
113    */

114   public static boolean toBoolean(ValueExp exp)
115     throws BadBinaryOpValueExpException
116   {
117     return AbstractExp.toBoolean(exp);
118   }
119   
120   /**
121    * Converts to a double value.
122    */

123   public static double toDouble(ValueExp exp)
124     throws BadBinaryOpValueExpException
125   {
126     return AbstractExp.toDouble(exp);
127   }
128 }
129
Popular Tags