0N/A/*
2362N/A * Copyright (c) 1999, 2004, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/Apackage javax.management;
0N/A
0N/A
0N/A/**
0N/A * Represents values that can be passed as arguments to
0N/A * relational expressions. Strings, numbers, attributes are valid values
0N/A * and should be represented by implementations of <CODE>ValueExp</CODE>.
0N/A *
0N/A * @since 1.5
0N/A */
0N/A/*
0N/A We considered generifying this interface as ValueExp<T>, where T is
0N/A the Java type that this expression generates. This allows some additional
0N/A checking in the various methods of the Query class, but in practice
0N/A not much. Typically you have something like
0N/A Query.lt(Query.attr("A"), Query.value(5)). We can arrange for Query.value
0N/A to have type ValueExp<Integer> (or maybe ValueExp<Long> or ValueExp<Number>)
0N/A but for Query.attr we can't do better than ValueExp<?> or plain ValueExp.
0N/A So even though we could define Query.lt as:
0N/A QueryExp <T> lt(ValueExp<T> v1, ValueExp<T> v2)
0N/A and thus prevent comparing a
0N/A number against a string, in practice the first ValueExp will almost always
0N/A be a Query.attr so this check serves no purpose. You would have to
0N/A write Query.<Number>attr("A"), for example, which would be awful. And,
0N/A if you wrote Query.<Integer>attr("A") you would then discover that you
0N/A couldn't compare it against Query.value(5) if the latter is defined as
0N/A ValueExp<Number>, or against Query.value(5L) if it is defined as
0N/A ValueExp<Integer>.
0N/A
0N/A Worse, for Query.in we would like to define:
0N/A QueryExp <T> in(ValueExp<T> val, ValueExp<T>[] valueList)
0N/A but this is unusable because you cannot write
0N/A "new ValueExp<Integer>[] {...}" (the compiler forbids it).
0N/A
0N/A The few mistakes you might catch with this generification certainly
0N/A wouldn't justify the hassle of modifying user code to get the checks
0N/A to be made and the "unchecked" warnings that would arise if it
0N/A wasn't so modified.
0N/A
0N/A We could reconsider this if the Query methods were augmented, for example
0N/A with:
0N/A AttributeValueExp<Number> numberAttr(String name);
0N/A AttributeValueExp<String> stringAttr(String name);
0N/A AttributeValueExp<Boolean> booleanAttr(String name);
0N/A QueryExp <T> in(ValueExp<T> val, Set<ValueExp<T>> valueSet).
0N/A But it's not really clear what numberAttr should do if it finds that the
0N/A attribute is not in fact a Number.
0N/A */
0N/Apublic interface ValueExp extends java.io.Serializable {
0N/A
0N/A /**
0N/A * Applies the ValueExp on a MBean.
0N/A *
0N/A * @param name The name of the MBean on which the ValueExp will be applied.
0N/A *
0N/A * @return The <CODE>ValueExp</CODE>.
0N/A *
0N/A * @exception BadStringOperationException
0N/A * @exception BadBinaryOpValueExpException
0N/A * @exception BadAttributeValueExpException
0N/A * @exception InvalidApplicationException
0N/A */
0N/A public ValueExp apply(ObjectName name)
0N/A throws BadStringOperationException, BadBinaryOpValueExpException,
0N/A BadAttributeValueExpException, InvalidApplicationException;
0N/A
0N/A /**
0N/A * Sets the MBean server on which the query is to be performed.
0N/A *
0N/A * @param s The MBean server on which the query is to be performed.
0N/A *
0N/A * @deprecated This method is not needed because a
0N/A * <code>ValueExp</code> can access the MBean server in which it
0N/A * is being evaluated by using {@link QueryEval#getMBeanServer()}.
0N/A */
0N/A @Deprecated
0N/A public void setMBeanServer(MBeanServer s) ;
0N/A}