Source code: org/mobicents/slee/container/management/jmx/ComponentIDArrayPropertyEditor.java
1 /*
2 * ComponentIDArrayPropertyEditor.java
3 *
4 * Created on Nov 23, 2004
5 *
6 * Created by: M. Ranganathan
7 *
8 * The Open SLEE project
9 *
10 * A SLEE for the people!
11 *
12 * The source code contained in this file is in in the public domain.
13 * It can be used in any project or product without prior permission,
14 * license or royalty payments. There is NO WARRANTY OF ANY KIND,
15 * EXPRESS, IMPLIED OR STATUTORY, INCLUDING, WITHOUT LIMITATION,
16 * THE IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
17 * AND DATA ACCURACY. We do not warrant or make any representations
18 * regarding the use of the software or the results thereof, including
19 * but not limited to the correctness, accuracy, reliability or
20 * usefulness of the software.
21 */
22
23 package org.mobicents.slee.container.management.jmx;
24
25 import org.mobicents.slee.container.management.ComponentIDImpl;
26
27 import javax.slee.ComponentID;
28
29 import org.jboss.util.propertyeditor.TextPropertyEditorSupport;
30
31 /**
32 *Propoerty editor for component ID array.
33 *
34 */
35 public class ComponentIDArrayPropertyEditor
36 extends TextPropertyEditorSupport {
37
38 public String getAsText( ) {
39 ComponentIDImpl[] componentIds = (ComponentIDImpl[]) this.getValue();
40 if ( componentIds == null) return "null";
41 else {
42 StringBuffer sb = new StringBuffer();
43 for ( int i = 0; i < componentIds.length; i++) {
44 sb.append(componentIds[i].toString());
45 sb.append("|");
46 }
47 return sb.toString();
48 }
49 }
50
51 /**
52 * Set the element as text value, parse it and setValue.
53 * The separator is "|" (need to check this).
54 */
55 public void setAsText(String text ) {
56 if ( text == null || text.equals("")) {
57 super.setValue( new ComponentIDImpl[0]);
58 } else {
59 java.util.ArrayList results = new java.util.ArrayList();
60 // the format for component ID is name vendor version.
61 java.util.StringTokenizer st = new java.util.StringTokenizer(text,"|",true);
62 ComponentIDPropertyEditor cidPropEditor = new ComponentIDPropertyEditor();
63 while (st.hasMoreTokens()) {
64 cidPropEditor.setAsText(st.nextToken());
65 st.nextToken();
66 results.add(cidPropEditor.getValue());
67 }
68 ComponentIDImpl[] cid = new ComponentIDImpl[results.size()];
69 results.toArray(cid);
70 this.setValue(cid);
71 }
72
73 }
74
75 }
76