Package com.sun.syndication.feed.module

Examples of com.sun.syndication.feed.module.DCModule


     * @param dcRoot the root element containing the module elements.
     * @return the module parsed from the element tree, <i>null</i> if none.
     */
    public Module parse(Element dcRoot) {
        boolean foundSomething = false;
        DCModule dcm = new DCModuleImpl();

        List eList = dcRoot.getChildren("title", getDCNamespace());
        if (eList.size() > 0) {
            foundSomething = true;
            dcm.setTitles(parseElementList(eList));
        }
        eList = dcRoot.getChildren("creator", getDCNamespace());
        if (eList.size() > 0) {
            foundSomething = true;
            dcm.setCreators(parseElementList(eList));
        }
        eList = dcRoot.getChildren("subject", getDCNamespace());
        if (eList.size() > 0) {
            foundSomething = true;
            dcm.setSubjects(parseSubjects(eList));
        }
        eList = dcRoot.getChildren("description", getDCNamespace());
        if (eList.size() > 0) {
            foundSomething = true;
            dcm.setDescriptions(parseElementList(eList));
        }
        eList = dcRoot.getChildren("publisher", getDCNamespace());
        if (eList.size() > 0) {
            foundSomething = true;
            dcm.setPublishers(parseElementList(eList));
        }
        eList = dcRoot.getChildren("contributor", getDCNamespace());
        if (eList.size() > 0) {
            foundSomething = true;
            dcm.setContributors(parseElementList(eList));
        }
        eList = dcRoot.getChildren("date", getDCNamespace());
        if (eList.size() > 0) {
            foundSomething = true;
            dcm.setDates(parseElementListDate(eList));
        }
        eList = dcRoot.getChildren("type", getDCNamespace());
        if (eList.size() > 0) {
            foundSomething = true;
            dcm.setTypes(parseElementList(eList));
        }
        eList = dcRoot.getChildren("format", getDCNamespace());
        if (eList.size() > 0) {
            foundSomething = true;
            dcm.setFormats(parseElementList(eList));
        }
        eList = dcRoot.getChildren("identifier", getDCNamespace());
        if (eList.size() > 0) {
            foundSomething = true;
            dcm.setIdentifiers(parseElementList(eList));
        }
        eList = dcRoot.getChildren("source", getDCNamespace());
        if (eList.size() > 0) {
            foundSomething = true;
            dcm.setSources(parseElementList(eList));
        }
        eList = dcRoot.getChildren("language", getDCNamespace());
        if (eList.size() > 0) {
            foundSomething = true;
            dcm.setLanguages(parseElementList(eList));
        }
        eList = dcRoot.getChildren("relation", getDCNamespace());
        if (eList.size() > 0) {
            foundSomething = true;
            dcm.setRelations(parseElementList(eList));
        }
        eList = dcRoot.getChildren("coverage", getDCNamespace());
        if (eList.size() > 0) {
            foundSomething = true;
            dcm.setCoverages(parseElementList(eList));
        }
        eList = dcRoot.getChildren("rights", getDCNamespace());
        if (eList.size() > 0) {
            foundSomething = true;
            dcm.setRightsList(parseElementList(eList));
        }

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


     * <p>
     * @param module the module to populate from.
     * @param element the root element to attach child elements to.
     */
    public final void generate(Module module, Element element) {
        DCModule dcModule = (DCModule) module;

        if (dcModule.getTitle() != null) {
            element.addContent(generateSimpleElementList("title", dcModule.getTitles()));
        }
        if (dcModule.getCreator() != null) {
            element.addContent(generateSimpleElementList("creator", dcModule.getCreators()));
        }
        List subjects = dcModule.getSubjects();
        for (int i = 0; i < subjects.size(); i++) {
            element.addContent(generateSubjectElement((DCSubject) subjects.get(i)));
        }
        if (dcModule.getDescription() != null) {
            element.addContent(generateSimpleElementList("description", dcModule.getDescriptions()));
        }
        if (dcModule.getPublisher() != null) {
            element.addContent(generateSimpleElementList("publisher", dcModule.getPublishers()));
        }
        if (dcModule.getContributors() != null) {
            element.addContent(generateSimpleElementList("contributor", dcModule.getContributors()));
        }
        if (dcModule.getDate() != null) {
            for (Iterator i = dcModule.getDates().iterator(); i.hasNext();) {
                element.addContent(generateSimpleElement("date",
                        DateParser.formatW3CDateTime((Date) i.next())));
            }
        }
        if (dcModule.getType() != null) {
            element.addContent(generateSimpleElementList("type", dcModule.getTypes()));
        }
        if (dcModule.getFormat() != null) {
            element.addContent(generateSimpleElementList("format", dcModule.getFormats()));
        }
        if (dcModule.getIdentifier() != null) {
            element.addContent(generateSimpleElementList("identifier", dcModule.getIdentifiers()));
        }
        if (dcModule.getSource() != null) {
            element.addContent(generateSimpleElementList("source", dcModule.getSources()));
        }
        if (dcModule.getLanguage() != null) {
            element.addContent(generateSimpleElementList("language", dcModule.getLanguages()));
        }
        if (dcModule.getRelation() != null) {
            element.addContent(generateSimpleElementList("relation", dcModule.getRelations()));
        }
        if (dcModule.getCoverage() != null) {
            element.addContent(generateSimpleElementList("coverage", dcModule.getCoverages()));
        }
        if (dcModule.getRights() != null) {
            element.addContent(generateSimpleElementList("rights", dcModule.getRightsList()));
        }
    }
View Full Code Here

    private void initFromRomeEntry(SyndFeed romeFeed, SyndEntry romeEntry) {
        setTitle(romeEntry.getTitle());
        setPermalink(romeEntry.getLink());
       
        // Play some games to get the author
        DCModule entrydc = (DCModule)romeEntry.getModule(DCModule.URI);
        DCModule feeddc = (DCModule)romeFeed.getModule(DCModule.URI);
        if (romeEntry.getAuthor() != null) {
            setAuthor(romeEntry.getAuthor());
        } else {
            setAuthor(entrydc.getCreator()); // use <dc:creator>
        }
View Full Code Here

                // only add DC module if any DC fields are configured
                if (dcCreatorField != null || dcDateField != null ||
                    dcDescriptionField != null)
                {
                    DCModule dc = new DCModuleImpl();
                    if (dcCreatorField != null)
                    {
                        Metadatum dcAuthors[] = item.getMetadataByMetadataString(dcCreatorField);
                        if (dcAuthors.length > 0)
                        {
                            List<String> creators = new ArrayList<String>();
                            for (Metadatum author : dcAuthors)
                            {
                                creators.add(author.value);
                            }
                            dc.setCreators(creators);
                        }
                    }
                    if (dcDateField != null && !hasDate)
                    {
                        Metadatum v[] = item.getMetadataByMetadataString(dcDateField);
                        if (v.length > 0)
                        {
                            dc.setDate((new DCDate(v[0].value)).toDate());
                        }
                    }
                    if (dcDescriptionField != null)
                    {
                        Metadatum v[] = item.getMetadataByMetadataString(dcDescriptionField);
                        if (v.length > 0)
                        {
                            StringBuffer descs = new StringBuffer();
                            for (Metadatum d : v)
                            {
                                if (descs.length() > 0)
                                {
                                    descs.append("\n\n");
                                }
                                descs.append(d.value);
                            }
                            dc.setDescription(descs.toString());
                        }
                    }
                    entry.getModules().add(dc);
                }
View Full Code Here

    private void initFromRomeEntry(SyndFeed romeFeed, SyndEntry romeEntry) {
        setTitle(romeEntry.getTitle());
        setPermalink(romeEntry.getLink());
       
        // Play some games to get the author
        DCModule entrydc = (DCModule)romeEntry.getModule(DCModule.URI);
        DCModule feeddc = (DCModule)romeFeed.getModule(DCModule.URI);
        if (romeEntry.getAuthor() != null) {
            setAuthor(romeEntry.getAuthor());
        } else {
            setAuthor(entrydc.getCreator()); // use <dc:creator>
        }
View Full Code Here

    }
    protected PlanetConverterForRSS20(String type) {
        super(type);
    }
    protected SyndEntry createSyndEntry(Item item) {
        DCModule dcm = (DCModule)item.getModule(DCModule.URI);
        Date dcdate = dcm != null ? dcm.getDate() : null;
        SyndEntry syndEntry = super.createSyndEntry(item);
        if (dcdate != null)
        {
            ((DCModule)syndEntry.getModule(DCModule.URI)).setDate(dcdate);
        }
View Full Code Here

    }


    public void generate(Module module, Element element) {

        DCModule dcModule = (DCModule)module;

        if (dcModule.getTitle() != null) {
            element.addContent(generateSimpleElement("title", dcModule.getTitle()));
        }
        if (dcModule.getCreator() != null) {
            element.addContent(generateSimpleElement("creator", dcModule.getCreator()));
        }
        List subjects = dcModule.getSubjects();
        for (int i = 0; i < subjects.size(); i++) {
            element.addContent(generateSubjectElement((DCSubject) subjects.get(i)));
        }
        if (dcModule.getDescription() != null) {
            element.addContent(generateSimpleElement("description", dcModule.getDescription()));
        }
        if (dcModule.getPublisher() != null) {
            element.addContent(generateSimpleElement("publisher", dcModule.getPublisher()));
        }
        List contributors = dcModule.getContributors();
        if (contributors != null) {
            for (int i = 0; i < contributors.size(); i++) {
                String contributor = (String)contributors.get(i);
                element.addContent(generateSimpleElement("contributor", contributor));
            }
        }
        if (dcModule.getDate() != null) {
            element.addContent(
                generateSimpleElement("date", DateParser.formatW3CDateTime(dcModule.getDate())));
        }
        if (dcModule.getType() != null) {
            element.addContent(generateSimpleElement("type", dcModule.getType()));
        }
        if (dcModule.getFormat() != null) {
            element.addContent(generateSimpleElement("format", dcModule.getFormat()));
        }
        if (dcModule.getIdentifier() != null) {
            element.addContent(generateSimpleElement("identifier", dcModule.getIdentifier()));
        }
        if (dcModule.getSource() != null) {
            element.addContent(generateSimpleElement("source", dcModule.getSource()));
        }
        if (dcModule.getLanguage() != null) {
            element.addContent(generateSimpleElement("language", dcModule.getLanguage()));
        }
        if (dcModule.getRelation() != null) {
            element.addContent(generateSimpleElement("relation", dcModule.getRelation()));
        }
        if (dcModule.getCoverage() != null) {
            element.addContent(generateSimpleElement("coverage", dcModule.getCoverage()));
        }
        if (dcModule.getRights() != null) {
            element.addContent(generateSimpleElement("rights", dcModule.getRights()));
        }
    }
View Full Code Here

     * @param dcRoot the root element containing the module elements.
     * @return the module parsed from the element tree, <i>null</i> if none.
     */
    public Module parse(Element dcRoot) {
        boolean foundSomething = false;
        DCModule dcm = new DCModuleImpl();

        List eList = dcRoot.getChildren("title", getDCNamespace());
        if (eList.size() > 0) {
            foundSomething = true;
            dcm.setTitles(parseElementList(eList));
        }
        eList = dcRoot.getChildren("creator", getDCNamespace());
        if (eList.size() > 0) {
            foundSomething = true;
            dcm.setCreators(parseElementList(eList));
        }
        eList = dcRoot.getChildren("subject", getDCNamespace());
        if (eList.size() > 0) {
            foundSomething = true;
            dcm.setSubjects(parseSubjects(eList));
        }
        eList = dcRoot.getChildren("description", getDCNamespace());
        if (eList.size() > 0) {
            foundSomething = true;
            dcm.setDescriptions(parseElementList(eList));
        }
        eList = dcRoot.getChildren("publisher", getDCNamespace());
        if (eList.size() > 0) {
            foundSomething = true;
            dcm.setPublishers(parseElementList(eList));
        }
        eList = dcRoot.getChildren("contributor", getDCNamespace());
        if (eList.size() > 0) {
            foundSomething = true;
            dcm.setContributors(parseElementList(eList));
        }
        eList = dcRoot.getChildren("date", getDCNamespace());
        if (eList.size() > 0) {
            foundSomething = true;
            dcm.setDates(parseElementListDate(eList));
        }
        eList = dcRoot.getChildren("type", getDCNamespace());
        if (eList.size() > 0) {
            foundSomething = true;
            dcm.setTypes(parseElementList(eList));
        }
        eList = dcRoot.getChildren("format", getDCNamespace());
        if (eList.size() > 0) {
            foundSomething = true;
            dcm.setFormats(parseElementList(eList));
        }
        eList = dcRoot.getChildren("identifier", getDCNamespace());
        if (eList.size() > 0) {
            foundSomething = true;
            dcm.setIdentifiers(parseElementList(eList));
        }
        eList = dcRoot.getChildren("source", getDCNamespace());
        if (eList.size() > 0) {
            foundSomething = true;
            dcm.setSources(parseElementList(eList));
        }
        eList = dcRoot.getChildren("language", getDCNamespace());
        if (eList.size() > 0) {
            foundSomething = true;
            dcm.setLanguages(parseElementList(eList));
        }
        eList = dcRoot.getChildren("relation", getDCNamespace());
        if (eList.size() > 0) {
            foundSomething = true;
            dcm.setRelations(parseElementList(eList));
        }
        eList = dcRoot.getChildren("coverage", getDCNamespace());
        if (eList.size() > 0) {
            foundSomething = true;
            dcm.setCoverages(parseElementList(eList));
        }
        eList = dcRoot.getChildren("rights", getDCNamespace());
        if (eList.size() > 0) {
            foundSomething = true;
            dcm.setRightsList(parseElementList(eList));
        }

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

            if (module.getUri().equals(DCModuleI.URI)) {
                dcModule = (DCModuleI) module;
            }
        }
        if (dcModule==null) {
            dcModule = new DCModule();
            modules.add(dcModule);
        }
        return dcModule;
    }
View Full Code Here

     * @param dcRoot the root element containing the module elements.
     * @return the module parsed from the element tree, <i>null</i> if none.
     */
    public Module parse(Element dcRoot) {
        boolean foundSomething = false;
        DCModule dcm = new DCModuleImpl();

        List eList = dcRoot.getChildren("title", getDCNamespace());
        if (eList.size() > 0) {
            foundSomething = true;
            dcm.setTitles(parseElementList(eList));
        }
        eList = dcRoot.getChildren("creator", getDCNamespace());
        if (eList.size() > 0) {
            foundSomething = true;
            dcm.setCreators(parseElementList(eList));
        }
        eList = dcRoot.getChildren("subject", getDCNamespace());
        if (eList.size() > 0) {
            foundSomething = true;
            dcm.setSubjects(parseSubjects(eList));
        }
        eList = dcRoot.getChildren("description", getDCNamespace());
        if (eList.size() > 0) {
            foundSomething = true;
            dcm.setDescriptions(parseElementList(eList));
        }
        eList = dcRoot.getChildren("publisher", getDCNamespace());
        if (eList.size() > 0) {
            foundSomething = true;
            dcm.setPublishers(parseElementList(eList));
        }
        eList = dcRoot.getChildren("contributor", getDCNamespace());
        if (eList.size() > 0) {
            foundSomething = true;
            dcm.setContributors(parseElementList(eList));
        }
        eList = dcRoot.getChildren("date", getDCNamespace());
        if (eList.size() > 0) {
            foundSomething = true;
            dcm.setDates(parseElementListDate(eList));
        }
        eList = dcRoot.getChildren("type", getDCNamespace());
        if (eList.size() > 0) {
            foundSomething = true;
            dcm.setTypes(parseElementList(eList));
        }
        eList = dcRoot.getChildren("format", getDCNamespace());
        if (eList.size() > 0) {
            foundSomething = true;
            dcm.setFormats(parseElementList(eList));
        }
        eList = dcRoot.getChildren("identifier", getDCNamespace());
        if (eList.size() > 0) {
            foundSomething = true;
            dcm.setIdentifiers(parseElementList(eList));
        }
        eList = dcRoot.getChildren("source", getDCNamespace());
        if (eList.size() > 0) {
            foundSomething = true;
            dcm.setSources(parseElementList(eList));
        }
        eList = dcRoot.getChildren("language", getDCNamespace());
        if (eList.size() > 0) {
            foundSomething = true;
            dcm.setLanguages(parseElementList(eList));
        }
        eList = dcRoot.getChildren("relation", getDCNamespace());
        if (eList.size() > 0) {
            foundSomething = true;
            dcm.setRelations(parseElementList(eList));
        }
        eList = dcRoot.getChildren("coverage", getDCNamespace());
        if (eList.size() > 0) {
            foundSomething = true;
            dcm.setCoverages(parseElementList(eList));
        }
        eList = dcRoot.getChildren("rights", getDCNamespace());
        if (eList.size() > 0) {
            foundSomething = true;
            dcm.setRightsList(parseElementList(eList));
        }

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

TOP

Related Classes of com.sun.syndication.feed.module.DCModule

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.