jdk/src/java.management/share/classes/javax/management/ValueExp.java
author darcy
Thu, 16 Apr 2015 09:51:29 -0700
changeset 29927 9cc3e111a1d8
parent 25859 3317bb8137f4
permissions -rw-r--r--
8077923: Add missing doclint in javax.management Reviewed-by: dfuchs
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
29927
9cc3e111a1d8 8077923: Add missing doclint in javax.management
darcy
parents: 25859
diff changeset
     2
 * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package javax.management;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
 * Represents values that can be passed as arguments to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 * relational expressions. Strings, numbers, attributes are valid values
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 * and should be represented by implementations of <CODE>ValueExp</CODE>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
  We considered generifying this interface as ValueExp<T>, where T is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
  the Java type that this expression generates.  This allows some additional
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
  checking in the various methods of the Query class, but in practice
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
  not much.  Typically you have something like
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
  Query.lt(Query.attr("A"), Query.value(5)).  We can arrange for Query.value
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
  to have type ValueExp<Integer> (or maybe ValueExp<Long> or ValueExp<Number>)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
  but for Query.attr we can't do better than ValueExp<?> or plain ValueExp.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
  So even though we could define Query.lt as:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
  QueryExp <T> lt(ValueExp<T> v1, ValueExp<T> v2)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
  and thus prevent comparing a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
  number against a string, in practice the first ValueExp will almost always
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
  be a Query.attr so this check serves no purpose.  You would have to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
  write Query.<Number>attr("A"), for example, which would be awful.  And,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
  if you wrote Query.<Integer>attr("A") you would then discover that you
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
  couldn't compare it against Query.value(5) if the latter is defined as
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
  ValueExp<Number>, or against Query.value(5L) if it is defined as
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
  ValueExp<Integer>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
  Worse, for Query.in we would like to define:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
  QueryExp <T> in(ValueExp<T> val, ValueExp<T>[] valueList)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
  but this is unusable because you cannot write
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
  "new ValueExp<Integer>[] {...}" (the compiler forbids it).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
  The few mistakes you might catch with this generification certainly
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
  wouldn't justify the hassle of modifying user code to get the checks
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
  to be made and the "unchecked" warnings that would arise if it
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
  wasn't so modified.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
  We could reconsider this if the Query methods were augmented, for example
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
  with:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
  AttributeValueExp<Number> numberAttr(String name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
  AttributeValueExp<String> stringAttr(String name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
  AttributeValueExp<Boolean> booleanAttr(String name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
  QueryExp <T> in(ValueExp<T> val, Set<ValueExp<T>> valueSet).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
  But it's not really clear what numberAttr should do if it finds that the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
  attribute is not in fact a Number.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
public interface ValueExp extends java.io.Serializable {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
     * Applies the ValueExp on a MBean.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
     * @param name The name of the MBean on which the ValueExp will be applied.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
     * @return  The <CODE>ValueExp</CODE>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
     *
29927
9cc3e111a1d8 8077923: Add missing doclint in javax.management
darcy
parents: 25859
diff changeset
    83
     * @throws BadStringOperationException when an invalid string
9cc3e111a1d8 8077923: Add missing doclint in javax.management
darcy
parents: 25859
diff changeset
    84
     * operation is passed to a method for constructing a query
9cc3e111a1d8 8077923: Add missing doclint in javax.management
darcy
parents: 25859
diff changeset
    85
     * @throws BadBinaryOpValueExpException when an invalid expression
9cc3e111a1d8 8077923: Add missing doclint in javax.management
darcy
parents: 25859
diff changeset
    86
     * is passed to a method for constructing a query
9cc3e111a1d8 8077923: Add missing doclint in javax.management
darcy
parents: 25859
diff changeset
    87
     * @throws BadAttributeValueExpException when an invalid MBean
9cc3e111a1d8 8077923: Add missing doclint in javax.management
darcy
parents: 25859
diff changeset
    88
     * attribute is passed to a query constructing method
9cc3e111a1d8 8077923: Add missing doclint in javax.management
darcy
parents: 25859
diff changeset
    89
     * @throws InvalidApplicationException when an invalid apply is attempted
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    public ValueExp apply(ObjectName name)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
            throws BadStringOperationException, BadBinaryOpValueExpException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
                   BadAttributeValueExpException, InvalidApplicationException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
     * Sets the MBean server on which the query is to be performed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
     * @param s The MBean server on which the query is to be performed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     * @deprecated This method is not needed because a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     * <code>ValueExp</code> can access the MBean server in which it
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
     * is being evaluated by using {@link QueryEval#getMBeanServer()}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
    public  void setMBeanServer(MBeanServer s) ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
}