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