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


Java ResourceGroovyMethods.getText方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: getText

import org.codehaus.groovy.runtime.ResourceGroovyMethods; //导入方法依赖的package包/类
/**
 * Get the text of the Groovy script at the given location.
 * If the location is a file path and it does not exist as given,
 * then {@link GroovyMain#huntForTheScriptFile(String)} is called to try
 * with some Groovy extensions appended.
 *
 * This method is not used to process scripts and is retained for backward
 * compatibility.  If you want to modify how GroovyMain processes scripts
 * then use {@link GroovyMain#getScriptSource(boolean, String)}.
 *
 * @param uriOrFilename
 * @return the text content at the location
 * @throws IOException
 * @deprecated
 */
@Deprecated
public String getText(String uriOrFilename) throws IOException {
    if (URI_PATTERN.matcher(uriOrFilename).matches()) {
        try {
            return ResourceGroovyMethods.getText(new URL(uriOrFilename));
        } catch (Exception e) {
            throw new GroovyRuntimeException("Unable to get script from URL: ", e);
        }
    }
    return ResourceGroovyMethods.getText(huntForTheScriptFile(uriOrFilename));
}
 
开发者ID:apache,项目名称:groovy,代码行数:27,代码来源:GroovyMain.java


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