1. /*
  2. * @(#)RoleStatus.java 1.13 03/12/19
  3. *
  4. * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package javax.management.relation;
  8. /**
  9. * This class describes the various problems which can be encountered when
  10. * accessing a role.
  11. *
  12. * @since 1.5
  13. */
  14. public class RoleStatus {
  15. //
  16. // Possible problems
  17. //
  18. /**
  19. * Problem type when trying to access an unknown role.
  20. */
  21. public static final int NO_ROLE_WITH_NAME = 1;
  22. /**
  23. * Problem type when trying to read a non-readable attribute.
  24. */
  25. public static final int ROLE_NOT_READABLE = 2;
  26. /**
  27. * Problem type when trying to update a non-writable attribute.
  28. */
  29. public static final int ROLE_NOT_WRITABLE = 3;
  30. /**
  31. * Problem type when trying to set a role value with less ObjectNames than
  32. * the minimum expected cardinality.
  33. */
  34. public static final int LESS_THAN_MIN_ROLE_DEGREE = 4;
  35. /**
  36. * Problem type when trying to set a role value with more ObjectNames than
  37. * the maximum expected cardinality.
  38. */
  39. public static final int MORE_THAN_MAX_ROLE_DEGREE = 5;
  40. /**
  41. * Problem type when trying to set a role value including the ObjectName of
  42. * a MBean not of the class expected for that role.
  43. */
  44. public static final int REF_MBEAN_OF_INCORRECT_CLASS = 6;
  45. /**
  46. * Problem type when trying to set a role value including the ObjectName of
  47. * a MBean not registered in the MBean Server.
  48. */
  49. public static final int REF_MBEAN_NOT_REGISTERED = 7;
  50. /**
  51. * Returns true if given value corresponds to a known role status, false
  52. * otherwise.
  53. *
  54. * @param theRoleStatus a status code.
  55. *
  56. * @return true if this value is a known role status.
  57. */
  58. public static boolean isRoleStatus(int theRoleStatus) {
  59. if (theRoleStatus != NO_ROLE_WITH_NAME &&
  60. theRoleStatus != ROLE_NOT_READABLE &&
  61. theRoleStatus != ROLE_NOT_WRITABLE &&
  62. theRoleStatus != LESS_THAN_MIN_ROLE_DEGREE &&
  63. theRoleStatus != MORE_THAN_MAX_ROLE_DEGREE &&
  64. theRoleStatus != REF_MBEAN_OF_INCORRECT_CLASS &&
  65. theRoleStatus != REF_MBEAN_NOT_REGISTERED) {
  66. return false;
  67. }
  68. return true;
  69. }
  70. }