RoleInfopublic class RoleInfo extends Object implements SerializableA RoleInfo object summarises a role in a relation type. |
Fields Summary |
---|
private static final long | oldSerialVersionUID | private static final long | newSerialVersionUID | private static final ObjectStreamField[] | oldSerialPersistentFields | private static final ObjectStreamField[] | newSerialPersistentFields | private static final long | serialVersionUID | private static final ObjectStreamField[] | serialPersistentFields | private static boolean | compat | public static int | ROLE_CARDINALITY_INFINITYTo specify an unlimited cardinality. | private String | name | private boolean | isReadable | private boolean | isWritable | private String | description | private int | minDegree | private int | maxDegree | private String | referencedMBeanClassName |
Constructors Summary |
---|
public RoleInfo(String theName, String theRefMBeanClassName, boolean theIsReadable, boolean theIsWritable, int theMinDegree, int theMaxDegree, String theDescription)Constructor.
//
// Constructors
//
init(theName,
theRefMBeanClassName,
theIsReadable,
theIsWritable,
theMinDegree,
theMaxDegree,
theDescription);
return;
| public RoleInfo(String theName, String theRefMBeanClassName, boolean theIsReadable, boolean theIsWritable)Constructor.
try {
init(theName,
theRefMBeanClassName,
theIsReadable,
theIsWritable,
1,
1,
null);
} catch (InvalidRoleInfoException exc) {
// OK : Can never happen as the minimum
// degree equals the maximum degree.
}
return;
| public RoleInfo(String theName, String theRefMBeanClassName)Constructor.
try {
init(theName,
theRefMBeanClassName,
true,
true,
1,
1,
null);
} catch (InvalidRoleInfoException exc) {
// OK : Can never happen as the minimum
// degree equals the maximum degree.
}
return;
| public RoleInfo(RoleInfo theRoleInfo)Copy constructor.
if (theRoleInfo == null) {
// Revisit [cebro] Localize message
String excMsg = "Invalid parameter.";
throw new IllegalArgumentException(excMsg);
}
try {
init(theRoleInfo.getName(),
theRoleInfo.getRefMBeanClassName(),
theRoleInfo.isReadable(),
theRoleInfo.isWritable(),
theRoleInfo.getMinDegree(),
theRoleInfo.getMaxDegree(),
theRoleInfo.getDescription());
} catch (InvalidRoleInfoException exc3) {
// OK : Can never happen as the minimum degree and the maximum
// degree were already checked at the time the theRoleInfo
// instance was created.
}
|
Methods Summary |
---|
public boolean | checkMaxDegree(int theValue)Returns a boolean to specify if given value is less or equal than
expected maximum degree (true if yes).
if (theValue >= ROLE_CARDINALITY_INFINITY &&
(maxDegree == ROLE_CARDINALITY_INFINITY ||
(theValue != ROLE_CARDINALITY_INFINITY &&
theValue <= maxDegree))) {
return true;
} else {
return false;
}
| public boolean | checkMinDegree(int theValue)Returns a boolean to specify if given value is greater or equal than
expected minimum degree (true if yes).
if (theValue >= ROLE_CARDINALITY_INFINITY &&
(minDegree == ROLE_CARDINALITY_INFINITY
|| theValue >= minDegree)) {
return true;
} else {
return false;
}
| public java.lang.String | getDescription()Returns description text for the role.
return description;
| public int | getMaxDegree()Returns maximum degree for corresponding role reference.
return maxDegree;
| public int | getMinDegree()Returns minimum degree for corresponding role reference.
return minDegree;
| public java.lang.String | getName()Returns the name of the role.
return name;
| public java.lang.String | getRefMBeanClassName()Returns name of type of MBean expected to be referenced in
corresponding role.
return referencedMBeanClassName;
| private void | init(java.lang.String theName, java.lang.String theRefMBeanClassName, boolean theIsReadable, boolean theIsWritable, int theMinDegree, int theMaxDegree, java.lang.String theDescription)
if (theName == null ||
theRefMBeanClassName == null) {
// Revisit [cebro] Localize message
String excMsg = "Invalid parameter.";
throw new IllegalArgumentException(excMsg);
}
name = theName;
isReadable = theIsReadable;
isWritable = theIsWritable;
if (theDescription != null) {
description = theDescription;
}
boolean invalidRoleInfoFlg = false;
StringBuffer excMsgStrB = new StringBuffer();
if (theMaxDegree != ROLE_CARDINALITY_INFINITY &&
(theMinDegree == ROLE_CARDINALITY_INFINITY ||
theMinDegree > theMaxDegree)) {
// Revisit [cebro] Localize message
excMsgStrB.append("Minimum degree ");
excMsgStrB.append(theMinDegree);
excMsgStrB.append(" is greater than maximum degree ");
excMsgStrB.append(theMaxDegree);
invalidRoleInfoFlg = true;
} else if (theMinDegree < ROLE_CARDINALITY_INFINITY ||
theMaxDegree < ROLE_CARDINALITY_INFINITY) {
// Revisit [cebro] Localize message
excMsgStrB.append("Minimum or maximum degree has an illegal value, must be [0, ROLE_CARDINALITY_INFINITY].");
invalidRoleInfoFlg = true;
}
if (invalidRoleInfoFlg) {
throw new InvalidRoleInfoException(excMsgStrB.toString());
}
minDegree = theMinDegree;
maxDegree = theMaxDegree;
referencedMBeanClassName = theRefMBeanClassName;
return;
| public boolean | isReadable()Returns read access mode for the role (true if it is readable).
return isReadable;
| public boolean | isWritable()Returns write access mode for the role (true if it is writable).
return isWritable;
| private void | readObject(java.io.ObjectInputStream in)Deserializes a {@link RoleInfo} from an {@link ObjectInputStream}.
if (compat)
{
// Read an object serialized in the old serial form
//
ObjectInputStream.GetField fields = in.readFields();
name = (String) fields.get("myName", null);
if (fields.defaulted("myName"))
{
throw new NullPointerException("myName");
}
isReadable = fields.get("myIsReadableFlg", false);
if (fields.defaulted("myIsReadableFlg"))
{
throw new NullPointerException("myIsReadableFlg");
}
isWritable = fields.get("myIsWritableFlg", false);
if (fields.defaulted("myIsWritableFlg"))
{
throw new NullPointerException("myIsWritableFlg");
}
description = (String) fields.get("myDescription", null);
if (fields.defaulted("myDescription"))
{
throw new NullPointerException("myDescription");
}
minDegree = fields.get("myMinDegree", (int)0);
if (fields.defaulted("myMinDegree"))
{
throw new NullPointerException("myMinDegree");
}
maxDegree = fields.get("myMaxDegree", (int)0);
if (fields.defaulted("myMaxDegree"))
{
throw new NullPointerException("myMaxDegree");
}
referencedMBeanClassName = (String) fields.get("myRefMBeanClassName", null);
if (fields.defaulted("myRefMBeanClassName"))
{
throw new NullPointerException("myRefMBeanClassName");
}
}
else
{
// Read an object serialized in the new serial form
//
in.defaultReadObject();
}
| public java.lang.String | toString()Returns a string describing the role info.
StringBuffer result = new StringBuffer();
result.append("role info name: " + name);
result.append("; isReadable: " + isReadable);
result.append("; isWritable: " + isWritable);
result.append("; description: " + description);
result.append("; minimum degree: " + minDegree);
result.append("; maximum degree: " + maxDegree);
result.append("; MBean class: " + referencedMBeanClassName);
return result.toString();
| private void | writeObject(java.io.ObjectOutputStream out)Serializes a {@link RoleInfo} to an {@link ObjectOutputStream}.
if (compat)
{
// Serializes this instance in the old serial form
//
ObjectOutputStream.PutField fields = out.putFields();
fields.put("myName", name);
fields.put("myIsReadableFlg", isReadable);
fields.put("myIsWritableFlg", isWritable);
fields.put("myDescription", description);
fields.put("myMinDegree", minDegree);
fields.put("myMaxDegree", maxDegree);
fields.put("myRefMBeanClassName", referencedMBeanClassName);
out.writeFields();
}
else
{
// Serializes this instance in the new serial form
//
out.defaultWriteObject();
}
|
|