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


Java GPathResult类代码示例

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


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

示例1: gpath

import groovy.util.slurpersupport.GPathResult; //导入依赖的package包/类
/**
 * Matches according to GPath.
 */
public Closure<Boolean> gpath(final String condition) throws TestException {
    return new Closure<Boolean>(this, this) {
        @Override
        public Boolean call(Object request) {
            try {
                GPathResult gpathRequest = new XmlSlurper().parseText(request.toString());
                Binding binding = getBinding();
                binding.setVariable("request", gpathRequest);
                return (Boolean) new GroovyShell(binding).evaluate(condition);
            }
            catch (Exception ex) {
                ex.printStackTrace(getTestCaseRun().getLog());
                getTestCaseRun().getLog().println("Failed to parse request as XML/JSON. Stub response: " + AdapterActivity.MAKE_ACTUAL_CALL);
                return false;
            }
        }
    };
}
 
开发者ID:CenturyLinkCloud,项目名称:mdw,代码行数:22,代码来源:TestCaseScript.java

示例2: locate

import groovy.util.slurpersupport.GPathResult; //导入依赖的package包/类
@Override
public GPathResult locate(GPathResult root, OfflineOptions options) throws Exception {
    boolean domain = Type.of(root) == Type.DOMAIN;

    Script script = (Script) (
            domain ? DOMAIN_SCRIPT_CLASS.newInstance() : STANDALONE_OR_HOST_SCRIPT_CLASS.newInstance()
    );
    script.setProperty("root", root);
    if (domain) {
        String defaultSocketBindingGroup = options.defaultProfile + "-sockets";
        if ("default".equals(options.defaultProfile)) {
            defaultSocketBindingGroup = "standard-sockets";
        }
        script.setProperty("defaultSocketBindingGroup", defaultSocketBindingGroup);
    }
    return (GPathResult) script.run();
}
 
开发者ID:wildfly-extras,项目名称:creaper,代码行数:18,代码来源:Subtree.java

示例3: getLauncherIcons

import groovy.util.slurpersupport.GPathResult; //导入依赖的package包/类
public static List<String> getLauncherIcons(File manifestFile)
        throws SAXException, ParserConfigurationException, IOException {
    GPathResult manifestXml = new XmlSlurper().parse(manifestFile);
    GPathResult applicationNode = (GPathResult) manifestXml.getProperty("application");

    String icon = String.valueOf(applicationNode.getProperty("@android:icon"));
    String roundIcon = String.valueOf(applicationNode.getProperty("@android:roundIcon"));

    List<String> icons = new ArrayList<>(2);
    if (!icon.isEmpty()) {
        icons.add(icon);
    }
    if (!roundIcon.isEmpty()) {
        icons.add(roundIcon);
    }

    return unmodifiableList(icons);

}
 
开发者ID:maskarade,项目名称:gradle-android-ribbonizer-plugin,代码行数:20,代码来源:Resources.java

示例4: parseProject

import groovy.util.slurpersupport.GPathResult; //导入依赖的package包/类
@Override
public AsProject parseProject(GPathResult gPathResult, String projectPath) {
    AsProject project = ModelStorage.getInstance().getProject();
    project.setPath(projectPath);

    project.buildModel(gPathResult);

    // Default settings
    if (StringUtils.isEmpty(project.getProjectBuildSettings().sdkModel.getFlexSDKPath())) {
        project.getProjectBuildSettings().sdkModel.setFlexSDKPath(ASPathUtils.getFlexSDKPath());
    }

    // Prepare dirs
    project.initPaths();

    return project;
}
 
开发者ID:code-orchestra,项目名称:colt-as,代码行数:18,代码来源:ASLiveCodingLanguageHandler.java

示例5: asString

