01: /*
02: * @(#)getLocale.java 1.2 04/12/06
03: *
04: * Copyright (c) 1997-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.lib;
10:
11: import pnuts.lang.Context;
12: import pnuts.lang.PnutsFunction;
13: import java.util.Locale;
14: import java.util.StringTokenizer;
15:
16: public class getLocale extends PnutsFunction {
17:
18: public getLocale() {
19: super ("getLocale");
20: }
21:
22: public boolean defined(int nargs) {
23: return nargs == 0 || nargs == 1;
24: }
25:
26: protected Object exec(Object[] args, Context context) {
27: int nargs = args.length;
28: if (nargs == 0) {
29: return locale.getLocale(context);
30: } else if (nargs == 1) {
31: return locale.toLocale(args[0]);
32: } else {
33: undefined(args, context);
34: return null;
35: }
36: }
37:
38: public String toString() {
39: return "function getLocale( { loc } )";
40: }
41: }
|