yarfraw.core.datamodel
Class Content

java.lang.Object
  extended by yarfraw.core.datamodel.Content
All Implemented Interfaces:
Serializable

public class Content
extends Object

  • Rss 2.0 - This is not officially supported, but if there's a <content:encoded /> element under <Item>, the content of the encoded element will be mapped to this class. The type will always be 'text' in this case.
  • Rss 1.0 - This is not officially supported, but if there's a <content:encoded /> element under <Item>, the content of the encoded element will be mapped to this class. The type will always be 'text' in this case.
  • Atom 1.0 - Data model of the 'atom:content' element in Atom 1.0 specs.
    http://atompub.org/2005/07/11/draft-ietf-atompub-format-10.html#atomContent
    If the content is XHTML, the xhtml elements can be found at the 'otherElements' list.
  • Author:
    jliang
    See Also:
    Serialized Form

    Field Summary
    protected  String _about
               
    protected  String _base
               
    protected  String _lang
               
    protected  Map<QName,String> _otherAttributes
               
    protected  List<Element> _otherElements
               
    protected  String _resource
               
     
    Constructor Summary
    Content()
               
    Content(String contentText)
               
     
    Method Summary
     Content addContentText(String contentText)
              Any text content.
     Content addOtherAttributes(QName namespace, String attribute)
              Add an attribute that is not in the RSS 2.0 specs.
     Content addOtherElement(Element element)
              Add an element that is not specified in the Rss specs.
    **Note** The element should not have an empty namespace to avoid collision with the specs elements.
     Content addOtherElement(String xmlString)
              Add an element that is not specified in the Rss specs.
    **Note** The element should not have an empty namespace to avoid collision with the specs elements.
     boolean equals(Object other)
               
     String getAbout()
              This maps to the required 'about' attribute that present of all second level elements (channel, image, item, and textinput).
     String getAttributeValueByLocalName(String localName)
              Search for attributes that are not in the spec by its local name.
     String getAttributeValueByQName(QName name)
              Search for attributes that are not in the spec by its QName.
     String getBase()
              This maps to the 'base' attribute that is common in all Atom 1.0 elements.
     List<String> getContentText()
              Any text content.
     Element getElementByLocalName(String localName)
              Search through the other element list and return the FIRST element that matches the input localName.
     Element getElementByNS(String namespaceURI, String localName)
              Search through the other element list and return the first element that matches both input the namespaceURI and the localName.
     String getLang()
              The language attribute indicates the language that is used by the enclosed element.
     Locale getLangAsLocale()
              The language attribute indicates the language that is used by the enclosed element.
     Map<QName,String> getOtherAttributes()
              Any other attribute that is not in the RSS specs.
     List<Element> getOtherElements()
              Other additional elements that are not in the Rss specs.
     String getResource()
              This maps to the optional 'resource' attribute that present in some Rss 1.0 elements.
     String getSrc()
              Atom 1.0 only
    atom:content MAY have a "src" attribute, whose value MUST be an IRI reference [RFC3987].
     String getType()
              Atom 1.0 only
    On the atom:content element, the value of the "type" attribute MAY be one of "text", "html", or "xhtml".
     int hashCode()
               
     Content setBase(String base)
              Atom 1.0 only
    Any element defined by this specification MAY have an xml:base attribute [W3C.REC-xmlbase-20010627].
     Content setContentText(List<String> contentText)
              Any text content.
     Content setLang(Locale lang)
              Rss 2.0 - <language> element.
     Content setLang(String lang)
              Rss 2.0 - <language> element.
     Content setOtherAttributes(Map<QName,String> otherAttributes)
              Any other attribute that is not in the RSS 2.0 specs.
     Content setOtherElements(List<Element> otherElements)
              Other additional elements that are not in the Rss specs.
    **Note** The element should not have an empty namespace to avoid collision with the specs elements.
     Content setSrc(String src)
              Atom 1.0 only
    atom:content MAY have a "src" attribute, whose value MUST be an IRI reference [RFC3987].
     Content setType(String type)
              Atom 1.0 only
    On the atom:content element, the value of the "type" attribute MAY be one of "text", "html", or "xhtml".
     String toString()
               
     void validate(FeedFormat format)
               
     
    Methods inherited from class java.lang.Object
    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
     

    Field Detail

    _base

    protected String _base

    _lang

    protected String _lang

    _resource

    protected String _resource

    _about

    protected String _about

    _otherAttributes

    protected Map<QName,String> _otherAttributes

    _otherElements

    protected List<Element> _otherElements
    Constructor Detail

    Content

    public Content()

    Content

    public Content(String contentText)
    Method Detail

    addContentText

    public Content addContentText(String contentText)
    Any text content.


    getContentText

    public List<String> getContentText()
    Any text content.


    setContentText

    public Content setContentText(List<String> contentText)
    Any text content.


    getSrc

    public String getSrc()
    Atom 1.0 only
    atom:content MAY have a "src" attribute, whose value MUST be an IRI reference [RFC3987]. If the "src" attribute is present, atom:content MUST be empty. Atom Processors MAY use the IRI to retrieve the content, and MAY chose to ignore remote content or 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 [MIMEREG], rather than "text", "html", or "xhtml". The value is advisory; that is to say, when the corresponding URI (mapped from an IRI, if necessary), is dereferenced, if the server providing that content also provides a media type, the server-provided media type is authoritative.


    setSrc

    public Content setSrc(String src)
    Atom 1.0 only
    atom:content MAY have a "src" attribute, whose value MUST be an IRI reference [RFC3987]. If the "src" attribute is present, atom:content MUST be empty. Atom Processors MAY use the IRI to retrieve the content, and MAY chose to ignore remote content or 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 [MIMEREG], rather than "text", "html", or "xhtml". The value is advisory; that is to say, when the corresponding URI (mapped from an IRI, if necessary), is dereferenced, if the server providing that content also provides a media type, the server-provided media type is authoritative.


    getType

    public String getType()
    Atom 1.0 only
    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 (see Section 4.2.6 of [MIMEREG]). If the type attribute is not provided, Atom Processors MUST behave as though it were present with a value of "text".


    setType

    public Content setType(String type)
    Atom 1.0 only
    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 (see Section 4.2.6 of [MIMEREG]). If the type attribute is not provided, Atom Processors MUST behave as though it were present with a value of "text".


    setOtherAttributes

    public Content setOtherAttributes(Map<QName,String> otherAttributes)
    Any other attribute that is not in the RSS 2.0 specs.


    addOtherAttributes

    public Content addOtherAttributes(QName namespace,
                                      String attribute)
    Add an attribute that is not in the RSS 2.0 specs.


    setOtherElements

    public Content setOtherElements(List<Element> otherElements)
    Other additional elements that are not in the Rss specs.
    **Note** The element should not have an empty namespace to avoid collision with the specs elements.


    addOtherElement

    public Content addOtherElement(Element element)
    Add an element that is not specified in the Rss specs.
    **Note** The element should not have an empty namespace to avoid collision with the specs elements.

    Parameters:
    element - - any element

    addOtherElement

    public Content addOtherElement(String xmlString)
                            throws SAXException,
                                   IOException,
                                   ParserConfigurationException
    Add an element that is not specified in the Rss specs.
    **Note** The element should not have an empty namespace to avoid collision with the specs elements.

    Parameters:
    xmlString - - any element
    Throws:
    ParserConfigurationException
    IOException
    SAXException

    setBase

    public Content setBase(String base)
    Atom 1.0 only
    Any element defined by this specification MAY have an xml:base attribute [W3C.REC-xmlbase-20010627]. When xml:base is used in an Atom Document, it serves the function described in section 5.1.1 of [RFC3986], establishing the base URI (or IRI) for resolving any relative references found within the effective scope of the xml:base attribute.

    Parameters:
    base -
    Returns:

    setLang

    public Content setLang(String lang)
  • Rss 2.0 - <language> element. The language the channel is written in. This allows aggregators to group all Italian language sites, for example, on a single page. A list of allowable values for this element, as provided by Netscape, is here. You may also use values defined by the W3C. Only <channel> support this element.
  • Rss 1.0 - <dc:language> element. A language of the intellectual content of the resource. Only <channel> and <item> support this element.
  • Atom 1.0 - 'lang' attribute

  • Note: for Rss 2.0 and Rss 1.0, only <channel> and <item>

    Parameters:
    lang -
    Returns:

    setLang

    public Content setLang(Locale lang)
  • Rss 2.0 - <language> element. The language the channel is written in. This allows aggregators to group all Italian language sites, for example, on a single page. A list of allowable values for this element, as provided by Netscape, is here. You may also use values defined by the W3C. Only <channel> support this element.
  • Rss 1.0 - <dc:language> element. A language of the intellectual content of the resource. Only <channel> and <item> support this element.
  • Atom 1.0 - 'lang' attribute

  • Note: for Rss 2.0 and Rss 1.0, only <channel> and <item>

    Parameters:
    lang -
    Returns:

    validate

    public void validate(FeedFormat format)
                  throws ValidationException
    Throws:
    ValidationException

    getBase

    public String getBase()
    This maps to the 'base' attribute that is common in all Atom 1.0 elements. Other FeedFormat will ignore this attribute.

    Returns:
    - attribute value.

    getLang

    public String getLang()
    The language attribute indicates the language that is used by the enclosed element.

    Returns:
    - attribute value.

    getLangAsLocale

    public Locale getLangAsLocale()
    The language attribute indicates the language that is used by the enclosed element.

    Returns:
    - a new Locale Object by parsing the lang attribute.

    getResource

    public String getResource()
    This maps to the optional 'resource' attribute that present in some Rss 1.0 elements. Other FeedFormat will ignore this attribute.

    Returns:
    - attribute value.

    getAbout

    public String getAbout()
    This maps to the required 'about' attribute that present of all second level elements (channel, image, item, and textinput). Other FeedFormat will ignore this attribute.

    Returns:
    - attribute value.

    getOtherElements

    public List<Element> getOtherElements()
    Other additional elements that are not in the Rss specs.


    getElementByNS

    public Element getElementByNS(String namespaceURI,
                                  String localName)
    Search through the other element list and return the first element that matches both input the namespaceURI and the localName.

    Parameters:
    namespaceURI - - namespaceURI of the element to be search for
    localName - - localName of the element
    Returns:
    - null if no matching element is found, the matching element otherwise.

    getElementByLocalName

    public Element getElementByLocalName(String localName)
    Search through the other element list and return the FIRST element that matches the input localName.

    Parameters:
    localName - - localName of the element
    Returns:
    - null if no matching element is found, the matching element otherwise.

    getOtherAttributes

    public Map<QName,String> getOtherAttributes()
    Any other attribute that is not in the RSS specs.


    getAttributeValueByLocalName

    public String getAttributeValueByLocalName(String localName)
    Search for attributes that are not in the spec by its local name.

    Parameters:
    localName - localName of the attribute
    Returns:
    null if attribute is not found, the value of the attribute otherwise

    getAttributeValueByQName

    public String getAttributeValueByQName(QName name)
    Search for attributes that are not in the spec by its QName.

    Parameters:
    name - QName of the attribute
    Returns:
    null if attribute is not found, the value of the attribute otherwise

    toString

    public String toString()
    Overrides:
    toString in class Object

    equals

    public boolean equals(Object other)
    Overrides:
    equals in class Object

    hashCode

    public int hashCode()
    Overrides:
    hashCode in class Object


    Copyright © 2008. All Rights Reserved.