Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 274980 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/pde/internal/runtime/registry/model/ConfigurationElement.java (+14 lines)
Lines 27-30 Link Here
27
	public Attribute[] getElements() {
27
	public Attribute[] getElements() {
28
		return elements;
28
		return elements;
29
	}
29
	}
30
31
	public ModelObject[] getChildren() {
32
		return elements;
33
	}
34
35
	public void addChild(ModelObject o) {
36
		if (o instanceof Attribute) {
37
			// XXX very ineffective
38
			Attribute[] tmp = new Attribute[elements.length + 1];
39
			System.arraycopy(elements, 0, tmp, 0, elements.length);
40
			tmp[tmp.length - 1] = (Attribute) o;
41
			elements = tmp;
42
		}
43
	}
30
}
44
}
(-)src/org/eclipse/pde/internal/runtime/registry/model/ModelObject.java (+13 lines)
Lines 17-20 Link Here
17
17
18
	private static final long serialVersionUID = 1L;
18
	private static final long serialVersionUID = 1L;
19
19
20
	protected RegistryModel model;
21
22
	public void setModel(RegistryModel model) {
23
		this.model = model;
24
	}
25
26
	public void addChild(ModelObject obj) {
27
		// empty
28
	}
29
30
	public ModelObject[] getChildren() {
31
		return null;
32
	}
20
}
33
}
(-)src/org/eclipse/pde/internal/runtime/registry/model/RegistryModel.java (-3 / +3 lines)
Lines 24-30 Link Here
24
	private BackendChangeListener backendListener = new BackendChangeListener() {
24
	private BackendChangeListener backendListener = new BackendChangeListener() {
25
		public void addBundle(Bundle adapter) {
25
		public void addBundle(Bundle adapter) {
26
			ModelChangeDelta delta = new ModelChangeDelta(adapter, ModelChangeDelta.ADDED);
26
			ModelChangeDelta delta = new ModelChangeDelta(adapter, ModelChangeDelta.ADDED);
27
27
			adapter.setModel(RegistryModel.this);
28
			bundles.put(new Long(adapter.getId()), adapter);
28
			bundles.put(new Long(adapter.getId()), adapter);
29
29
30
			if (adapter.getFragmentHost() != null) {
30
			if (adapter.getFragmentHost() != null) {
Lines 62-68 Link Here
62
62
63
		public void updateBundle(Bundle adapter, int updated) {
63
		public void updateBundle(Bundle adapter, int updated) {
64
			ModelChangeDelta delta = new ModelChangeDelta(adapter, updated);
64
			ModelChangeDelta delta = new ModelChangeDelta(adapter, updated);
65
65
			adapter.setModel(RegistryModel.this);
66
			bundles.put(new Long(adapter.getId()), adapter); // replace old with new one
66
			bundles.put(new Long(adapter.getId()), adapter); // replace old with new one
67
67
68
			if (adapter.getFragmentHost() != null) {
68
			if (adapter.getFragmentHost() != null) {
Lines 113-119 Link Here
113
113
114
		public void updateService(ServiceRegistration adapter) {
114
		public void updateService(ServiceRegistration adapter) {
115
			services.put(new Long(adapter.getId()), adapter);
115
			services.put(new Long(adapter.getId()), adapter);
116
116
			adapter.setModel(RegistryModel.this);
117
			ModelChangeDelta delta = new ModelChangeDelta(adapter, ModelChangeDelta.UPDATED);
117
			ModelChangeDelta delta = new ModelChangeDelta(adapter, ModelChangeDelta.UPDATED);
118
118
119
			fireModelChangeEvent(new ModelChangeDelta[] {delta});
119
			fireModelChangeEvent(new ModelChangeDelta[] {delta});
(-)src/org/eclipse/pde/internal/runtime/registry/model/ServiceRegistration.java (+14 lines)
Lines 130-133 Link Here
130
		}
130
		}
131
		return 0;
131
		return 0;
132
	}
132
	}
133
134
	public void addChild(ModelObject obj) {
135
		if (obj instanceof Property) {
136
			// XXX very ineffective
137
			Property[] tmp = new Property[properties.length + 1];
138
			System.arraycopy(properties, 0, tmp, 0, properties.length);
139
			tmp[tmp.length - 1] = (Property) obj;
140
			properties = tmp;
141
		}
142
	}
143
144
	public ModelObject[] getChildren() {
145
		return properties;
146
	}
133
}
147
}
(-)src/org/eclipse/pde/internal/runtime/registry/model/Extension.java (+14 lines)
Lines 106-109 Link Here
106
		result = prime * result + ((namespaceIdentifier == null) ? 0 : namespaceIdentifier.hashCode());
106
		result = prime * result + ((namespaceIdentifier == null) ? 0 : namespaceIdentifier.hashCode());
107
		return result;
107
		return result;
108
	}
108
	}
109
110
	public void addChild(ModelObject o) {
111
		if (o instanceof ConfigurationElement) {
112
			// XXX very ineffective
113
			ConfigurationElement[] tmp = new ConfigurationElement[configurationElements.length + 1];
114
			System.arraycopy(configurationElements, 0, tmp, 0, configurationElements.length);
115
			tmp[tmp.length - 1] = (ConfigurationElement) o;
116
			configurationElements = tmp;
117
		}
118
	}
119
120
	public ModelObject[] getChildren() {
121
		return configurationElements;
122
	}
109
}
123
}
(-)src/org/eclipse/pde/internal/runtime/registry/model/Bundle.java (+23 lines)
Lines 141-144 Link Here
141
	public BundlePrerequisite[] getExportedPackages() {
141
	public BundlePrerequisite[] getExportedPackages() {
142
		return exportedPackages;
142
		return exportedPackages;
143
	}
143
	}
144
145
	public ModelObject[] getChildren() {
146
		ModelObject[] children = new ModelObject[imports.length + libraries.length];
147
		System.arraycopy(imports, 0, children, 0, imports.length);
148
		System.arraycopy(libraries, 0, children, imports.length, libraries.length);
149
		return children;
150
	}
151
152
	public void addChild(ModelObject o) {
153
		if (o instanceof BundlePrerequisite) {
154
			// XXX very ineffective
155
			BundlePrerequisite[] tmp = new BundlePrerequisite[imports.length + 1];
156
			System.arraycopy(imports, 0, tmp, 0, imports.length);
157
			tmp[tmp.length - 1] = (BundlePrerequisite) o;
158
			imports = tmp;
159
		} else if (o instanceof BundleLibrary) {
160
			// XXX very ineffective
161
			BundleLibrary[] tmp = new BundleLibrary[libraries.length + 1];
162
			System.arraycopy(libraries, 0, tmp, 0, libraries.length);
163
			tmp[tmp.length - 1] = (BundleLibrary) o;
164
			libraries = tmp;
165
		}
166
	}
144
}
167
}
(-)src/org/eclipse/pde/internal/runtime/registry/model/ExtensionPoint.java (+10 lines)
Lines 89-92 Link Here
89
			return false;
