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