Package groovy.util.slurpersupport

Examples of groovy.util.slurpersupport.GPathResult


   
    static class GPath_FieldValue extends FieldValue_Object
    {
        public Object getFieldValuePrimitive (Object receiver, FieldPath keyPath)
        {
            GPathResult node = (GPathResult)receiver;
            String key = keyPath.car();

            // magic keys...
            if (key.equals("tagName")) {
                return node.name();
            }

            if (key.equals("children")) {
                return node.children();
            }

            if (key.equals("text")) {
                return node.text();
            }

            if (key.endsWith("[]")) {
                key = key.substring(0, key.length()-2);
                return node.getProperty(key);
            }

            // Expect single value
            Object val = node.getProperty(key);

            if (val instanceof GPathResult) {
                int size = ((GPathResult)val).size();
                val = size > 0 ? ((GPathResult)val).getAt(0) : null;
            }
View Full Code Here


                try {
                    inputStream = descriptor.getInputStream();

                    // Xpath: /grails/plugins/plugin, where root is /grails
                    GPathResult root = SpringIOUtils.createXmlSlurper().parse(inputStream);
                    GPathResult plugins = (GPathResult) root.getProperty("plugins");
                    GPathResult nodes = (GPathResult) plugins.getProperty("plugin");

                    for (int i = 0, count = nodes.size(); i < count; i++) {
                        GPathResult node = (GPathResult) nodes.getAt(i);
                        final String pluginName = node.text();
                        Class<?> clazz;
                        if (classLoader instanceof GroovyClassLoader) {
                            clazz = classLoader.loadClass(pluginName);
                        }
                        else {
View Full Code Here

    protected void initializeProvidedArtefacts(GPathResult descriptor) {

        List<Class> artefacts = new ArrayList<Class>();
        if (descriptor != null) {
            GPathResult resources = (GPathResult) descriptor.getProperty("resources");
            if (!resources.isEmpty()) {
                GPathResult allResources = (GPathResult) resources.getProperty("resource");
                if (!allResources.isEmpty()) {
                    final ClassLoader classLoader = application.getClassLoader();
                    for (Iterator i = allResources.nodeIterator(); i.hasNext();) {
                        final String className = ((Node)i.next()).text();
                        try {
                            artefacts.add(classLoader.loadClass(className));
                        } catch (ClassNotFoundException e) {
                            LOG.error("Class not found loading plugin resource [" + className + "]. Resource skipped.", e);
View Full Code Here

            for (Resource resource : resources) {
                InputStream input = null;

                try {
                    input = resource.getInputStream();
                    final GPathResult result = slurper.parse(input);
                    GPathResult pluginClass = (GPathResult) result.getProperty("type");
                    if (pluginClass.size() == 1) {
                        final String pluginClassName = pluginClass.text();
                        if (StringUtils.hasText(pluginClassName)) {
                            loadCorePlugin(pluginClassName, resource, result);
                        }
                    } else {
                        final Iterator iterator = pluginClass.nodeIterator();
                        while (iterator.hasNext()) {
                            Node node = (Node) iterator.next();
                            final String pluginClassName = node.text();
                            if (StringUtils.hasText(pluginClassName)) {
                                loadCorePlugin(pluginClassName, resource, result);
View Full Code Here

    @SuppressWarnings("deprecation")
    public void testWriteSlurperResult() throws SAXException, ParserConfigurationException, IOException {
        String testXml = "<root><books><book isbn=\"45734957\">" +
                         "<title>Misery</title><author>Stephen King</author>" +
                         "</book></books></root>";
        GPathResult result = new XmlSlurper().parseText(testXml);

        StringWriter output = new StringWriter(testXml.length() + 20);
        GrailsUtil.writeSlurperResult(result, output);

        testXml = testXml.replaceAll("<root>", "<root xmlns='http://java.sun.com/xml/ns/j2ee'>");
View Full Code Here

    String rawUWSInfo = "";
    String msgMeta = "";
    XmlSlurper slupler;
    try {
      slupler = new XmlSlurper();
      GPathResult result = slupler.parseText(message);
      for (Iterator iterator = result.childNodes(); iterator.hasNext();) {
        Node next = (Node)iterator.next();
        if(!"UWSInfo".equalsIgnoreCase(next.name())) {
          continue;
        }
        rawUWSInfo = next.text();
View Full Code Here

TOP

Related Classes of groovy.util.slurpersupport.GPathResult

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.