Package org.rometools.feed.module.sle

Examples of org.rometools.feed.module.sle.SimpleListExtension


    public void generate(Module module, Element element) {
        if (!(module instanceof SimpleListExtension)) {
            return;
        }

        SimpleListExtension sle = (SimpleListExtension) module;
        addNotNullElement(element, "treatAs", sle.getTreatAs());

        Group[] groups = sle.getGroupFields();
        Element listInfo = new Element("listinfo", ModuleParser.NS);

        for (int i = 0; (groups != null) && (i < groups.length); i++) {
            Element group = new Element("group", ModuleParser.NS);

            if (groups[i].getNamespace() != Namespace.NO_NAMESPACE) {
                addNotNullAttribute(group, "ns", groups[i].getNamespace().getURI());
            }

            addNotNullAttribute(group, "element", groups[i].getElement());
            addNotNullAttribute(group, "label", groups[i].getLabel());
            listInfo.addContent(group);
        }

        Sort[] sorts = sle.getSortFields();

        for (int i = 0; (sorts != null) && (i < sorts.length); i++) {
            Element sort = new Element("sort", ModuleParser.NS);

            if (sorts[i].getNamespace() != Namespace.NO_NAMESPACE) {
View Full Code Here


    public Module parse(Element element) {
        if (element.getChild("treatAs", NS) == null) {
            return null;
        }

        SimpleListExtension sle = new SimpleListExtensionImpl();
        sle.setTreatAs(element.getChildText("treatAs", NS));

        Element listInfo = element.getChild("listinfo", NS);
        List groups = listInfo.getChildren("group", NS);
        ArrayList values = new ArrayList();

        for (int i = 0; (groups != null) && (i < groups.size()); i++) {
            Element ge = (Element) groups.get(i);
            Namespace ns = (ge.getAttribute("ns") == null) ? element.getNamespace() : Namespace.getNamespace(ge.getAttributeValue("ns"));
            String elementName = ge.getAttributeValue("element");
            String label = ge.getAttributeValue("label");
            values.add(new Group(ns, elementName, label));
        }

        sle.setGroupFields((Group[]) values.toArray(new Group[values.size()]));
        values = (values.size() == 0) ? values : new ArrayList();

        List sorts = listInfo.getChildren("sort", NS);

        for (int i = 0; (sorts != null) && (i < sorts.size()); i++) {
            Element se = (Element) sorts.get(i);
            System.out.println("Parse cf:sort "+se.getAttributeValue("element")+se.getAttributeValue("data-type"));
            Namespace ns = (se.getAttributeValue("ns") == null) ? element.getNamespace() : Namespace.getNamespace(se.getAttributeValue("ns"));
            String elementName = se.getAttributeValue("element");
            String label = se.getAttributeValue("label");
            String dataType = se.getAttributeValue("data-type");
            boolean defaultOrder = (se.getAttributeValue("default") == null) ? false : new Boolean(se.getAttributeValue("default")).booleanValue();
            values.add(new Sort(ns, elementName, dataType, label, defaultOrder));
        }

        sle.setSortFields((Sort[]) values.toArray(new Sort[values.size()]));
        insertValues(sle, element.getChildren());

        return sle;
    }
View Full Code Here

TOP

Related Classes of org.rometools.feed.module.sle.SimpleListExtension

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.