Package com.rometools.rome.feed.module

Examples of com.rometools.rome.feed.module.DCModule


     */
    @Override
    public Module parse(final Element dcRoot, final Locale locale) {

        boolean foundSomething = false;
        final DCModule dcm = new DCModuleImpl();

        final List<Element> titles = dcRoot.getChildren("title", getDCNamespace());
        if (!titles.isEmpty()) {
            foundSomething = true;
            dcm.setTitles(parseElementList(titles));
        }

        final List<Element> creators = dcRoot.getChildren("creator", getDCNamespace());
        if (!creators.isEmpty()) {
            foundSomething = true;
            dcm.setCreators(parseElementList(creators));
        }

        final List<Element> subjects = dcRoot.getChildren("subject", getDCNamespace());
        if (!subjects.isEmpty()) {
            foundSomething = true;
            dcm.setSubjects(parseSubjects(subjects));
        }

        final List<Element> descriptions = dcRoot.getChildren("description", getDCNamespace());
        if (!descriptions.isEmpty()) {
            foundSomething = true;
            dcm.setDescriptions(parseElementList(descriptions));
        }

        final List<Element> publishers = dcRoot.getChildren("publisher", getDCNamespace());
        if (!publishers.isEmpty()) {
            foundSomething = true;
            dcm.setPublishers(parseElementList(publishers));
        }

        final List<Element> contributors = dcRoot.getChildren("contributor", getDCNamespace());
        if (!contributors.isEmpty()) {
            foundSomething = true;
            dcm.setContributors(parseElementList(contributors));
        }

        final List<Element> dates = dcRoot.getChildren("date", getDCNamespace());
        if (!dates.isEmpty()) {
            foundSomething = true;
            dcm.setDates(parseElementListDate(dates, locale));
        }

        final List<Element> types = dcRoot.getChildren("type", getDCNamespace());
        if (!types.isEmpty()) {
            foundSomething = true;
            dcm.setTypes(parseElementList(types));
        }

        final List<Element> formats = dcRoot.getChildren("format", getDCNamespace());
        if (!formats.isEmpty()) {
            foundSomething = true;
            dcm.setFormats(parseElementList(formats));
        }

        final List<Element> identifiers = dcRoot.getChildren("identifier", getDCNamespace());
        if (!identifiers.isEmpty()) {
            foundSomething = true;
            dcm.setIdentifiers(parseElementList(identifiers));
        }

        final List<Element> sources = dcRoot.getChildren("source", getDCNamespace());
        if (!sources.isEmpty()) {
            foundSomething = true;
            dcm.setSources(parseElementList(sources));
        }

        final List<Element> languages = dcRoot.getChildren("language", getDCNamespace());
        if (!languages.isEmpty()) {
            foundSomething = true;
            dcm.setLanguages(parseElementList(languages));
        }

        final List<Element> relations = dcRoot.getChildren("relation", getDCNamespace());
        if (!relations.isEmpty()) {
            foundSomething = true;
            dcm.setRelations(parseElementList(relations));
        }

        final List<Element> coverages = dcRoot.getChildren("coverage", getDCNamespace());
        if (!coverages.isEmpty()) {
            foundSomething = true;
            dcm.setCoverages(parseElementList(coverages));
        }

        final List<Element> rights = dcRoot.getChildren("rights", getDCNamespace());
        if (!rights.isEmpty()) {
            foundSomething = true;
            dcm.setRightsList(parseElementList(rights));
        }

        if (foundSomething) {
            return dcm;
        } else {
View Full Code Here


     *
     */
    @Override
    public void setAuthor(final String author) {
        // Get the DCModule so that we can check to see if "creator" is already set.
        final DCModule dcModule = getDCModule();
        final String currentValue = dcModule.getCreator();

        if (Strings.isEmpty(currentValue)) {
            getDCModule().setCreator(author);
        }
    }
View Full Code Here

     * @param element the root element to attach child elements to.
     */
    @Override
    public final void generate(final Module module, final Element element) {

        final DCModule dcModule = (DCModule) module;

        final String title = dcModule.getTitle();
        if (title != null) {
            element.addContent(generateSimpleElementList("title", dcModule.getTitles()));
        }

        final String creator = dcModule.getCreator();
        if (creator != null) {
            element.addContent(generateSimpleElementList("creator", dcModule.getCreators()));
        }

        final List<DCSubject> subjects = dcModule.getSubjects();
        for (final DCSubject dcSubject : subjects) {
            element.addContent(generateSubjectElement(dcSubject));
        }

        final String description = dcModule.getDescription();
        if (description != null) {
            element.addContent(generateSimpleElementList("description", dcModule.getDescriptions()));
        }

        final String publisher = dcModule.getPublisher();
        if (publisher != null) {
            element.addContent(generateSimpleElementList("publisher", dcModule.getPublishers()));
        }

        final List<String> contributors = dcModule.getContributors();
        if (contributors != null) {
            element.addContent(generateSimpleElementList("contributor", contributors));
        }

        final Date dcDate = dcModule.getDate();
        if (dcDate != null) {
            for (final Date date : dcModule.getDates()) {
                element.addContent(generateSimpleElement("date", DateParser.formatW3CDateTime(date, Locale.US)));
            }
        }

        final String type = dcModule.getType();
        if (type != null) {
            element.addContent(generateSimpleElementList("type", dcModule.getTypes()));
        }

        final String format = dcModule.getFormat();
        if (format != null) {
            element.addContent(generateSimpleElementList("format", dcModule.getFormats()));
        }

        final String identifier = dcModule.getIdentifier();
        if (identifier != null) {
            element.addContent(generateSimpleElementList("identifier", dcModule.getIdentifiers()));
        }

        final String source = dcModule.getSource();
        if (source != null) {
            element.addContent(generateSimpleElementList("source", dcModule.getSources()));
        }

        final String language = dcModule.getLanguage();
        if (language != null) {
            element.addContent(generateSimpleElementList("language", dcModule.getLanguages()));
        }

        final String relation = dcModule.getRelation();
        if (relation != null) {
            element.addContent(generateSimpleElementList("relation", dcModule.getRelations()));
        }

        final String coverage = dcModule.getCoverage();
        if (coverage != null) {
            element.addContent(generateSimpleElementList("coverage", dcModule.getCoverages()));
        }

        final String rights = dcModule.getRights();
        if (rights != null) {
            element.addContent(generateSimpleElementList("rights", dcModule.getRightsList()));
        }

    }
View Full Code Here

    protected TestSyndFeedRSS10DCMulti(final String feedType, final String feedFileName) {
        super(feedType, feedFileName);
    }

    public void testChannelDCModule() throws Exception {
        final DCModule dc = (DCModule) this.getCachedSyndFeed().getModule(DCModule.URI);
        testDCModule(dc, "channel.");
    }
View Full Code Here

    }

    protected void testItemDCModule(final int i) throws Exception {
        final List<SyndEntry> entries = this.getCachedSyndFeed().getEntries();
        final SyndEntry entry = entries.get(i);
        final DCModule dc = (DCModule) entry.getModule(DCModule.URI);
        testDCModule(dc, "item[" + i + "].");
    }
View Full Code Here

    protected TestSyndFeedRSS10DCSyModules(final String feedType, final String feedFileName) {
        super(feedType, feedFileName);
    }

    public void testChannelDCModule() throws Exception {
        final DCModule dc = (DCModule) this.getCachedSyndFeed().getModule(DCModule.URI);
        testDCModule(dc, "channel.");
    }
View Full Code Here

    }

    protected void testItemDCModule(final int i) throws Exception {
        final List<SyndEntry> entries = this.getCachedSyndFeed().getEntries();
        final SyndEntry entry = entries.get(i);
        final DCModule dc = (DCModule) entry.getModule(DCModule.URI);
        testDCModule(dc, "item[" + i + "].");

    }
