Package org.apache.abdera.model

Examples of org.apache.abdera.model.Content

Per RFC4287:

 The "atom:content" element either contains or links to the content of the entry.  The content of atom:content is Language-Sensitive. atomInlineTextContent = element atom:content { atomCommonAttributes, attribute type { "text" | "html" }?, (text) } atomInlineXHTMLContent = element atom:content { atomCommonAttributes, attribute type { "xhtml" }, xhtmlDiv } atomInlineOtherContent = element atom:content { atomCommonAttributes, attribute type { atomMediaType }?, (text|anyElement) } atomOutOfLineContent = element atom:content { atomCommonAttributes, attribute type { atomMediaType }?, attribute src { atomUri }, empty } atomContent = atomInlineTextContent | atomInlineXHTMLContent | atomInlineOtherContent | atomOutOfLineContent 

   
    String typeStr = getStringOrNull(entry, CONTENT_TYPE);
    Factory factory = Abdera.getInstance().getFactory();
    String textContent = getStringOrNull(entry, CONTENT);
    Type type = Type.valueOf(typeStr);
    Content content = factory.newContent(type);
    switch (type) {
      case TEXT:
        content.setValue(textContent);
        return content;
      case XHTML:
        content.setWrappedValue(textContent);
        return content;
      default
    }
    return null;
  }
View Full Code Here


    }

    public Content newContent(Type type, Element parent) {
        if (type == null)
            type = Content.Type.TEXT;
        Content content = new FOMContent(type, (OMContainer)parent, this);
        if (type.equals(Content.Type.XML))
            content.setMimeType(XML_MEDIA_TYPE);
        return content;
    }
View Full Code Here

        return newContent(mediaType, null);
    }

    public Content newContent(MimeType mediaType, Element parent) {
        Content.Type type = (MimeTypeHelper.isXml(mediaType.toString())) ? Content.Type.XML : Content.Type.MEDIA;
        Content content = newContent(type, parent);
        content.setMimeType(mediaType.toString());
        return content;
    }
View Full Code Here

     * Sets the content for this entry as @type="text"
     */
    public Content setContent(String value) {
        complete();
        FOMFactory factory = (FOMFactory)this.factory;
        Content content = factory.newContent();
        content.setValue(value);
        setContentElement(content);
        return content;
    }
View Full Code Here

    /**
     * Sets the content for this entry
     */
    public Content setContent(String value, Content.Type type) {
        FOMFactory factory = (FOMFactory)this.factory;
        Content content = factory.newContent(type);
        content.setValue(value);
        setContentElement(content);
        return content;
    }
View Full Code Here

    /**
     * Sets the content for this entry
     */
    public Content setContent(Element value) {
        FOMFactory factory = (FOMFactory)this.factory;
        Content content = factory.newContent();
        content.setValueElement(value);
        setContentElement(content);
        return content;
    }
View Full Code Here

    public Content setContent(Element element, String mediaType) {
        try {
            if (MimeTypeHelper.isText(mediaType))
                throw new IllegalArgumentException();
            FOMFactory factory = (FOMFactory)this.factory;
            Content content = factory.newContent(new MimeType(mediaType));
            content.setValueElement(element);
            setContentElement(content);
            return content;
        } catch (javax.activation.MimeTypeParseException e) {
            throw new org.apache.abdera.util.MimeTypeParseException(e);
        }
View Full Code Here

            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        } else {
            FOMFactory factory = (FOMFactory)this.factory;
            Content content = factory.newContent(Content.Type.MEDIA);
            content.setDataHandler(dataHandler);
            if (mediatype != null)
                content.setMimeType(mediatype);
            setContentElement(content);
            return content;
        }
    }
View Full Code Here

     * Sets the content for this entry
     */
    public Content setContent(InputStream in) {
        InputStreamDataSource ds = new InputStreamDataSource(in);
        DataHandler dh = new DataHandler(ds);
        Content content = setContent(dh);
        return content;
    }
View Full Code Here

     * @throws MimeTypeParseException
     */
    public Content setContent(String value, String mediatype) {
        try {
            FOMFactory factory = (FOMFactory)this.factory;
            Content content = factory.newContent(new MimeType(mediatype));
            content.setValue(value);
            content.setMimeType(mediatype);
            setContentElement(content);
            return content;
        } catch (javax.activation.MimeTypeParseException e) {
            throw new org.apache.abdera.util.MimeTypeParseException(e);
        }
View Full Code Here

TOP

Related Classes of org.apache.abdera.model.Content

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.