当前位置: 首页>>代码示例>>Java>>正文


Java Opml类代码示例

本文整理汇总了Java中com.rometools.opml.feed.opml.Opml的典型用法代码示例。如果您正苦于以下问题:Java Opml类的具体用法?Java Opml怎么用?Java Opml使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Opml类属于com.rometools.opml.feed.opml包,在下文中一共展示了Opml类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: categoryOf

import com.rometools.opml.feed.opml.Opml; //导入依赖的package包/类
private NodeList categoryOf(final String... categories) {

        try {

            final Outline outline = new Outline("outline1", null);
            outline.setCategories(Arrays.asList(categories));

            final Opml opml = new Opml();
            opml.setFeedType("opml_2.0");
            opml.setTitle("title");
            opml.setOutlines(Arrays.asList(outline));

            final WireFeedOutput output = new WireFeedOutput();
            final String xml = output.outputString(opml);

            final Document document = XMLUnit.buildControlDocument(xml);
            return XMLUnit.newXpathEngine().getMatchingNodes("/opml/body/outline/@category", document);

        } catch (final Exception e) {
            throw new RuntimeException(e);
        }

    }
 
开发者ID:rometools,项目名称:rome,代码行数:24,代码来源:OPML20GeneratorTest.java

示例2: exportOpml

import com.rometools.opml.feed.opml.Opml; //导入依赖的package包/类
@GET
@Path("/export")
@UnitOfWork
@Produces(MediaType.APPLICATION_XML)
@ApiOperation(value = "OPML export", notes = "Export an OPML file of the user's subscriptions")
@Timed
public Response exportOpml(@SecurityCheck User user) {
	Opml opml = opmlExporter.export(user);
	WireFeedOutput output = new WireFeedOutput();
	String opmlString = null;
	try {
		opmlString = output.outputString(opml);
	} catch (Exception e) {
		return Response.status(Status.INTERNAL_SERVER_ERROR).entity(e).build();
	}
	return Response.ok(opmlString).build();
}
 
开发者ID:Athou,项目名称:commafeed,代码行数:18,代码来源:FeedREST.java

示例3: generates_OPML_correctly

import com.rometools.opml.feed.opml.Opml; //导入依赖的package包/类
@Test
public void generates_OPML_correctly() {
	when(feedCategoryDAO.findAll(user)).thenReturn(categories);
	when(feedSubscriptionDAO.findAll(user)).thenReturn(subscriptions);

	Opml opml = new OPMLExporter(feedCategoryDAO, feedSubscriptionDAO).export(user);

	List<Outline> rootOutlines = opml.getOutlines();
	assertEquals(2, rootOutlines.size());
	assertTrue(containsCategory(rootOutlines, "cat1"));
	assertTrue(containsFeed(rootOutlines, "rootFeed", "rootFeed.com"));

	Outline cat1Outline = getCategoryOutline(rootOutlines, "cat1");
	List<Outline> cat1Children = cat1Outline.getChildren();
	assertEquals(2, cat1Children.size());
	assertTrue(containsCategory(cat1Children, "cat2"));
	assertTrue(containsFeed(cat1Children, "cat1Feed", "cat1Feed.com"));

	Outline cat2Outline = getCategoryOutline(cat1Children, "cat2");
	List<Outline> cat2Children = cat2Outline.getChildren();
	assertEquals(1, cat2Children.size());
	assertTrue(containsFeed(cat2Children, "cat2Feed", "cat2Feed.com"));
}
 
开发者ID:Athou,项目名称:commafeed,代码行数:24,代码来源:OPMLExporterTest.java

示例4: addOwner

import com.rometools.opml.feed.opml.Opml; //导入依赖的package包/类
protected void addOwner(final Opml opml, final SyndFeed syndFeed) {
    if (opml.getOwnerEmail() != null || opml.getOwnerName() != null) {
        final List<SyndPerson> authors = new ArrayList<SyndPerson>();
        final SyndPerson person = new SyndPersonImpl();
        person.setEmail(opml.getOwnerEmail());
        person.setName(opml.getOwnerName());
        authors.add(person);
        syndFeed.setAuthors(authors);
    }
}
 
开发者ID:rometools,项目名称:rome,代码行数:11,代码来源:ConverterForOPML10.java

示例5: copyInto

import com.rometools.opml.feed.opml.Opml; //导入依赖的package包/类
/**
 * Makes a deep copy/conversion of the values of a real feed into a SyndFeedImpl.
 * <p>
 * It assumes the given SyndFeedImpl has no properties set.
 * <p>
 *
 * @param feed real feed to copy/convert.
 * @param syndFeed the SyndFeedImpl that will contain the copied/converted values of the real feed.
 */
@Override
public void copyInto(final WireFeed feed, final SyndFeed syndFeed) {
    final Opml opml = (Opml) feed;
    syndFeed.setTitle(opml.getTitle());
    addOwner(opml, syndFeed);
    syndFeed.setPublishedDate(opml.getModified() != null ? opml.getModified() : opml.getCreated());
    syndFeed.setFeedType(opml.getFeedType());
    syndFeed.setModules(opml.getModules());
    syndFeed.setFeedType(getType());

    createEntries(new Stack<Integer>(), syndFeed.getEntries(), opml.getOutlines());
}
 
开发者ID:rometools,项目名称:rome,代码行数:22,代码来源:ConverterForOPML10.java

示例6: generate

import com.rometools.opml.feed.opml.Opml; //导入依赖的package包/类
/**
 * Creates an XML document (JDOM) for the given feed bean.
 *
 * @param feed the feed bean to generate the XML document from.
 * @return the generated XML document (JDOM).
 * @throws IllegalArgumentException thrown if the type of the given feed bean does not match with the type of the
 *             WireFeedGenerator.
 * @throws FeedException thrown if the XML Document could not be created.
 */
