Package org.rometools.feed.module.content

Examples of org.rometools.feed.module.content.ContentModuleImpl


        return ContentModule.URI;
    }

    public com.sun.syndication.feed.module.Module parse(org.jdom2.Element element) {
        boolean foundSomething = false;
        ContentModule cm = new ContentModuleImpl();
        List encodeds = element.getChildren("encoded", CONTENT_NS);
        ArrayList contentStrings = new ArrayList();
        ArrayList encodedStrings = new ArrayList();

        if (encodeds.size() > 0) {
            foundSomething = true;

            for (int i = 0; i < encodeds.size(); i++) {
                Element encodedElement = (Element) encodeds.get(i);
                encodedStrings.add(encodedElement.getText());
                contentStrings.add(encodedElement.getText());
            }
        }

        ArrayList contentItems = new ArrayList();
        List items = element.getChildren("items", CONTENT_NS);

        for (int i = 0; i < items.size(); i++) {
            foundSomething = true;

            List lis = ((Element) items.get(i)).getChild("Bag", RDF_NS).getChildren("li", RDF_NS);

            for (int j = 0; j < lis.size(); j++) {
                ContentItem ci = new ContentItem();
                Element li = (Element) lis.get(j);
                Element item = li.getChild("item", CONTENT_NS);
                Element format = item.getChild("format", CONTENT_NS);
                Element encoding = item.getChild("encoding", CONTENT_NS);
                Element value = item.getChild("value", RDF_NS);

                if (value != null) {
                    if (value.getAttributeValue("parseType", RDF_NS) != null) {
                        ci.setContentValueParseType(value.getAttributeValue("parseType", RDF_NS));
                    }

                    if ((ci.getContentValueParseType() != null) && ci.getContentValueParseType().equals("Literal")) {
                        ci.setContentValue(getXmlInnerText(value));
                        contentStrings.add(getXmlInnerText(value));
                        ci.setContentValueNamespaces(value.getAdditionalNamespaces());
                    } else {
                        ci.setContentValue(value.getText());
                        contentStrings.add(value.getText());
                    }

                    ci.setContentValueDOM(((Element) value.clone()).getContent());
                }

                if (format != null) {
                    ci.setContentFormat(format.getAttribute("resource", RDF_NS).getValue());
                }

                if (encoding != null) {
                    ci.setContentEncoding(encoding.getAttribute("resource", RDF_NS).getValue());
                }

                if (item != null) {
                    Attribute about = item.getAttribute("about", RDF_NS);

                    if (about != null) {
                        ci.setContentAbout(about.getValue());
                    }
                }

                contentItems.add(ci);
            }
        }

        cm.setEncodeds(encodedStrings);
        cm.setContentItems(contentItems);
        cm.setContents(contentStrings);

        return (foundSomething) ? cm : null;
    }
View Full Code Here

TOP

Related Classes of org.rometools.feed.module.content.ContentModuleImpl

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.