KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > osgi > framework > console > CommandInterpreter


1 /*******************************************************************************
2  * Copyright (c) 2003, 2005 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11
12 package org.eclipse.osgi.framework.console;
13
14 import java.util.Dictionary JavaDoc;
15 import org.osgi.framework.Bundle;
16
17 /**
18  * A command interpreter is a shell that can interpret command
19  * lines. This object is passed as parameter when a CommandProvider
20  * is invoked.
21  * <p>
22  * This interface is not intended to be implemented by clients.
23  * </p>
24  * @since 3.1
25  */

26 public interface CommandInterpreter {
27     /**
28      * Get the next argument in the input.
29      *
30      * E.g. if the commandline is hello world, the _hello method
31      * will get "world" as the first argument.
32      */

33     public String JavaDoc nextArgument();
34
35     /**
36      * Execute a command line as if it came from the end user
37      * and return the result.
38      *
39      * Throws any exceptions generated by the command that executed.
40      */

41     public Object JavaDoc execute(String JavaDoc cmd);
42
43     /**
44      * Prints an object to the outputstream
45      *
46      * @param o the object to be printed
47      */

48     public void print(Object JavaDoc o);
49
50     /**
51      * Prints an empty line to the outputstream
52      */

53     public void println();
54
55     /**
56      * Prints an object to the output medium (appended with newline character).
57      * <p>
58      * If running on the target environment the user is prompted with '--more'
59      * if more than the configured number of lines have been printed without user prompt.
60      * That way the user of the program has control over the scrolling.
61      * <p>
62      * For this to work properly you should not embedded "\n" etc. into the string.
63      *
64      * @param o the object to be printed
65      */

66     public void println(Object JavaDoc o);
67
68     /**
69      * Print a stack trace including nested exceptions.
70      * @param t The offending exception
71      */

72     public void printStackTrace(Throwable JavaDoc t);
73
74     /**
75      * Prints the given dictionary sorted by keys.
76      *
77      * @param dic the dictionary to print
78      * @param title the header to print above the key/value pairs
79      */

80     public void printDictionary(Dictionary JavaDoc dic, String JavaDoc title);
81
82     /**
83      * Prints the given bundle resource if it exists
84      *
85      * @param bundle the bundle containing the resource
86      * @param resource the resource to print
87      */

88     public void printBundleResource(Bundle bundle, String JavaDoc resource);
89 }
90
91
Popular Tags