@Override
public Document generate(final WireFeed feed) throws IllegalArgumentException, FeedException {

    if (!(feed instanceof Opml)) {
        throw new IllegalArgumentException("Not an OPML file");
    }

    final Opml opml = (Opml) feed;
    final Document doc = new Document();
    final Element root = new Element("opml");
    root.setAttribute("version", "1.0");
    doc.addContent(root);

    final Element head = generateHead(opml);

    if (head != null) {
        root.addContent(head);
    }

    final Element body = new Element("body");
    root.addContent(body);
    super.generateFeedModules(opml.getModules(), root);
    body.addContent(generateOutlines(opml.getOutlines()));

    return doc;
}
 
开发者ID:rometools,项目名称:rome,代码行数:36,代码来源:OPML10Generator.java

示例7: generateHead

import com.rometools.opml.feed.opml.Opml; //导入依赖的package包/类
protected Element generateHead(final Opml opml) {
    final Element head = new Element("head");
    boolean hasHead = false;

    if (opml.getCreated() != null) {
        hasHead |= addNotNullSimpleElement(head, "dateCreated", DateParser.formatRFC822(opml.getCreated(), Locale.US));
    }

    hasHead |= addNotNullSimpleElement(head, "expansionState", intArrayToCsvString(opml.getExpansionState()));

    if (opml.getModified() != null) {
        hasHead |= addNotNullSimpleElement(head, "dateModified", DateParser.formatRFC822(opml.getModified(), Locale.US));
    }

    hasHead |= addNotNullSimpleElement(head, "ownerEmail", opml.getOwnerEmail());
    hasHead |= addNotNullSimpleElement(head, "ownerName", opml.getOwnerName());
    hasHead |= addNotNullSimpleElement(head, "title", opml.getTitle());
    hasHead |= addNotNullSimpleElement(head, "vertScrollState", opml.getVerticalScrollState());
    hasHead |= addNotNullSimpleElement(head, "windowBottom", opml.getWindowBottom());
    hasHead |= addNotNullSimpleElement(head, "windowLeft", opml.getWindowLeft());
    hasHead |= addNotNullSimpleElement(head, "windowRight", opml.getWindowRight());
    hasHead |= addNotNullSimpleElement(head, "windowTop", opml.getWindowTop());

    if (hasHead) {
        return head;
    } else {
        return null;
    }
}
 
开发者ID:rometools,项目名称:rome,代码行数:30,代码来源:OPML10Generator.java

示例8: generateHead

import com.rometools.opml.feed.opml.Opml; //导入依赖的package包/类
@Override
protected Element generateHead(final Opml opml) {

    final Element docsElement = new Element("docs");
    docsElement.setText(opml.getDocs());

    final Element headElement = super.generateHead(opml);
    headElement.addContent(docsElement);
    return headElement;

}
 
开发者ID:rometools,项目名称:rome,代码行数:12,代码来源:OPML20Generator.java

示例9: importOpml

import com.rometools.opml.feed.opml.Opml; //导入依赖的package包/类
public void importOpml(User user, String xml) {
	xml = xml.substring(xml.indexOf('<'));
	WireFeedInput input = new WireFeedInput();
	try {
		Opml feed = (Opml) input.build(new StringReader(xml));
		List<Outline> outlines = feed.getOutlines();
		for (int i = 0; i < outlines.size(); i++) {
			handleOutline(user, outlines.get(i), null, i);
		}
	} catch (Exception e) {
		log.error(e.getMessage(), e);
	}

}
 
开发者ID:Athou,项目名称:commafeed,代码行数:15,代码来源:OPMLImporter.java

示例10: export

import com.rometools.opml.feed.opml.Opml; //导入依赖的package包/类
public Opml export(User user) {
	Opml opml = new Opml();
	opml.setFeedType("opml_1.1");
	opml.setTitle(String.format("%s subscriptions in CommaFeed", user.getName()));
	opml.setCreated(new Date());

	List<FeedCategory> categories = feedCategoryDAO.findAll(user);
	Collections.sort(categories,
			(e1, e2) -> MoreObjects.firstNonNull(e1.getPosition(), 0) - MoreObjects.firstNonNull(e2.getPosition(), 0));

	List<FeedSubscription> subscriptions = feedSubscriptionDAO.findAll(user);
	Collections.sort(subscriptions,
			(e1, e2) -> MoreObjects.firstNonNull(e1.getPosition(), 0) - MoreObjects.firstNonNull(e2.getPosition(), 0));

	// export root categories
	for (FeedCategory cat : categories.stream().filter(c -> c.getParent() == null).collect(Collectors.toList())) {
		opml.getOutlines().add(buildCategoryOutline(cat, categories, subscriptions));
	}

	// export root subscriptions
	for (FeedSubscription sub : subscriptions.stream().filter(s -> s.getCategory() == null).collect(Collectors.toList())) {
		opml.getOutlines().add(buildSubscriptionOutline(sub));
	}

	return opml;

}
 
开发者ID:Athou,项目名称:commafeed,代码行数:28,代码来源:OPMLExporter.java

示例11: generateHead

import com.rometools.opml.feed.opml.Opml; //导入依赖的package包/类
@Override
protected Element generateHead(Opml opml) {
	Element head = new Element("head");
	addNotNullSimpleElement(head, "title", opml.getTitle());
	return head;
}
 
开发者ID:Athou,项目名称:commafeed,代码行数:7,代码来源:OPML11Generator.java


注:本文中的com.rometools.opml.feed.opml.Opml类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。