本文整理汇总了Java中clojure.java.api.Clojure.read方法的典型用法代码示例。如果您正苦于以下问题:Java Clojure.read方法的具体用法?Java Clojure.read怎么用?Java Clojure.read使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类clojure.java.api.Clojure
的用法示例。
在下文中一共展示了Clojure.read方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadClojureFn
import clojure.java.api.Clojure; //导入方法依赖的package包/类
private static void loadClojureFn() {
ClassLoader previous = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(IcepickProcessor.class.getClassLoader());
try {
Object ns = Clojure.read("icepick.processor");
IFn require = Clojure.var("clojure.core", "require");
require.invoke(ns);
PROCESS = Clojure.var("icepick.processor", "process");
} finally {
Thread.currentThread().setContextClassLoader(previous);
}
}
示例2: callClojureFn
import clojure.java.api.Clojure; //导入方法依赖的package包/类
public static void callClojureFn(String fn, Object... args) {
Symbol var = (Symbol)Clojure.read(fn);
IFn require = Clojure.var("clojure.core", "require");
require.invoke(Symbol.create(var.getNamespace()));
ISeq argsSeq = ArraySeq.create(args);
Clojure.var(var.getNamespace(), var.getName()).applyTo(argsSeq);
}
示例3: inject
import clojure.java.api.Clojure; //导入方法依赖的package包/类
List<String> inject(TypeElement typeElement, List<String> previousAnnotations) {
if (typeElement == null) {
return new ArrayList<>();
}
AnnotationMirror clojureAnnotation = getClojureAnnotation(typeElement);
if (clojureAnnotation == null) {
return new ArrayList<>();
}
List<String> out = new ArrayList<>();
ClassLoader previousLoader = Thread.currentThread().getContextClassLoader();
List<String> hierarchyStrings = new ArrayList<>();
Thread.currentThread().setContextClassLoader(BraqueAnnotationProcessor.class.getClassLoader());
try {
String clojure = getAnnotationMirrorValueAsString(clojureAnnotation);
Object place = Clojure.read("'" + placeToString(mPlace));
String name = mName;
String klass = mKlass;
List<TypeElement> hierarchyTypes = getClassHierarchy(mTypeTree);
for (TypeElement stage : hierarchyTypes) {
hierarchyStrings.add("\"" + stage.getQualifiedName().toString() + "\"");
}
Object klasshierarchy = Clojure.read("(list " + StringUtils.join(hierarchyStrings, " ") + ")");
String iface = mIface;
String type = mType;
Object many = Clojure.read("'" + PropertyManynessUtils.toString(mPropertyManyness).toLowerCase());
String path = mPath;
List<String> previousAnnotationsQuoted = new ArrayList<>();
for (String prev : previousAnnotations) {
previousAnnotationsQuoted.add("\"" + prev + "\"");
}
Object previous = Clojure.read("'(" + StringUtils.join(previousAnnotationsQuoted, " ") + ")");
Object objdef = Clojure.read("{:current " + makeObjDef(mDeclarationsPropertyToTypeMap) + " :super " + makeObjDef(mSuperPropertyToTypeMap) + "}");
String clojureFn = "(ns braque) (defn " + mRandom.next()
+ " [place name klass klasshierarchy iface type many path previous objdef] " + clojure + ")";
Compiler.load(new StringReader(clojureFn));
Var bar = RT.var("braque", mRandom.current());
Object result = bar.invoke(place, name, klass, klasshierarchy, iface, type, many, path, previous, objdef);
if (result != null && result instanceof ISeq) {
do {
Object first = ((ISeq) result).first();
if (first != null && first instanceof String) {
out.add((String) first);
}
result = ((ISeq) result).next();
} while (result != null);
}
} finally {
Thread.currentThread().setContextClassLoader(previousLoader);
return out;
}
}