001/*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.apache.juneau.bean.html5;
018
019import java.net.*;
020
021import org.apache.juneau.*;
022import org.apache.juneau.annotation.*;
023
024/**
025 * DTO for an HTML <a class="doclink" href="https://www.w3.org/TR/html5/document-metadata.html#the-link-element">&lt;link&gt;</a>
026 * element.
027 *
028 * <p>
029 * The link element specifies relationships between the current document and an external resource.
030 * It is most commonly used to link to stylesheets, but can also be used to establish site icons,
031 * prefetch resources, define alternate versions of the document, and more. Link elements are typically
032 * placed in the head section of an HTML document.
033 *
034 * <h5 class='section'>Examples:</h5>
035 * <p class='bcode w800'>
036 *    <jc>// Stylesheet link</jc>
037 *    Link <jv>stylesheet</jv> = <jsm>link</jsm>()
038 *       .rel(<js>"stylesheet"</js>)
039 *       .href(<js>"/css/styles.css"</js>);
040 *
041 *    <jc>// Favicon link</jc>
042 *    Link <jv>favicon</jv> = <jsm>link</jsm>()
043 *       .rel(<js>"icon"</js>)
044 *       .type(<js>"image/x-icon"</js>)
045 *       .href(<js>"/favicon.ico"</js>);
046 *
047 *    <jc>// Preload resource</jc>
048 *    Link <jv>preload</jv> = <jsm>link</jsm>()
049 *       .rel(<js>"preload"</js>)
050 *       .href(<js>"/fonts/myfont.woff2"</js>)
051 *       ._as(<js>"font"</js>)
052 *       .type(<js>"font/woff2"</js>)
053 *       .crossorigin(<js>"anonymous"</js>);
054 *
055 *    <jc>// Alternate language version</jc>
056 *    Link <jv>alternate</jv> = <jsm>link</jsm>()
057 *       .rel(<js>"alternate"</js>)
058 *       .href(<js>"/es/page.html"</js>)
059 *       .hreflang(<js>"es"</js>);
060 *
061 *    <jc>// Responsive stylesheet with media query</jc>
062 *    Link <jv>print</jv> = <jsm>link</jsm>()
063 *       .rel(<js>"stylesheet"</js>)
064 *       .href(<js>"/css/print.css"</js>)
065 *       .media(<js>"print"</js>);
066 *
067 *    <jc>// Canonical URL for SEO</jc>
068 *    Link <jv>canonical</jv> = <jsm>link</jsm>()
069 *       .rel(<js>"canonical"</js>)
070 *       .href(<js>"https://example.com/page"</js>);
071 *
072 *    <jc>// DNS prefetch for performance</jc>
073 *    Link <jv>dnsPrefetch</jv> = <jsm>link</jsm>()
074 *       .rel(<js>"dns-prefetch"</js>)
075 *       .href(<js>"https://cdn.example.com"</js>);
076 * </p>
077 *
078 * <p>
079 * The following convenience methods are provided for constructing instances of this bean:
080 * <ul class='javatree'>
081 *    <li class='jc'>{@link HtmlBuilder}
082 *    <ul class='javatree'>
083 *       <li class='jm'>{@link HtmlBuilder#link() link()}
084 *    </ul>
085 * </ul>
086 * </p>
087 *
088 * <h5 class='section'>See Also:</h5><ul>
089 *    <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/JuneauBeanHtml5">juneau-bean-html5</a>
090 * </ul>
091 */
092@Bean(typeName = "link")
093public class Link extends HtmlElementVoid {
094
095   /**
096    * Creates an empty {@link Link} element.
097    */
098   public Link() {}
099
100   /**
101    * Creates a {@link Link} element with the specified {@link Link#href(Object)} attribute.
102    *
103    * @param href The {@link Link#href(Object)} attribute.
104    */
105   public Link(Object href) {
106      href(href);
107   }
108
109   @Override /* Overridden from HtmlElement */
110   public Link _class(String value) { // NOSONAR - Intentional naming.
111      super._class(value);
112      return this;
113   }
114
115   @Override /* Overridden from HtmlElement */
116   public Link accesskey(String value) {
117      super.accesskey(value);
118      return this;
119   }
120
121   @Override /* Overridden from HtmlElement */
122   public Link attr(String key, Object val) {
123      super.attr(key, val);
124      return this;
125   }
126
127   @Override /* Overridden from HtmlElement */
128   public Link attrUri(String key, Object val) {
129      super.attrUri(key, val);
130      return this;
131   }
132
133   @Override /* Overridden from HtmlElement */
134   public Link contenteditable(Object value) {
135      super.contenteditable(value);
136      return this;
137   }
138
139   /**
140    * <a class="doclink" href="https://www.w3.org/TR/html5/document-metadata.html#attr-link-crossorigin">crossorigin</a>
141    * attribute.
142    *
143    * <p>
144    * Specifies how the element handles cross-origin requests for CORS (Cross-Origin Resource Sharing).
145    *
146    * <p>
147    * Possible values:
148    * <ul>
149    *    <li><js>"anonymous"</js> - Cross-origin requests are made without credentials</li>
150    *    <li><js>"use-credentials"</js> - Cross-origin requests include credentials</li>
151    * </ul>
152    *
153    * @param value How to handle cross-origin requests.
154    * @return This object.
155    */
156   public Link crossorigin(String value) {
157      attr("crossorigin", value);
158      return this;
159   }
160
161   @Override /* Overridden from HtmlElement */
162   public Link dir(String value) {
163      super.dir(value);
164      return this;
165   }
166
167   @Override /* Overridden from HtmlElement */
168   public Link hidden(Object value) {
169      super.hidden(value);
170      return this;
171   }
172
173   /**
174    * <a class="doclink" href="https://www.w3.org/TR/html5/document-metadata.html#attr-link-href">href</a> attribute.
175    *
176    * <p>
177    * Address of the hyperlink.
178    *
179    * <p>
180    * The value can be of any of the following types: {@link URI}, {@link URL}, {@link String}.
181    * Strings must be valid URIs.
182    *
183    * <p>
184    * URIs defined by {@link UriResolver} can be used for values.
185    *
186    * @param value
187    *    The new value for this attribute.
188    *    Typically a {@link URL} or {@link String}.
189    * @return This object.
190    */
191   public Link href(Object value) {
192      attrUri("href", value);
193      return this;
194   }
195
196   /**
197    * <a class="doclink" href="https://www.w3.org/TR/html5/document-metadata.html#attr-link-hreflang">hreflang</a>
198    * attribute.
199    *
200    * <p>
201    * Specifies the language of the linked resource. Used for SEO and accessibility purposes.
202    *
203    * <p>
204    * Examples:
205    * <ul>
206    *    <li><js>"en"</js> - English</li>
207    *    <li><js>"es"</js> - Spanish</li>
208    *    <li><js>"fr"</js> - French</li>
209    *    <li><js>"de"</js> - German</li>
210    *    <li><js>"zh"</js> - Chinese</li>
211    *    <li><js>"ja"</js> - Japanese</li>
212    * </ul>
213    *
214    * @param value The language code of the linked resource.
215    * @return This object.
216    */
217   public Link hreflang(String value) {
218      attr("hreflang", value);
219      return this;
220   }
221
222   @Override /* Overridden from HtmlElement */
223   public Link id(String value) {
224      super.id(value);
225      return this;
226   }
227
228   @Override /* Overridden from HtmlElement */
229   public Link lang(String value) {
230      super.lang(value);
231      return this;
232   }
233
234   /**
235    * <a class="doclink" href="https://www.w3.org/TR/html5/document-metadata.html#attr-link-media">media</a> attribute.
236    *
237    * <p>
238    * Specifies which media types the linked resource applies to. Used primarily with stylesheets.
239    *
240    * <p>
241    * Common values:
242    * <ul>
243    *    <li><js>"all"</js> - All media types (default)</li>
244    *    <li><js>"screen"</js> - Computer screens</li>
245    *    <li><js>"print"</js> - Printers and print preview</li>
246    *    <li><js>"handheld"</js> - Handheld devices</li>
247    *    <li><js>"projection"</js> - Projectors</li>
248    *    <li><js>"(max-width: 768px)"</js> - Media queries</li>
249    * </ul>
250    *
251    * @param value The media types the linked resource applies to.
252    * @return This object.
253    */
254   public Link media(String value) {
255      attr("media", value);
256      return this;
257   }
258
259   @Override /* Overridden from HtmlElement */
260   public Link onabort(String value) {
261      super.onabort(value);
262      return this;
263   }
264
265   @Override /* Overridden from HtmlElement */
266   public Link onblur(String value) {
267      super.onblur(value);
268      return this;
269   }
270
271   @Override /* Overridden from HtmlElement */
272   public Link oncancel(String value) {
273      super.oncancel(value);
274      return this;
275   }
276
277   @Override /* Overridden from HtmlElement */
278   public Link oncanplay(String value) {
279      super.oncanplay(value);
280      return this;
281   }
282
283   @Override /* Overridden from HtmlElement */
284   public Link oncanplaythrough(String value) {
285      super.oncanplaythrough(value);
286      return this;
287   }
288
289   @Override /* Overridden from HtmlElement */
290   public Link onchange(String value) {
291      super.onchange(value);
292      return this;
293   }
294
295   @Override /* Overridden from HtmlElement */
296   public Link onclick(String value) {
297      super.onclick(value);
298      return this;
299   }
300
301   @Override /* Overridden from HtmlElement */
302   public Link oncuechange(String value) {
303      super.oncuechange(value);
304      return this;
305   }
306
307   @Override /* Overridden from HtmlElement */
308   public Link ondblclick(String value) {
309      super.ondblclick(value);
310      return this;
311   }
312
313   @Override /* Overridden from HtmlElement */
314   public Link ondurationchange(String value) {
315      super.ondurationchange(value);
316      return this;
317   }
318
319   @Override /* Overridden from HtmlElement */
320   public Link onemptied(String value) {
321      super.onemptied(value);
322      return this;
323   }
324
325   @Override /* Overridden from HtmlElement */
326   public Link onended(String value) {
327      super.onended(value);
328      return this;
329   }
330
331   @Override /* Overridden from HtmlElement */
332   public Link onerror(String value) {
333      super.onerror(value);
334      return this;
335   }
336
337   @Override /* Overridden from HtmlElement */
338   public Link onfocus(String value) {
339      super.onfocus(value);
340      return this;
341   }
342
343   @Override /* Overridden from HtmlElement */
344   public Link oninput(String value) {
345      super.oninput(value);
346      return this;
347   }
348
349   @Override /* Overridden from HtmlElement */
350   public Link oninvalid(String value) {
351      super.oninvalid(value);
352      return this;
353   }
354
355   @Override /* Overridden from HtmlElement */
356   public Link onkeydown(String value) {
357      super.onkeydown(value);
358      return this;
359   }
360
361   @Override /* Overridden from HtmlElement */
362   public Link onkeypress(String value) {
363      super.onkeypress(value);
364      return this;
365   }
366
367   @Override /* Overridden from HtmlElement */
368   public Link onkeyup(String value) {
369      super.onkeyup(value);
370      return this;
371   }
372
373   @Override /* Overridden from HtmlElement */
374   public Link onload(String value) {
375      super.onload(value);
376      return this;
377   }
378
379   @Override /* Overridden from HtmlElement */
380   public Link onloadeddata(String value) {
381      super.onloadeddata(value);
382      return this;
383   }
384
385   @Override /* Overridden from HtmlElement */
386   public Link onloadedmetadata(String value) {
387      super.onloadedmetadata(value);
388      return this;
389   }
390
391   @Override /* Overridden from HtmlElement */
392   public Link onloadstart(String value) {
393      super.onloadstart(value);
394      return this;
395   }
396
397   @Override /* Overridden from HtmlElement */
398   public Link onmousedown(String value) {
399      super.onmousedown(value);
400      return this;
401   }
402
403   @Override /* Overridden from HtmlElement */
404   public Link onmouseenter(String value) {
405      super.onmouseenter(value);
406      return this;
407   }
408
409   @Override /* Overridden from HtmlElement */
410   public Link onmouseleave(String value) {
411      super.onmouseleave(value);
412      return this;
413   }
414
415   @Override /* Overridden from HtmlElement */
416   public Link onmousemove(String value) {
417      super.onmousemove(value);
418      return this;
419   }
420
421   @Override /* Overridden from HtmlElement */
422   public Link onmouseout(String value) {
423      super.onmouseout(value);
424      return this;
425   }
426
427   @Override /* Overridden from HtmlElement */
428   public Link onmouseover(String value) {
429      super.onmouseover(value);
430      return this;
431   }
432
433   @Override /* Overridden from HtmlElement */
434   public Link onmouseup(String value) {
435      super.onmouseup(value);
436      return this;
437   }
438
439   @Override /* Overridden from HtmlElement */
440   public Link onmousewheel(String value) {
441      super.onmousewheel(value);
442      return this;
443   }
444
445   @Override /* Overridden from HtmlElement */
446   public Link onpause(String value) {
447      super.onpause(value);
448      return this;
449   }
450
451   @Override /* Overridden from HtmlElement */
452   public Link onplay(String value) {
453      super.onplay(value);
454      return this;
455   }
456
457   @Override /* Overridden from HtmlElement */
458   public Link onplaying(String value) {
459      super.onplaying(value);
460      return this;
461   }
462
463   @Override /* Overridden from HtmlElement */
464   public Link onprogress(String value) {
465      super.onprogress(value);
466      return this;
467   }
468
469   @Override /* Overridden from HtmlElement */
470   public Link onratechange(String value) {
471      super.onratechange(value);
472      return this;
473   }
474
475   @Override /* Overridden from HtmlElement */
476   public Link onreset(String value) {
477      super.onreset(value);
478      return this;
479   }
480
481   @Override /* Overridden from HtmlElement */
482   public Link onresize(String value) {
483      super.onresize(value);
484      return this;
485   }
486
487   @Override /* Overridden from HtmlElement */
488   public Link onscroll(String value) {
489      super.onscroll(value);
490      return this;
491   }
492
493   @Override /* Overridden from HtmlElement */
494   public Link onseeked(String value) {
495      super.onseeked(value);
496      return this;
497   }
498
499   @Override /* Overridden from HtmlElement */
500   public Link onseeking(String value) {
501      super.onseeking(value);
502      return this;
503   }
504
505   @Override /* Overridden from HtmlElement */
506   public Link onselect(String value) {
507      super.onselect(value);
508      return this;
509   }
510
511   @Override /* Overridden from HtmlElement */
512   public Link onshow(String value) {
513      super.onshow(value);
514      return this;
515   }
516
517   @Override /* Overridden from HtmlElement */
518   public Link onstalled(String value) {
519      super.onstalled(value);
520      return this;
521   }
522
523   @Override /* Overridden from HtmlElement */
524   public Link onsubmit(String value) {
525      super.onsubmit(value);
526      return this;
527   }
528
529   @Override /* Overridden from HtmlElement */
530   public Link onsuspend(String value) {
531      super.onsuspend(value);
532      return this;
533   }
534
535   @Override /* Overridden from HtmlElement */
536   public Link ontimeupdate(String value) {
537      super.ontimeupdate(value);
538      return this;
539   }
540
541   @Override /* Overridden from HtmlElement */
542   public Link ontoggle(String value) {
543      super.ontoggle(value);
544      return this;
545   }
546
547   @Override /* Overridden from HtmlElement */
548   public Link onvolumechange(String value) {
549      super.onvolumechange(value);
550      return this;
551   }
552
553   @Override /* Overridden from HtmlElement */
554   public Link onwaiting(String value) {
555      super.onwaiting(value);
556      return this;
557   }
558
559   /**
560    * <a class="doclink" href="https://www.w3.org/TR/html5/document-metadata.html#attr-link-rel">rel</a> attribute.
561    *
562    * <p>
563    * Specifies the relationship between the current document and the linked resource.
564    *
565    * <p>
566    * Common values:
567    * <ul>
568    *    <li><js>"stylesheet"</js> - External CSS stylesheet</li>
569    *    <li><js>"icon"</js> - Favicon or site icon</li>
570    *    <li><js>"canonical"</js> - Canonical URL for SEO</li>
571    *    <li><js>"alternate"</js> - Alternative version of the page</li>
572    *    <li><js>"preload"</js> - Resource to preload</li>
573    *    <li><js>"prefetch"</js> - Resource to prefetch</li>
574    *    <li><js>"dns-prefetch"</js> - DNS lookup to prefetch</li>
575    *    <li><js>"next"</js> - Next page in a sequence</li>
576    *    <li><js>"prev"</js> - Previous page in a sequence</li>
577    * </ul>
578    *
579    * @param value The relationship between the document and linked resource.
580    * @return This object.
581    */
582   public Link rel(String value) {
583      attr("rel", value);
584      return this;
585   }
586
587   /**
588    * <a class="doclink" href="https://www.w3.org/TR/html5/links.html#attr-link-sizes">sizes</a> attribute.
589    *
590    * <p>
591    * Specifies the sizes of icons for different device contexts. Used with <c>rel="icon"</c> or <c>rel="apple-touch-icon"</c>.
592    *
593    * <p>
594    * Common values:
595    * <ul>
596    *    <li><js>"16x16"</js> - Small favicon</li>
597    *    <li><js>"32x32"</js> - Standard favicon</li>
598    *    <li><js>"180x180"</js> - Apple touch icon</li>
599    *    <li><js>"192x192"</js> - Android icon</li>
600    *    <li><js>"512x512"</js> - Large icon</li>
601    *    <li><js>"any"</js> - Any size</li>
602    * </ul>
603    *
604    * @param value The sizes of the linked icon resource.
605    * @return This object.
606    */
607   public Link sizes(String value) {
608      attr("sizes", value);
609      return this;
610   }
611
612   @Override /* Overridden from HtmlElement */
613   public Link spellcheck(Object value) {
614      super.spellcheck(value);
615      return this;
616   }
617
618   @Override /* Overridden from HtmlElement */
619   public Link style(String value) {
620      super.style(value);
621      return this;
622   }
623
624   @Override /* Overridden from HtmlElement */
625   public Link tabindex(Object value) {
626      super.tabindex(value);
627      return this;
628   }
629
630   @Override /* Overridden from HtmlElement */
631   public Link title(String value) {
632      super.title(value);
633      return this;
634   }
635
636   @Override /* Overridden from HtmlElement */
637   public Link translate(Object value) {
638      super.translate(value);
639      return this;
640   }
641
642   /**
643    * <a class="doclink" href="https://www.w3.org/TR/html5/document-metadata.html#attr-link-type">type</a> attribute.
644    *
645    * <p>
646    * Specifies the MIME type of the linked resource. Helps browsers determine how to handle the resource.
647    *
648    * <p>
649    * Common values:
650    * <ul>
651    *    <li><js>"text/css"</js> - CSS stylesheet</li>
652    *    <li><js>"text/javascript"</js> - JavaScript file</li>
653    *    <li><js>"application/json"</js> - JSON data</li>
654    *    <li><js>"image/png"</js> - PNG image</li>
655    *    <li><js>"image/jpeg"</js> - JPEG image</li>
656    *    <li><js>"image/svg+xml"</js> - SVG image</li>
657    *    <li><js>"font/woff2"</js> - Web font</li>
658    * </ul>
659    *
660    * @param value The MIME type of the linked resource.
661    * @return This object.
662    */
663   public Link type(String value) {
664      attr("type", value);
665      return this;
666   }
667}