01: /*
02: * @(#)newDocument.java 1.2 04/12/06
03: *
04: * Copyright (c) 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 org.pnuts.xml;
10:
11: import pnuts.lang.*;
12: import org.pnuts.util.*;
13: import javax.xml.parsers.*;
14:
15: public class newDocument extends PnutsFunction {
16:
17: public newDocument() {
18: super ("newDocument");
19: }
20:
21: public boolean defined(int nargs) {
22: return nargs == 0;
23: }
24:
25: protected Object exec(Object[] args, Context context) {
26: if (args.length != 0) {
27: undefined(args, context);
28: return null;
29: }
30: DocumentBuilder builder = Util
31: .getDocumentBuilder(null, context);
32: return builder.newDocument();
33: }
34:
35: public String toString() {
36: return "function newDocument()";
37: }
38: }
|