import groovy.util.slurpersupport.GPathResult; //导入依赖的package包/类
private static String asString(GPathResult node) {
    // little bit of hackery to avoid Groovy dependency in this file
    try {
        Object builder = ((Class) Class.forName("groovy.xml.StreamingMarkupBuilder")).newInstance();
        InvokerHelper.setProperty(builder, "encoding", "UTF-8");
        Writable w = (Writable) InvokerHelper.invokeMethod(builder, "bindNode", node);
        return "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + w.toString();
    } catch (Exception e) {
        return "Couldn't convert node to string because: " + e.getMessage();
    }
}
 
开发者ID:apache,项目名称:groovy,代码行数:12,代码来源:XmlUtil.java

示例6: getDocument

import groovy.util.slurpersupport.GPathResult; //导入依赖的package包/类
/**
 * @return The GPathResult instance created by consuming a stream of SAX events
 *         Note if one of the parse methods has been called then this returns null
 *         Note if this is called more than once all calls after the first will return null
 */
public GPathResult getDocument() {
    try {
        // xml namespace is always defined
        if (namespaceAware) {
            namespaceTagHints.put("xml", "http://www.w3.org/XML/1998/namespace");
        }
        return new NodeChild(currentNode, null, namespaceTagHints);
    } finally {
        currentNode = null;
    }
}
 
开发者ID:apache,项目名称:groovy,代码行数:17,代码来源:XmlSlurper.java

示例7: parse

import groovy.util.slurpersupport.GPathResult; //导入依赖的package包/类
/**
 * Parses the content of the given file as XML turning it into a GPathResult object
 *
 * @param file the File to parse
 * @return An object which supports GPath expressions
 * @throws SAXException Any SAX exception, possibly wrapping another exception.
 * @throws IOException An IO exception from the parser, possibly from a byte stream
 *         or character stream supplied by the application.
 */
public GPathResult parse(final File file) throws IOException, SAXException {
    final FileInputStream fis = new FileInputStream(file);
    final InputSource input = new InputSource(fis);
    input.setSystemId("file://" + file.getAbsolutePath());
    try {
        return parse(input);
    } finally {
        fis.close();
    }
}
 
开发者ID:apache,项目名称:groovy,代码行数:20,代码来源:XmlSlurper.java

示例8: of

import groovy.util.slurpersupport.GPathResult; //导入依赖的package包/类
public static Type of(GPathResult root) {
    String rootElement = root.name();
    if ("domain".equals(rootElement)) {
        return Type.DOMAIN;
    } else if ("host".equals(rootElement)) {
        return Type.HOST;
    } else if ("server".equals(rootElement)) {
        return Type.SERVER;
    } else {
        throw new IllegalArgumentException("Unknown root node '" + rootElement + "'");
    }
}
 
开发者ID:wildfly-extras,项目名称:creaper,代码行数:13,代码来源:Subtree.java

示例9: addIfMissing

