Package ganymede.notebook
Class NotebookContext
- java.lang.Object
-
- ganymede.notebook.NotebookContext
-
public class NotebookContext extends Object
- Author:
- Allen D. Ball
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classNotebookContext.SQLSQL-specific context.
-
Field Summary
Fields Modifier and Type Field Description List<String>classpathListofclasspathentries.ScriptContextcontextCommonScriptContextsupplied toMagic.execute(String,String,JsonNode).List<String>importsListof accumulatedimports.KernelkernelKernelmodel.static StringNAMEThe name ("$$") theNotebookContextinstance is bound to in theJShellinstance.SessionsessionSessionmodel.NotebookContext.SQLsqlSQL-specific context.Map<String,String>types
-
Constructor Summary
Constructors Constructor Description NotebookContext()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description JsonNodeasJson(Object object)StringasYaml(Object object)NotebookFunctionto convert anObjectto YAML representation.static Stringbootstrap()Method to generate the bootstrap code for a newJShellinstance.voiddisplay(Object object)NotebookFunctionto display from a Notebook cell.ClassLoadergetClassLoader()Method to get thecontextClassLoader.static Method[]getNotebookFunctions()Method to get theNotebookContextMethods annotated withNotebookFunctionthat should be linked into theNotebookenvironment.static Set<String>imports(JShell jshell)Static method to get the current imports.voidinvoke(String name)static voidinvoke(JShell jshell, String name)MagicMapmagics()Provide access to theNotebookContextMagicMap.static voidpostExecute(JShell jshell)Static method used by theShellREPL to update theNotebookContextafter execution.static voidpreExecute(JShell jshell)Static method used by theShellREPL to update theNotebookContextinstance before execution.voidprint(Object object)NotebookFunctionto print from a Notebook cell.voidrefresh()Method to update notebook context.static Stringunescape(String literal)Method to unescape a Java-escaped string literal.static Map<String,String>variables(JShell jshell)Static method to get the currentMapof defined variables to their type definitions.
-
-
-
Field Detail
-
NAME
public static final String NAME
The name ("$$") theNotebookContextinstance is bound to in theJShellinstance.- See Also:
- Constant Field Values
-
context
public final ScriptContext context
CommonScriptContextsupplied toMagic.execute(String,String,JsonNode).
-
sql
public final NotebookContext.SQL sql
-
-
Constructor Detail
-
NotebookContext
public NotebookContext()
-
-
Method Detail
-
getClassLoader
public ClassLoader getClassLoader()
Method to get thecontextClassLoader.- Returns:
- The
NotebookContextClassLoader.
-
magics
public MagicMap magics()
Provide access to theNotebookContextMagicMap.- Returns:
- The
MagicMap.
-
display
@NotebookFunction public void display(Object object)
NotebookFunctionto display from a Notebook cell.- Parameters:
object- TheObjectto display.
-
print
@NotebookFunction public void print(Object object)
NotebookFunctionto print from a Notebook cell.- Parameters:
object- TheObjectto print.
-
asJson
@NotebookFunction public JsonNode asJson(Object object)
-
asYaml
@NotebookFunction public String asYaml(Object object)
NotebookFunctionto convert anObjectto YAML representation.
-
bootstrap
public static String bootstrap()
Method to generate the bootstrap code for a newJShellinstance.- Returns:
- The boostrap code.
-
getNotebookFunctions
public static Method[] getNotebookFunctions()
Method to get theNotebookContextMethods annotated withNotebookFunctionthat should be linked into theNotebookenvironment.- Returns:
- The array of
Methods.
-
variables
public static Map<String,String> variables(JShell jshell)
Static method to get the currentMapof defined variables to their type definitions.
-
preExecute
public static void preExecute(JShell jshell)
Static method used by theShellREPL to update theNotebookContextinstance before execution.- Parameters:
jshell- TheJShell.
-
postExecute
public static void postExecute(JShell jshell)
Static method used by theShellREPL to update theNotebookContextafter execution.- Parameters:
jshell- TheJShell.
-
invoke
public static void invoke(JShell jshell, String name)
- Parameters:
jshell- TheJShell.name- The magic name.
-
-