01: /*
02: * xtc - The eXTensible Compiler
03: * Copyright (C) 2006-2007 New York University
04: *
05: * This program is free software; you can redistribute it and/or
06: * modify it under the terms of the GNU General Public License
07: * version 2 as published by the Free Software Foundation.
08: *
09: * This program is distributed in the hope that it will be useful,
10: * but WITHOUT ANY WARRANTY; without even the implied warranty of
11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12: * GNU General Public License for more details.
13: *
14: * You should have received a copy of the GNU General Public License
15: * along with this program; if not, write to the Free Software
16: * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
17: * USA.
18: */
19: package xtc.xform;
20:
21: import java.util.List;
22:
23: /**
24: * UpperCaseFunction external method class.
25: *
26: * @version $Revision: 1.8 $
27: */
28: class UpperCaseFunction implements Function {
29:
30: /**
31: * Get the name of the function.
32: * @return The function name
33: */
34: public String getName() {
35: return "uppercase";
36: }
37:
38: /**
39: * Takes a string and converts its characters to upper case
40: * @param args The string to convert
41: * @return The uppercased string
42: */
43: public Object apply(List<Object> args) {
44: Engine.Sequence<?> arg = (Engine.Sequence<?>) args.get(0);
45: Item item = (Item) arg.get(0);
46: String val = (String) item.object;
47: Item resItem = new Item(val.toUpperCase(), null, 0);
48: Engine.Sequence<Item> result = new Engine.Sequence<Item>();
49: result.add(resItem);
50: return result;
51: }
52: }
|