1 11 package org.eclipse.core.runtime; 12 13 20 public class MultiStatus extends Status { 21 22 24 private IStatus[] children; 25 26 37 public MultiStatus(String pluginId, int code, IStatus[] newChildren, String message, Throwable exception) { 38 this(pluginId, code, message, exception); 39 Assert.isLegal(newChildren != null); 40 int maxSeverity = getSeverity(); 41 for (int i = 0; i < newChildren.length; i++) { 42 Assert.isLegal(newChildren[i] != null); 43 int severity = newChildren[i].getSeverity(); 44 if (severity > maxSeverity) 45 maxSeverity = severity; 46 } 47 this.children = new IStatus[newChildren.length]; 48 setSeverity(maxSeverity); 49 System.arraycopy(newChildren, 0, this.children, 0, newChildren.length); 50 } 51 52 62 public MultiStatus(String pluginId, int code, String message, Throwable exception) { 63 super(OK, pluginId, code, message, exception); 64 children = new IStatus[0]; 65 } 66 67 72 public void add(IStatus status) { 73 Assert.isLegal(status != null); 74 IStatus[] result = new IStatus[children.length + 1]; 75 System.arraycopy(children, 0, result, 0, children.length); 76 result[result.length - 1] = status; 77 children = result; 78 int newSev = status.getSeverity(); 79 if (newSev > getSeverity()) { 80 setSeverity(newSev); 81 } 82 } 83 84 91 public void addAll(IStatus status) { 92 Assert.isLegal(status != null); 93 IStatus[] statuses = status.getChildren(); 94 for (int i = 0; i < statuses.length; i++) { 95 add(statuses[i]); 96 } 97 } 98 99 102 public IStatus[] getChildren() { 103 return children; 104 } 105 106 109 public boolean isMultiStatus() { 110 return true; 111 } 112 113 124 public void merge(IStatus status) { 125 Assert.isLegal(status != null); 126 if (!status.isMultiStatus()) { 127 add(status); 128 } else { 129 addAll(status); 130 } 131 } 132 133 137 public String toString() { 138 StringBuffer buf = new StringBuffer (super.toString()); 139 buf.append(" children=["); for (int i = 0; i < children.length; i++) { 141 if (i != 0) { 142 buf.append(" "); } 144 buf.append(children[i].toString()); 145 } 146 buf.append("]"); return buf.toString(); 148 } 149 } 150 | Popular Tags |