KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > emf > codegen > ecore > templates > model > PluginXML


1 package org.eclipse.emf.codegen.ecore.templates.model;
2
3 import java.util.*;
4 import org.eclipse.emf.codegen.ecore.genmodel.*;
5
6 public class PluginXML
7 {
8   protected static String JavaDoc nl;
9   public static synchronized PluginXML create(String JavaDoc lineSeparator)
10   {
11     nl = lineSeparator;
12     PluginXML result = new PluginXML();
13     nl = null;
14     return result;
15   }
16
17   protected final String JavaDoc NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
18   protected final String JavaDoc TEXT_1 = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + NL + "<?eclipse version=\"3.0\"?>" + NL;
19   protected final String JavaDoc TEXT_2 = NL;
20   protected final String JavaDoc TEXT_3 = "<!--" + NL + " <copyright>" + NL + " </copyright>" + NL;
21   protected final String JavaDoc TEXT_4 = NL + " ";
22   protected final String JavaDoc TEXT_5 = "Id";
23   protected final String JavaDoc TEXT_6 = NL + "-->" + NL + "" + NL + "<plugin";
24   protected final String JavaDoc TEXT_7 = ">";
25   protected final String JavaDoc TEXT_8 = NL + " name = \"%pluginName\"" + NL + " id = \"";
26   protected final String JavaDoc TEXT_9 = "\"" + NL + " version = \"1.0.0\"";
27   protected final String JavaDoc TEXT_10 = NL + " provider-name = \"%providerName\"" + NL + " class = \"";
28   protected final String JavaDoc TEXT_11 = "$Implementation\">";
29   protected final String JavaDoc TEXT_12 = NL + " provider-name = \"%providerName\">";
30   protected final String JavaDoc TEXT_13 = NL + NL + " <requires>";
31   protected final String JavaDoc TEXT_14 = NL + " <import plugin=\"";
32   protected final String JavaDoc TEXT_15 = "\" ";
33   protected final String JavaDoc TEXT_16 = "export=\"true\"";
34   protected final String JavaDoc TEXT_17 = "/>";
35   protected final String JavaDoc TEXT_18 = NL + " </requires>" + NL + "" + NL + " <runtime>";
36   protected final String JavaDoc TEXT_19 = NL + " <library name=\"";
37   protected final String JavaDoc TEXT_20 = ".jar\">";
38   protected final String JavaDoc TEXT_21 = NL + " <library name=\".\">";
39   protected final String JavaDoc TEXT_22 = NL + " <export name=\"*\"/>" + NL + " </library>" + NL + " </runtime>";
40   protected final String JavaDoc TEXT_23 = NL + NL + " <extension point=\"org.eclipse.emf.ecore.generated_package\">" + NL + " <package " + NL + " uri = \"";
41   protected final String JavaDoc TEXT_24 = "\" " + NL + " class = \"";
42   protected final String JavaDoc TEXT_25 = "\"";
43   protected final String JavaDoc TEXT_26 = " />";
44   protected final String JavaDoc TEXT_27 = NL + " genModel = \"";
45   protected final String JavaDoc TEXT_28 = "\" /> ";
46   protected final String JavaDoc TEXT_29 = NL + " </extension>";
47   protected final String JavaDoc TEXT_30 = NL + NL + " <extension point=\"org.eclipse.emf.ecore.extension_parser\">" + NL + " <parser " + NL + " type=\"";
48   protected final String JavaDoc TEXT_31 = "\" " + NL + " class=\"";
49   protected final String JavaDoc TEXT_32 = "\" />" + NL + " </extension>";
50   protected final String JavaDoc TEXT_33 = NL + NL + "</plugin>" + NL;
51   protected final String JavaDoc TEXT_34 = NL;
52
53   public String JavaDoc generate(Object JavaDoc argument)
54   {
55     StringBuffer JavaDoc stringBuffer = new StringBuffer JavaDoc();
56     
57 /**
58  * <copyright>
59  *
60  * Copyright (c) 2002-2005 IBM Corporation and others.
61  * All rights reserved. This program and the accompanying materials
62  * are made available under the terms of the Eclipse Public License v1.0
63  * which accompanies this distribution, and is available at
64  * http://www.eclipse.org/legal/epl-v10.html
65  *
66  * Contributors:
67  * IBM - Initial API and implementation
68  *
69  * </copyright>
70  */

71
72     GenModel genModel = (GenModel)argument;
73     stringBuffer.append(TEXT_1);
74     stringBuffer.append(TEXT_2);
75     stringBuffer.append(TEXT_3);
76     stringBuffer.append(TEXT_4);
77     stringBuffer.append("$");
78     stringBuffer.append(TEXT_5);
79     stringBuffer.append("$");
80     stringBuffer.append(TEXT_6);
81     if (genModel.isBundleManifest()) {
82     stringBuffer.append(TEXT_7);
83     } else {
84     stringBuffer.append(TEXT_8);
85     stringBuffer.append(genModel.getModelPluginID());
86     stringBuffer.append(TEXT_9);
87     if (genModel.hasModelPluginClass()) {
88     stringBuffer.append(TEXT_10);
89     stringBuffer.append(genModel.getQualifiedModelPluginClassName());
90     stringBuffer.append(TEXT_11);
91     } else {
92     stringBuffer.append(TEXT_12);
93     }
94     stringBuffer.append(TEXT_13);
95     for (Iterator j=genModel.getModelRequiredPlugins().iterator(); j.hasNext();) { String JavaDoc pluginID = (String JavaDoc)j.next();
96     stringBuffer.append(TEXT_14);
97     stringBuffer.append(pluginID);
98     stringBuffer.append(TEXT_15);
99     if (!pluginID.startsWith("org.eclipse.core.runtime")) {
100     stringBuffer.append(TEXT_16);
101     }
102     stringBuffer.append(TEXT_17);
103     }
104     stringBuffer.append(TEXT_18);
105     if (genModel.isRuntimeJar()) {
106     stringBuffer.append(TEXT_19);
107     stringBuffer.append(genModel.getModelPluginID());
108     stringBuffer.append(TEXT_20);
109     } else {
110     stringBuffer.append(TEXT_21);
111     }
112     stringBuffer.append(TEXT_22);
113     }
114     for (Iterator i = genModel.getAllGenPackagesWithClassifiers().iterator(); i.hasNext(); ) { GenPackage genPackage = (GenPackage)i.next();
115     stringBuffer.append(TEXT_23);
116     stringBuffer.append(genPackage.getNSURI());
117     stringBuffer.append(TEXT_24);
118     stringBuffer.append(genPackage.getQualifiedPackageInterfaceName());
119     stringBuffer.append(TEXT_25);
120     if (!genModel.hasLocalGenModel()) {
121     stringBuffer.append(TEXT_26);
122     } else {
123     stringBuffer.append(TEXT_27);
124     stringBuffer.append(genModel.getRelativeGenModelLocation());
125     stringBuffer.append(TEXT_28);
126     }
127     stringBuffer.append(TEXT_29);
128     if (genPackage.getResource() != GenResourceKind.NONE_LITERAL) {
129     stringBuffer.append(TEXT_30);
130     stringBuffer.append(genPackage.getPrefix().toLowerCase());
131     stringBuffer.append(TEXT_31);
132     stringBuffer.append(genPackage.getQualifiedResourceFactoryClassName());
133     stringBuffer.append(TEXT_32);
134     }
135     }
136     stringBuffer.append(TEXT_33);
137     stringBuffer.append(TEXT_34);
138     return stringBuffer.toString();
139   }
140 }
141
Popular Tags