KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > apisupport > project > universe > BinaryEntry


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.apisupport.project.universe;
21
22 import java.io.File JavaDoc;
23 import java.io.IOException JavaDoc;
24 import java.util.HashSet JavaDoc;
25 import java.util.Set JavaDoc;
26 import java.util.TreeSet JavaDoc;
27 import org.netbeans.modules.apisupport.project.ManifestManager;
28 import org.netbeans.modules.apisupport.project.Util;
29 import org.openide.modules.Dependency;
30
31 final class BinaryEntry extends AbstractEntry {
32
33     private final String JavaDoc cnb;
34     private final File JavaDoc jar;
35     private final String JavaDoc cpext;
36     private final File JavaDoc nbdestdir;
37     private final File JavaDoc clusterDir;
38     private final String JavaDoc releaseVersion;
39     private final String JavaDoc specVersion;
40     private final String JavaDoc[] providedTokens;
41     private LocalizedBundleInfo bundleInfo;
42     private final ManifestManager.PackageExport[] publicPackages;
43     private final String JavaDoc[] friends;
44     private final boolean deprecated;
45     private final String JavaDoc[] runDependencies;
46     private Set JavaDoc<String JavaDoc> allPackageNames;
47     
48     public BinaryEntry(String JavaDoc cnb, File JavaDoc jar, File JavaDoc[] exts, File JavaDoc nbdestdir, File JavaDoc clusterDir,
49             String JavaDoc releaseVersion, String JavaDoc specVersion, String JavaDoc[] providedTokens,
50             ManifestManager.PackageExport[] publicPackages, String JavaDoc[] friends,
51             boolean deprecated, Set JavaDoc<Dependency> moduleDependencies) {
52         this.cnb = cnb;
53         this.jar = jar;
54         this.nbdestdir = nbdestdir;
55         this.clusterDir = clusterDir;
56         StringBuffer JavaDoc _cpext = new StringBuffer JavaDoc();
57         for (int i = 0; i < exts.length; i++) {
58             _cpext.append(':');
59             _cpext.append(exts[i].getAbsolutePath());
60         }
61         cpext = _cpext.toString();
62         this.releaseVersion = releaseVersion;
63         this.specVersion = specVersion;
64         this.providedTokens = providedTokens;
65         this.publicPackages = publicPackages;
66         this.friends = friends;
67         this.deprecated = deprecated;
68         Set JavaDoc<String JavaDoc> deps = new TreeSet JavaDoc<String JavaDoc>();
69         for (Dependency d : moduleDependencies) {
70             String JavaDoc codename = d.getName();
71             int slash = codename.lastIndexOf('/');
72             if (slash == -1) {
73                 deps.add(codename);
74             } else {
75                 deps.add(codename.substring(0, slash));
76             }
77         }
78         runDependencies = deps.toArray(new String JavaDoc[deps.size()]);
79     }
80     
81     //private boolean recurring;
82
public File JavaDoc getSourceLocation() {
83         NbPlatform platform = NbPlatform.getPlatformByDestDir(getDestDir());
84             /*
85             assert !recurring : jar;
86             recurring = true;
87             try {
88              */

89         return platform.getSourceLocationOfModule(getJarLocation());
90             /*
91             } finally {
92                 recurring = false;
93             }
94              */

95     }
96     
97     public String JavaDoc getNetBeansOrgPath() {
98         return null;
99     }
100     
101     public File JavaDoc getJarLocation() {
102         return jar;
103     }
104     
105     public File JavaDoc getDestDir() {
106         return nbdestdir;
107     }
108     
109     public String JavaDoc getCodeNameBase() {
110         return cnb;
111     }
112     
113     public File JavaDoc getClusterDirectory() {
114         return clusterDir;
115     }
116     
117     public String JavaDoc getClassPathExtensions() {
118         return cpext;
119     }
120     
121     public String JavaDoc getReleaseVersion() {
122         return releaseVersion;
123     }
124     
125     public String JavaDoc getSpecificationVersion() {
126         return specVersion;
127     }
128     
129     public String JavaDoc[] getProvidedTokens() {
130         return providedTokens;
131     }
132     
133     protected LocalizedBundleInfo getBundleInfo() {
134         if (bundleInfo == null) {
135             bundleInfo = Util.findLocalizedBundleInfoFromJAR(getJarLocation());
136             if (bundleInfo == null) {
137                 bundleInfo = LocalizedBundleInfo.EMPTY;
138             }
139         }
140         return bundleInfo;
141     }
142     
143     public ManifestManager.PackageExport[] getPublicPackages() {
144         return publicPackages;
145     }
146     
147     public synchronized Set JavaDoc<String JavaDoc> getAllPackageNames() {
148         if (allPackageNames == null) {
149             allPackageNames = new TreeSet JavaDoc<String JavaDoc>();
150             Util.scanJarForPackageNames(allPackageNames, getJarLocation());
151         }
152         return allPackageNames;
153     }
154     
155     public boolean isDeclaredAsFriend(String JavaDoc cnb) {
156         return isDeclaredAsFriend(friends, cnb);
157     }
158     
159     public boolean isDeprecated() {
160         return deprecated;
161     }
162     
163     public String JavaDoc toString() {
164         File JavaDoc source = getSourceLocation();
165         return "BinaryEntry[" + getJarLocation() + (source != null ? "," + source : "") + "]"; // NOI18N
166
}
167     
168     protected Set JavaDoc<String JavaDoc> computePublicClassNamesInMainModule() throws IOException JavaDoc {
169         Set JavaDoc<String JavaDoc> result = new HashSet JavaDoc<String JavaDoc>();
170         scanJarForPublicClassNames(result, jar);
171         return result;
172     }
173
174     public String JavaDoc[] getRunDependencies() {
175         return runDependencies;
176     }
177     
178 }
179
Popular Tags