001: /**
002: * The XMOJO Project 5
003: * Copyright © 2003 XMOJO.org. All rights reserved.
004:
005: * NO WARRANTY
006:
007: * BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR
008: * THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
009: * OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
010: * PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
011: * OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
012: * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
013: * TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE
014: * LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
015: * REPAIR OR CORRECTION.
016:
017: * IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL
018: * ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE
019: * THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
020: * GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
021: * USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF
022: * DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
023: * PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE),
024: * EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
025: * SUCH DAMAGES.
026: **/package javax.management;
027:
028: import java.io.Serializable;
029:
030: /**
031: * Represents an MBean attribute by associating its name with its value. The
032: * MBean server and other objects use this class to get and set attributes values.
033: */
034: public class Attribute implements Serializable {
035: /**
036: * @serial Attribute name.
037: */
038: private String name = null;
039:
040: /**
041: * @serial Attribute value
042: */
043: private Object value = null;
044:
045: /**
046: * Constructs an Attribute object which associates the given attribute
047: * name with the given value.
048: *
049: * @param name A String containing the name of the attribute to be created.
050: * Cannot be null.
051: *
052: * @param value The Object which is assigned to the attribute. This
053: * object must be of the same type as the attribute.
054: */
055: public Attribute(String name, Object value) {
056: if (name == null) {
057: throw new RuntimeOperationsException(
058: new IllegalArgumentException(
059: "Attribute name cannot be null "));
060: }
061:
062: this .name = name;
063: this .value = value;
064: }
065:
066: /**
067: * Returns a String containing the name of the attribute.
068: *
069: * @return name of the attribute
070: */
071: public String getName() {
072: return name;
073: }
074:
075: /**
076: * Returns an Object that is the value of this attribute.
077: * @return value of the attribute as Object
078: */
079: public Object getValue() {
080: return value;
081: }
082:
083: /**
084: * Compares the current Attribute Object with another Attribute Object.
085: *
086: * @param object The Attribute that the current Attribute is to be compared with.
087: *
088: * @return True if the two Attribute objects are equal, otherwise false.
089: */
090: public boolean equals(Object obj) {
091: if (!(obj instanceof Attribute))
092: return false;
093:
094: Attribute att = (Attribute) obj;
095: if (att.getName().equals(name) && att.getValue().equals(value))
096: return true;
097:
098: return false;
099: }
100: }
|