89
			return false;
90
		return true;
90
		return true;
91
	}
91
	}
92
93
	public void addChild(ModelObject obj) {
94
		if (obj instanceof Extension) {
95
			extensions.add(obj);
96
		}
97
	}
98
99
	public ModelObject[] getChildren() {
100
		return (ModelObject[]) extensions.toArray(new ModelObject[extensions.size()]);
101
	}
92
}
102
}
(-)src/org/eclipse/pde/internal/runtime/registry/model/ModelChangeDelta.java (-3 / +11 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2008, 2009 IBM Corporation and others.
2
 * Copyright (c) 2008 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
Lines 7-21 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Wojciech Galanciak <wojciech.galanciak@gmail.com> - bug 282804
11
 *******************************************************************************/
10
 *******************************************************************************/
12
package org.eclipse.pde.internal.runtime.registry.model;
11
package org.eclipse.pde.internal.runtime.registry.model;
13
12
14
/**
13
/**
15
 * Delta model objects are of type IBundle, IService, IExtension, IExtensionPoint
14
 * Delta model objects are of type IBundle, IService, IExtension, IExtensionPoint
16
 */
15
 */
17
public class ModelChangeDelta {
16
public class ModelChangeDelta extends ModelObject {
18
17
18
	private static final long serialVersionUID = 1L;
19
	public static final int ADDED = 0;
19
	public static final int ADDED = 0;
20
	public static final int UPDATED = 1;
20
	public static final int UPDATED = 1;
21
	public static final int REMOVED = 2;
21
	public static final int REMOVED = 2;
Lines 47-52 Link Here
47
		return fFlag;
47
		return fFlag;
48
	}
48
	}
49
49
50
	public void addChild(ModelObject o) {
51
		setModelObject(o);
52
	}
53
54
	public ModelObject[] getChildren() {
55
		return new ModelObject[] {fObject};
56
	}
57
50
	public void setModelObject(ModelObject fObject) {
58
	public void setModelObject(ModelObject fObject) {
51
		this.fObject = fObject;
59
		this.fObject = fObject;
52
	}
60
	}
(-)src/org/eclipse/pde/internal/runtime/registry/model/Property.java (-1 / +5 lines)
Lines 131-135 Link Here
131
		// simply compare strings
131
		// simply compare strings
132
		return name0.compareTo(name1);
132
		return name0.compareTo(name1);
133
	}
