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


Java ResourceGroovyMethods类代码示例

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


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

示例1: parseFile

import org.codehaus.groovy.runtime.ResourceGroovyMethods; //导入依赖的package包/类
private Object parseFile(File file, String charset) {
    Reader reader = null;
    try {
        if (charset == null || charset.length() == 0) {
            reader = ResourceGroovyMethods.newReader(file);
        } else {
            reader = ResourceGroovyMethods.newReader(file, charset);
        }
        return parse(reader);
    } catch (IOException ioe) {
        throw new JsonException("Unable to process file: " + file.getPath(), ioe);
    } finally {
        if (reader != null) {
            DefaultGroovyMethodsSupport.closeWithWarning(reader);
        }
    }
}
 
开发者ID:apache,项目名称:groovy,代码行数:18,代码来源:JsonSlurperClassic.java

示例2: parseURL

import org.codehaus.groovy.runtime.ResourceGroovyMethods; //导入依赖的package包/类
private Object parseURL(URL url, Map params) {
    Reader reader = null;
    try {
        if (params == null || params.isEmpty()) {
            reader = ResourceGroovyMethods.newReader(url);
        } else {
            reader = ResourceGroovyMethods.newReader(url, params);
        }
        return parse(reader);
    } catch (IOException ioe) {
        throw new JsonException("Unable to process url: " + url.toString(), ioe);
    } finally {
        if (reader != null) {
            DefaultGroovyMethodsSupport.closeWithWarning(reader);
        }
    }
}
 
开发者ID:apache,项目名称:groovy,代码行数:18,代码来源:JsonSlurperClassic.java

示例3: parse

import org.codehaus.groovy.runtime.ResourceGroovyMethods; //导入依赖的package包/类
public Object parse(File file, String charset) {
    Reader reader = null;
    try {
        if (charset == null || charset.length() == 0) {
            reader = ResourceGroovyMethods.newReader(file);
        } else {
            reader = ResourceGroovyMethods.newReader(file, charset);
        }
        return parse(reader);
    } catch (IOException ioe) {
        throw new JsonException("Unable to process file: " + file.getPath(), ioe);
    } finally {
        if (reader != null) {
            DefaultGroovyMethodsSupport.closeWithWarning(reader);
        }
    }
}
 
开发者ID:apache,项目名称:groovy,代码行数:18,代码来源:BaseJsonParser.java

示例4: parseURL

import org.codehaus.groovy.runtime.ResourceGroovyMethods; //导入依赖的package包/类
private Object parseURL(URL url, Map params) {
    Reader reader = null;
    try {
        if (params == null || params.isEmpty()) {
            reader = ResourceGroovyMethods.newReader(url);
        } else {
            reader = ResourceGroovyMethods.newReader(url, params);
        }
        return createParser().parse(reader);
    } catch (IOException ioe) {
        throw new JsonException("Unable to process url: " + url.toString(), ioe);
    } finally {
        if (reader != null) {
            DefaultGroovyMethodsSupport.closeWithWarning(reader);
        }
    }
}
 
开发者ID:apache,项目名称:groovy,代码行数:18,代码来源:JsonSlurper.java

示例5: testCustomClassTemplate

import org.codehaus.groovy.runtime.ResourceGroovyMethods; //导入依赖的package包/类
public void testCustomClassTemplate() throws Exception {
    executeTarget("testCustomClassTemplate");

    final File testfilesPackageDir = new File(tmpDir, "org/codehaus/groovy/tools/groovydoc/testfiles");
    System.err.println("testfilesPackageDir = " + testfilesPackageDir);
    final String[] list = testfilesPackageDir.list(new FilenameFilter() {
        public boolean accept(File file, String name) {
            return name.equals("DocumentedClass.html");
        }
    });

    assertNotNull("Dir not found: " + testfilesPackageDir.getAbsolutePath(), list);
    assertEquals(1, list.length);
    File documentedClassHtmlDoc = new File(testfilesPackageDir, list[0]);

    List<String> lines = ResourceGroovyMethods.readLines(documentedClassHtmlDoc);
    assertTrue("\"<title>DocumentedClass</title>\" not in: " + lines, lines.contains("<title>DocumentedClass</title>"));
    assertTrue("\"This is a custom class template.\" not in: " + lines, lines.contains("This is a custom class template."));
}
 
