本文整理了Java中clojure.lang.Namespace.findOrCreate()
方法的一些代码示例,展示了Namespace.findOrCreate()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Namespace.findOrCreate()
方法的具体详情如下:
包路径:clojure.lang.Namespace
类名称:Namespace
方法名:findOrCreate
暂无
代码示例来源:origin: apache/nifi
@Override
public Object eval(Reader reader, ScriptContext context) throws ScriptException {
try {
// Get engine bindings and send them to Clojure
Bindings engineBindings = context.getBindings(ScriptContext.ENGINE_SCOPE);
engineBindings.entrySet().forEach((entry) -> Var.intern(Namespace.findOrCreate(NAMESPACE_SYMBOL), Symbol.create(entry.getKey().intern()), entry.getValue(), true));
Var.pushThreadBindings(
RT.map(RT.CURRENT_NS, RT.CURRENT_NS.deref(),
RT.IN, new LineNumberingPushbackReader(context.getReader()),
RT.OUT, context.getWriter(),
RT.ERR, context.getErrorWriter()));
Object result = Compiler.load(reader);
return result;
} catch (Exception e) {
throw new ScriptException(e);
} finally {
Namespace.remove(NAMESPACE_SYMBOL);
}
}
代码示例来源:origin: org.dunaj/clojure
private Object readResolve() throws ObjectStreamException {
// ensures that serialized namespaces are "deserialized" to the
// namespace in the present runtime
return findOrCreate(name);
}
}
代码示例来源:origin: videlalvaro/clochure
private Object readResolve() throws ObjectStreamException {
// ensures that serialized namespaces are "deserialized" to the
// namespace in the present runtime
return findOrCreate(name);
}
}
代码示例来源:origin: org.dunaj/clojure
public Object invoke(Object arg1) {
Symbol nsname = (Symbol) arg1;
Namespace ns = Namespace.findOrCreate(nsname);
CURRENT_NS.set(ns);
return ns;
}
};
代码示例来源:origin: videlalvaro/clochure
public Object invoke(Object arg1) {
Symbol nsname = (Symbol) arg1;
Namespace ns = Namespace.findOrCreate(nsname);
CURRENT_NS.set(ns);
return ns;
}
};
代码示例来源:origin: org.dunaj/clojure
public Object invoke(Object __form, Object __env,Object arg1) {
Symbol nsname = (Symbol) arg1;
Namespace ns = Namespace.findOrCreate(nsname);
CURRENT_NS.set(ns);
return ns;
}
};
代码示例来源:origin: org.dunaj/clojure
public static Var intern(Symbol nsName, Symbol sym){
Namespace ns = Namespace.findOrCreate(nsName);
return intern(ns, sym);
}
代码示例来源:origin: videlalvaro/clochure
public Object invoke(Object __form, Object __env,Object arg1) {
Symbol nsname = (Symbol) arg1;
Namespace ns = Namespace.findOrCreate(nsname);
CURRENT_NS.set(ns);
return ns;
}
};
代码示例来源:origin: org.dunaj/clojure
private static Namespace namespace(String s) {
return Namespace.findOrCreate(Symbol.intern(s));
}
代码示例来源:origin: org.dunaj/clojure
public Object invoke(Object arg1) {
Symbol nsname = (Symbol) arg1;
Namespace ns = Namespace.findOrCreate(nsname);
ns.addDefaultImports();
CURRENT_NS.set(ns);
return ns;
}
};
代码示例来源:origin: videlalvaro/clochure
public static Var intern(Namespace ns, Symbol sym){
return ns.intern(sym);
}
代码示例来源:origin: org.wicketstuff/console-engine
private Associative applyBindings(final Map<String, Object> bindings,
Associative mappings) {
if (bindings != null) {
final Set<Entry<String, Object>> entrySet = bindings.entrySet();
for (final Entry<String, Object> entry : entrySet) {
final Symbol symbol = Symbol.intern(entry.getKey());
final Namespace userNs = Namespace.findOrCreate(Symbol
.create("user".intern()));
final Var var = Var.intern(userNs, symbol);
mappings = mappings.assoc(var, entry.getValue());
}
}
return mappings;
}
代码示例来源:origin: org.wicketstuff/wicketstuff-console-engine
private Associative applyBindings(final Map<String, Object> bindings, Associative mappings)
{
if (bindings != null)
{
final Set<Entry<String, Object>> entrySet = bindings.entrySet();
for (final Entry<String, Object> entry : entrySet)
{
final Symbol symbol = Symbol.intern(entry.getKey());
final Namespace userNs = Namespace.findOrCreate(Symbol.create("user".intern()));
final Var var = Var.intern(userNs, symbol);
var.setDynamic(true);
mappings = mappings.assoc(var, entry.getValue());
}
}
return mappings;
}
代码示例来源:origin: io.tesla.polyglot/tesla-polyglot-clojure
public void write(Writer writer, Map<String, Object> stringObjectMap, Model model) throws IOException {
try {
final Var REQUIRE = Var.intern(RT.CLOJURE_NS, Symbol.create("require"));
final Symbol REFLECTOR = Symbol.create("org.sonatype.maven.polyglot.clojure.dsl.writer");
REQUIRE.invoke(REFLECTOR);
final Var WRITER = Var.intern(Namespace.findOrCreate(REFLECTOR), Symbol.create("write-model"));
WRITER.invoke(model, writer);
} catch (Exception e) {
e.printStackTrace();
// Don't use new IOException(e) because it doesn't exist in Java 5
throw (IOException) new IOException(e.toString()).initCause(e);
}
}
代码示例来源:origin: org.dunaj/clojure
static public Var var(String ns, String name){
return Var.intern(Namespace.findOrCreate(Symbol.intern(null, ns)), Symbol.intern(null, name));
}
代码示例来源:origin: videlalvaro/clochure
static public Var var(String ns, String name, Object init){
return Var.intern(Namespace.findOrCreate(Symbol.intern(null, ns)), Symbol.intern(null, name), init);
}
代码示例来源:origin: org.dunaj/clojure
static public Var var(String ns, String name, Object init){
return Var.intern(Namespace.findOrCreate(Symbol.intern(null, ns)), Symbol.intern(null, name), init);
}
代码示例来源:origin: org.dunaj/clojure
public static Var internPrivate(String nsName, String sym){
Namespace ns = Namespace.findOrCreate(Symbol.intern(nsName));
Var ret = intern(ns, Symbol.intern(sym));
ret.setMeta(privateMeta);
return ret;
}
代码示例来源:origin: videlalvaro/clochure
public static Var internPrivate(String nsName, String sym){
Namespace ns = Namespace.findOrCreate(Symbol.intern(nsName));
Var ret = intern(ns, Symbol.intern(sym));
ret.setMeta(privateMeta);
return ret;
}
代码示例来源:origin: org.apache.nifi/nifi-scripting-processors
@Override
public Object eval(Reader reader, ScriptContext context) throws ScriptException {
try {
// Get engine bindings and send them to Clojure
Bindings engineBindings = context.getBindings(ScriptContext.ENGINE_SCOPE);
engineBindings.entrySet().forEach((entry) -> Var.intern(Namespace.findOrCreate(NAMESPACE_SYMBOL), Symbol.create(entry.getKey().intern()), entry.getValue(), true));
Var.pushThreadBindings(
RT.map(RT.CURRENT_NS, RT.CURRENT_NS.deref(),
RT.IN, new LineNumberingPushbackReader(context.getReader()),
RT.OUT, context.getWriter(),
RT.ERR, context.getErrorWriter()));
Object result = Compiler.load(reader);
return result;
} catch (Exception e) {
throw new ScriptException(e);
} finally {
Namespace.remove(NAMESPACE_SYMBOL);
}
}
内容来源于网络,如有侵权,请联系作者删除!