01: /*
02: * @(#)init.java 1.4 05/05/25
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.io;
10:
11: import pnuts.lang.Context;
12: import pnuts.ext.ModuleBase;
13:
14: /**
15: * Initialization of the pnuts.io module
16: */
17: public class init extends ModuleBase {
18:
19: static String[] files = { "pnuts/io/stream", "pnuts/io/gzip",
20: "pnuts/io/encode" };
21:
22: static String[][] functions = {
23: // pnuts/io/stream
24: { "pipe", "stringReader", "stringWriter", "openByteArray",
25: "openCharArray", "getByteArray", "getCharArray" },
26: // pnuts/io/gzip
27: { "zcat", "gzip" },
28: // pnuts/io/encode
29: { "base64encode", "base64decode", "uuencode", "uudecode",
30: "unicodeToString", "stringToUnicode" } };
31:
32: static String[] javaFunctions = { "readBoolean", "readShort",
33: "readUnsignedByte", "readUnsignedShort", "readInt",
34: "readChar", "readLong", "readFloat", "readDouble",
35: "readUTF", "writeInt", "writeBoolean", "writeShort",
36: "writeChar", "writeLong", "writeFloat", "writeDouble",
37: "writeChars", "writeUTF", "dataInput", "dataOutput",
38: "read", "readText", "writeText", "readBytes", "writeBytes",
39: "open", "reader", "writer", "openURL",
40: "setCharacterEncoding", "getCharacterEncoding",
41: "writeObject", "readObject", "translate" };
42:
43: static String[] requiredModules = { "pnuts.lib",
44: "pnuts.multithread" };
45:
46: protected String[] getRequiredModules() {
47: return requiredModules;
48: }
49:
50: protected String getPrefix() {
51: return "org";
52: }
53:
54: public Object execute(Context context) {
55: for (int i = 0; i < files.length; i++) {
56: autoload(functions[i], files[i], context);
57: }
58: for (int i = 0; i < javaFunctions.length; i++) {
59: autoloadFunction(javaFunctions[i], context);
60: }
61: return null;
62: }
63: }
|