1 /* 2 Licensed to the Apache Software Foundation (ASF) under one 3 or more contributor license agreements. See the NOTICE file 4 distributed with this work for additional information 5 regarding copyright ownership. The ASF licenses this file 6 to you under the Apache License, Version 2.0 (the 7 "License"); you may not use this file except in compliance 8 with the License. You may obtain a copy of the License at 9 10 http://www.apache.org/licenses/LICENSE-2.0 11 12 Unless required by applicable law or agreed to in writing, 13 software distributed under the License is distributed on an 14 "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 KIND, either express or implied. See the License for the 16 specific language governing permissions and limitations 17 under the License. 18 =================== DO NOT EDIT THIS FILE ==================== 19 Generated by Modello 2.5.1, 20 any modifications will be overwritten. 21 ============================================================== 22 */ 23 24 package org.apache.maven.doxia.site; 25 26 /** 27 * The configuration of an external JS file to be embedded in the 28 * HTML. Leads to an inclusion via the "script" element. 29 * 30 * @version $Revision$ $Date$ 31 */ 32 @SuppressWarnings( "all" ) 33 public class ExternalJs 34 implements java.io.Serializable, java.lang.Cloneable 35 { 36 37 //--------------------------/ 38 //- Class/Member Variables -/ 39 //--------------------------/ 40 41 /** 42 * The URL to include via "script" element with its "src" 43 * attribute in the HTML. 44 */ 45 private String URL; 46 47 /** 48 * The integrity hash to use for the external JS file emitted 49 * in the "script" element's "integrity" attribute. Its 50 * semantics are described in https://www.w3.org/TR/sri-2/ and 51 * its usage is strongly recommended. Some example tools for 52 * calculating the value are outlined in 53 * https://developer.mozilla.org/en-US/docs/Web/Security/Defenses/Subresource_Integrity#tools_for_generating_sri_hashes. 54 */ 55 private String integrity; 56 57 /** 58 * The referrerpolicy attribute to use when requesting the 59 * external JS file. Its semantics are described in 60 * https://www.w3.org/TR/referrer-policy/ and setting it to 61 * "no-referrer" prevents sharing unnecessary information with 62 * 3rd parties. 63 */ 64 private String referrerpolicy = "no-referrer"; 65 66 /** 67 * Other attributes to include in the "script" element for this 68 * external JS file, in the form of a whitespace separated list 69 * of key=value pairs. The keys and values will be included 70 * as-is in the generated "script" element, without any 71 * validation. 72 */ 73 private String otherAttributes; 74 75 76 //-----------/ 77 //- Methods -/ 78 //-----------/ 79 80 /** 81 * Method clone. 82 * 83 * @return ExternalJs 84 */ 85 public ExternalJs clone() 86 { 87 try 88 { 89 ExternalJs copy = (ExternalJs) super.clone(); 90 91 return copy; 92 } 93 catch ( java.lang.Exception ex ) 94 { 95 throw (java.lang.RuntimeException) new java.lang.UnsupportedOperationException( getClass().getName() 96 + " does not support clone()" ).initCause( ex ); 97 } 98 } //-- ExternalJs clone() 99 100 /** 101 * Method equals. 102 * 103 * @param other a other object. 104 * @return boolean 105 */ 106 public boolean equals( Object other ) 107 { 108 if ( this == other ) 109 { 110 return true; 111 } 112 113 if ( !( other instanceof ExternalJs ) ) 114 { 115 return false; 116 } 117 118 ExternalJs that = (ExternalJs) other; 119 boolean result = true; 120 121 result = result && ( getURL() == null ? that.getURL() == null : getURL().equals( that.getURL() ) ); 122 result = result && ( getIntegrity() == null ? that.getIntegrity() == null : getIntegrity().equals( that.getIntegrity() ) ); 123 result = result && ( getReferrerpolicy() == null ? that.getReferrerpolicy() == null : getReferrerpolicy().equals( that.getReferrerpolicy() ) ); 124 result = result && ( getOtherAttributes() == null ? that.getOtherAttributes() == null : getOtherAttributes().equals( that.getOtherAttributes() ) ); 125 126 return result; 127 } //-- boolean equals( Object ) 128 129 /** 130 * Get the integrity hash to use for the external JS file 131 * emitted in the "script" element's "integrity" attribute. Its 132 * semantics are described in https://www.w3.org/TR/sri-2/ and 133 * its usage is strongly recommended. Some example tools for 134 * calculating the value are outlined in 135 * https://developer.mozilla.org/en-US/docs/Web/Security/Defenses/Subresource_Integrity#tools_for_generating_sri_hashes. 136 * 137 * @return String 138 */ 139 public String getIntegrity() 140 { 141 return this.integrity; 142 } //-- String getIntegrity() 143 144 /** 145 * Get other attributes to include in the "script" element for 146 * this external JS file, in the form of a whitespace separated 147 * list of key=value pairs. The keys and values will be 148 * included as-is in the generated "script" element, without 149 * any validation. 150 * 151 * @return String 152 */ 153 public String getOtherAttributes() 154 { 155 return this.otherAttributes; 156 } //-- String getOtherAttributes() 157 158 /** 159 * Get the referrerpolicy attribute to use when requesting the 160 * external JS file. Its semantics are described in 161 * https://www.w3.org/TR/referrer-policy/ and setting it to 162 * "no-referrer" prevents sharing unnecessary information with 163 * 3rd parties. 164 * 165 * @return String 166 */ 167 public String getReferrerpolicy() 168 { 169 return this.referrerpolicy; 170 } //-- String getReferrerpolicy() 171 172 /** 173 * Get the URL to include via "script" element with its "src" 174 * attribute in the HTML. 175 * 176 * @return String 177 */ 178 public String getURL() 179 { 180 return this.URL; 181 } //-- String getURL() 182 183 /** 184 * Method hashCode. 185 * 186 * @return int 187 */ 188 public int hashCode() 189 { 190 int result = 17; 191 192 result = 37 * result + ( URL != null ? URL.hashCode() : 0 ); 193 result = 37 * result + ( integrity != null ? integrity.hashCode() : 0 ); 194 result = 37 * result + ( referrerpolicy != null ? referrerpolicy.hashCode() : 0 ); 195 result = 37 * result + ( otherAttributes != null ? otherAttributes.hashCode() : 0 ); 196 197 return result; 198 } //-- int hashCode() 199 200 /** 201 * Set the integrity hash to use for the external JS file 202 * emitted in the "script" element's "integrity" attribute. Its 203 * semantics are described in https://www.w3.org/TR/sri-2/ and 204 * its usage is strongly recommended. Some example tools for 205 * calculating the value are outlined in 206 * https://developer.mozilla.org/en-US/docs/Web/Security/Defenses/Subresource_Integrity#tools_for_generating_sri_hashes. 207 * 208 * @param integrity a integrity object. 209 */ 210 public void setIntegrity( String integrity ) 211 { 212 this.integrity = integrity; 213 } //-- void setIntegrity( String ) 214 215 /** 216 * Set other attributes to include in the "script" element for 217 * this external JS file, in the form of a whitespace separated 218 * list of key=value pairs. The keys and values will be 219 * included as-is in the generated "script" element, without 220 * any validation. 221 * 222 * @param otherAttributes a otherAttributes object. 223 */ 224 public void setOtherAttributes( String otherAttributes ) 225 { 226 this.otherAttributes = otherAttributes; 227 } //-- void setOtherAttributes( String ) 228 229 /** 230 * Set the referrerpolicy attribute to use when requesting the 231 * external JS file. Its semantics are described in 232 * https://www.w3.org/TR/referrer-policy/ and setting it to 233 * "no-referrer" prevents sharing unnecessary information with 234 * 3rd parties. 235 * 236 * @param referrerpolicy a referrerpolicy object. 237 */ 238 public void setReferrerpolicy( String referrerpolicy ) 239 { 240 this.referrerpolicy = referrerpolicy; 241 } //-- void setReferrerpolicy( String ) 242 243 /** 244 * Set the URL to include via "script" element with its "src" 245 * attribute in the HTML. 246 * 247 * @param URL a URL object. 248 */ 249 public void setURL( String URL ) 250 { 251 this.URL = URL; 252 } //-- void setURL( String ) 253 254 /** 255 * Method toString. 256 * 257 * @return String 258 */ 259 public java.lang.String toString() 260 { 261 StringBuilder buf = new StringBuilder( 128 ); 262 263 buf.append( "URL = '" ); 264 buf.append( getURL() ); 265 buf.append( "'" ); 266 buf.append( "\n" ); 267 buf.append( "integrity = '" ); 268 buf.append( getIntegrity() ); 269 buf.append( "'" ); 270 buf.append( "\n" ); 271 buf.append( "referrerpolicy = '" ); 272 buf.append( getReferrerpolicy() ); 273 buf.append( "'" ); 274 buf.append( "\n" ); 275 buf.append( "otherAttributes = '" ); 276 buf.append( getOtherAttributes() ); 277 buf.append( "'" ); 278 279 return buf.toString(); 280 } //-- java.lang.String toString() 281 282 283 /** 284 * @return the "script" element to include in the HTML for this external JS file. 285 */ 286 public String asScriptTag() { 287 StringBuilder sb = new StringBuilder(); 288 sb.append( "<script src=\"" ).append( URL ).append( "\"" ); 289 if ( integrity != null ) { 290 sb.append( " integrity=\"" ).append( integrity ).append( "\"" ); 291 sb.append( " crossorigin=\"anonymous\"" ); 292 } 293 if ( referrerpolicy != null ) { 294 sb.append( " referrerpolicy=\"" ).append( referrerpolicy ).append( "\"" ); 295 } 296 if ( otherAttributes != null ) { 297 sb.append( " " ).append( otherAttributes ); 298 } 299 sb.append( "></script>" ); 300 return sb.toString(); 301 } 302 303 }