001// *************************************************************************************************************************** 002// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file * 003// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file * 004// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance * 005// * with the License. You may obtain a copy of the License at * 006// * * 007// * http://www.apache.org/licenses/LICENSE-2.0 * 008// * * 009// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an * 010// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * 011// * specific language governing permissions and limitations under the License. * 012// *************************************************************************************************************************** 013package org.apache.juneau.dto.atom; 014 015import static org.apache.juneau.xml.annotation.XmlFormat.*; 016 017import org.apache.juneau.annotation.*; 018import org.apache.juneau.xml.annotation.*; 019 020/** 021 * Represents an <c>atomLink</c> construct in the RFC4287 specification. 022 * 023 * <h5 class='figure'>Schema</h5> 024 * <p class='bcode w800'> 025 * atomLink = 026 * element atom:link { 027 * atomCommonAttributes, 028 * attribute href { atomUri }, 029 * attribute rel { atomNCName | atomUri }?, 030 * attribute type { atomMediaType }?, 031 * attribute hreflang { atomLanguageTag }?, 032 * attribute title { text }?, 033 * attribute length { text }?, 034 * undefinedContent 035 * } 036 * </p> 037 * 038 * <ul class='seealso'> 039 * <li class='link'>{@doc DtoAtom} 040 * <li class='jp'>{@doc package-summary.html#TOC} 041 * </ul> 042 */ 043@Bean(typeName="link") 044public class Link extends Common { 045 046 private String href; 047 private String rel; 048 private String type; 049 private String hreflang; 050 private String title; 051 private Integer length; 052 053 054 /** 055 * Normal constructor. 056 * 057 * @param rel The rel of the link. 058 * @param type The type of the link. 059 * @param href The URI of the link. 060 */ 061 public Link(String rel, String type, String href) { 062 rel(rel).type(type).href(href); 063 } 064 065 /** Bean constructor. */ 066 public Link() {} 067 068 069 //----------------------------------------------------------------------------------------------------------------- 070 // Bean properties 071 //----------------------------------------------------------------------------------------------------------------- 072 073 /** 074 * Returns the href of the target of this link. 075 * 076 * @return The href of the target of this link. 077 */ 078 @Xml(format=ATTR) 079 public String getHref() { 080 return href; 081 } 082 083 /** 084 * Sets the href of the target of this link. 085 * 086 * @param href The href of the target of this link. 087 * @return This object (for method chaining). 088 */ 089 @Beanp("href") 090 public Link href(String href) { 091 this.href = href; 092 return this; 093 } 094 095 /** 096 * Returns the rel of this link. 097 * 098 * @return The rel of this link. 099 */ 100 @Xml(format=ATTR) 101 public String getRel() { 102 return rel; 103 } 104 105 /** 106 * Sets the rel of this link. 107 * 108 * @param rel The rel of this link. 109 * @return This object (for method chaining). 110 */ 111 @Beanp("rel") 112 public Link rel(String rel) { 113 this.rel = rel; 114 return this; 115 } 116 117 /** 118 * Returns the content type of the target of this link. 119 * 120 * @return The content type of the target of this link. 121 */ 122 @Xml(format=ATTR) 123 public String getType() { 124 return type; 125 } 126 127 /** 128 * Sets the content type of the target of this link. 129 * 130 * <p> 131 * Must be one of the following: 132 * <ul> 133 * <li><js>"text"</js> 134 * <li><js>"html"</js> 135 * <li><js>"xhtml"</js> 136 * <li><jk>null</jk> (defaults to <js>"text"</js>) 137 * </ul> 138 * 139 * @param type The content type of the target of this link. 140 * @return This object (for method chaining). 141 */ 142 @Beanp("type") 143 public Link type(String type) { 144 this.type = type; 145 return this; 146 } 147 148 /** 149 * Returns the language of the target of this link. 150 * 151 * @return The language of the target of this link. 152 */ 153 @Xml(format=ATTR) 154 public String getHreflang() { 155 return hreflang; 156 } 157 158 /** 159 * Sets the language of the target of this link. 160 * 161 * @param hreflang The language of the target of this link. 162 * @return This object (for method chaining). 163 */ 164 @Beanp("hreflang") 165 public Link hreflang(String hreflang) { 166 this.hreflang = hreflang; 167 return this; 168 } 169 170 /** 171 * Returns the title of the target of this link. 172 * 173 * @return The title of the target of this link. 174 */ 175 @Xml(format=ATTR) 176 public String getTitle() { 177 return title; 178 } 179 180 /** 181 * Sets the title of the target of this link. 182 * 183 * @param title The title of the target of this link. 184 * @return This object (for method chaining). 185 */ 186 @Beanp("title") 187 public Link title(String title) { 188 this.title = title; 189 return this; 190 } 191 192 /** 193 * Returns the length of the contents of the target of this link. 194 * 195 * @return The length of the contents of the target of this link. 196 */ 197 @Xml(format=ATTR) 198 public Integer getLength() { 199 return length; 200 } 201 202 /** 203 * Sets the length of the contents of the target of this link. 204 * 205 * @param length The length of the contents of the target of this link. 206 * @return This object (for method chaining). 207 */ 208 @Beanp("length") 209 public Link length(Integer length) { 210 this.length = length; 211 return this; 212 } 213 214 215 //----------------------------------------------------------------------------------------------------------------- 216 // Overridden setters (to simplify method chaining) 217 //----------------------------------------------------------------------------------------------------------------- 218 219 @Override /* Common */ 220 public Link base(Object base) { 221 super.base(base); 222 return this; 223 } 224 225 @Override /* Common */ 226 public Link lang(String lang) { 227 super.lang(lang); 228 return this; 229 } 230}