01: /*
02: * @(#)init.java 1.2 04/12/06
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.nio;
10:
11: import pnuts.lang.Runtime;
12: import pnuts.lang.Package;
13: import pnuts.lang.Context;
14: import pnuts.lang.PnutsFunction;
15: import pnuts.ext.ModuleBase;
16:
17: /**
18: * Initialization of the pnuts.text module
19: */
20: public class init extends ModuleBase {
21:
22: static String[] files = { "pnuts/nio/nio", };
23:
24: static String[][] functions = { {
25: // "open",
26: // "reader",
27: // "writer",
28: // "openBuffer",
29: // "openDirectBuffer",
30: // "openChannel",
31: // "transferChannel",
32: "mapFile", "charset", "charsets" } };
33:
34: static String[] javaFunctions = { "scanLines" };
35:
36: protected String getPrefix() {
37: return "org";
38: }
39:
40: public Object execute(Context context) {
41: try {
42: Class.forName("java.nio.Buffer");
43: } catch (Exception e) {
44: return null;
45: }
46: context.clearPackages();
47: context.usePackage("pnuts.io");
48: context.usePackage("pnuts.lib");
49: context.usePackage("pnuts.text");
50:
51: for (int i = 0; i < files.length; i++) {
52: autoload(functions[i], files[i], context);
53: }
54: for (int i = 0; i < javaFunctions.length; i++) {
55: autoloadFunction(javaFunctions[i], context);
56: }
57: return null;
58: }
59: }
|