Author: ivol37 at gmail.com Date: Mon Nov 29 16:35:11 2010 New Revision: 453
Log: [AMDATU-198] Added Atom synd link utility class Added: trunk/amdatu-libraries/utilities/src/main/java/org/amdatu/libraries/utilities/rest/ trunk/amdatu-libraries/utilities/src/main/java/org/amdatu/libraries/utilities/rest/AtomSyndicationLink.java Added: trunk/amdatu-libraries/utilities/src/main/java/org/amdatu/libraries/utilities/rest/AtomSyndicationLink.java ============================================================================== --- (empty file) +++ trunk/amdatu-libraries/utilities/src/main/java/org/amdatu/libraries/utilities/rest/AtomSyndicationLink.java Mon Nov 29 16:35:11 2010 @@ -0,0 +1,111 @@ +/* + Copyright (C) 2010 Amdatu.org + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + */ +package org.amdatu.libraries.utilities.rest; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlRootElement; + +/** + * This class represents an Atom syndication link and can be used to enable HATEOS in RESTful services. + * Since the JAX-RS specification does not come with a definition of this class, we provide it (such that + * dependencies on implementation specific classes like SyndLink in Apache Wink). + * + * @author ivol + */ + at SuppressWarnings("restriction") + at XmlRootElement(name = "link") + at XmlAccessorType(XmlAccessType.NONE) +public class AtomSyndicationLink { + @XmlAttribute(name = "href") + private String m_href; + + @XmlAttribute(name = "rel") + private String m_rel; + + @XmlAttribute(name = "type") + private String m_type; + + /** + * Returns the href attribute of an Atom Syndication link. This is the URL the REST client can traverse to to + * get new information or change the state of the application. + * + * @return the href attribute of an Atom Syndication link + */ + public String getHref() { + return m_href; + } + + /** + * Sets the href attribute of an Atom Syndication link. This is the URL the REST client can traverse to to + * get new information or change the state of the application. + * + * @param href the href attribute of an Atom Syndication link + * @return the Aton Syndication Link itself, according to the Builder pattern + */ + public AtomSyndicationLink setHref(String href) { + m_href = href; + return this; + } + + /** + * Returns the rel attribute of an Atom Syndication link. This attribute represents the relationship between the + * resource and the referenced resource. W3C recommendations can be found on + * http://www.w3.org/TR/html4/struct/links.html#adef-rel + * + * @return the rel attribute of an Atom Syndication link + */ + public String getRel() { + return m_rel; + } + + /** + * Sets the rel attribute of an Atom Syndication link. This attribute represents the relationship between the + * resource and the referenced resource. W3C recommendations can be found on + * http://www.w3.org/TR/html4/struct/links.html#adef-rel + * + * @param rel The rel attribute of an Atom Syndication link + * @return the Aton Syndication Link itself, according to the Builder pattern + */ + public AtomSyndicationLink setRel(String rel) { + m_rel = rel; + return this; + } + + /** + * Returns the type attribute of an Atom Syndication link. The type represents the exchanged media type of the + * resource the URL points to. + * + * @return the type attribute of an Atom Syndication link + */ + public String getType() { + return m_type; + } + + /** + * Sets the type attribute of an Atom Syndication link. The type represents the exchanged media type of the + * resource the URL points to. + * + * @param type The type attribute of an Atom Syndication link + * @return the Aton Syndication Link itself, according to the Builder pattern + */ + public AtomSyndicationLink setType(String type) { + m_type = type; + return this; + } +}
