Search in sources :

Example 1 with Content

use of org.apache.abdera.model.Content in project cxf by apache.

the class JAXRSAtomBookTest method createBookEntry.

private Entry createBookEntry(int id, String name) throws Exception {
    Book b = new Book();
    b.setId(id);
    b.setName(name);
    Factory factory = Abdera.getNewFactory();
    JAXBContext jc = JAXBContext.newInstance(Book.class);
    Entry e = factory.getAbdera().newEntry();
    e.setTitle(b.getName());
    e.setId(Long.toString(b.getId()));
    StringWriter writer = new StringWriter();
    jc.createMarshaller().marshal(b, writer);
    Content ct = factory.newContent(Content.Type.XML);
    ct.setValue(writer.toString());
    e.setContentElement(ct);
    return e;
}
Also used : Entry(org.apache.abdera.model.Entry) StringWriter(java.io.StringWriter) Content(org.apache.abdera.model.Content) Factory(org.apache.abdera.factory.Factory) JAXBContext(javax.xml.bind.JAXBContext)

Example 2 with Content

use of org.apache.abdera.model.Content in project cxf by apache.

the class AtomPojoProvider method setEntryContent.

protected void setEntryContent(Factory factory, Entry e, String content) {
    Content ct = factory.newContent(Content.Type.XML);
    ct.setValue(content);
    e.setContentElement(ct);
}
Also used : Content(org.apache.abdera.model.Content)

Aggregations

Content (org.apache.abdera.model.Content)2 StringWriter (java.io.StringWriter)1 JAXBContext (javax.xml.bind.JAXBContext)1 Factory (org.apache.abdera.factory.Factory)1 Entry (org.apache.abdera.model.Entry)1