Package org.gedcomx.links
Class Link
- java.lang.Object
-
- 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
Fields Modifier and Type Field Description static Set<String>NON_UNIQUE_RELSThe list of link rels that support multi-valued links.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Linkaccept(String accept)Build out this link with an accept.Linkallow(String allow)Build out this link with an 'allow'.Linkcount(Integer count)Build out this link with a count.StringgetAccept()Metadata about the acceptable media type(s) that can be used to update (i.e.StringgetAllow()Metadata about the allowable methods that can be used to transition to the resource being linked.IntegergetCount()The number of elements in the page, if this link refers to a page of resources.URIgetHref()The target IRI of the link.StringgetHreflang()The language of the resource being linked to.StringgetHttpHeaderValue()Format this link as a Link header per RFC 5988.StringgetJsonKey()The json key that is used define this link in a map.IntegergetOffset()The index of the offset of the page, if this link refers to a page of resources.StringgetRel()The link relationship.IntegergetResults()The total number of results in the page to which this links, if this link refers to a page of resources.StringgetTemplate()A URI template per RFC 6570, used to link to a range of URIs, such as for the purpose of linking to a query.StringgetTitle()Human-readable information about the link.StringgetType()Metadata about the available media type(s) of the resource being linked to.Linkhref(URI href)Build out this link with an href.Linkhreflang(String hreflang)Build out this link with an href lang.booleanisHasUniqueKey()Linkoffset(Integer offset)Build out this link with an offset.Linkrel(String rel)Build out this link with a rel.Linkresults(Integer results)Build out this link with total results.voidsetAccept(String accept)Metadata about the media type(s) that can be used to update (i.e.voidsetAllow(String allow)Metadata about the allowable methods that can be used to transition to the resource being linked.voidsetCount(Integer count)The number of elements in the page, if this link refers to a page of resources.voidsetHref(URI href)The link URI.voidsetHreflang(String hreflang)The language of the resource being linked to.voidsetJsonKey(String jsonKey)The json key that is used define this link in a map.voidsetOffset(Integer offset)The index of the offset of the page, if this link refers to a page of resources.voidsetRel(String rel)The link relationship.voidsetResults(Integer results)The total number of results in the page to which this links, if this link refers to a page of resources.voidsetTemplate(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.voidsetTitle(String title)Human-readable information about the link.voidsetType(String type)Metadata about the available media type(s) of the resource being linked to.Linktemplate(String template)Build out this link with a template.Linktitle(String title)Build out this link with a title.StringtoString()Linktype(String type)Build out this link with a type.
-
-
-
Method Detail
-
isHasUniqueKey
public boolean isHasUniqueKey()
- Specified by:
isHasUniqueKeyin interfaceHasJsonKey
-
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:
getJsonKeyin interfaceHasJsonKey- 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:
setJsonKeyin interfaceHasJsonKey- 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.
-
-