01: /*
02: * @(#)init.java 1.5 05/06/28
03: *
04: * Copyright (c) 2001-2004 Sun Microsystems, Inc. All Rights Reserved.
05: *
06: * See the file "LICENSE.txt" for information on usage and redistribution
07: * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
08: */
09: package pnuts.util;
10:
11: import pnuts.lang.Context;
12: import pnuts.ext.ModuleBase;
13:
14: /**
15: * Initialization of the pnuts.util module
16: */
17: public class init extends ModuleBase {
18:
19: static String[] javaFunctions = { "nonPublicMemberAccess",
20: "publicMemberAccess", "versionInfo", "rangeEnum",
21: "loopEnum", "getProperty", "loadProperties",
22: "saveProperties", "setProperty", };
23:
24: static String[] files = { "pnuts/util/file", "pnuts/util/ls",
25: "pnuts/util/class", "pnuts/util/shellUtil",
26: "pnuts/util/zip", "pnuts/util/system",
27: "pnuts/util/manifest", "pnuts/util/property",
28: "pnuts/util/pack200" };
29:
30: static String[][] functions = {
31: { // pnuts/util/file
32: "exists", "isDirectory", "canRead", "canWrite", "pwd",
33: "chdir", "delete", "mkdir", "renameTo",
34: "walkDirectory", "cat", "createTempFile", "copy" },
35: { // pnuts/util/ls
36: "ls" }, { // pnuts/util/class
37: "dumpclass", "supertypes" }, { // pnuts/util/shellUtil
38: "shellExpand" }, { // pnuts/util/zip
39: "readZip", "readZipEntries", "openZip", "writeZip",
40: "writeZipEntries", "updateZip", "mergeZip",
41: "extractZip" }, { // pnuts/util/system
42: "system" }, { // pnuts/util/manifest
43: "manifest" },
44: // pnuts/util/property
45: { "loadProperty" // for backward compatibility
46: },
47: // pnuts/util/pack200
48: { "pack200", "unpack200" } };
49:
50: static String[] requiredModules = { "pnuts.lib", "pnuts.io",
51: "pnuts.multithread", "pnuts.regex" };
52:
53: protected String[] getRequiredModules() {
54: return requiredModules;
55: }
56:
57: protected String getPrefix() {
58: return "org";
59: }
60:
61: public Object execute(Context context) {
62: for (int i = 0; i < javaFunctions.length; i++) {
63: autoloadFunction(javaFunctions[i], context);
64: }
65:
66: for (int i = 0; i < files.length; i++) {
67: autoload(functions[i], files[i], context);
68: }
69: return null;
70: }
71: }
|