1 11 package org.eclipse.pde.internal.core.plugin; 12 13 import java.io.PrintWriter ; 14 15 import org.eclipse.pde.core.plugin.IPluginExtension; 16 import org.eclipse.pde.core.plugin.IPluginExtensionPoint; 17 import org.eclipse.pde.internal.core.PDEState; 18 import org.w3c.dom.Node ; 19 import org.w3c.dom.NodeList ; 20 21 public class Extensions extends AbstractExtensions { 22 23 private static final long serialVersionUID = 1L; 24 25 private boolean fValid; 26 private boolean fIsFragment; 27 28 public Extensions() { 29 } 30 31 void load(Extensions srcPluginBase) { 32 super.load(srcPluginBase); 33 fValid = hasRequiredAttributes(); 34 } 35 36 void load(Node node, String schemaVersion) { 37 fSchemaVersion = schemaVersion; 38 if (node == null) 39 return; 40 NodeList children = node.getChildNodes(); 41 for (int i = 0; i < children.getLength(); i++) { 42 Node child = children.item(i); 43 if (child.getNodeType() == Node.ELEMENT_NODE) { 44 processChild(child); 45 } 46 } 47 fValid = hasRequiredAttributes(); 48 } 49 50 void load(PDEState state, long bundleID) { 51 Node [] nodes = state.getAllExtensions(bundleID); 52 for (int i = 0; i < nodes.length; i++) { 53 Node child = nodes[i]; 54 if (child.getNodeType() == Node.ELEMENT_NODE) { 55 processChild(child); 56 } 57 } 58 fValid = hasRequiredAttributes(); 59 fSchemaVersion = state.getSchemaVersion(bundleID); 60 } 61 62 public void reset() { 63 super.reset(); 64 fValid=false; 65 } 66 67 public boolean isValid() { 68 return fValid; 69 } 70 71 public void write(String indent, PrintWriter writer) { 72 writer.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); if (fSchemaVersion != null) 74 writer.println("<?eclipse version=\"" + fSchemaVersion + "\"?>"); writer.println(fIsFragment ? "<fragment>" : "<plugin>"); 77 String firstIndent = " "; 79 Object [] children = getExtensionPoints(); 80 if (children.length > 0) 81 writer.println(); 82 for (int i = 0; i < children.length; i++) { 83 ((IPluginExtensionPoint) children[i]).write(firstIndent, writer); 84 } 85 86 children = getExtensions(); 88 if (children.length > 0) 89 writer.println(); 90 for (int i = 0; i < children.length; i++) { 91 ((IPluginExtension) children[i]).write(firstIndent, writer); 92 } 93 writer.println(); 94 writer.println(fIsFragment ? "</fragment>" : "</plugin>"); } 96 97 public void setIsFragment(boolean isFragment) { 98 fIsFragment = isFragment; 99 } 100 } 101 | Popular Tags |