133
	}
134
	
134
135
	public String toString() {
136
		return "Property(\"" + name + "\", \"" + value + "\")";
137
	}
138
135
}
139
}
(-)src/org/eclipse/pde/internal/runtime/registry/RegistryBrowser.java (-1 / +1 lines)
Lines 157-163 Link Here
157
	}
157
	}
158
158
159
	private void initializeModel() {
159
	private void initializeModel() {
160
		model = RegistryModelFactory.getRegistryModel("local:///"); //$NON-NLS-1$
160
		model = RegistryModelFactory.getRegistryModel("jmx:///"); //$NON-NLS-1$
161
161
162
		fTreeViewer.setInput(model);
162
		fTreeViewer.setInput(model);
163
		listener = new RegistryBrowserModelChangeListener(RegistryBrowser.this);
163
		listener = new RegistryBrowserModelChangeListener(RegistryBrowser.this);
(-)src/org/eclipse/pde/internal/runtime/registry/model/ModelSerializer.java (+356 lines)
Added Link Here
1
package org.eclipse.pde.internal.runtime.registry.model;
2
3
import java.util.*;
4
import org.xml.sax.Attributes;
5
import org.xml.sax.SAXException;
6
import org.xml.sax.helpers.DefaultHandler;
7
8
public class ModelSerializer {
9
10
	private static final String BUNDLE = "bundle"; //$NON-NLS-1$
11
	private static final String USING_BUNDLES = "usingBundles"; //$NON-NLS-1$
12
	private static final String CLASSES = "classes"; //$NON-NLS-1$
13
	private static final String EXTENSION_POINT_UNIQUE_IDENTIFIER = "extensionPointUniqueIdentifier"; //$NON-NLS-1$
14
	private static final String CONTRIBUTOR = "contributor"; //$NON-NLS-1$
15
	private static final String LABEL = "label"; //$NON-NLS-1$
16
	private static final String UNIQUE_IDENTIFIER = "uniqueIdentifier"; //$NON-NLS-1$
17
	private static final String NAMESPACE_IDENTIFIER = "namespaceIdentifier"; //$NON-NLS-1$
18
	private static final String IS_EXPORTED = "isExported"; //$NON-NLS-1$
19
	private static final String LIBRARY = "library"; //$NON-NLS-1$
20
	private static final String ID = "id"; //$NON-NLS-1$
21
	private static final String STATE = "state"; //$NON-NLS-1$
22
	private static final String VERSION = "version"; //$NON-NLS-1$
23
	private static final String IS_ENABLED = "isEnabled"; //$NON-NLS-1$
24
	private static final String LOCATION = "location"; //$NON-NLS-1$
25
	private static final String SYMBOLIC_NAME = "symbolicName"; //$NON-NLS-1$
26
	private static final String VALUE = "value"; //$NON-NLS-1$
27
	private static final String NAME = "name"; //$NON-NLS-1$
28
	private static final String FLAG = "flag"; //$NON-NLS-1$
29
30
	public static abstract class XMLHandler extends DefaultHandler {
31
32
		private Stack stack = new Stack();
33
34
		public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
35
			if (qName.equals("start")) //$NON-NLS-1$
36
				return;
37
38
			ModelObject o = create(qName);
39
			if (o == null)
40
				return;
41
42
			for (int i = 0; i < attributes.getLength(); i++) {
43
				set(o, attributes.getQName(i), attributes.getValue(i));
44
			}
45
46
			if (!(o instanceof ModelChangeDelta)) {
47
				((ModelObject) stack.peek()).addChild(o);
48
			}
49
50
			//System.out.println("push " + o); //XXX remove syso
51
			stack.push(o);
52
53
		}
54
55
		public void endElement(String uri, String localName, String qName) throws SAXException {
56
			if (qName.equals("start"))
57
				return;
58
59
			//System.out.print("pop "); //XXX remove syso
60
			ModelObject o = (ModelObject) stack.pop();
61
			//System.out.println(o); //XXX remove syso
62
63
			if (o instanceof ModelChangeDelta) {
64
				handleDelta((ModelChangeDelta) o);
65
			}
66
		}
67
68
		public abstract void handleDelta(ModelChangeDelta delta);
69
70
	}
71
72
	protected static void set(ModelObject o, String name, String value) {
73
		if (o instanceof Attribute) {
74
			Attribute attribute = (Attribute) o;
75
			if (NAME.equals(name)) {
76
				attribute.setName(value);
77
			} else if (VALUE.equals(name)) {
78
				attribute.setValue(value);
79
			}
80
81
		} else if (o instanceof Bundle) {
82
			Bundle bundle = (Bundle) o;
83
84
			if (SYMBOLIC_NAME.equals(name)) {
85
				bundle.setSymbolicName(value);
86
			} else if (LOCATION.equals(name)) {
87
				bundle.setLocation(value);
88
			} else if (IS_ENABLED.equals(name)) {
89
				bundle.setEnabled(Boolean.valueOf(value).booleanValue());
90
			} else if (VERSION.equals(name)) {
91
				bundle.setVersion(value);
92
			} else if (STATE.equals(name)) {
93
				bundle.setState(Integer.parseInt(value));
94
			} else if (ID.equals(name)) {
95
				bundle.setId(Long.parseLong(value));
96
			}
97
98
		} else if (o instanceof BundleLibrary) {
99
			BundleLibrary library = (BundleLibrary) o;
100
			if (LIBRARY.equals(name)) {
101
				library.setLibrary(value);
102
			}
103
104
		} else if (o instanceof BundlePrerequisite) {
105
			BundlePrerequisite prereq = (BundlePrerequisite) o;
106
			if (NAME.equals(name)) {
107
				prereq.setName(value);
108
			} else if (VERSION.equals(name)) {
109
				prereq.setVersion(value);
110
			} else if (IS_EXPORTED.equals(name)) {
111
				prereq.setExported(Boolean.valueOf(value).booleanValue());
112
			}
113
114
		} else if (o instanceof Extension) {
115
			Extension ext = (Extension) o;
116
			if (NAMESPACE_IDENTIFIER.equals(name)) {
117
				ext.setNamespaceIdentifier(value);
118
			} else if (LABEL.equals(name)) {
119
				ext.setLabel(value);
120
			} else if (EXTENSION_POINT_UNIQUE_IDENTIFIER.equals(name)) {
121
				ext.setExtensionPointUniqueIdentifier(value);
122
			} else if (CONTRIBUTOR.equals(name)) {
123
				ext.setContributor(Long.valueOf(value));
124
			}
125
126
		} else if (o instanceof ExtensionPoint) {
127
			ExtensionPoint extPt = (ExtensionPoint) o;
128
			if (LABEL.equals(name)) {
129
				extPt.setLabel(value);
130
			} else if (UNIQUE_IDENTIFIER.equals(name)) {
131
				extPt.setUniqueIdentifier(value);
132
			} else if (NAMESPACE_IDENTIFIER.equals(name)) {
133
				extPt.setNamespaceIdentifier(value);
134
			} else if (CONTRIBUTOR.equals(name)) {
135
				extPt.setContributor(Long.valueOf(value));
136
			}
137
138
		} else if (o instanceof ServiceRegistration) {
139
			ServiceRegistration service = (ServiceRegistration) o;
140
			if (ID.equals(name)) {
141
				service.setId(Long.parseLong(value));
142
			} else if (BUNDLE.equals(name)) {
143
				service.setBundle(value);
144
			} else if (USING_BUNDLES.equals(name)) {
145
				StringTokenizer st = new StringTokenizer(value, ",");
146
				List l = new ArrayList();
147
				while (st.hasMoreTokens()) {
148
					l.add(Long.valueOf(st.nextToken()));
149
				}
150
				long[] ids = new long[l.size()];
151
				for (int i = 0; i < l.size(); i++) {
152
					ids[i] = ((Long) l.get(i)).longValue();
153
				}
154
				service.setUsingBundles(ids);
155
			} else if (CLASSES.equals(name)) {
156
				StringTokenizer st = new StringTokenizer(value, ",");
157
				List l = new ArrayList();
158
				while (st.hasMoreTokens()) {
159
					l.add(st.nextToken());
160
				}
161
162
				ServiceName sn = new ServiceName((String[]) l.toArray(new String[l.size()]));
163
				service.setName(sn);
164
			}
165
		} else if (o instanceof Property) {
166
			Property property = (Property) o;
167
			if (NAME.equals(name)) {
168
				property.setName(value);
169
			} else if (VALUE.equals(name)) {
170
				property.setValue(value);
171
			}
172
173
		} else if (o instanceof ModelChangeDelta) {
174
			ModelChangeDelta delta = (ModelChangeDelta) o;
175
176
			if (FLAG.equals(name)) {
177
				delta.setFlag(Integer.parseInt(value));
178
			}
179
		}
180
	}
181
182
	protected static void addAttribute(StringBuffer sb, String name, String value) {
183
		if (value == null)
184
			return;
185
186
		sb.append(" ").append(name).append("=\"").append(getWritableString(value)).append("\"");
187
	}
188
189
	protected static void addAttributes(StringBuffer sb, ModelObject o) {
190
191
		if (o instanceof Attribute) {
192
			Attribute attribute = (Attribute) o;
193
			addAttribute(sb, NAME, attribute.getName());
194
			addAttribute(sb, VALUE, attribute.getValue());
195
196
		} else if (o instanceof Bundle) {
197
			Bundle bundle = (Bundle) o;
198
199
			addAttribute(sb, SYMBOLIC_NAME, bundle.getSymbolicName());
200
			addAttribute(sb, LOCATION, bundle.getLocation());
201
			addAttribute(sb, IS_ENABLED, Boolean.toString(bundle.isEnabled()));
202
			addAttribute(sb, VERSION, bundle.getVersion());
203
			addAttribute(sb, STATE, Integer.toString(bundle.getState()));
204
			addAttribute(sb, ID, Long.toString(bundle.getId()));
205
206
		} else if (o instanceof BundleLibrary) {
207
			BundleLibrary library = (BundleLibrary) o;
208
			addAttribute(sb, LIBRARY, library.getLibrary());
209
210
		} else if (o instanceof BundlePrerequisite) {
211
			BundlePrerequisite prereq = (BundlePrerequisite) o;
212
			addAttribute(sb, NAME, prereq.getName());
213
			addAttribute(sb, VERSION, prereq.getVersion());
214
			addAttribute(sb, IS_EXPORTED, Boolean.toString(prereq.isExported()));
215
216
		} else if (o instanceof Extension) {
217
			Extension ext = (Extension) o;
218
			addAttribute(sb, NAMESPACE_IDENTIFIER, ext.getNamespaceIdentifier());
219
			addAttribute(sb, LABEL, ext.getLabel());
220
			addAttribute(sb, EXTENSION_POINT_UNIQUE_IDENTIFIER, ext.getExtensionPointUniqueIdentifier());
221
			Long id = ext.getContributorId();
222
			if (id != null)
223
				addAttribute(sb, CONTRIBUTOR, id.toString());
224
225
		} else if (o instanceof ExtensionPoint) {
226
			ExtensionPoint extPt = (ExtensionPoint) o;
227
			addAttribute(sb, LABEL, extPt.getLabel());
228
			addAttribute(sb, UNIQUE_IDENTIFIER, extPt.getUniqueIdentifier());
229
			addAttribute(sb, NAMESPACE_IDENTIFIER, extPt.getNamespaceIdentifier());
230
			Long id = extPt.getContributorId();
231
			if (id != null)
232
				addAttribute(sb, CONTRIBUTOR, id.toString());
233
234
		} else if (o instanceof ServiceRegistration) {
235
			ServiceRegistration service = (ServiceRegistration) o;
236
			addAttribute(sb, ID, Long.toString(service.getId()));
237
			addAttribute(sb, BUNDLE, service.getBundle());
238
			addAttribute(sb, USING_BUNDLES, arrayToString(service.getUsingBundleIds()));
239
			addAttribute(sb, CLASSES, arrayToString(service.getName().getClasses()));
240
241
		} else if (o instanceof Property) {
242
			Property property = (Property) o;
243
			addAttribute(sb, NAME, property.getName());
244
			addAttribute(sb, VALUE, property.getValue());
245
246
		} else if (o instanceof ModelChangeDelta) {
247
			ModelChangeDelta delta = (ModelChangeDelta) o;
248
			addAttribute(sb, FLAG, Integer.toString(delta.getFlag()));
249
		}
250
	}
251
252
	private static String arrayToString(Object[] array) {
253
		StringBuffer sb = new StringBuffer();
254
		for (int i = 0; i < array.length; i++) {
255
			if (i > 0)
256
				sb.append(',');
257
			sb.append(array[i]);
258
		}
259
260
		return sb.toString();
261
	}
262
263
	private static String arrayToString(long[] array) {
264
		StringBuffer sb = new StringBuffer();
265
		for (int i = 0; i < array.length; i++) {
266
			if (i > 0)
267
				sb.append(',');
268
			sb.append(array[i]);
269
		}
270
271
		return sb.toString();
272
	}
273
274
	private static ModelObject create(String name) {
275
		if (Attribute.class.getName().equals(name)) {
276
			return new Attribute();
277
		} else if (Bundle.class.getName().equals(name)) {
278
			return new Bundle();
279
		} else if (BundleLibrary.class.getName().equals(name)) {
280
			return new BundleLibrary();
281
		} else if (BundlePrerequisite.class.getName().equals(name)) {
282
			return new BundlePrerequisite();
283
		} else if (ConfigurationElement.class.getName().equals(name)) {
284
			return new ConfigurationElement();
285
		} else if (Extension.class.getName().equals(name)) {
286
			return new Extension();
287
		} else if (ExtensionPoint.class.getName().equals(name)) {
288
			return new ExtensionPoint();
289
		} else if (ModelChangeDelta.class.getName().equals(name)) {
290
			return new ModelChangeDelta();
291
		} else if (ServiceRegistration.class.getName().equals(name)) {
292
			return new ServiceRegistration();
293
		} else if (Property.class.getName().equals(name)) {
294
			return new Property();
295
		}
296
297
		return null;
298
	}
299
300
	public static String serialize(ModelObject o) {
301
		return serialize(o, new StringBuffer());
302
	}
303
304
	// XXX From PDEXMLHelper
305
	private static String getWritableString(String source) {
306
		if (source == null)
307
			return ""; //$NON-NLS-1$
308
		StringBuffer buf = new StringBuffer();
309
		for (int i = 0; i < source.length(); i++) {
310
			char c = source.charAt(i);
311
			switch (c) {
312
				case '&' :
313
					buf.append("&amp;"); //$NON-NLS-1$
314
					break;
315
				case '<' :
316
					buf.append("&lt;"); //$NON-NLS-1$
317
					break;
318
				case '>' :
319
					buf.append("&gt;"); //$NON-NLS-1$
320
					break;
321
				case '\'' :
322
					buf.append("&apos;"); //$NON-NLS-1$
323
					break;
324
				case '\"' :
325
					buf.append("&quot;"); //$NON-NLS-1$
326
					break;
327
				default :
328
					buf.append(c);
329
					break;
330
			}
331
		}
332
		return buf.toString();
333
	}
334
335
	private static String serialize(ModelObject o, StringBuffer sb) {
336
		String className = o.getClass().getName();
337
		sb.append('<').append(className);
338
339
		addAttributes(sb, o);
340
341
		sb.append('>').append('\n');
342
343
		ModelObject[] children = o.getChildren();
344
345
		if (children != null) {
346
			for (int i = 0; i < children.length; i++) {
347
				if (children[i] != null)
348
					serialize(children[i], sb);
349
			}
350
		}
351
352
		sb.append("</").append(className).append('>').append('\n'); //$NON-NLS-1$
353
354
		return sb.toString();
355
	}
356
}

Return to bug 274980