View Full Code Here

    protected TestSyndFeedAtom03DCSyModules(final String feedType, final String feedFileName) {
        super(feedType, feedFileName);
    }

    public void testModules() throws Exception {
        final DCModule dc = (DCModule) this.getCachedSyndFeed().getModule(DCModule.URI);
        assertNotNull(dc);
        final SyModule sy = (SyModule) this.getCachedSyndFeed().getModule(SyModule.URI);
        assertNotNull(sy);
    }
View Full Code Here

        final SyModule sy = (SyModule) this.getCachedSyndFeed().getModule(SyModule.URI);
        assertNotNull(sy);
    }

    public void testFeedDCModule() throws Exception {
        final DCModule dc = (DCModule) this.getCachedSyndFeed().getModule(DCModule.URI);
        testDCModule(dc, "feed.", false, 0);
    }
View Full Code Here

    }

    protected void testEntryDCModule(final int i) throws Exception {
        final List<SyndEntry> entries = this.getCachedSyndFeed().getEntries();
        final SyndEntry entry = entries.get(i);
        final DCModule dc = (DCModule) entry.getModule(DCModule.URI);
        testDCModule(dc, "feed.entry[" + i + "].", true, i);

    }
View Full Code Here

TOP

Related Classes of com.rometools.rome.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.