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 <a class="doclink" href="https://www.w3.org/TR/html5/scripting-1.html#the-script-element"><script></a> 023 * element. 024 * 025 * <h5 class='section'>See Also:</h5> 026 * <ul class='doctree'> 027 * <li class='link'><a class='doclink' href='../../../../../overview-summary.html#juneau-dto.HTML5'>Overview > juneau-dto > HTML5</a> 028 * </ul> 029 */ 030@Bean(typeName="script") 031public class Script extends HtmlElementRawText { 032 033 /** 034 * <a class="doclink" href="https://www.w3.org/TR/html5/scripting-1.html#attr-script-async">async</a> attribute. 035 * 036 * <p> 037 * Execute script asynchronously. 038 * 039 * @param async 040 * The new value for this attribute. 041 * Typically a {@link Boolean} or {@link String}. 042 * @return This object (for method chaining). 043 */ 044 public final Script async(Object async) { 045 attr("async", async); 046 return this; 047 } 048 049 /** 050 * <a class="doclink" href="https://www.w3.org/TR/html5/scripting-1.html#attr-script-charset">charset</a> attribute. 051 * 052 * <p> 053 * Character encoding of the external script resource. 054 * 055 * @param charset The new value for this attribute. 056 * @return This object (for method chaining). 057 */ 058 public final Script charset(String charset) { 059 attr("charset", charset); 060 return this; 061 } 062 063 /** 064 * <a class="doclink" href="https://www.w3.org/TR/html5/scripting-1.html#attr-script-crossorigin">crossorigin</a> 065 * attribute. 066 * 067 * <p> 068 * How the element handles cross-origin requests. 069 * 070 * @param crossorigin The new value for this attribute. 071 * @return This object (for method chaining). 072 */ 073 public final Script crossorigin(String crossorigin) { 074 attr("crossorigin", crossorigin); 075 return this; 076 } 077 078 /** 079 * <a class="doclink" href="https://www.w3.org/TR/html5/scripting-1.html#attr-script-defer">defer</a> attribute. 080 * 081 * <p> 082 * Defer script execution. 083 * 084 * @param defer 085 * The new value for this attribute. 086 * Typically a {@link Boolean} or {@link String}. 087 * @return This object (for method chaining). 088 */ 089 public final Script defer(Object defer) { 090 attr("defer", defer); 091 return this; 092 } 093 094 /** 095 * <a class="doclink" href="https://www.w3.org/TR/html5/scripting-1.html#attr-script-src">src</a> attribute. 096 * 097 * <p> 098 * Address of the resource. 099 * 100 * <p> 101 * The value can be of any of the following types: {@link URI}, {@link URL}, {@link String}. 102 * Strings must be valid URIs. 103 * 104 * <p> 105 * URIs defined by {@link UriResolver} can be used for values. 106 * 107 * @param src 108 * The new value for this attribute. 109 * Typically a {@link URL} or {@link String}. 110 * @return This object (for method chaining). 111 */ 112 public final Script src(Object src) { 113 attrUri("src", src); 114 return this; 115 } 116 117 /** 118 * <a class="doclink" href="https://www.w3.org/TR/html5/scripting-1.html#attr-script-type">type</a> attribute. 119 * 120 * <p> 121 * Type of embedded resource. 122 * 123 * @param type The new value for this attribute. 124 * @return This object (for method chaining). 125 */ 126 public final Script type(String type) { 127 attr("type", type); 128 return this; 129 } 130 131 132 //-------------------------------------------------------------------------------- 133 // Overridden methods 134 //-------------------------------------------------------------------------------- 135 136 @Override /* HtmlElement */ 137 public final Script _class(String _class) { 138 super._class(_class); 139 return this; 140 } 141 142 @Override /* HtmlElement */ 143 public final Script id(String id) { 144 super.id(id); 145 return this; 146 } 147 148 @Override /* HtmlElementText */ 149 public Script text(Object text) { 150 super.text(text); 151 return this; 152 } 153}