01: /**************************************************************************/
02: /* N I C E */
03: /* A high-level object-oriented research language */
04: /* (c) Daniel Bonniot 2001 */
05: /* */
06: /* This program is free software; you can redistribute it and/or modify */
07: /* it under the terms of the GNU General Public License as published by */
08: /* the Free Software Foundation; either version 2 of the License, or */
09: /* (at your option) any later version. */
10: /* */
11: /**************************************************************************/package bossa.modules;
12:
13: import bossa.util.*;
14: import java.io.*;
15:
16: /**
17: An abstract package source, where source or interface files
18: and compiled code if applicable can be found.
19:
20: @version $Date: 2005/04/12 12:38:10 $
21: @author Daniel Bonniot
22: */
23:
24: abstract class CompiledContent {
25: abstract Content.Unit[] getDefinitions();
26:
27: /** Date of the last succesful compilation of this package. */
28: long lastCompilation;
29:
30: gnu.bytecode.ClassType bytecode;
31: gnu.bytecode.ClassType dispatch;
32:
33: abstract void addClasses(java.util.Set/*<Content.Stream>*/classes);
34:
35: /**
36: Read a compiled class.
37:
38: @param name the fully qualified name of the class
39: */
40: abstract gnu.bytecode.ClassType readClass(String name);
41:
42: /** return a short name to display this package source
43: (typically a file name, an URL, ...) */
44: abstract public String getName();
45:
46: /** return a longer string that identifies the type of package source too. */
47: abstract public String toString();
48:
49: static CompiledContent create(Package pkg, java.net.URL url) {
50: if (url.getProtocol().equals("file")) {
51: File dir = new File(url.getFile()).getParentFile();
52: return DirectoryCompiledContent.create(pkg, dir);
53: }
54:
55: if (url.getProtocol().equals("jar")) {
56: String jar = url.getFile();
57: jar = jar.substring(jar.indexOf(':') + 1, jar.indexOf('!'));
58: try {
59: return JarCompiledContent.create(pkg,
60: new java.util.jar.JarFile(jar));
61: } catch (IOException e) {
62: return null;
63: }
64: }
65:
66: return null;
67: }
68: }
|