当前位置: 首页>>代码示例>>Java>>正文


Java Clojure.read方法代码示例

本文整理汇总了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);
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:13,代码来源:IcepickProcessor.java

示例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);
}
 
开发者ID:alda-lang,项目名称:alda-client-java,代码行数:8,代码来源:Util.java

示例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;
    }
}
 
开发者ID:Jongla,项目名称:braque,代码行数:57,代码来源:ClojureHelper.java


注:本文中的clojure.java.api.Clojure.read方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。