yarfraw.core.datamodel
Class Link

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

public class Link
extends Object

  • Rss 2.0 and Rss 1.0 - the <link> element. The href field will be used as the text content of the <link> element.
  • Atom 1.0 - The "atom:link" element defines a reference from an entry or feed to a Web resource. This specification assigns no meaning to the content (if any) of this element.
    Please note that in an Atom feed, there is no elements for 'enclosure' (@see Enclosure) objects. You can, however, add enclosure object to an Atom feed using this class.
  • 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
    Link()
               
    Link(String href)
               
    Link(String href, String rel, String type, String hreflang, String title, Integer length)
               
     
    Method Summary
     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.
     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 getHref()
              Rss 1.0 & Rss 2.0 - text content of the <link> element Atom 1.0 - The "href" attribute contains the link's IRI.
     String getHreflang()
              Atom 1.0 only
    The "hreflang" attribute's content describes the language of the resource pointed to by the href attribute.
     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.
     Integer getLength()
              Atom 1.0 only
    The "length" attribute indicates an advisory length of the linked content in octets; it is a hint about the content length of the representation returned when the IRI in the href attribute is mapped to a URI and dereferenced.
     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 getRel()
              Atom 1.0 only
    atom:link elements MAY have a "rel" attribute that indicates the link relation type.
     String getResource()
              This maps to the optional 'resource' attribute that present in some Rss 1.0 elements.
     String getTitle()
              Atom 1.0 only
    The "title" attribute conveys human-readable information about the link.
     String getType()
              Atom 1.0 only
    On the link element, the "type" attribute's value is an advisory media type; it is a hint about the type of the representation that is expected to be returned when the value of the href attribute is dereferenced.
     int hashCode()
               
     Link setBase(String base)
              Atom 1.0 only
    Any element defined by this specification MAY have an xml:base attribute [W3C.REC-xmlbase-20010627].
     Link setHref(String href)
              Rss 1.0 & Rss 2.0 - text content of the <link> element Atom 1.0 - The "href" attribute contains the link's IRI.
     Link setHreflang(Locale hreflang)
              Atom 1.0 only
    The "hreflang" attribute's content describes the language of the resource pointed to by the href attribute.
     Link setHreflang(String hreflang)
              Atom 1.0 only
    The "hreflang" attribute's content describes the language of the resource pointed to by the href attribute.
     Link setLang(Locale lang)
              Rss 2.0 - <language> element.
     Link setLang(String lang)
              Rss 2.0 - <language> element.
     Link setLength(Integer length)
              Atom 1.0 only
    The "length" attribute indicates an advisory length of the linked content in octets; it is a hint about the content length of the representation returned when the IRI in the href attribute is mapped to a URI and dereferenced.
     Link setRel(String rel)
              Atom 1.0 only
    atom:link elements MAY have a "rel" attribute that indicates the link relation type.
     Link setTitle(String title)
              Atom 1.0 only
    The "title" attribute conveys human-readable information about the link.
     Link setType(String type)
              Atom 1.0 only
    On the link element, the "type" attribute's value is an advisory media type; it is a hint about the type of the representation that is expected to be returned when the value of the href attribute is dereferenced.
     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

    Link

    public Link()

    Link

    public Link(String href)

    Link

    public Link(String href,
                String rel,
                String type,
                String hreflang,
                String title,
                Integer length)
    Method Detail

    getHref

    public String getHref()
  • Rss 1.0 & Rss 2.0 - text content of the <link> element
  • Atom 1.0 - The "href" attribute contains the link's IRI. atom:link elements MUST have a href attribute, whose value MUST be a IRI reference [RFC3987].

  • setHref

    public Link setHref(String href)
  • Rss 1.0 & Rss 2.0 - text content of the <link> element
  • Atom 1.0 - The "href" attribute contains the link's IRI. atom:link elements MUST have a href attribute, whose value MUST be a IRI reference [RFC3987].

  • getRel

    public String getRel()
    Atom 1.0 only
    atom:link elements MAY have a "rel" attribute that indicates the link relation type. If the "rel" attribute is not present, the link element MUST be interpreted as if the link relation type is "alternate".


    setRel

    public Link setRel(String rel)
    Atom 1.0 only
    atom:link elements MAY have a "rel" attribute that indicates the link relation type. If the "rel" attribute is not present, the link element MUST be interpreted as if the link relation type is "alternate".


    getType

    public String getType()
    Atom 1.0 only
    On the link element, the "type" attribute's value is an advisory media type; it is a hint about the type of the representation that is expected to be returned when the value of the href attribute is dereferenced. Note that the type attribute does not override the actual media type returned with the representation. Link elements MAY have a type attribute, whose value MUST conform to the syntax of a MIME media type [MIMEREG].


    setType

    public Link setType(String type)
    Atom 1.0 only
    On the link element, the "type" attribute's value is an advisory media type; it is a hint about the type of the representation that is expected to be returned when the value of the href attribute is dereferenced. Note that the type attribute does not override the actual media type returned with the representation. Link elements MAY have a type attribute, whose value MUST conform to the syntax of a MIME media type [MIMEREG].


    getHreflang

    public String getHreflang()
    Atom 1.0 only
    The "hreflang" attribute's content describes the language of the resource pointed to by the href attribute. When used together with the rel="alternate", it implies a translated version of the entry. Link elements MAY have an hreflang attribute, whose value MUST be a language tag [RFC3066].


    setHreflang

    public Link setHreflang(String hreflang)
    Atom 1.0 only
    The "hreflang" attribute's content describes the language of the resource pointed to by the href attribute. When used together with the rel="alternate", it implies a translated version of the entry. Link elements MAY have an hreflang attribute, whose value MUST be a language tag [RFC3066].


    setHreflang

    public Link setHreflang(Locale hreflang)
    Atom 1.0 only
    The "hreflang" attribute's content describes the language of the resource pointed to by the href attribute. When used together with the rel="alternate", it implies a translated version of the entry. Link elements MAY have an hreflang attribute, whose value MUST be a language tag [RFC3066].


    getTitle

    public String getTitle()
    Atom 1.0 only
    The "title" attribute conveys human-readable information about the link. The content of the "title" attribute is Language-Sensitive. Link elements MAY have a title attribute.


    setTitle

    public Link setTitle(String title)
    Atom 1.0 only
    The "title" attribute conveys human-readable information about the link. The content of the "title" attribute is Language-Sensitive. Link elements MAY have a title attribute.


    getLength

    public Integer getLength()
    Atom 1.0 only
    The "length" attribute indicates an advisory length of the linked content in octets; it is a hint about the content length of the representation returned when the IRI in the href attribute is mapped to a URI and dereferenced. Note that the length attribute does not override the actual content length of the representation as reported by the underlying protocol. Link elements MAY have a length attribute.


    setLength

    public Link setLength(Integer length)
    Atom 1.0 only
    The "length" attribute indicates an advisory length of the linked content in octets; it is a hint about the content length of the representation returned when the IRI in the href attribute is mapped to a URI and dereferenced. Note that the length attribute does not override the actual content length of the representation as reported by the underlying protocol. Link elements MAY have a length attribute.


    setBase

    public Link 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 Link 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:

    setLang

    public Link 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:

    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.