01: /*******************************************************************************
02: * Copyright (c) 2000, 2007 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.pde.internal.core.plugin;
11:
12: import java.io.PrintWriter;
13:
14: import org.eclipse.pde.core.plugin.IPluginExtension;
15: import org.eclipse.pde.core.plugin.IPluginExtensionPoint;
16:
17: public class Extensions extends AbstractExtensions {
18:
19: private static final long serialVersionUID = 1L;
20:
21: private Boolean fValid;
22: private boolean fIsFragment;
23:
24: public Extensions(boolean readOnly) {
25: super (readOnly);
26: }
27:
28: void load(Extensions srcPluginBase) {
29: super .load(srcPluginBase);
30: }
31:
32: void load(String schemaVersion) {
33: fSchemaVersion = schemaVersion;
34: }
35:
36: public void reset() {
37: super .reset();
38: fValid = null;
39: }
40:
41: public boolean isValid() {
42: if (fValid == null) {
43: fValid = new Boolean(hasRequiredAttributes());
44: }
45: return fValid.booleanValue();
46: }
47:
48: public void write(String indent, PrintWriter writer) {
49: writer.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); //$NON-NLS-1$
50: if (fSchemaVersion != null)
51: writer
52: .println("<?eclipse version=\"" + fSchemaVersion + "\"?>"); //$NON-NLS-1$ //$NON-NLS-2$
53: writer.println(fIsFragment ? "<fragment>" : "<plugin>"); //$NON-NLS-1$ //$NON-NLS-2$
54:
55: String firstIndent = " "; //$NON-NLS-1$
56:
57: Object[] children = getExtensionPoints();
58: if (children.length > 0)
59: writer.println();
60: for (int i = 0; i < children.length; i++) {
61: ((IPluginExtensionPoint) children[i]).write(firstIndent,
62: writer);
63: }
64:
65: // add extensions
66: children = getExtensions();
67: if (children.length > 0)
68: writer.println();
69: for (int i = 0; i < children.length; i++) {
70: ((IPluginExtension) children[i]).write(firstIndent, writer);
71: }
72: writer.println();
73: writer.println(fIsFragment ? "</fragment>" : "</plugin>"); //$NON-NLS-1$ //$NON-NLS-2$
74: }
75:
76: public void setIsFragment(boolean isFragment) {
77: fIsFragment = isFragment;
78: }
79: }
|