1 23 24 30 31 package com.sun.enterprise.admin.monitor.stats.lb; 32 33 public class ClusterStats implements com.sun.enterprise.admin.monitor.stats.lb.ClusterStatsInterface, com.sun.enterprise.admin.monitor.stats.lb.CommonBean { 34 private java.lang.String _Id; 35 private java.util.List _InstanceStats = new java.util.ArrayList (); 37 public ClusterStats() { 38 _Id = ""; 39 } 40 41 public ClusterStats(com.sun.enterprise.admin.monitor.stats.lb.ClusterStats source) { 43 _Id = source._Id; 44 for (java.util.Iterator it = source._InstanceStats.iterator(); 45 it.hasNext(); ) { 46 _InstanceStats.add(new com.sun.enterprise.admin.monitor.stats.lb.InstanceStats((com.sun.enterprise.admin.monitor.stats.lb.InstanceStats)it.next())); 47 } 48 } 49 50 public void setId(java.lang.String value) { 52 _Id = value; 53 } 54 55 public java.lang.String getId() { 56 return _Id; 57 } 58 59 public void setInstanceStats(com.sun.enterprise.admin.monitor.stats.lb.InstanceStats[] value) { 61 if (value == null) 62 value = new InstanceStats[0]; 63 _InstanceStats.clear(); 64 for (int i = 0; i < value.length; ++i) { 65 _InstanceStats.add(value[i]); 66 } 67 } 68 69 public void setInstanceStats(int index, com.sun.enterprise.admin.monitor.stats.lb.InstanceStats value) { 70 _InstanceStats.set(index, value); 71 } 72 73 public com.sun.enterprise.admin.monitor.stats.lb.InstanceStats[] getInstanceStats() { 74 InstanceStats[] arr = new InstanceStats[_InstanceStats.size()]; 75 return (InstanceStats[]) _InstanceStats.toArray(arr); 76 } 77 78 public java.util.List fetchInstanceStatsList() { 79 return _InstanceStats; 80 } 81 82 public com.sun.enterprise.admin.monitor.stats.lb.InstanceStats getInstanceStats(int index) { 83 return (InstanceStats)_InstanceStats.get(index); 84 } 85 86 public int sizeInstanceStats() { 88 return _InstanceStats.size(); 89 } 90 91 public int addInstanceStats(com.sun.enterprise.admin.monitor.stats.lb.InstanceStats value) { 92 _InstanceStats.add(value); 93 return _InstanceStats.size()-1; 94 } 95 96 public int removeInstanceStats(com.sun.enterprise.admin.monitor.stats.lb.InstanceStats value) { 98 int pos = _InstanceStats.indexOf(value); 99 if (pos >= 0) { 100 _InstanceStats.remove(pos); 101 } 102 return pos; 103 } 104 105 public void writeNode(java.io.Writer out, String nodeName, String indent) throws java.io.IOException { 106 out.write(indent); 107 out.write("<"); 108 out.write(nodeName); 109 if (_Id != null) { 111 out.write(" id"); out.write("='"); com.sun.enterprise.admin.monitor.stats.lb.LoadBalancerStats.writeXML(out, _Id, true); 114 out.write("'"); } 116 out.write(">\n"); 117 String nextIndent = indent + " "; 118 for (java.util.Iterator it = _InstanceStats.iterator(); 119 it.hasNext(); ) { 120 com.sun.enterprise.admin.monitor.stats.lb.InstanceStats element = (com.sun.enterprise.admin.monitor.stats.lb.InstanceStats)it.next(); 121 if (element != null) { 122 element.writeNode(out, "instance-stats", nextIndent); 123 } 124 } 125 out.write(indent); 126 out.write("</"+nodeName+">\n"); 127 } 128 129 public void readNode(org.w3c.dom.Node node) { 130 if (node.hasAttributes()) { 131 org.w3c.dom.NamedNodeMap attrs = node.getAttributes(); 132 org.w3c.dom.Attr attr; 133 attr = (org.w3c.dom.Attr ) attrs.getNamedItem("id"); 134 if (attr != null) { 135 _Id = attr.getValue(); 136 } 137 } 138 org.w3c.dom.NodeList children = node.getChildNodes(); 139 for (int i = 0, size = children.getLength(); i < size; ++i) { 140 org.w3c.dom.Node childNode = children.item(i); 141 String childNodeName = (childNode.getLocalName() == null ? childNode.getNodeName().intern() : childNode.getLocalName().intern()); 142 String childNodeValue = ""; 143 if (childNode.getFirstChild() != null) { 144 childNodeValue = childNode.getFirstChild().getNodeValue(); 145 } 146 if (childNodeName == "instance-stats") { 147 InstanceStats aInstanceStats = new com.sun.enterprise.admin.monitor.stats.lb.InstanceStats(); 148 aInstanceStats.readNode(childNode); 149 _InstanceStats.add(aInstanceStats); 150 } 151 else { 152 } 154 } 155 } 156 157 public void validate() throws com.sun.enterprise.admin.monitor.stats.lb.LoadBalancerStats.ValidateException { 158 boolean restrictionFailure = false; 159 if (getId() == null) { 161 throw new com.sun.enterprise.admin.monitor.stats.lb.LoadBalancerStats.ValidateException("getId() == null", "id", this); } 163 for (int _index = 0; _index < sizeInstanceStats(); ++_index) { 165 com.sun.enterprise.admin.monitor.stats.lb.InstanceStats element = getInstanceStats(_index); 166 if (element != null) { 167 element.validate(); 168 } 169 } 170 } 171 172 public void changePropertyByName(String name, Object value) { 173 if (name == null) return; 174 name = name.intern(); 175 if (name == "id") 176 setId((java.lang.String )value); 177 else if (name == "instanceStats") 178 addInstanceStats((InstanceStats)value); 179 else if (name == "instanceStats[]") 180 setInstanceStats((InstanceStats[]) value); 181 else 182 throw new IllegalArgumentException (name+" is not a valid property name for ClusterStats"); 183 } 184 185 public Object fetchPropertyByName(String name) { 186 if (name == "id") 187 return getId(); 188 if (name == "instanceStats[]") 189 return getInstanceStats(); 190 throw new IllegalArgumentException (name+" is not a valid property name for ClusterStats"); 191 } 192 193 public com.sun.enterprise.admin.monitor.stats.lb.CommonBean[] childBeans(boolean recursive) { 195 java.util.List children = new java.util.LinkedList (); 196 childBeans(recursive, children); 197 com.sun.enterprise.admin.monitor.stats.lb.CommonBean[] result = new com.sun.enterprise.admin.monitor.stats.lb.CommonBean[children.size()]; 198 return (com.sun.enterprise.admin.monitor.stats.lb.CommonBean[]) children.toArray(result); 199 } 200 201 public void childBeans(boolean recursive, java.util.List beans) { 203 for (java.util.Iterator it = _InstanceStats.iterator(); 204 it.hasNext(); ) { 205 com.sun.enterprise.admin.monitor.stats.lb.InstanceStats element = (com.sun.enterprise.admin.monitor.stats.lb.InstanceStats)it.next(); 206 if (element != null) { 207 if (recursive) { 208 element.childBeans(true, beans); 209 } 210 beans.add(element); 211 } 212 } 213 } 214 215 public boolean equals(Object o) { 216 if (o == this) 217 return true; 218 if (!(o instanceof com.sun.enterprise.admin.monitor.stats.lb.ClusterStats)) 219 return false; 220 com.sun.enterprise.admin.monitor.stats.lb.ClusterStats inst = (com.sun.enterprise.admin.monitor.stats.lb.ClusterStats) o; 221 if (!(_Id == null ? inst._Id == null : _Id.equals(inst._Id))) 222 return false; 223 if (sizeInstanceStats() != inst.sizeInstanceStats()) 224 return false; 225 for (java.util.Iterator it = _InstanceStats.iterator(), it2 = inst._InstanceStats.iterator(); 227 it.hasNext() && it2.hasNext(); ) { 228 com.sun.enterprise.admin.monitor.stats.lb.InstanceStats element = (com.sun.enterprise.admin.monitor.stats.lb.InstanceStats)it.next(); 229 com.sun.enterprise.admin.monitor.stats.lb.InstanceStats element2 = (com.sun.enterprise.admin.monitor.stats.lb.InstanceStats)it2.next(); 230 if (!(element == null ? element2 == null : element.equals(element2))) 231 return false; 232 } 233 return true; 234 } 235 236 public int hashCode() { 237 int result = 17; 238 result = 37*result + (_Id == null ? 0 : _Id.hashCode()); 239 result = 37*result + (_InstanceStats == null ? 0 : _InstanceStats.hashCode()); 240 return result; 241 } 242 243 public String toString() { 244 java.io.StringWriter sw = new java.io.StringWriter (); 245 try { 246 writeNode(sw, "ClusterStats", ""); 247 } catch (java.io.IOException e) { 248 } 251 return sw.toString(); 252 } 253 } 254 255 256 325 | Popular Tags |