import groovy.util.slurpersupport.GPathResult; //导入依赖的package包/类
void addIfMissing(GPathResult root, OfflineOptions options) {
    boolean domain = Type.of(root) == Type.DOMAIN;

    if (skipInDomain && domain) {
        return;
    }

    try {
        Script script = (Script) scriptClass.newInstance();
        script.setProperty("root", root);
        script.run();
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:wildfly-extras,项目名称:creaper,代码行数:16,代码来源:Subtree.java

示例10: transformRawDataToGraphml

import groovy.util.slurpersupport.GPathResult; //导入依赖的package包/类
public void transformRawDataToGraphml(Reader in, Writer out) {
        try {

            GPathResult response = new XmlSlurper().parse(new InputSource(in));
            Binding binding = new Binding();
            binding.setProperty("input", response);
            binding.setProperty("output", out);

           // binding = new Binding();
           // Expect4Groovy.createBindings(connection, binding, true);
           // binding.setProperty("params", params);

           // String gseRoots = new File().toURI().toURL().toString();
            String[] roots =  new String[]{projectPath+"/iDiscover/conf/groovy/"+File.separator};
            GroovyScriptEngine gse = new GroovyScriptEngine(roots);
            gse.run("RawData2GraphmlTransformer.groovy", binding);

//            Class clazz = Class.forName(new File(projectPath,rawData2GraphmlGroovyTransformer).toURI().toURL().toString());
//            Constructor constructor = clazz.getDeclaredConstructor(Binding.class);
//            Script script = (Script) constructor.newInstance(binding);
//            script.run();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
 
开发者ID:iTransformers,项目名称:netTransformer,代码行数:26,代码来源:GraphmlFileLogGroovyDiscoveryListener.java

示例11: asXml

import groovy.util.slurpersupport.GPathResult; //导入依赖的package包/类
public static GPathResult asXml(String xml) {
    try {
        return (new XmlSlurper()).parseText(xml);
    } catch (Exception e) {
        throw new RuntimeException("invalid XML");
    }
}
 
开发者ID:eBay,项目名称:restcommander,代码行数:8,代码来源:JavaExtensions.java

示例12: translate

import groovy.util.slurpersupport.GPathResult; //导入依赖的package包/类
private String translate(GPathResult root) {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    IndentPrinter printer = createIndentPrinter(baos);
    walkXml(printer, (NodeChild) root);
    printer.flush();

    return baos.toString();
}
 
开发者ID:aalmiray,项目名称:griffon2,代码行数:9,代码来源:Xml2Groovy.java

示例13: adapter

import groovy.util.slurpersupport.GPathResult; //导入依赖的package包/类
/**
 * responder closure call is delayed until stub server calls back
 */
public TestCaseAdapterStub adapter(Closure<Boolean> matcher, Closure<String> responder, Closure<?> init) throws TestException {
    final TestCaseAdapterStub adapterStub = new TestCaseAdapterStub(matcher, responder);
    if (init != null) {
        init.setResolveStrategy(Closure.DELEGATE_FIRST);
        init.setDelegate(adapterStub);
        init.call();
    }
    if (responder == null) {
        adapterStub.setResponder(new Closure<String>(this, adapterStub) {
            @Override
            public String call(Object request) {
                // binding for request
                final TestCaseRun testCaseRun = getTestCaseRun();
                if (adapterStub.getResponse().indexOf("${") >= 0) {
                    try {
                        Binding binding = getBinding();
                        if (request.toString().startsWith("{")) {
                            Object req = new JsonSlurper().parseText(request.toString());
                            binding.setVariable("request", req);
                        }
                        else {
                            GPathResult gpathRequest = new XmlSlurper().parseText(request.toString());
                            binding.setVariable("request", gpathRequest);
                        }
                        CompilerConfiguration compilerCfg = new CompilerConfiguration();
                        compilerCfg.setScriptBaseClass(DelegatingScript.class.getName());
                        GroovyShell shell = new GroovyShell(TestCaseScript.class.getClassLoader(), binding, compilerCfg);
                        shell.setProperty("out", testCaseRun.getLog());
                        DelegatingScript script = (DelegatingScript) shell.parse("return \"\"\"" + adapterStub.getResponse() + "\"\"\"");
                        script.setDelegate(TestCaseScript.this);
                        return script.run().toString();
                    }
                    catch (Exception ex) {
                        getTestCaseRun().getLog().println("Cannot perform stub substitutions for request: " + request);
                        ex.printStackTrace(getTestCaseRun().getLog());
                    }
                }
                return adapterStub.getResponse();
            }
        });
    }
    return adapterStub;
}
 
开发者ID:CenturyLinkCloud,项目名称:mdw,代码行数:47,代码来源:TestCaseScript.java

示例14: fromString

import groovy.util.slurpersupport.GPathResult; //导入依赖的package包/类
@Converter
public GPathResult fromString(String input) throws ParserConfigurationException, SAXException, IOException {
    return new XmlSlurper().parseText(input);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:5,代码来源:GPathResultConverter.java

示例15: fromStringSource

import groovy.util.slurpersupport.GPathResult; //导入依赖的package包/类
@Converter
public GPathResult fromStringSource(StringSource input) throws IOException, SAXException, ParserConfigurationException {
    return fromString(input.getText());
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:5,代码来源:GPathResultConverter.java


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