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 <code>atomLink</code> 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 * <h5 class='section'>See Also:</h5> 039 * <ul class='doctree'> 040 * <li class='link'>{@doc juneau-dto.Atom} 041 * <li class='jp'>{@doc package-summary.html#TOC} 042 * </ul> 043 */ 044@Bean(typeName="link") 045public class Link extends Common { 046 047 private String href; 048 private String rel; 049 private String type; 050 private String hreflang; 051 private String title; 052 private Integer length; 053 054 055 /** 056 * Normal constructor. 057 * 058 * @param rel The rel of the link. 059 * @param type The type of the link. 060 * @param href The URI of the link. 061 */ 062 public Link(String rel, String type, String href) { 063 rel(rel).type(type).href(href); 064 } 065 066 /** Bean constructor. */ 067 public Link() {} 068 069 070 //----------------------------------------------------------------------------------------------------------------- 071 // Bean properties 072 //----------------------------------------------------------------------------------------------------------------- 073 074 /** 075 * Returns the href of the target of this link. 076 * 077 * @return The href of the target of this link. 078 */ 079 @Xml(format=ATTR) 080 public String getHref() { 081 return href; 082 } 083 084 /** 085 * Sets the href of the target of this link. 086 * 087 * @param href The href of the target of this link. 088 * @return This object (for method chaining). 089 */ 090 @BeanProperty("href") 091 public Link href(String href) { 092 this.href = href; 093 return this; 094 } 095 096 /** 097 * Returns the rel of this link. 098 * 099 * @return The rel of this link. 100 */ 101 @Xml(format=ATTR) 102 public String getRel() { 103 return rel; 104 } 105 106 /** 107 * Sets the rel of this link. 108 * 109 * @param rel The rel of this link. 110 * @return This object (for method chaining). 111 */ 112 @BeanProperty("rel") 113 public Link rel(String rel) { 114 this.rel = rel; 115 return this; 116 } 117 118 /** 119 * Returns the content type of the target of this link. 120 * 121 * @return The content type of the target of this link. 122 */ 123 @Xml(format=ATTR) 124 public String getType() { 125 return type; 126 } 127 128 /** 129 * Sets the content type of the target of this link. 130 * 131 * <p> 132 * Must be one of the following: 133 * <ul> 134 * <li><js>"text"</js> 135 * <li><js>"html"</js> 136 * <li><js>"xhtml"</js> 137 * <li><jk>null</jk> (defaults to <js>"text"</js>) 138 * </ul> 139 * 140 * @param type The content type of the target of this link. 141 * @return This object (for method chaining). 142 */ 143 @BeanProperty("type") 144 public Link type(String type) { 145 this.type = type; 146 return this; 147 } 148 149 /** 150 * Returns the language of the target of this link. 151 * 152 * @return The language of the target of this link. 153 */ 154 @Xml(format=ATTR) 155 public String getHreflang() { 156 return hreflang; 157 } 158 159 /** 160 * Sets the language of the target of this link. 161 * 162 * @param hreflang The language of the target of this link. 163 * @return This object (for method chaining). 164 */ 165 @BeanProperty("hreflang") 166 public Link hreflang(String hreflang) { 167 this.hreflang = hreflang; 168 return this; 169 } 170 171 /** 172 * Returns the title of the target of this link. 173 * 174 * @return The title of the target of this link. 175 */ 176 @Xml(format=ATTR) 177 public String getTitle() { 178 return title; 179 } 180 181 /** 182 * Sets the title of the target of this link. 183 * 184 * @param title The title of the target of this link. 185 * @return This object (for method chaining). 186 */ 187 @BeanProperty("title") 188 public Link title(String title) { 189 this.title = title; 190 return this; 191 } 192 193 /** 194 * Returns the length of the contents of the target of this link. 195 * 196 * @return The length of the contents of the target of this link. 197 */ 198 @Xml(format=ATTR) 199 public Integer getLength() { 200 return length; 201 } 202 203 /** 204 * Sets the length of the contents of the target of this link. 205 * 206 * @param length The length of the contents of the target of this link. 207 * @return This object (for method chaining). 208 */ 209 @BeanProperty("length") 210 public Link length(Integer length) { 211 this.length = length; 212 return this; 213 } 214 215 216 //----------------------------------------------------------------------------------------------------------------- 217 // Overridden setters (to simplify method chaining) 218 //----------------------------------------------------------------------------------------------------------------- 219 220 @Override /* Common */ 221 public Link base(Object base) { 222 super.base(base); 223 return this; 224 } 225 226 @Override /* Common */ 227 public Link lang(String lang) { 228 super.lang(lang); 229 return this; 230 } 231}