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


Java IO类代码示例

本文整理汇总了Java中org.codehaus.groovy.tools.shell.IO的典型用法代码示例。如果您正苦于以下问题:Java IO类的具体用法?Java IO怎么用?Java IO使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


IO类属于org.codehaus.groovy.tools.shell包,在下文中一共展示了IO类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: shouldPluginSugar

import org.codehaus.groovy.tools.shell.IO; //导入依赖的package包/类
@Test
public void shouldPluginSugar() throws Exception {
    MetaRegistryUtil.clearRegistry(new HashSet<>(Arrays.asList(TinkerGraph.class)));

    final SugarGremlinPlugin plugin = new SugarGremlinPlugin();

    final Groovysh groovysh = new Groovysh();

    final Map<String, Object> env = new HashMap<>();
    env.put("ConsolePluginAcceptor.io", new IO());
    env.put("ConsolePluginAcceptor.shell", groovysh);

    final SpyPluginAcceptor spy = new SpyPluginAcceptor(groovysh::execute, () -> env);
    plugin.pluginTo(spy);

    groovysh.getInterp().getContext().setProperty("g", TinkerFactory.createClassic());
    assertEquals(6l, ((GraphTraversal) groovysh.execute("g.traversal().V()")).count().next());
    assertEquals(6l, ((GraphTraversal) groovysh.execute("g.traversal().V")).count().next());
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:20,代码来源:SugarGremlinPluginTest.java

示例2: shouldPluginUtilities

import org.codehaus.groovy.tools.shell.IO; //导入依赖的package包/类
@Test
public void shouldPluginUtilities() throws Exception {
    final UtilitiesGremlinPlugin plugin = new UtilitiesGremlinPlugin();

    final Groovysh groovysh = new Groovysh();
    groovysh.getInterp().getContext().setProperty("g", TinkerFactory.createClassic());

    final Map<String, Object> env = new HashMap<>();
    env.put("ConsolePluginAcceptor.io", new IO());
    env.put("ConsolePluginAcceptor.shell", groovysh);

    final SpyPluginAcceptor spy = new SpyPluginAcceptor(groovysh::execute, () -> env);
    plugin.pluginTo(spy);

    assertThat(groovysh.execute("describeGraph(org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph)").toString(), containsString("IMPLEMENTATION - org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph"));
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:17,代码来源:UtilitiesGremlinPluginTest.java

示例3: pluginTo

import org.codehaus.groovy.tools.shell.IO; //导入依赖的package包/类
/**
 * {@inheritDoc}
 * <p/>
 * Provides a base implementation for plugins by grabbing the console environment variables and assigning them
 * to the {@link #io} and {@link #shell} member variables.
 *
 * @throws IllegalEnvironmentException if {@link #requireConsoleEnvironment} is set to true and if either
 *                                     the {@link #io} and {@link #shell} member variables are null.
 */
@Override
public void pluginTo(final PluginAcceptor pluginAcceptor) throws IllegalEnvironmentException, PluginInitializationException {
    final Map<String, Object> environment = pluginAcceptor.environment();
    io = (IO) environment.get(ENV_CONSOLE_IO);
    shell = (Groovysh) environment.get(ENV_CONSOLE_SHELL);

    if (requireConsoleEnvironment && (null == io || null == shell))
        throw new IllegalEnvironmentException(this, ENV_CONSOLE_SHELL, ENV_CONSOLE_IO);

    try {
        afterPluginTo(pluginAcceptor);
    } catch (PluginInitializationException pie) {
        throw pie;
    } catch (Exception ex) {
        throw new PluginInitializationException(ex);
    }
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:27,代码来源:AbstractGremlinPlugin.java

示例4: preferenceChange

import org.codehaus.groovy.tools.shell.IO; //导入依赖的package包/类
public void preferenceChange(final PreferenceChangeEvent event) {
    if (event.getKey().equals(VERBOSITY_KEY)) {
        String name = event.getNewValue();

        if (name == null) {
            name = IO.Verbosity.INFO.name;
        }

        try {
            verbosity = IO.Verbosity.forName(name);
        }
        catch (Exception e) {
            event.getNode().put(event.getKey(), verbosity.name);
        }
    }
}
 
开发者ID:apache,项目名称:groovy,代码行数:17,代码来源:Preferences.java

示例5: GroovyInterpreter

import org.codehaus.groovy.tools.shell.IO; //导入依赖的package包/类
public GroovyInterpreter(Binding binding) throws IOException {
	this.binding = binding;
	if (this.binding == null)
		this.binding = new Binding();

	is = new PipedInputStream();
	os = new PipedOutputStream();
	pis = new PipedInputStream(os);
	pos = new PipedOutputStream(is);

	System.setProperty(TerminalFactory.JLINE_TERMINAL, "none");
	AnsiConsole.systemInstall();
	Ansi.setDetector(new AnsiDetector());

	binding.setProperty("out", new ImmediateFlushingPrintWriter(pos));

	shell = new Groovysh(binding, new IO(pis, pos, pos));
	// {
	// @Override
	// public void displayWelcomeBanner(InteractiveShellRunner runner) {
	// // do nothing
	// }
	// };
	shell.getIo().setVerbosity(Verbosity.QUIET);
}
 
开发者ID:jonhare,项目名称:COMP6237,代码行数:26,代码来源:GroovyInterpreter.java

示例6: initializeShellWithScript

import org.codehaus.groovy.tools.shell.IO; //导入依赖的package包/类
private void initializeShellWithScript(final IO io, final String initScriptFile, final Groovysh groovy) {
    if (initScriptFile != null) {
        String line = "";
        try {
            final BufferedReader reader = new BufferedReader(new InputStreamReader(
                    new FileInputStream(initScriptFile), Charset.forName("UTF-8")));
            while ((line = reader.readLine()) != null) {
                groovy.execute(line);
            }

            reader.close();
        } catch (FileNotFoundException fnfe) {
            io.err.println(String.format("Gremlin initialization file not found at [%s].", initScriptFile));
            System.exit(1);
        } catch (IOException ioe) {
            io.err.println(String.format("Bad line in Gremlin initialization file at [%s].", line));
            System.exit(1);
        }
    }
}
 
开发者ID:graben1437,项目名称:titan0.5.4-hbase1.1.1-custom,代码行数:21,代码来源:Console.java

示例7: GremlinSession

import org.codehaus.groovy.tools.shell.IO; //导入依赖的package包/类
public GremlinSession(Database database) {
    this.database = database;
    PrintStream out = new PrintStream(new BufferedOutputStream(baos));

    io = new IO(System.in, out, out);

    Map<String, Object> bindings = new HashMap<String, Object>();
    bindings.put("g", getGremlinWrappedGraph());
    bindings.put("out", out);

    initialBindings = new ArrayList<String>(bindings.keySet());

    try {
        scriptEngine = new GremlinWebConsole(new Binding(bindings), io);
    } catch (final Exception failure) {
        scriptEngine = new GremlinWebConsole() {
            @Override
            public void execute(String script) {
                io.out.println("Could not start Groovy during Gremlin initialization, reason:");
                failure.printStackTrace(io.out);
            }
        };
    }
}
 
开发者ID:neo4j-contrib,项目名称:gremlin-plugin,代码行数:25,代码来源:GremlinSession.java

示例8: shouldConstructRemoteAcceptorWhenInConsoleEnvironment

import org.codehaus.groovy.tools.shell.IO; //导入依赖的package包/类
@Test
public void shouldConstructRemoteAcceptorWhenInConsoleEnvironment() throws Exception {
    final DriverGremlinPlugin plugin = new DriverGremlinPlugin();
    final Map<String, Object> env = new HashMap<>();
    env.put("ConsolePluginAcceptor.io", new IO());
    env.put("ConsolePluginAcceptor.shell", new Groovysh());
    final SpyPluginAcceptor spy = new SpyPluginAcceptor(() -> env);
    plugin.pluginTo(spy);

    assertThat(plugin.remoteAcceptor().isPresent(), is(true));
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:12,代码来源:DriverGremlinPluginTest.java

示例9: pluginTo

import org.codehaus.groovy.tools.shell.IO; //导入依赖的package包/类
@Override
public void pluginTo(final PluginAcceptor pluginAcceptor) {
	pluginAcceptor.addImports(IMPORTS);
	final Groovysh groovy = (Groovysh) pluginAcceptor.environment().get("ConsolePluginAcceptor.shell");
	final IO io = (IO) pluginAcceptor.environment().get("ConsolePluginAcceptor.io");      
	groovy.register(new Bio4jCommand(groovy, io));
}
 
开发者ID:bio4j,项目名称:exporter,代码行数:8,代码来源:Bio4jGremlinPlugin.java

示例10: exportGraphson

import org.codehaus.groovy.tools.shell.IO; //导入依赖的package包/类
public static void exportGraphson(Groovysh shell, IO io, String query, String path) throws IOException {
	// prepare to export
	path = resolvePath(path, DEFAULT_JSON_NAME);
	File file = new File(path);
	FileOutputStream f = new FileOutputStream(file);
	GraphSONWriter w = GraphSONWriter.build().create();
	
	// execute the given query
	shell.execute("t = " + query + ";null");
	Traversal<?, Vertex> traversal = (Traversal<?, Vertex>) shell.getInterp().getContext().getProperty("t");
	
	// try exporting
	try {
		w.writeVertices(f, traversal);
	} catch (ClassCastException e){
		shell.execute("t = " + query + ";null");
		Traversal<?, Edge> edgeTraversal = (Traversal<?, Edge>) shell.getInterp().getContext().getProperty("t");
		while (edgeTraversal.hasNext()){
			Edge edge = edgeTraversal.next();
			w.writeEdge(f, edge);
		}
		
	}
	// done
	f.close();
	io.out.println("==> exported to " + path);				
}
 
开发者ID:bio4j,项目名称:exporter,代码行数:28,代码来源:ExporterCore.java

示例11: exportGraphml

import org.codehaus.groovy.tools.shell.IO; //导入依赖的package包/类
public static void exportGraphml(Groovysh shell, IO io, String graphName, String path) throws IOException {
	// prepare to export
	path = resolvePath(path, DEFAULT_XML_NAME);
	File file = new File(path);
	FileOutputStream f = new FileOutputStream(file);
	GraphMLWriter w = GraphMLWriter.build().create();
	
	// get the graph and export it to file
	Graph graph = (Graph) shell.getInterp().getContext().getProperty(graphName);		
	w.writeGraph(f, graph);
	
	// done
	f.close();
	io.out.println("==> exported to " + path);			
}
 
开发者ID:bio4j,项目名称:exporter,代码行数:16,代码来源:ExporterCore.java

示例12: runGroovy

import org.codehaus.groovy.tools.shell.IO; //导入依赖的package包/类
protected void runGroovy() {
    try {
        LOGGER.info("Running groovy shell");
        IO io = new IO(in, out, err);

        LOGGER.info("in: {} out: {}  err: {}", in, out, err);

        // TODO: fix to allow other bindings.
        Binding binding = new Binding();
        binding.setVariable("out", io.out);

        Groovysh groovysh = new Groovysh(binding, io);
        InteractiveShellRunner isr = new InteractiveShellRunner(groovysh, new GroovyPrompt(this));

        isr.setErrorHandler(new OutputStreamErrorHandler(this, err));

        try {
            // groovysh.run((String) null);
            isr.run();
        } catch (Exception e) {
            try (PrintStream ps = new PrintStream(out)) {
                e.printStackTrace(ps);
            }
            this.alive = false;
        }
    } finally {
        this.alive = false;
        destroy();
        callback.onExit(exitValue());
    }
}
 
开发者ID:yahoo,项目名称:artifactory_ssh_proxy,代码行数:32,代码来源:GroovyShellWrapper.java

示例13: before

import org.codehaus.groovy.tools.shell.IO; //导入依赖的package包/类
@Before
public void before() {
    io = mock(IO.class);
    mBean = mock(GroovyMBean.class);

    groovysh = new Groovysh(io);

    jmxCommand = new JmxCommand(groovysh) {
        @Override
        GroovyMBean getMBean(String beanName) {
            return mBean;
        }
    };
}
 
开发者ID:barnyard,项目名称:pi,代码行数:15,代码来源:JmxCommandTest.java

示例14: setIo

import org.codehaus.groovy.tools.shell.IO; //导入依赖的package包/类
public static void setIo(IO ioObject) {
  io = ioObject;
}
 
开发者ID:vybs,项目名称:sqoop-on-spark,代码行数:4,代码来源:ShellEnvironment.java

示例15: getIo

import org.codehaus.groovy.tools.shell.IO; //导入依赖的package包/类
public static IO getIo() {
  return io;
}
 
开发者ID:vybs,项目名称:sqoop-on-spark,代码行数:4,代码来源:ShellEnvironment.java


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