public classClojureextends java.lang.ObjectThe Clojure class provides a minimal interface to bootstrap Clojure access from other JVM languages. It provides:
IFn interface.read for reading data using Clojure's edn readerTo lookup and call a Clojure function:
IFn plus = Clojure.var("clojure.core", "+"); plus.invoke(1, 2);Functions inclojure.core are automatically loaded. Other namespaces can be loaded viarequire:
IFn require = Clojure.var("clojure.core", "require"); require.invoke(Clojure.read("clojure.set"));IFns can be passed to higher order functions, e.g. the example below passesinc tomap:
IFn map = Clojure.var("clojure.core", "map"); IFn inc = Clojure.var("clojure.core", "inc"); map.invoke(inc, Clojure.read("[1 2 3]"));| Modifier and Type | Method and Description |
|---|---|
static java.lang.Object | read(java.lang.String s)Read one object from the String s. |
staticIFn | var(java.lang.Object qualifiedName)Returns the var associated with qualifiedName. |
staticIFn | var(java.lang.Object ns, java.lang.Object name)Returns an IFn associated with the namespace and name. |
public static IFn var(java.lang.Object qualifiedName)
qualifiedName - a String or clojure.lang.Symbolpublic static IFn var(java.lang.Object ns, java.lang.Object name)
ns - a String or clojure.lang.Symbolname - a String or clojure.lang.Symbolpublic static java.lang.Object read(java.lang.String s)
s - a String