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


Java GroovyShell.setProperty方法代码示例

本文整理汇总了Java中groovy.lang.GroovyShell.setProperty方法的典型用法代码示例。如果您正苦于以下问题:Java GroovyShell.setProperty方法的具体用法?Java GroovyShell.setProperty怎么用?Java GroovyShell.setProperty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在groovy.lang.GroovyShell的用法示例。


在下文中一共展示了GroovyShell.setProperty方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: run

import groovy.lang.GroovyShell; //导入方法依赖的package包/类
/**
 * Standalone execution for Designer and Gradle.
 */
public void run() {
    startExecution();

    CompilerConfiguration compilerConfig = new CompilerConfiguration(System.getProperties());
    compilerConfig.setScriptBaseClass(TestCaseScript.class.getName());
    Binding binding = new Binding();
    binding.setVariable("testCaseRun", this);

    ClassLoader classLoader = this.getClass().getClassLoader();
    GroovyShell shell = new GroovyShell(classLoader, binding, compilerConfig);
    shell.setProperty("out", getLog());
    setupContextClassLoader(shell);
    try {
        shell.run(new GroovyCodeSource(getTestCase().file()), new String[0]);
        finishExecution(null);
    }
    catch (IOException ex) {
        throw new RuntimeException(ex.getMessage(), ex);
    }
}
 
开发者ID:CenturyLinkCloud,项目名称:mdw,代码行数:24,代码来源:StandaloneTestCaseRun.java

示例2: testInvokeRawMethod

import groovy.lang.GroovyShell; //导入方法依赖的package包/类
@Test
public void testInvokeRawMethod() throws Exception {
  ListMethods itf = list -> {
    JsonObject combined = new JsonObject();
    list.forEach(combined::mergeIn);
    return combined;
  };
  CompilerConfiguration config = new CompilerConfiguration();
  Properties props = new Properties();
  props.setProperty("groovy.disabled.global.ast.transformations", "io.vertx.lang.groovy.VertxTransformation");
  config.configure(props);
  GroovyShell shell = new GroovyShell(config);
  shell.setProperty("itf", itf);
  Object o = shell.evaluate("return itf.jsonList([new io.vertx.core.json.JsonObject().put('foo', 'foo_value'), new io.vertx.core.json.JsonObject().put('bar', 'bar_value')])");
  JsonObject result = (JsonObject) o;
  assertEquals(result, new JsonObject().put("foo", "foo_value").put("bar", "bar_value"));
}
 
开发者ID:vert-x3,项目名称:vertx-lang-groovy,代码行数:18,代码来源:IntegrationTest.java

示例3: getShell

import groovy.lang.GroovyShell; //导入方法依赖的package包/类
private GroovyShell getShell(MessageReceivedEvent event) {
    GroovyShell shell = groovyService.createShell();
    shell.setProperty("message", event.getMessage());
    shell.setProperty("channel", event.getChannel());
    shell.setProperty("guild", event.getGuild());
    shell.setProperty("member", event.getMember());
    shell.setProperty("author", event.getAuthor());
    return shell;
}
 
开发者ID:GoldRenard,项目名称:JuniperBotJ,代码行数:10,代码来源:GroovyCommand.java

示例4: compile

import groovy.lang.GroovyShell; //导入方法依赖的package包/类
private void compile(String code) {

        clearLog();

        try {

            CompilerConfiguration cc = new CompilerConfiguration();

            cc.addCompilationCustomizers(
                    new ImportCustomizer().
                    addStarImports("eu.mihosoft.pow.client",
                            "eu.mihosoft.pow.net.api",
                            "eu.mihosoft.pow.lab"));

            GroovyShell shell = new GroovyShell(getClass().getClassLoader(),
                    new Binding(), cc);

            shell.setProperty("advancedApi", Main.getPOWRemoteAPI());
            shell.setProperty("api", POWApi.newApi());

            Script script = shell.parse(code);

            Thread t = new Thread(() -> {
                Object obj = script.run();
            });
            t.start();

        } catch (Throwable ex) {
            ex.printStackTrace(System.err);
        }
    }
 
开发者ID:miho,项目名称:PiOnWheels,代码行数:32,代码来源:InteractionScreenController.java

