001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: package org.netbeans.modules.apisupport.project.universe;
043:
044: import java.io.File;
045: import java.io.IOException;
046: import java.util.HashSet;
047: import java.util.Set;
048: import java.util.TreeSet;
049: import org.netbeans.modules.apisupport.project.ManifestManager;
050: import org.netbeans.modules.apisupport.project.Util;
051: import org.openide.modules.Dependency;
052:
053: final class BinaryEntry extends AbstractEntry {
054:
055: private final String cnb;
056: private final File jar;
057: private final String cpext;
058: private final File nbdestdir;
059: private final File clusterDir;
060: private final String releaseVersion;
061: private final String specVersion;
062: private final String[] providedTokens;
063: private LocalizedBundleInfo bundleInfo;
064: private final ManifestManager.PackageExport[] publicPackages;
065: private final String[] friends;
066: private final boolean deprecated;
067: private final String[] runDependencies;
068: private Set<String> allPackageNames;
069:
070: public BinaryEntry(String cnb, File jar, File[] exts,
071: File nbdestdir, File clusterDir, String releaseVersion,
072: String specVersion, String[] providedTokens,
073: ManifestManager.PackageExport[] publicPackages,
074: String[] friends, boolean deprecated,
075: Set<Dependency> moduleDependencies) {
076: this .cnb = cnb;
077: this .jar = jar;
078: this .nbdestdir = nbdestdir;
079: this .clusterDir = clusterDir;
080: StringBuffer _cpext = new StringBuffer();
081: for (int i = 0; i < exts.length; i++) {
082: _cpext.append(':');
083: _cpext.append(exts[i].getAbsolutePath());
084: }
085: cpext = _cpext.toString();
086: this .releaseVersion = releaseVersion;
087: this .specVersion = specVersion;
088: this .providedTokens = providedTokens;
089: this .publicPackages = publicPackages;
090: this .friends = friends;
091: this .deprecated = deprecated;
092: Set<String> deps = new TreeSet<String>();
093: for (Dependency d : moduleDependencies) {
094: String codename = d.getName();
095: int slash = codename.lastIndexOf('/');
096: if (slash == -1) {
097: deps.add(codename);
098: } else {
099: deps.add(codename.substring(0, slash));
100: }
101: }
102: runDependencies = deps.toArray(new String[deps.size()]);
103: }
104:
105: //private boolean recurring;
106: public File getSourceLocation() {
107: NbPlatform platform = NbPlatform
108: .getPlatformByDestDir(getDestDir());
109: /*
110: assert !recurring : jar;
111: recurring = true;
112: try {
113: */
114: return platform.getSourceLocationOfModule(getJarLocation());
115: /*
116: } finally {
117: recurring = false;
118: }
119: */
120: }
121:
122: public String getNetBeansOrgPath() {
123: return null;
124: }
125:
126: public File getJarLocation() {
127: return jar;
128: }
129:
130: public File getDestDir() {
131: return nbdestdir;
132: }
133:
134: public String getCodeNameBase() {
135: return cnb;
136: }
137:
138: public File getClusterDirectory() {
139: return clusterDir;
140: }
141:
142: public String getClassPathExtensions() {
143: return cpext;
144: }
145:
146: public String getReleaseVersion() {
147: return releaseVersion;
148: }
149:
150: public String getSpecificationVersion() {
151: return specVersion;
152: }
153:
154: public String[] getProvidedTokens() {
155: return providedTokens;
156: }
157:
158: protected LocalizedBundleInfo getBundleInfo() {
159: if (bundleInfo == null) {
160: bundleInfo = Util
161: .findLocalizedBundleInfoFromJAR(getJarLocation());
162: if (bundleInfo == null) {
163: bundleInfo = LocalizedBundleInfo.EMPTY;
164: }
165: }
166: return bundleInfo;
167: }
168:
169: public ManifestManager.PackageExport[] getPublicPackages() {
170: return publicPackages;
171: }
172:
173: public synchronized Set<String> getAllPackageNames() {
174: if (allPackageNames == null) {
175: allPackageNames = new TreeSet<String>();
176: Util.scanJarForPackageNames(allPackageNames,
177: getJarLocation());
178: }
179: return allPackageNames;
180: }
181:
182: public boolean isDeclaredAsFriend(String cnb) {
183: return isDeclaredAsFriend(friends, cnb);
184: }
185:
186: public boolean isDeprecated() {
187: return deprecated;
188: }
189:
190: public String toString() {
191: File source = getSourceLocation();
192: return "BinaryEntry[" + getJarLocation()
193: + (source != null ? "," + source : "") + "]"; // NOI18N
194: }
195:
196: protected Set<String> computePublicClassNamesInMainModule()
197: throws IOException {
198: Set<String> result = new HashSet<String>();
199: scanJarForPublicClassNames(result, jar);
200: return result;
201: }
202:
203: public String[] getRunDependencies() {
204: return runDependencies;
205: }
206:
207: }
|