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: * LastFunction external method class.
25: *
26: * @version $Revision: 1.7 $
27: */
28: class LastFunction implements Function {
29:
30: /**
31: * Get the name of the function.
32: * @return The function name
33: */
34: public String getName() {
35: return "last";
36: }
37:
38: /**
39: * return the number of items in the Sequence
40: * @param args The sequence
41: * @return The number of items in sequence
42: */
43: public Object apply(List<Object> args) {
44: Integer res = new Integer(((Engine.Sequence) args.get(0))
45: .size());
46: return res;
47: }
48: }
|