org.rhq.enterprise.client
Class InteractiveJavascriptCompletor
java.lang.Object
org.rhq.enterprise.client.InteractiveJavascriptCompletor
- All Implemented Interfaces:
- jline.Completor
public class InteractiveJavascriptCompletor
- extends Object
- implements jline.Completor
A Contextual JavaScript interactive completor. Not perfect, but
handles a fair number of cases.
- Author:
- Greg Hinkle
|
Method Summary |
int |
complete(String s,
int i,
List list)
|
int |
completeParameters(Object baseObject,
String params,
int i,
List<String> list,
Method method)
Split apart the parameters to a method call and complete the last parameter. |
int |
contextComplete(Object baseObject,
String s,
int i,
List<String> list)
Base Object can be an object where we're looking for methods on it, or an
interface. |
ScriptContext |
getContext()
|
void |
setContext(ScriptContext context)
|
void |
setServices(Map<String,Object> services)
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
InteractiveJavascriptCompletor
public InteractiveJavascriptCompletor(jline.ConsoleReader reader)
setServices
public void setServices(Map<String,Object> services)
complete
public int complete(String s,
int i,
List list)
- Specified by:
complete in interface jline.Completor
contextComplete
public int contextComplete(Object baseObject,
String s,
int i,
List<String> list)
- Base Object can be an object where we're looking for methods on it, or an
interface. This recursively works off the completions left to right.
Objects can be completed with fields or method calls.
method parameters are completed with type matching
method result chainings are completed based on declared return types
e.g. have a Resource in context as myResource. Original string is
"myResource.name". This method would be called with a baseObject ==
to myResource and the string "name".
Note: this method will not and should not execute methods, but will
read field properties to continue chained completions.
- Parameters:
baseObject - the context object or class to complete froms - the relative command string to checki - list -
- Returns:
- location of relative completion
completeParameters
public int completeParameters(Object baseObject,
String params,
int i,
List<String> list,
Method method)
- Split apart the parameters to a method call and complete the last parameter. If the last
paramater has a valid value close that field with a "," for the next param or a ")" if is
the last parameter. Does all machting according to the type of the parameters of the
supplied method.
- Parameters:
baseObject - params - i - list - method -
- Returns:
getContext
public ScriptContext getContext()
setContext
public void setContext(ScriptContext context)
Copyright © 2008-2012 Red Hat, Inc.. All Rights Reserved.