开发者ID:apache,项目名称:groovy,代码行数:20,代码来源:GroovyDocTest.java

示例6: GroovyCodeSource

import org.codehaus.groovy.runtime.ResourceGroovyMethods; //导入依赖的package包/类
public GroovyCodeSource(URL url) {
    if (url == null) {
        throw new RuntimeException("Could not construct a GroovyCodeSource from a null URL");
    }
    this.url = url;
    // TODO: GROOVY-6561: GroovyMain got the name this way: script.substring(script.lastIndexOf("/") + 1)
    this.name = url.toExternalForm();
    this.codeSource = new CodeSource(url, (java.security.cert.Certificate[]) null);
    try {
        String contentEncoding = getContentEncoding(url);
        if (contentEncoding != null) {
            this.scriptText = ResourceGroovyMethods.getText(url, contentEncoding);
        } else {
            this.scriptText = ResourceGroovyMethods.getText(url); // falls-back on default encoding
        }
    } catch (IOException e) {
        throw new RuntimeException("Impossible to read the text content from " + name, e);
    }
}
 
开发者ID:apache,项目名称:groovy,代码行数:20,代码来源:GroovyCodeSource.java

示例7: testLaunchesJUnitTestSuite

import org.codehaus.groovy.runtime.ResourceGroovyMethods; //导入依赖的package包/类
public void testLaunchesJUnitTestSuite() throws Exception {
    // create a valid (empty) test suite on disk
    String testName = "GroovyShellTestJUnit3Test"+System.currentTimeMillis();
    File testSuite = new File(System.getProperty("java.io.tmpdir"), testName);
    ResourceGroovyMethods.write(testSuite, "import junit.framework.*; \r\n" +
            "public class " + testName + " extends TestSuite { \r\n" +
            "    public static Test suite() { \r\n" +
            "        return new TestSuite(); \r\n" +
            "    } \r\n" +
            "} \r\n");
    testSuite.deleteOnExit();
    
    PrintStream out = System.out;
    System.setOut( new PrintStream(new ByteArrayOutputStream()) );
    try {
        // makes this more of an integration test than a unit test...
        GroovyShell.main( new String[] { testSuite.getCanonicalPath() });
    } finally {
        System.setOut( out );
    }
}
 
开发者ID:apache,项目名称:groovy,代码行数:22,代码来源:GroovyShellTest.java

示例8: leftShift

