View Javadoc
1   /**
2    * Copyright 2014 Internet2
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *   http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  /*
17   * Copyright (C) 2006-2007 blair christensen.
18   * All Rights Reserved.
19   *
20   * You may use and distribute under the same terms as Grouper itself.
21   */
22  
23  package edu.internet2.middleware.grouper.app.gsh;
24  import bsh.CallStack;
25  import bsh.Interpreter;
26  
27  /**
28   * Run previous {@link GrouperShell} commands.
29   * <p/>
30   * @author  blair christensen.
31   * @version $Id: last.java,v 1.2 2008-09-29 03:38:28 mchyzer Exp $
32   * @since   0.0.1
33   */
34  public class last {
35  
36    // PROTECTED CLASS CONSTANTS //
37    protected static final int LAST = -1;
38  
39  
40    // PUBLIC CLASS METHODS //
41  
42    /**
43     * Run last command.
44     * <p/>
45     * @param   i     BeanShell interpreter.
46     * @param   stack BeanShell call stack.
47     * @throws  GrouperShellException
48     * @since   0.0.1
49     */
50    public static void invoke(Interpreter i, CallStack stack) 
51      throws  GrouperShellException
52    {
53      GrouperShell.setOurCommand(i, true);
54      ShellHelper.last(i, LAST); // As -1 will be the currently eval'd
55                                 // command, -2 will get us the prior command.
56                                 // Yes, I know, this sucks.
57    } // public static void invoke(i, stack, parent, name)
58  
59    /**
60     * Run the command at position <i>idx</i>.
61     * <p/>
62     * @param   i     BeanShell interpreter.
63     * @param   stack BeanShell call stack.
64     * @param   idx   Run command <i>idx</i>.
65     * @throws  GrouperShellException
66     * @since   0.0.1
67     */
68    public static void invoke(Interpreter i, CallStack stack, int idx) 
69      throws  GrouperShellException
70    {
71      GrouperShell.setOurCommand(i, true);
72      ShellHelper.last(i, idx);
73    } // public static void invoke(i, stack, idx)
74  
75  } // public class last
76