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.html5; 014 015import java.net.*; 016import java.net.URI; 017 018import org.apache.juneau.*; 019import org.apache.juneau.annotation.*; 020 021/** 022 * DTO for an HTML {@doc ExtHTML5.document-metadata#the-link-element <link>} 023 * element. 024 * 025 * <ul class='seealso'> 026 * <li class='link'>{@doc DtoHtml5} 027 * </ul> 028 */ 029@Bean(typeName="link") 030public class Link extends HtmlElementVoid { 031 032 /** 033 * Creates an empty {@link Link} element. 034 */ 035 public Link() {} 036 037 /** 038 * Creates a {@link Link} element with the specified {@link Link#href(Object)} attribute. 039 * 040 * @param href The {@link Link#href(Object)} attribute. 041 */ 042 public Link(Object href) { 043 href(href); 044 } 045 046 /** 047 * {@doc ExtHTML5.document-metadata#attr-link-crossorigin crossorigin} 048 * attribute. 049 * 050 * <p> 051 * How the element handles cross-origin requests. 052 * 053 * @param crossorigin The new value for this attribute. 054 * @return This object (for method chaining). 055 */ 056 public final Link crossorigin(String crossorigin) { 057 attr("crossorigin", crossorigin); 058 return this; 059 } 060 061 /** 062 * {@doc ExtHTML5.document-metadata#attr-link-href href} attribute. 063 * 064 * <p> 065 * Address of the hyperlink. 066 * 067 * <p> 068 * The value can be of any of the following types: {@link URI}, {@link URL}, {@link String}. 069 * Strings must be valid URIs. 070 * 071 * <p> 072 * URIs defined by {@link UriResolver} can be used for values. 073 * 074 * @param href 075 * The new value for this attribute. 076 * Typically a {@link URL} or {@link String}. 077 * @return This object (for method chaining). 078 */ 079 public final Link href(Object href) { 080 attrUri("href", href); 081 return this; 082 } 083 084 /** 085 * {@doc ExtHTML5.document-metadata#attr-link-hreflang hreflang} 086 * attribute. 087 * 088 * <p> 089 * Language of the linked resource. 090 * 091 * @param hreflang The new value for this attribute. 092 * @return This object (for method chaining). 093 */ 094 public final Link hreflang(String hreflang) { 095 attr("hreflang", hreflang); 096 return this; 097 } 098 099 /** 100 * {@doc ExtHTML5.document-metadata#attr-link-media media} attribute. 101 * 102 * <p> 103 * Applicable media. 104 * 105 * @param media The new value for this attribute. 106 * @return This object (for method chaining). 107 */ 108 public final Link media(String media) { 109 attr("media", media); 110 return this; 111 } 112 113 /** 114 * {@doc ExtHTML5.document-metadata#attr-link-rel rel} attribute. 115 * 116 * <p> 117 * Relationship between the document containing the hyperlink and the destination resource. 118 * 119 * @param rel The new value for this attribute. 120 * @return This object (for method chaining). 121 */ 122 public final Link rel(String rel) { 123 attr("rel", rel); 124 return this; 125 } 126 127 /** 128 * {@doc ExtHTML5.links#attr-link-sizes sizes} attribute. 129 * 130 * <p> 131 * Sizes of the icons (for rel="icon"). 132 * 133 * @param sizes The new value for this attribute. 134 * @return This object (for method chaining). 135 */ 136 public final Link sizes(String sizes) { 137 attr("sizes", sizes); 138 return this; 139 } 140 141 /** 142 * {@doc ExtHTML5.document-metadata#attr-link-type type} attribute. 143 * 144 * <p> 145 * Hint for the type of the referenced resource. 146 * 147 * @param type The new value for this attribute. 148 * @return This object (for method chaining). 149 */ 150 public final Link type(String type) { 151 attr("type", type); 152 return this; 153 } 154 155 156 //----------------------------------------------------------------------------------------------------------------- 157 // Overridden methods 158 //----------------------------------------------------------------------------------------------------------------- 159 160 @Override /* HtmlElement */ 161 public final Link _class(String _class) { 162 super._class(_class); 163 return this; 164 } 165 166 @Override /* HtmlElement */ 167 public final Link id(String id) { 168 super.id(id); 169 return this; 170 } 171 172 @Override /* HtmlElement */ 173 public final Link style(String style) { 174 super.style(style); 175 return this; 176 } 177}