import org.codehaus.groovy.runtime.ResourceGroovyMethods; //导入依赖的package包/类
public TestFile leftShift(Object content) {
    getParentFile().mkdirs();
    try {
        ResourceGroovyMethods.leftShift(this, content);
        return this;
    } catch (IOException e) {
        throw new RuntimeException(String.format("Could not append to test file '%s'", this), e);
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:10,代码来源:TestFile.java

示例9: setText

import org.codehaus.groovy.runtime.ResourceGroovyMethods; //导入依赖的package包/类
public TestFile setText(String content) {
    getParentFile().mkdirs();
    try {
        ResourceGroovyMethods.setText(this, content);
        return this;
    } catch (IOException e) {
        throw new RuntimeException(String.format("Could not append to test file '%s'", this), e);
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:10,代码来源:TestFile.java

示例10: setOverview

import org.codehaus.groovy.runtime.ResourceGroovyMethods; //导入依赖的package包/类
private void setOverview() {
    String path = properties.getProperty("overviewFile");
    if (path != null && path.length() > 0) {
        try {
            String content = ResourceGroovyMethods.getText(new File(path));
            calcThenSetOverviewDescription(content);
        } catch (IOException e) {
            System.err.println("Unable to load overview file: " + e.getMessage());
        }
    }
}
 
开发者ID:apache,项目名称:groovy,代码行数:12,代码来源:GroovyRootDocBuilder.java

示例11: createNewArgs

import org.codehaus.groovy.runtime.ResourceGroovyMethods; //导入依赖的package包/类
private void createNewArgs(String txt) throws IOException {
    final String[] args = cmdline.getCommandline();
    // Temporary file - delete on exit, create (assured unique name).
    final File tempFile = FileUtils.getFileUtils().createTempFile(PREFIX, SUFFIX, null, true, true);
    final String[] commandline = new String[args.length + 1];
    ResourceGroovyMethods.write(tempFile, txt);
    commandline[0] = tempFile.getCanonicalPath();
    System.arraycopy(args, 0, commandline, 1, args.length);
    super.clearArgs();
    for (String arg : commandline) {
        final Commandline.Argument argument = super.createArg();
        argument.setValue(arg);
    }
}
 
开发者ID:apache,项目名称:groovy,代码行数:15,代码来源:Groovy.java

示例12: safeScanScript

import org.codehaus.groovy.runtime.ResourceGroovyMethods; //导入依赖的package包/类
private void safeScanScript(File file) {
    try {
        scanScript(new StringReader(ResourceGroovyMethods.getText(file)));
    } catch (final Exception ex) {
        ex.printStackTrace();
    }
}
 
开发者ID:apache,项目名称:groovy,代码行数:8,代码来源:LexerFrame.java

示例13: processFiles

import org.codehaus.groovy.runtime.ResourceGroovyMethods; //导入依赖的package包/类
public static void processFiles(List<String> fileNames) throws Exception {
    Iterator i = fileNames.iterator();
    while (i.hasNext()) {
        String filename = (String) i.next();
        File f = new File(filename);
        String text = ResourceGroovyMethods.getText(f);
        System.out.println(convert(filename, text, true, true));
    }
}
 
开发者ID:apache,项目名称:groovy,代码行数:10,代码来源:Java2GroovyProcessor.java

示例14: asCollection

import org.codehaus.groovy.runtime.ResourceGroovyMethods; //导入依赖的package包/类
public static Collection asCollection(Object value) {
    if (value == null) {
        return Collections.EMPTY_LIST;
    } else if (value instanceof Collection) {
        return (Collection) value;
    } else if (value instanceof Map) {
        Map map = (Map) value;
        return map.entrySet();
    } else if (value.getClass().isArray()) {
        return arrayAsCollection(value);
    } else if (value instanceof MethodClosure) {
        MethodClosure method = (MethodClosure) value;
        IteratorClosureAdapter adapter = new IteratorClosureAdapter(method.getDelegate());
        method.call(adapter);
        return adapter.asList();
    } else if (value instanceof String || value instanceof GString) {
        return StringGroovyMethods.toList((CharSequence) value);
    } else if (value instanceof File) {
        try {
            return ResourceGroovyMethods.readLines((File) value);
        } catch (IOException e) {
            throw new GroovyRuntimeException("Error reading file: " + value, e);
        }
    } else if (value instanceof Class && ((Class) value).isEnum()) {
        Object[] values = (Object[]) InvokerHelper.invokeMethod(value, "values", EMPTY_OBJECT_ARRAY);
        return Arrays.asList(values);
    } else {
        // let's assume it's a collection of 1
        return Collections.singletonList(value);
    }
}
 
开发者ID:apache,项目名称:groovy,代码行数:32,代码来源:DefaultTypeTransformation.java

示例15: visit

import org.codehaus.groovy.runtime.ResourceGroovyMethods; //导入依赖的package包/类
public void visit(ASTNode[] nodes, final SourceUnit source) {
    if (nodes.length != 2 || !(nodes[0] instanceof AnnotationNode) || !(nodes[1] instanceof AnnotatedNode)) {
        throw new RuntimeException("Internal error: expecting [AnnotationNode, AnnotatedNode] but got: " + Arrays.asList(nodes));
    }
    AnnotatedNode parent = (AnnotatedNode) nodes[1];
    File f = new File("temp/log.txt");
    try {
        ResourceGroovyMethods.append(f, parent.getClass().getSimpleName() + " " +
                parent.getAnnotations().get(0).getMember("value").getText() + " ");
    } catch (IOException e) {
        e.printStackTrace();
    }
}
 
开发者ID:apache,项目名称:groovy,代码行数:14,代码来源:MyIntegerAnnoTraceASTTransformation.java


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