示例5: createknowledgeBase

import groovy.lang.GroovyShell; //导入方法依赖的package包/类
public void createknowledgeBase(String arabicKnowledgeBase) {
	//initialisation
	arabicKnowledgeBase = arabicKnowledgeBase.replaceAll("،", ",");
	lexemes.clear();
	lexemes	= Lexer.getLexemes(arabicKnowledgeBase);
	cuts.initialize();
	getConstants(lexemes);
	getVariables(lexemes);
	 
	FromGui.insert(PrincipalWindow.interpreter, "/>  ", Color.BLACK);
			
	//construct RuleSet
	String code = "";
		try {
			ANTLRInputStream input = new ANTLRInputStream( arabicKnowledgeBase );
			ArabicPrologLexer lexer = new ArabicPrologLexer(input);
			CommonTokenStream tokens = new CommonTokenStream(lexer);
			ArabicPrologParser parser = new ArabicPrologParser(tokens);
			ParseTree tree = parser.ruleSet();
			// showTree(parser,tree);
			// Walk it and attach our listener
		    ParseTreeWalker walker = new ParseTreeWalker();
	        ArabicPrologBaseListener listener = new ArabicPrologBaseListener();
			walker.DEFAULT.walk(listener, tree);
			code = ArabicPrologBaseListener.code.replaceAll(",\\)", "\\)")+";";
			code  = code.replaceAll(",;", ";");
			//System.out.println(code);
			}
			catch (Exception e){e.printStackTrace();}
				
			//convert String to java code with groovy
			Binding binding = new Binding();
			GroovyShell shell = new GroovyShell(binding);
			shell.setProperty("constants", constants);
			shell.setProperty("variables", variables);
			shell.setProperty("cuts", cuts);
			shell.setProperty("id", id);
			//System.out.println(constants);
			//System.out.println(variables);
			Object value = shell.evaluate(
					  "import unification_solver.*	;"
					+ "import front_end.Converter 	;"
					+ "RuleSet a = "+code+" return a;");
			ruleSet = (RuleSet) value;	
}
 
开发者ID:BlidiWajdi,项目名称:Mujeed-Arabic-Prolog,代码行数:46,代码来源:Parser.java

示例6: getQueryToSolve

import groovy.lang.GroovyShell; //导入方法依赖的package包/类
public static Object getQueryToSolve(String userQuery) {
	userQuery = userQuery.replaceAll("،", ",");
	lexemes.clear();
	lexemes = Lexer.getLexemes(userQuery);
	getConstants(lexemes);
	getVariables(lexemes);
	cuts.initialize();

	query = userQuery;
	String code = "";
	try {
	userQuery = userQuery.replaceAll("،", ",");
	ANTLRInputStream input = new ANTLRInputStream( userQuery );
	ArabicPrologLexer lexer = new ArabicPrologLexer(input);
	CommonTokenStream tokens = new CommonTokenStream(lexer);
	ArabicPrologParser parser = new ArabicPrologParser(tokens);
	ParseTree tree = parser.query();
	//showTree(parser, tree);
	// Walk it and attach our listener
       ParseTreeWalker walker = new ParseTreeWalker();
       ArabicPrologBaseListener listener = new ArabicPrologBaseListener();
   
	walker.DEFAULT.walk(listener, tree);
	code = ArabicPrologBaseListener.code.replaceAll(",\\)", "\\)")+";";
	code  = code.replaceAll(",;", ";");
	//System.out.println(code);
	}
	catch (Exception e){e.printStackTrace();}
	
	//convert String to java code with groovy
	Binding binding = new Binding();
	GroovyShell shell = new GroovyShell(binding);
	shell.setProperty("constants", constants);
	shell.setProperty("variables", variables);
	shell.setProperty("cuts", cuts);
	shell.setProperty("id", id);
	Object value = shell.evaluate(
			  "import unification_solver.*	;"
			+ "import front_end.Converter 	;"
			+ "Object a = "+code+" return a;");
	Object a = value;
	return a;
}
 
开发者ID:BlidiWajdi,项目名称:Mujeed-Arabic-Prolog,代码行数:44,代码来源:Parser.java


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