blob: 7d58436189b302d98aa686b9eabcdf9c0761a6f1 [file] [log] [blame]
J. Duke319a3b92007-12-01 00:00:00 +00001/*
2 * Copyright 2000-2005 Sun Microsystems, Inc. All Rights Reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Sun designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Sun in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
22 * CA 95054 USA or visit www.sun.com if you need additional information or
23 * have any questions.
24 */
25
26package javax.management.relation;
27
28/**
29 * This class describes the various problems which can be encountered when
30 * accessing a role.
31 *
32 * @since 1.5
33 */
34public class RoleStatus {
35
36 //
37 // Possible problems
38 //
39
40 /**
41 * Problem type when trying to access an unknown role.
42 */
43 public static final int NO_ROLE_WITH_NAME = 1;
44 /**
45 * Problem type when trying to read a non-readable attribute.
46 */
47 public static final int ROLE_NOT_READABLE = 2;
48 /**
49 * Problem type when trying to update a non-writable attribute.
50 */
51 public static final int ROLE_NOT_WRITABLE = 3;
52 /**
53 * Problem type when trying to set a role value with less ObjectNames than
54 * the minimum expected cardinality.
55 */
56 public static final int LESS_THAN_MIN_ROLE_DEGREE = 4;
57 /**
58 * Problem type when trying to set a role value with more ObjectNames than
59 * the maximum expected cardinality.
60 */
61 public static final int MORE_THAN_MAX_ROLE_DEGREE = 5;
62 /**
63 * Problem type when trying to set a role value including the ObjectName of
64 * a MBean not of the class expected for that role.
65 */
66 public static final int REF_MBEAN_OF_INCORRECT_CLASS = 6;
67 /**
68 * Problem type when trying to set a role value including the ObjectName of
69 * a MBean not registered in the MBean Server.
70 */
71 public static final int REF_MBEAN_NOT_REGISTERED = 7;
72
73 /**
74 * Returns true if given value corresponds to a known role status, false
75 * otherwise.
76 *
77 * @param status a status code.
78 *
79 * @return true if this value is a known role status.
80 */
81 public static boolean isRoleStatus(int status) {
82 if (status != NO_ROLE_WITH_NAME &&
83 status != ROLE_NOT_READABLE &&
84 status != ROLE_NOT_WRITABLE &&
85 status != LESS_THAN_MIN_ROLE_DEGREE &&
86 status != MORE_THAN_MAX_ROLE_DEGREE &&
87 status != REF_MBEAN_OF_INCORRECT_CLASS &&
88 status != REF_MBEAN_NOT_REGISTERED) {
89 return false;
90 }
91 return true;
92 }
93}