org.apache.abdera.model
Interface Content

All Superinterfaces:
Base, java.lang.Cloneable, Element

public interface Content
extends Element

Represents an atom:content element.

Atom has a very clearly defined and extremely flexible content model. The model allows for five basic types of 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

 


Nested Class Summary
static class Content.Type
          Used to identify the type of content
 
Method Summary
 Content.Type getContentType()
          Returns the Content Type
 javax.activation.DataHandler getDataHandler()
          Attempts to Base64 decode the string value of the content element.
 javax.activation.MimeType getMimeType()
          RFC4287: On the atom:content element, the value of the "type" attribute MAY be one of "text", "html", or "xhtml".
 org.apache.abdera.i18n.iri.IRI getResolvedSrc()
          Returns the fully qualified URI form of the content src attribute.
 org.apache.abdera.i18n.iri.IRI getSrc()
          RFC4287: atom:content MAY have a "src" attribute, whose value MUST be an IRI reference.
 java.lang.String getValue()
          Returns the string value of this atom:content element
<T extends Element>
T
getValueElement()
          Return the value element or null if type="text", type="html" or type is some non-XML media type
 java.lang.String getWrappedValue()
          Return the string value of the atom:content element with the enclosing div tag if type="xhtml"
 void setContentType(Content.Type type)
          Set the Content Type
 void setDataHandler(javax.activation.DataHandler dataHandler)
          Sets the string value of the content element by Base64 encoding the specifed byte array.
 void setMimeType(java.lang.String type)
          RFC4287: On the atom:content element, the value of the "type" attribute MAY be one of "text", "html", or "xhtml".
 void setSrc(java.lang.String src)
          RFC4287: atom:content MAY have a "src" attribute, whose value MUST be an IRI reference.
 void setValue(java.lang.String value)
          Set the string value of the atom:content element
<T extends Element>
void
setValueElement(T value)
          Set the value element of the content.
 void setWrappedValue(java.lang.String wrappedValue)
          Set the string value of the atom:content with the enclosing div tag
 
Methods inherited from interface org.apache.abdera.model.Element
declareNS, discard, getAttributes, getAttributeValue, getAttributeValue, getBaseUri, getDocument, getElements, getExtensionAttributes, getFirstChild, getFirstChild, getLanguage, getLanguageTag, getLocale, getMustPreserveWhitespace, getNamespaces, getNextSibling, getNextSibling, getParentElement, getPreviousSibling, getPreviousSibling, getQName, getResolvedBaseUri, getText, removeAttribute, setAttributeValue, setAttributeValue, setBaseUri, setBaseUri, setLanguage, setMustPreserveWhitespace, setParentElement, setText, setText
 
Methods inherited from interface org.apache.abdera.model.Base
addComment, clone, getDefaultWriterOptions, getFactory, writeTo, writeTo, writeTo, writeTo, writeTo, writeTo, writeTo, writeTo
 

Method Detail

getContentType

Content.Type getContentType()
Returns the Content Type

Returns:
The Content Type

setContentType

void setContentType(Content.Type type)
Set the Content Type

Parameters:
type - The Content Type

getValueElement

<T extends Element> T getValueElement()
Return the value element or null if type="text", type="html" or type is some non-XML media type

Returns:
The first child element of the atom:content element or null

setValueElement

<T extends Element> void setValueElement(T value)
Set the value element of the content. If the value is a Div, the type attribute will be set to type="xhtml", otherwise, the attribute will be set to type="application/xml"

Parameters:
value - The element to set

getMimeType

javax.activation.MimeType getMimeType()
RFC4287: On the atom:content element, the value of the "type" attribute MAY be one of "text", "html", or "xhtml". Failing that, it MUST conform to the syntax of a MIME media type, but MUST NOT be a composite type. If neither the type attribute nor the src attribute is provided, Atom Processors MUST behave as though the type attribute were present with a value of "text".

Returns:
null if type = text, html or xhtml, otherwise a media type

setMimeType

void setMimeType(java.lang.String type)
RFC4287: On the atom:content element, the value of the "type" attribute MAY be one of "text", "html", or "xhtml". Failing that, it MUST conform to the syntax of a MIME media type, but MUST NOT be a composite type. If neither the type attribute nor the src attribute is provided, Atom Processors MUST behave as though the type attribute were present with a value of "text".

Parameters:
type - The media type
Throws:
MimeTypeParseException - if the media type is malformed

getSrc

org.apache.abdera.i18n.iri.IRI getSrc()

RFC4287: atom:content MAY have a "src" attribute, whose value MUST be an IRI reference. If the "src" attribute is present, atom:content MUST be empty. Atom Processors MAY use the IRI to retrieve the content and MAY choose to ignore remote content or to present it in a different manner than local content.

If the "src" attribute is present, the "type" attribute SHOULD be provided and MUST be a MIME media type, rather than "text", "html", or "xhtml".

Returns:
The IRI value of the src attribute or null if none
Throws:
IRISyntaxException - if the src attribute value is malformed

getResolvedSrc

org.apache.abdera.i18n.iri.IRI getResolvedSrc()
Returns the fully qualified URI form of the content src attribute.

Returns:
The IRI value of the src attribute resolved against the in-scope Base URI
Throws:
IRISyntaxException - if the src attribute value is malformed

setSrc

void setSrc(java.lang.String src)

RFC4287: atom:content MAY have a "src" attribute, whose value MUST be an IRI reference. If the "src" attribute is present, atom:content MUST be empty. Atom Processors MAY use the IRI to retrieve the content and MAY choose to ignore remote content or to present it in a different manner than local content.

If the "src" attribute is present, the "type" attribute SHOULD be provided and MUST be a MIME media type, rather than "text", "html", or "xhtml".

Parameters:
src - The IRI to use as the src attribute value for the content
Throws:
IRISyntaxException - if the src value is malformed

getDataHandler

javax.activation.DataHandler getDataHandler()
Attempts to Base64 decode the string value of the content element.

Returns:
A DataHandler or null
Throws:
java.lang.UnsupportedOperationException - if type = text, html, xhtml, or any application/*+xml, or text/* type

setDataHandler

void setDataHandler(javax.activation.DataHandler dataHandler)
Sets the string value of the content element by Base64 encoding the specifed byte array.

Parameters:
dataHandler - The DataHandler for the binary content requiring Base64 encoding
Throws:
java.lang.UnsupportedOperationException - if type = text, html, xhtml, or any application/*+xml, or text/* type

getValue

java.lang.String getValue()
Returns the string value of this atom:content element

Returns:
The string value

setValue

void setValue(java.lang.String value)
Set the string value of the atom:content element

Parameters:
value - The string value

getWrappedValue

java.lang.String getWrappedValue()
Return the string value of the atom:content element with the enclosing div tag if type="xhtml"

Returns:
The div wrapped value

setWrappedValue

void setWrappedValue(java.lang.String wrappedValue)
Set the string value of the atom:content with the enclosing div tag

Parameters:
wrappedValue - The string value with the wrapping div tag