f63e8e14129cb69a0ea0d838bff282c0c71fa0a2
[mirror_edk2.git] / Tools / Source / MigrationTools / org / tianocore / migration / MsaOwner.java
1 package org.tianocore.migration;
2
3 import org.tianocore.*;
4
5 public class MsaOwner {
6 public static final String COPYRIGHT = "Copyright (c) 2006, Intel Corporation";
7 public static final String VERSION = "1.0";
8 public static final String ABSTRACT = "Component name for module ";
9 public static final String DESCRIPTION = "FIX ME!";
10 public static final String LICENSE = "All rights reserved.\n" +
11 " This software and associated documentation (if any) is furnished\n" +
12 " under a license and may only be used or copied in accordance\n" +
13 " with the terms of the license. Except as permitted by such\n" +
14 " license, no part of this software or documentation may be\n" +
15 " reproduced, stored in a retrieval system, or transmitted in any\n" +
16 " form or by any means without the express written consent of\n" +
17 " Intel Corporation.";
18 public static final String SPECIFICATION = "FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052";
19
20 private ModuleSurfaceAreaDocument msadoc = ModuleSurfaceAreaDocument.Factory.newInstance();
21
22 private ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = null;
23 private MsaHeaderDocument.MsaHeader msaheader = null;
24 private LicenseDocument.License license = null;
25 private ModuleDefinitionsDocument.ModuleDefinitions md = null;
26 private SourceFilesDocument.SourceFiles sourcefiles = null; //found local .h files are not written
27 private GuidsDocument.Guids guids = null;
28 private ProtocolsDocument.Protocols protocols = null;
29 private PPIsDocument.PPIs ppis = null;
30 private PackageDependenciesDocument.PackageDependencies pd = null;
31 private LibraryClassDefinitionsDocument.LibraryClassDefinitions libclassdefs = null;
32 private ExternsDocument.Externs externs = null;
33
34 //-----------------------------msaheader-------------------------------------//
35 public final boolean addSpecification (String specification) {
36 if (msaheader.getSpecification() == null) {
37 if (specification == null) {
38 msaheader.setSpecification(SPECIFICATION);
39 } else {
40 msaheader.setSpecification(specification);
41 }
42 return true;
43 } else {
44 MigrationTool.ui.println ("Warning: Duplicate Specification");
45 return false;
46 }
47 }
48
49 public final boolean addLicense (String licensecontent) {
50 if (msaheader.getLicense() == null) {
51 license = msaheader.addNewLicense();
52 if (licensecontent == null) {
53 license.setStringValue(LICENSE);
54 } else {
55 license.setStringValue(licensecontent);
56 }
57 return true;
58 } else {
59 MigrationTool.ui.println ("Warning: Duplicate License");
60 return false;
61 }
62 }
63
64 public final boolean addDescription (String description) {
65 if (msaheader.getDescription() == null) {
66 if (description == null) {
67 msaheader.setDescription(DESCRIPTION);
68 } else {
69 msaheader.setDescription(description);
70 }
71 return true;
72 } else {
73 MigrationTool.ui.println ("Warning: Duplicate Description");
74 return false;
75 }
76 }
77
78 public final boolean addAbstract (String abs) {
79 if (msaheader.getAbstract() == null) {
80 if (abs == null) {
81 msaheader.setAbstract(ABSTRACT + msaheader.getModuleName());
82 } else {
83 msaheader.setVersion(abs);
84 }
85 return true;
86 } else {
87 MigrationTool.ui.println ("Warning: Duplicate Abstract");
88 return false;
89 }
90 }
91
92 public final boolean addVersion (String version) {
93 if (msaheader.getVersion() == null) {
94 if (version == null) {
95 msaheader.setVersion(VERSION);
96 } else {
97 msaheader.setVersion(version);
98 }
99 return true;
100 } else {
101 MigrationTool.ui.println ("Warning: Duplicate Version");
102 return false;
103 }
104 }
105
106 public final boolean addCopyRight (String copyright) {
107 if (msaheader.getCopyright() == null) {
108 if (copyright == null) {
109 msaheader.setCopyright(COPYRIGHT);
110 } else {
111 msaheader.setCopyright(copyright);
112 }
113 return true;
114 } else {
115 MigrationTool.ui.println ("Warning: Duplicate CopyRight");
116 return false;
117 }
118 }
119
120 public final boolean addModuleType (String moduletype) {
121 if (msaheader.getModuleType() == null) {
122 msaheader.setModuleType(ModuleTypeDef.Enum.forString(moduletype));
123 return true;
124 } else {
125 MigrationTool.ui.println ("Warning: Duplicate ModuleType");
126 return false;
127 }
128 }
129
130 public final boolean addGuidValue (String guidvalue) {
131 if (msaheader.getGuidValue() == null) {
132 msaheader.setGuidValue(guidvalue);
133 return true;
134 } else {
135 MigrationTool.ui.println ("Warning: Duplicate GuidValue");
136 return false;
137 }
138 }
139
140 public final boolean addModuleName (String modulename) {
141 if (msaheader.getModuleName() == null) {
142 msaheader.setModuleName(modulename);
143 return true;
144 } else {
145 MigrationTool.ui.println ("Warning: Duplicate ModuleName");
146 return false;
147 }
148 }
149 //-----------------------------msaheader-------------------------------------//
150
151 public final void addSourceFiles (String filename, int arch) {
152
153 }
154
155 private final MsaOwner init () {
156 msa = msadoc.addNewModuleSurfaceArea();
157 msaheader = msa.addNewMsaHeader();
158 md = msa.addNewModuleDefinitions();
159 sourcefiles = msa.addNewSourceFiles();
160 pd = msa.addNewPackageDependencies();
161 libclassdefs = msa.addNewLibraryClassDefinitions();
162 externs = msa.addNewExterns();
163 return this;
164 }
165
166 public static final MsaOwner initNewMsaOwner() {
167 return new MsaOwner().init();
168 }
169 }