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 class
NotebookContext.SQL
SQL
-specific context.
-
Field Summary
Fields Modifier and Type Field Description List<String>
classpath
List
ofclasspath
entries.ScriptContext
context
CommonScriptContext
supplied toMagic.execute(String,String,JsonNode)
.List<String>
imports
List
of accumulatedimport
s.Kernel
kernel
Kernel
model.static String
NAME
The name ("$$") theNotebookContext
instance is bound to in theJShell
instance.Session
session
Session
model.NotebookContext.SQL
sql
SQL
-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 JsonNode
asJson(Object object)
String
asYaml(Object object)
NotebookFunction
to convert anObject
to YAML representation.static String
bootstrap()
Method to generate the bootstrap code for a newJShell
instance.void
display(Object object)
NotebookFunction
to display from a Notebook cell.ClassLoader
getClassLoader()
Method to get thecontext
ClassLoader
.static Method[]
getNotebookFunctions()
Method to get theNotebookContext
Method
s annotated withNotebookFunction
that should be linked into theNotebook
environment.static Set<String>
imports(JShell jshell)
Static method to get the current imports.void
invoke(String name)
static void
invoke(JShell jshell, String name)
MagicMap
magics()
Provide access to theNotebookContext
MagicMap
.static void
postExecute(JShell jshell)
Static method used by theShell
REPL to update theNotebookContext
after execution.static void
preExecute(JShell jshell)
Static method used by theShell
REPL to update theNotebookContext
instance before execution.void
print(Object object)
NotebookFunction
to print from a Notebook cell.void
refresh()
Method to update notebook context.static String
unescape(String literal)
Method to unescape a Java-escaped string literal.static Map<String,String>
variables(JShell jshell)
Static method to get the currentMap
of defined variables to their type definitions.
-
-
-
Field Detail
-
NAME
public static final String NAME
The name ("$$") theNotebookContext
instance is bound to in theJShell
instance.- See Also:
- Constant Field Values
-
context
public final ScriptContext context
CommonScriptContext
supplied 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 thecontext
ClassLoader
.- Returns:
- The
NotebookContext
ClassLoader
.
-
magics
public MagicMap magics()
Provide access to theNotebookContext
MagicMap
.- Returns:
- The
MagicMap
.
-
display
@NotebookFunction public void display(Object object)
NotebookFunction
to display from a Notebook cell.- Parameters:
object
- TheObject
to display.
-
print
@NotebookFunction public void print(Object object)
NotebookFunction
to print from a Notebook cell.- Parameters:
object
- TheObject
to print.
-
asJson
@NotebookFunction public JsonNode asJson(Object object)
-
asYaml
@NotebookFunction public String asYaml(Object object)
NotebookFunction
to convert anObject
to YAML representation.
-
bootstrap
public static String bootstrap()
Method to generate the bootstrap code for a newJShell
instance.- Returns:
- The boostrap code.
-
getNotebookFunctions
public static Method[] getNotebookFunctions()
Method to get theNotebookContext
Method
s annotated withNotebookFunction
that should be linked into theNotebook
environment.- Returns:
- The array of
Method
s.
-
variables
public static Map<String,String> variables(JShell jshell)
Static method to get the currentMap
of defined variables to their type definitions.
-
preExecute
public static void preExecute(JShell jshell)
Static method used by theShell
REPL to update theNotebookContext
instance before execution.- Parameters:
jshell
- TheJShell
.
-
postExecute
public static void postExecute(JShell jshell)
Static method used by theShell
REPL to update theNotebookContext
after execution.- Parameters:
jshell
- TheJShell
.
-
invoke
public static void invoke(JShell jshell, String name)
- Parameters:
jshell
- TheJShell
.name
- The magic name.
-
-