• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ResourceGroovyMethods类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: testGenerateResourceFile

import org.codehaus.groovy.runtime.ResourceGroovyMethods; //导入依赖的package包/类
@Test
public void testGenerateResourceFile() {
    File httpdTemplate = new File("../jwala-common/src/test/resources/HttpdConfTemplate.tpl");
    try {
        List<Group> groups = new ArrayList<>();
        List<Jvm> jvms = new ArrayList<>();
        List<WebServer> webServers = new ArrayList<>();
        List<Application> applications = new ArrayList<>();
        Group group = new Group(new Identifier<Group>(1111L),
                "groupName",
                new HashSet<>(jvms),
                new HashSet<>(webServers),
                new HashSet<History>(),
                new HashSet<>(applications));
        groups.add(group);
        applications.add(new Application(new Identifier<Application>(111L), "hello-world-1", "d:/jwala/app/archive", "/hello-world-1", group, true, true, false, "testWar.war", "d:/test1/deployPath"));
        applications.add(new Application(new Identifier<Application>(222L), "hello-world-2", "d:/jwala/app/archive", "/hello-world-2", group, true, true, false, "testWar.war", "d:/test2/deployPath"));
        applications.add(new Application(new Identifier<Application>(333L), "hello-world-3", "d:/jwala/app/archive", "/hello-world-3", group, true, true, false, "testWar.war", "d:/test3/deployPath"));
        WebServer webServer = new WebServer(new Identifier<WebServer>(1L), groups, "Apache2.4", "localhost", 80, 443,
                new com.cerner.jwala.common.domain.model.path.Path("/statusPath"), WebServerReachableState.WS_UNREACHABLE, null);
        webServers.add(webServer);
        jvms.add(new Jvm(new Identifier<Jvm>(11L), "tc1", "someHostGenerateMe", new HashSet<>(groups), 11010, 11011, 11012, -1, 11013,
                new com.cerner.jwala.common.domain.model.path.Path("/statusPath"), "EXAMPLE_OPTS=%someEvn%/someVal", JvmState.JVM_STOPPED, "", null, null, null, null, null, null, null));
        jvms.add(new Jvm(new Identifier<Jvm>(22L), "tc2", "someHostGenerateMe", new HashSet<>(groups), 11020, 11021, 11022, -1, 11023,
                new com.cerner.jwala.common.domain.model.path.Path("/statusPath"), "EXAMPLE_OPTS=%someEvn%/someVal", JvmState.JVM_STOPPED, "", null, null, null, null, null, null, null));

        when(Config.mockGroupPesistenceService.getGroups()).thenReturn(groups);
        when(Config.mockAppPersistenceService.findApplicationsBelongingTo(anyString())).thenReturn(applications);
        when(Config.mockJvmPersistenceService.getJvmsAndWebAppsByGroupName(anyString())).thenReturn(jvms);
        when(Config.mockWebServerPersistenceService.getWebServersByGroupName(anyString())).thenReturn(webServers);

        System.setProperty(ApplicationProperties.PROPERTIES_ROOT_PATH,
                this.getClass().getClassLoader().getResource("vars.properties").getPath().replace("vars.properties", ""));

        final ResourceGroup resourceGroup = resourceService.generateResourceGroup();
        String output = resourceService.generateResourceFile(ResourceGroovyMethods.getText(httpdTemplate), ResourceGroovyMethods.getText(httpdTemplate), resourceGroup, webServer, ResourceGeneratorType.TEMPLATE);

        String expected = ResourceGroovyMethods.getText(new File("../jwala-common/src/test/resources/HttpdConfTemplate-EXPECTED.conf"));
        expected = expected.replaceAll("\\r", "").replaceAll("\\n", "");
        output = output.replaceAll("\\r", "").replaceAll("\\n", "");
        String diff = StringUtils.difference(output, expected);
        assertEquals(expected, output);
    } catch (IOException e) {
        fail(e.getMessage());
    }
}
 
开发者ID:cerner,项目名称:jwala,代码行数:47,代码来源:ResourceServiceImplTest.java


示例17: deleteTempDir

import org.codehaus.groovy.runtime.ResourceGroovyMethods; //导入依赖的package包/类
@AfterClass public static void deleteTempDir() {
  ResourceGroovyMethods.deleteDir(TAPE_ROOT);
}
 
开发者ID:airbnb,项目名称:okreplay,代码行数:4,代码来源:TapeNameTest.java


示例18: getReader

import org.codehaus.groovy.runtime.ResourceGroovyMethods; //导入依赖的package包/类
public Reader getReader(String resourceName) throws IOException {
    return ResourceGroovyMethods.newReader(new File(basedir + resourceName));
}
 
开发者ID:apache,项目名称:groovy,代码行数:4,代码来源:FileSystemResourceManager.java


示例19: writeToOutput

import org.codehaus.groovy.runtime.ResourceGroovyMethods; //导入依赖的package包/类
public void writeToOutput(String fileName, String text, String charset) throws Exception {
    File file = new File(fileName);
    file.getParentFile().mkdirs();
    ResourceGroovyMethods.write(file, text, charset, true);
}
 
开发者ID:apache,项目名称:groovy,代码行数:6,代码来源:FileOutputTool.java


示例20: tearDown

import org.codehaus.groovy.runtime.ResourceGroovyMethods; //导入依赖的package包/类
@Override
protected void tearDown() throws Exception {
    ResourceGroovyMethods.deleteDir(tmpDir);
    super.tearDown();
}
 
开发者ID:apache,项目名称:groovy,代码行数:6,代码来源:GroovyDocTest.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java PactFragment类代码示例发布时间:2022-05-23
下一篇:
Java OpConditional类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap