comparison org.eclipse.equinox.common/src/org/eclipse/core/runtime/MultiStatus.d @ 105:bbe49769ec18

...
author Frank Benoit <benoit@tionex.de>
date Sun, 08 Nov 2009 12:42:30 +0100
parents bc29606a740c
children
comparison
equal deleted inserted replaced
104:88652073d1c2 105:bbe49769ec18
2 * Copyright (c) 2000, 2006 IBM Corporation and others. 2 * Copyright (c) 2000, 2006 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials 3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0 4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at 5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html 6 * http://www.eclipse.org/legal/epl-v10.html
7 * 7 *
8 * Contributors: 8 * Contributors:
9 * IBM Corporation - initial API and implementation 9 * IBM Corporation - initial API and implementation
10 * Port to the D programming language:
11 * Frank Benoit <benoit@tionex.de>
12 *******************************************************************************/ 10 *******************************************************************************/
13 module org.eclipse.core.runtime.MultiStatus; 11 // Port to the D programming language:
14 12 // Frank Benoit <benoit@tionex.de>
15 import org.eclipse.core.runtime.Assert; 13 module org.eclipse.core.runtimeMultiStatus;
16 import org.eclipse.core.runtime.Status;
17 import org.eclipse.core.runtime.IStatus;
18 14
19 import java.lang.all; 15 import java.lang.all;
20 static import tango.text.Text; 16
17 import org.eclipse.core.runtimeStatus; // packageimport
18 import org.eclipse.core.runtimeAssert; // packageimport
19 import org.eclipse.core.runtimeIStatus; // packageimport
21 20
22 /** 21 /**
23 * A concrete multi-status implementation, 22 * A concrete multi-status implementation,
24 * suitable either for instantiating or subclassing. 23 * suitable either for instantiating or subclassing.
25 * <p> 24 * <p>
26 * This class can be used without OSGi running. 25 * This class can be used without OSGi running.
27 * </p> 26 * </p>
28 */ 27 */
39 * @param code the plug-in-specific status code 38 * @param code the plug-in-specific status code
40 * @param newChildren the list of children status objects 39 * @param newChildren the list of children status objects
41 * @param message a human-readable message, localized to the 40 * @param message a human-readable message, localized to the
42 * current locale 41 * current locale
43 * @param exception a low-level exception, or <code>null</code> if not 42 * @param exception a low-level exception, or <code>null</code> if not
44 * applicable 43 * applicable
45 */ 44 */
46 public this(String pluginId, int code, IStatus[] newChildren, String message, Exception exception) { 45 public this(String pluginId, int code, IStatus[] newChildren, String message, Throwable exception) {
47 this(pluginId, code, message, exception); 46 this(pluginId, code, message, exception);
48 Assert.isLegal(newChildren !is null); 47 Assert.isLegal(newChildren !is null);
49 int maxSeverity = getSeverity(); 48 int maxSeverity = getSeverity();
50 for (int i = 0; i < newChildren.length; i++) { 49 for (int i = 0; i < newChildren.length; i++) {
51 Assert.isLegal(newChildren[i] !is null); 50 Assert.isLegal(newChildren[i] !is null);
53 if (severity > maxSeverity) 52 if (severity > maxSeverity)
54 maxSeverity = severity; 53 maxSeverity = severity;
55 } 54 }
56 this.children = new IStatus[newChildren.length]; 55 this.children = new IStatus[newChildren.length];
57 setSeverity(maxSeverity); 56 setSeverity(maxSeverity);
58 SimpleType!(IStatus).arraycopy(newChildren, 0, this.children, 0, newChildren.length); 57 System.arraycopy(newChildren, 0, this.children, 0, newChildren.length);
59 } 58 }
60 59
61 /** 60 /**
62 * Creates and returns a new multi-status object with no children. 61 * Creates and returns a new multi-status object with no children.
63 * 62 *
64 * @param pluginId the unique identifier of the relevant plug-in 63 * @param pluginId the unique identifier of the relevant plug-in
65 * @param code the plug-in-specific status code 64 * @param code the plug-in-specific status code
66 * @param message a human-readable message, localized to the 65 * @param message a human-readable message, localized to the
67 * current locale 66 * current locale
68 * @param exception a low-level exception, or <code>null</code> if not 67 * @param exception a low-level exception, or <code>null</code> if not
69 * applicable 68 * applicable
70 */ 69 */
71 public this(String pluginId, int code, String message, Exception exception) { 70 public this(String pluginId, int code, String message, Throwable exception) {
72 super(OK, pluginId, code, message, exception); 71 super(OK, pluginId, code, message, exception);
73 children = new IStatus[0]; 72 children = new IStatus[0];
74 } 73 }
75 74
76 /** 75 /**
79 * @param status the new child status 78 * @param status the new child status
80 */ 79 */
81 public void add(IStatus status) { 80 public void add(IStatus status) {
82 Assert.isLegal(status !is null); 81 Assert.isLegal(status !is null);
83 IStatus[] result = new IStatus[children.length + 1]; 82 IStatus[] result = new IStatus[children.length + 1];
84 SimpleType!(IStatus).arraycopy(children, 0, result, 0, children.length); 83 System.arraycopy(children, 0, result, 0, children.length);
85 result[result.length - 1] = status; 84 result[result.length - 1] = status;
86 children = result; 85 children = result;
87 int newSev = status.getSeverity(); 86 int newSev = status.getSeverity();
88 if (newSev > getSeverity()) { 87 if (newSev > getSeverity()) {
89 setSeverity(newSev); 88 setSeverity(newSev);
106 } 105 }
107 106
108 /* (Intentionally not javadoc'd) 107 /* (Intentionally not javadoc'd)
109 * Implements the corresponding method on <code>IStatus</code>. 108 * Implements the corresponding method on <code>IStatus</code>.
110 */ 109 */
111 public override IStatus[] getChildren() { 110 public IStatus[] getChildren() {
112 return children; 111 return children;
113 } 112 }
114 113
115 /* (Intentionally not javadoc'd) 114 /* (Intentionally not javadoc'd)
116 * Implements the corresponding method on <code>IStatus</code>. 115 * Implements the corresponding method on <code>IStatus</code>.
117 */ 116 */
118 public override bool isMultiStatus() { 117 public bool isMultiStatus() {
119 return true; 118 return true;
120 } 119 }
121 120
122 /** 121 /**
123 * Merges the given status into this multi-status. 122 * Merges the given status into this multi-status.
124 * Equivalent to <code>add(status)</code> if the 123 * Equivalent to <code>add(status)</code> if the
125 * given status is not a multi-status. 124 * given status is not a multi-status.
126 * Equivalent to <code>addAll(status)</code> if the 125 * Equivalent to <code>addAll(status)</code> if the
127 * given status is a multi-status. 126 * given status is a multi-status.
128 * 127 *
129 * @param status the status to merge into this one 128 * @param status the status to merge into this one
130 * @see #add(IStatus) 129 * @see #add(IStatus)
131 * @see #addAll(IStatus) 130 * @see #addAll(IStatus)
132 */ 131 */
138 addAll(status); 137 addAll(status);
139 } 138 }
140 } 139 }
141 140
142 /** 141 /**
143 * Returns a string representation of the status, suitable 142 * Returns a string representation of the status, suitable
144 * for debugging purposes only. 143 * for debugging purposes only.
145 */ 144 */
146 public override String toString() { 145 public String toString() {
147 tango.text.Text.Text!(char) buf = new tango.text.Text.Text!(char); 146 StringBuffer buf = new StringBuffer(super.toString());
148 buf.append(super.toString());
149 buf.append(" children=["); //$NON-NLS-1$ 147 buf.append(" children=["); //$NON-NLS-1$
150 for (int i = 0; i < children.length; i++) { 148 for (int i = 0; i < children.length; i++) {
151 if (i !is 0) { 149 if (i !is 0) {
152 buf.append(" "); //$NON-NLS-1$ 150 buf.append(" "); //$NON-NLS-1$
153 } 151 }
154 buf.append( (cast(Object)children[i]).toString()); 152 buf.append(children[i].toString());
155 } 153 }
156 buf.append("]"); //$NON-NLS-1$ 154 buf.append("]"); //$NON-NLS-1$
157 return buf.toString(); 155 return buf.toString();
158 } 156 }
159 } 157 }