org.gedcomx.links
Class Link

java.lang.Object
  extended by org.gedcomx.links.Link
All Implemented Interfaces:
HasJsonKey

public class Link
extends Object
implements HasJsonKey

A hypermedia link, used to drive the state of a hypermedia-enabled genealogical data application.

Author:
Ryan Heaton
See Also:
RFC 5988, Atom Syndication Format, Section 4.2.7

Field Summary
static Set<String> NON_UNIQUE_RELS
          The list of link rels that support multi-valued links.
 
Constructor Summary
Link()
           
Link(String rel, URI href)
           
 
Method Summary
 Link accept(String accept)
          Build out this link with an accept.
 Link allow(String allow)
          Build out this link with an 'allow'.
 Link count(Integer count)
          Build out this link with a count.
 String getAccept()
          Metadata about the acceptable media type(s) that can be used to update (i.e.
 String getAllow()
          Metadata about the allowable methods that can be used to transition to the resource being linked.
 Integer getCount()
          The number of elements in the page, if this link refers to a page of resources.
 URI getHref()
          The target IRI of the link.
 String getHreflang()
          The language of the resource being linked to.
 String getHttpHeaderValue()
          Format this link as a Link header per RFC 5988.
 String getJsonKey()
          The json key that is used define this link in a map.
 Integer getOffset()
          The index of the offset of the page, if this link refers to a page of resources.
 String getRel()
          The link relationship.
 Integer getResults()
          The total number of results in the page to which this links, if this link refers to a page of resources.
 String getTemplate()
          A URI template per RFC 6570, used to link to a range of URIs, such as for the purpose of linking to a query.
 String getTitle()
          Human-readable information about the link.
 String getType()
          Metadata about the available media type(s) of the resource being linked to.
 Link href(URI href)
          Build out this link with an href.
 Link hreflang(String hreflang)
          Build out this link with an href lang.
 boolean isHasUniqueKey()
           
 Link offset(Integer offset)
          Build out this link with an offset.
 Link rel(String rel)
          Build out this link with a rel.
 Link results(Integer results)
          Build out this link with total results.
 void setAccept(String accept)
          Metadata about the media type(s) that can be used to update (i.e.
 void setAllow(String allow)
          Metadata about the allowable methods that can be used to transition to the resource being linked.
 void setCount(Integer count)
          The number of elements in the page, if this link refers to a page of resources.
 void setHref(URI href)
          The link URI.
 void setHreflang(String hreflang)
          The language of the resource being linked to.
 void setJsonKey(String jsonKey)
          The json key that is used define this link in a map.
 void setOffset(Integer offset)
          The index of the offset of the page, if this link refers to a page of resources.
 void setRel(String rel)
          The link relationship.
 void setResults(Integer results)
          The total number of results in the page to which this links, if this link refers to a page of resources.
 void setTemplate(String template)
          A URI template per RFC 6570, used to link to a range of URIs, such as for the purpose of linking to a query.
 void setTitle(String title)
          Human-readable information about the link.
 void setType(String type)
          Metadata about the available media type(s) of the resource being linked to.
 Link template(String template)
          Build out this link with a template.
 Link title(String title)
          Build out this link with a title.
 String toString()
           
 Link type(String type)
          Build out this link with a type.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NON_UNIQUE_RELS

public static final Set<String> NON_UNIQUE_RELS
The list of link rels that support multi-valued links. Be careful about editing this because it might break backwards-compatibility with JSON clients.

Constructor Detail

Link

public Link(String rel,
            URI href)

Link

public Link()
Method Detail

isHasUniqueKey

public boolean isHasUniqueKey()
Specified by:
isHasUniqueKey in interface HasJsonKey

getRel

public String getRel()
The link relationship.

Returns:
The link relationship.

setRel

public void setRel(String rel)
The link relationship.

Parameters:
rel - The link relationship.

rel

public Link rel(String rel)
Build out this link with a rel.

Parameters:
rel - The rel.
Returns:
this.

getJsonKey

public String getJsonKey()
The json key that is used define this link in a map.

Specified by:
getJsonKey in interface HasJsonKey
Returns:
The json key that is used define this link in a map.

setJsonKey

public void setJsonKey(String jsonKey)
The json key that is used define this link in a map.

Specified by:
setJsonKey in interface HasJsonKey
Parameters:
jsonKey - The json key that is used define this link in a map.

getHref

public URI getHref()
The target IRI of the link.

Returns:
The target IRI of the link.

setHref

public void setHref(URI href)
The link URI.

Parameters:
href - The link URI.

href

public Link href(URI href)
Build out this link with an href.

Parameters:
href - The href.
Returns:
this.

getTemplate

public String getTemplate()
A URI template per RFC 6570, used to link to a range of URIs, such as for the purpose of linking to a query. A link specifying a template can be formally referred to as a "Templated Link (LT)" per Amundsen, M. (2011). Hypermedia APIs with HTML5 and Node. O'Reilly.

Returns:
A URI template per RFC 6570, used to link to a range of URIs, such as for the purpose of linking to a query.

setTemplate

public void setTemplate(String template)
A URI template per RFC 6570, used to link to a range of URIs, such as for the purpose of linking to a query. A link specifying a template can be formally referred to as a "Templated Link (LT)" per Amundsen, M. (2011). Hypermedia APIs with HTML5 and Node. O'Reilly.

Parameters:
template - A URI template per RFC 6570, used to link to a range of URIs, such as for the purpose of linking to a query.

template

public Link template(String template)
Build out this link with a template.

Parameters:
template - The template
Returns:
this.

getType

public String getType()
Metadata about the available media type(s) of the resource being linked to. The value of the "type" attribute is as defined by the HTTP specification, RFC 2616, Section 3.7. Note that this attribute can be considered an "Update Control (CU)" per Amundsen, M. (2011). Hypermedia APIs with HTML5 and Node. O'Reilly.

Returns:
Metadata about the available media type(s) of the resource being linked to.

setType

public void setType(String type)
Metadata about the available media type(s) of the resource being linked to. The value of the "type" attribute is as defined by the HTTP specification, RFC 2616, Section 3.7. Note that this attribute can be considered an "Read Control (CR)" per Amundsen, M. (2011). Hypermedia APIs with HTML5 and Node. O'Reilly.

Parameters:
type - Metadata about the available media type(s) of the resource being linked to.

type

public Link type(String type)
Build out this link with a type.

Parameters:
type - The type.
Returns:
this.

getAccept

public String getAccept()
Metadata about the acceptable media type(s) that can be used to update (i.e. change the state of) the resource being linked to. The value of the "accept" attribute is as defined by the HTTP specification, RFC 2616, Section 3.7. Note that this attribute can be considered an "Read Control (CR)" per Amundsen, M. (2011). Hypermedia APIs with HTML5 and Node. O'Reilly.

Returns:
Metadata about the available media type(s) of the resource being linked to.

setAccept

public void setAccept(String accept)
Metadata about the media type(s) that can be used to update (i.e. change the state of) the resource being linked to. The value of the "accept" attribute is as defined by the HTTP specification, RFC 2616, Section 3.7. Note that this attribute can be considered an "Update Control (CU)" per Amundsen, M. (2011). Hypermedia APIs with HTML5 and Node. O'Reilly.

Parameters:
accept - Metadata about the available media type(s) of the resource being linked to.

accept

public Link accept(String accept)
Build out this link with an accept.

Parameters:
accept - The accept.
Returns:
this.

getAllow

public String getAllow()
Metadata about the allowable methods that can be used to transition to the resource being linked. The value of the "allow" attribute is as defined by the HTTP specification, RFC 2616, Section 14.7. Note that this attribute can be considered an "Method Control (CM)" per Amundsen, M. (2011). Hypermedia APIs with HTML5 and Node. O'Reilly.

Returns:
Metadata about the available media type(s) of the resource being linked to.

setAllow

public void setAllow(String allow)
Metadata about the allowable methods that can be used to transition to the resource being linked. The value of the "allow" attribute is as defined by the HTTP specification, RFC 2616, Section 14.7. Note that this attribute can be considered an "Method Control (CM)" per Amundsen, M. (2011). Hypermedia APIs with HTML5 and Node. O'Reilly.

Parameters:
allow - Metadata about the available media type(s) of the resource being linked to.

allow

public Link allow(String allow)
Build out this link with an 'allow'.

Parameters:
allow - The allow.
Returns:
this.

getHreflang

public String getHreflang()
The language of the resource being linked to. Note that this attribute can be considered an "Update Control (CU)" per Amundsen, M. (2011). Hypermedia APIs with HTML5 and Node. O'Reilly.

Returns:
The language of the resource being linked to.

setHreflang

public void setHreflang(String hreflang)
The language of the resource being linked to. Note that this attribute can be considered an "Update Control (CU)" per Amundsen, M. (2011). Hypermedia APIs with HTML5 and Node. O'Reilly.

Parameters:
hreflang - The language of the resource being linked to.

hreflang

public Link hreflang(String hreflang)
Build out this link with an href lang.

Parameters:
hreflang - The hreflang.
Returns:
this.

getTitle

public String getTitle()
Human-readable information about the link.

Returns:
Human-readable information about the link.

setTitle

public void setTitle(String title)
Human-readable information about the link.

Parameters:
title - Human-readable information about the link.

title

public Link title(String title)
Build out this link with a title.

Parameters:
title - The title.
Returns:
this.

getCount

public Integer getCount()
The number of elements in the page, if this link refers to a page of resources.

Returns:
The number of elements in the page, if this link refers to a page of resources.

setCount

public void setCount(Integer count)
The number of elements in the page, if this link refers to a page of resources.

Parameters:
count - The number of elements in the page, if this link refers to a page of resources.

count

public Link count(Integer count)
Build out this link with a count.

Parameters:
count - The count.
Returns:
this.

getOffset

public Integer getOffset()
The index of the offset of the page, if this link refers to a page of resources.

Returns:
The index of the offset of the page, if this link refers to a page of resources.

setOffset

public void setOffset(Integer offset)
The index of the offset of the page, if this link refers to a page of resources.

Parameters:
offset - The index of the offset of the page, if this link refers to a page of resources.

offset

public Link offset(Integer offset)
Build out this link with an offset.

Parameters:
offset - The offset.
Returns:
this.

getResults

public Integer getResults()
The total number of results in the page to which this links, if this link refers to a page of resources.

Returns:
The total number of results in the page to which this links, if this link refers to a page of resources.

setResults

public void setResults(Integer results)
The total number of results in the page to which this links, if this link refers to a page of resources.

Parameters:
results - The total number of results in the page to which this links, if this link refers to a page of resources.

results

public Link results(Integer results)
Build out this link with total results.

Parameters:
results - The total results count.
Returns:
this.

getHttpHeaderValue

public String getHttpHeaderValue()
Format this link as a Link header per RFC 5988.

Returns:
The value of this link formatted per RFC 5988.

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2015. All rights reserved.