Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: com/tripi/asp/AbstractFunctionNode.java


1   /**
2    * ArrowHead ASP Server 
3    * This is a source file for the ArrowHead ASP Server - an 100% Java
4    * VBScript interpreter and ASP server.
5    *
6    * For more information, see http://www.tripi.com/arrowhead
7    *
8    * Copyright (C) 2002  Terence Haddock
9    *
10   * This program is free software; you can redistribute it and/or modify
11   * it under the terms of the GNU General Public License as published by
12   * the Free Software Foundation; either version 2 of the License, or
13   * (at your option) any later version.
14   *
15   * This program is distributed in the hope that it will be useful,
16   * but WITHOUT ANY WARRANTY; without even the implied warranty of
17   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18   * GNU General Public License for more details.
19   *
20   * You should have received a copy of the GNU General Public License
21   * along with this program; if not, write to the Free Software
22   * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23   *
24   */
25  package com.tripi.asp;
26  
27  import java.util.Vector;
28  
29  /**
30   * AbstractFunctionNode contains basic code used by most Function
31   * nodes including converting a VarListNode node to a Vector of
32   * de-referenced values.
33   *
34   * @author Terence Haddock
35   * @version 0.9
36   */
37  public abstract class AbstractFunctionNode extends DefaultNode
38      implements FunctionNode
39  {
40      /**
41       * Overloaded class to handle executing functions, will convert
42       * the variable list passed in to a Vector of elements.
43       * @param varList parameter list
44       * @param context Current context.
45       * @return result of the function call
46       * @throws AspException if any error occurs.
47       * @see FunctionNode#execute(VarListNode,AspContext)
48       * @see AbstractFunctionNode#execute(Vector,AspContext)
49       */
50      public Object execute(VarListNode varList, AspContext context)
51          throws AspException
52      {
53          Vector values = (Vector)varList.execute(context);
54          for (int i = 0; i < values.size(); i++)
55          {
56              Object obj = values.get(i);
57              while (obj instanceof SimpleReference) {
58                  obj = ((SimpleReference)obj).getValue();
59              }
60              values.set(i, obj);
61          }
62          return execute(values, context);
63      }
64  
65      /**
66       * Abstract class to handle executing a function.
67       * @param values De-referenced values
68       * @param context Current context.
69       * @return result of the function call
70       * @throws AspException if any error occurs.
71       * @see FunctionNode#execute(VarListNode,AspContext)
72       * @see AbstractFunctionNode#execute(Vector,AspContext)
73       */
74      abstract public Object execute(Vector values, AspContext context)
75          throws AspException;
76  }