User: juhalindfors
Date: 02/01/16 03:25:48
Modified: src/main/javax/management/modelmbean DescriptorSupport.java
Log:
implements Cloneable (RI does not but it should)
some NYIs fixed
Revision Changes Path
1.2 +68 -55 jmx/src/main/javax/management/modelmbean/DescriptorSupport.java
Index: DescriptorSupport.java
===================================================================
RCS file:
/cvsroot/jboss/jmx/src/main/javax/management/modelmbean/DescriptorSupport.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DescriptorSupport.java 2001/12/10 17:24:35 1.1
+++ DescriptorSupport.java 2002/01/16 11:25:48 1.2
@@ -20,111 +20,124 @@
* @see javax.management.Descriptor
*
* @author <a href="mailto:[EMAIL PROTECTED]">Juha Lindfors</a>.
- * @version $Revision: 1.1 $
+ * @version $Revision: 1.2 $
*/
public class DescriptorSupport
- implements Descriptor
+ implements Descriptor, Cloneable
{
// Attributes ----------------------------------------------------
public String currClass;
- private Map fields = new HashMap();
-
+ private Map fieldMap = new HashMap();
+
// Constructors --------------------------------------------------
- public DescriptorSupport()
- {
-
- }
+ public DescriptorSupport()
+ {}
public DescriptorSupport(int initNumFields) throws MBeanException,
RuntimeOperationsException
- {
-
- }
-
- public DescriptorSupport(DescriptorSupport inDescr)
- {
-
- }
-
- public DescriptorSupport(String inStr) throws MBeanException,
RuntimeOperationsException, XMLParseException
+ { }
+
+ public DescriptorSupport(DescriptorSupport inDescr)
{
-
+ // FIXME
+ throw new Error("NYI: copy constructor");
}
-
+
+
public DescriptorSupport(String[] fieldNames, Object[] fieldValues) throws
RuntimeOperationsException
{
-
+ setFields(fieldNames, fieldValues);
}
-
+
public DescriptorSupport(String[] fields)
{
-
+ // FIXME: implement the behavior in javadoc
+
+ for (int i = 0; i < fields.length; ++i)
+ {
+ int index = fields[i].indexOf('=');
+ if (index == -1)
+ continue;
+
+ String field = fields[i].substring(0, index);
+ String value = fields[i].substring(index + 1, fields[i].length());
+
+ fieldMap.put(field, value);
+ }
}
-
+
// Public --------------------------------------------------------
public Object getFieldValue(String inFieldName)
{
- // FIXME: null or empty string
- return fields.get(inFieldName);
+ // FIXME: null or empty string
+ return fieldMap.get(inFieldName);
}
-
+
public void setField(String inFieldName, Object fieldValue)
{
- fields.put(inFieldName, fieldValue);
+ fieldMap.put(inFieldName, fieldValue);
}
-
+
public String[] getFields()
{
- String[] fieldStrings = new String[fields.size()];
- Iterator it = fields.keySet().iterator();
- for (int i = 0; i < fields.size(); ++i)
+ String[] fieldStrings = new String[fieldMap.size()];
+ Iterator it = fieldMap.keySet().iterator();
+ for (int i = 0; i < fieldMap.size(); ++i)
{
String key = (String)it.next();
- fieldStrings[i] = key + "=" + fields.get(key);
+ fieldStrings[i] = key + "=" + fieldMap.get(key);
}
-
+
return fieldStrings;
}
-
- public String[] getFieldNames()
+
+ public String[] getFieldNames()
{
- return (String[])fields.keySet().toArray(new String[0]);
+ return (String[])fieldMap.keySet().toArray(new String[0]);
}
-
+
public Object[] getFieldValues(String[] fieldNames)
{
- return fields.values().toArray();
+ return fieldMap.values().toArray();
}
-
+
public void setFields(String[] fieldNames, Object[] fieldValues) throws
RuntimeOperationsException
{
- // FIXME: NYI
- throw new Error("NYI");
+ for (int i = 0; i < fieldNames.length; ++i)
+ {
+ String name = fieldNames[i];
+ if (name != null)
+ fieldMap.put(name, fieldValues[i]);
+ }
}
-
+
public Object clone() throws RuntimeOperationsException
{
- // FIXME: NYI
- throw new Error("NYI");
+ try
+ {
+ Descriptor descr = (Descriptor)super.clone();
+ String[] fieldNames = this.getFieldNames();
+ descr.setFields(fieldNames, this.getFieldValues(fieldNames));
+
+ return descr;
+ }
+ catch (CloneNotSupportedException e)
+ {
+ throw new Error(e.toString());
+ }
}
-
+
public void removeField(String fieldName)
{
- fields.remove(fieldName);
+ fieldMap.remove(fieldName);
}
-
+
public boolean isValid() throws RuntimeOperationsException
{
// FIXME: NYI
throw new Error("NYI");
}
-
- public String toXMLString()
- {
- // FIXME: NYI
- throw new Error("NYI");
- }
-
+
// Object overrides ----------------------------------------------
public String toString()
{
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development