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 org.apache.juneau.annotation.*;
020import org.apache.juneau.common.utils.*;
021import org.apache.juneau.internal.*;
022
023/**
024 * DTO for an HTML <a class="doclink" href="https://www.w3.org/TR/html5/document-metadata.html#the-style-element">&lt;style&gt;</a>
025 * element.
026 *
027 * <p>
028 * The style element allows authors to embed CSS style information in their documents. It contains
029 * CSS rules that apply to the document. The style element is typically placed in the head section
030 * of the document, but can also be used inline. The CSS contained within the style element is
031 * processed by the browser and applied to the document.
032 *
033 * <h5 class='section'>Examples:</h5>
034 * <p class='bcode w800'>
035 *    <jk>import static</jk> org.apache.juneau.bean.html5.HtmlBuilder.*;
036 * 
037 *    <jc>// Basic CSS styles</jc>
038 *    Style <jv>basic</jv> = <jsm>style</jsm>()
039 *       .text(<js>"body { font-family: Arial, sans-serif; }"</js>);
040 * 
041 *    <jc>// CSS with media query</jc>
042 *    Style <jv>responsive</jv> = <jsm>style</jsm>()
043 *       .media(<js>"screen and (max-width: 600px)"</js>)
044 *       .text(<js>"body { font-size: 14px; }"</js>);
045 * 
046 *    <jc>// Multiple CSS rules</jc>
047 *    Style <jv>multiple</jv> = <jsm>style</jsm>()
048 *       .text(
049 *          <js>"h1 { color: blue; }"</js>,
050 *          <js>"p { margin: 10px; }"</js>,
051 *          <js>".highlight { background-color: yellow; }"</js>
052 *       );
053 * 
054 *    <jc>// CSS with type specification</jc>
055 *    Style <jv>typed</jv> = <jsm>style</jsm>()
056 *       .type(<js>"text/css"</js>)
057 *       .text(<js>".button { padding: 10px; background: #007bff; }"</js>);
058 * 
059 *    <jc>// Print-specific styles</jc>
060 *    Style <jv>print</jv> = <jsm>style</jsm>()
061 *       .media(<js>"print"</js>)
062 *       .text(<js>"body { color: black; background: white; }"</js>);
063 * </p>
064 *
065 * <p>
066 * The following convenience methods are provided for constructing instances of this bean:
067 * <ul class='javatree'>
068 *    <li class='jc'>{@link HtmlBuilder}
069 *    <ul class='javatree'>
070 *       <li class='jm'>{@link HtmlBuilder#style() style()}
071 *       <li class='jm'>{@link HtmlBuilder#style(Object, Object...) style(Object, Object...)}
072 *    </ul>
073 * </ul>
074 * </p>
075 *
076 * <h5 class='section'>See Also:</h5><ul>
077 *    <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/JuneauBeanHtml5">juneau-bean-html5</a>
078 * </ul>
079 */
080@Bean(typeName="style")
081public class Style extends HtmlElementRawText {
082
083   /**
084    * Creates an empty {@link Style} element.
085    */
086   public Style() {}
087
088   /**
089    * Creates a {@link Style} element with the specified {@link Style#text(Object)} node.
090    *
091    * @param text The {@link Style#text(Object)} node.
092    */
093   public Style(Object text) {
094      text(text);
095   }
096
097   /**
098    * Creates a {@link Style} element with the specified inner text.
099    *
100    * @param text
101    *    The contents of the style element.
102    *    <br>Values will be concatenated with newlines.
103    */
104   public Style(String...text) {
105      text(Utils.joinnl(text));
106   }
107
108   /**
109    * <a class="doclink" href="https://www.w3.org/TR/html5/document-metadata.html#attr-style-media">media</a> attribute.
110    *
111    * <p>
112    * Specifies the media types for which the stylesheet applies. This allows you to target
113    * specific devices or media types.
114    *
115    * <p>
116    * Common values:
117    * <ul>
118    *    <li><js>"all"</js> - All media types (default)</li>
119    *    <li><js>"screen"</js> - Computer screens</li>
120    *    <li><js>"print"</js> - Printers and print preview</li>
121    *    <li><js>"handheld"</js> - Handheld devices</li>
122    *    <li><js>"projection"</js> - Projectors</li>
123    *    <li><js>"tv"</js> - Television</li>
124    * </ul>
125    *
126    * @param media The media types for which the stylesheet applies.
127    * @return This object.
128    */
129   public Style media(String value) {
130      attr("media", value);
131      return this;
132   }
133
134   /**
135    * <a class="doclink" href="https://www.w3.org/TR/html5/document-metadata.html#attr-style-type">type</a> attribute.
136    *
137    * <p>
138    * Type of embedded resource.
139    *
140    * @param type The new value for this attribute.
141    * @return This object.
142    */
143   public Style type(String value) {
144      attr("type", value);
145      return this;
146   }
147
148   //-----------------------------------------------------------------------------------------------------------------
149   // Overridden methods
150   //-----------------------------------------------------------------------------------------------------------------
151   @Override /* Overridden from HtmlElement */
152   public Style _class(String value) {  // NOSONAR - Intentional naming.
153      super._class(value);
154      return this;
155   }
156
157   @Override /* Overridden from HtmlElement */
158   public Style accesskey(String value) {
159      super.accesskey(value);
160      return this;
161   }
162
163   @Override /* Overridden from HtmlElement */
164   public Style contenteditable(Object value) {
165      super.contenteditable(value);
166      return this;
167   }
168
169   @Override /* Overridden from HtmlElement */
170   public Style dir(String value) {
171      super.dir(value);
172      return this;
173   }
174
175   @Override /* Overridden from HtmlElement */
176   public Style hidden(Object value) {
177      super.hidden(value);
178      return this;
179   }
180
181   @Override /* Overridden from HtmlElement */
182   public Style id(String value) {
183      super.id(value);
184      return this;
185   }
186
187   @Override /* Overridden from HtmlElement */
188   public Style lang(String value) {
189      super.lang(value);
190      return this;
191   }
192
193   @Override /* Overridden from HtmlElement */
194   public Style onabort(String value) {
195      super.onabort(value);
196      return this;
197   }
198
199   @Override /* Overridden from HtmlElement */
200   public Style onblur(String value) {
201      super.onblur(value);
202      return this;
203   }
204
205   @Override /* Overridden from HtmlElement */
206   public Style oncancel(String value) {
207      super.oncancel(value);
208      return this;
209   }
210
211   @Override /* Overridden from HtmlElement */
212   public Style oncanplay(String value) {
213      super.oncanplay(value);
214      return this;
215   }
216
217   @Override /* Overridden from HtmlElement */
218   public Style oncanplaythrough(String value) {
219      super.oncanplaythrough(value);
220      return this;
221   }
222
223   @Override /* Overridden from HtmlElement */
224   public Style onchange(String value) {
225      super.onchange(value);
226      return this;
227   }
228
229   @Override /* Overridden from HtmlElement */
230   public Style onclick(String value) {
231      super.onclick(value);
232      return this;
233   }
234
235   @Override /* Overridden from HtmlElement */
236   public Style oncuechange(String value) {
237      super.oncuechange(value);
238      return this;
239   }
240
241   @Override /* Overridden from HtmlElement */
242   public Style ondblclick(String value) {
243      super.ondblclick(value);
244      return this;
245   }
246
247   @Override /* Overridden from HtmlElement */
248   public Style ondurationchange(String value) {
249      super.ondurationchange(value);
250      return this;
251   }
252
253   @Override /* Overridden from HtmlElement */
254   public Style onemptied(String value) {
255      super.onemptied(value);
256      return this;
257   }
258
259   @Override /* Overridden from HtmlElement */
260   public Style onended(String value) {
261      super.onended(value);
262      return this;
263   }
264
265   @Override /* Overridden from HtmlElement */
266   public Style onerror(String value) {
267      super.onerror(value);
268      return this;
269   }
270
271   @Override /* Overridden from HtmlElement */
272   public Style onfocus(String value) {
273      super.onfocus(value);
274      return this;
275   }
276
277   @Override /* Overridden from HtmlElement */
278   public Style oninput(String value) {
279      super.oninput(value);
280      return this;
281   }
282
283   @Override /* Overridden from HtmlElement */
284   public Style oninvalid(String value) {
285      super.oninvalid(value);
286      return this;
287   }
288
289   @Override /* Overridden from HtmlElement */
290   public Style onkeydown(String value) {
291      super.onkeydown(value);
292      return this;
293   }
294
295   @Override /* Overridden from HtmlElement */
296   public Style onkeypress(String value) {
297      super.onkeypress(value);
298      return this;
299   }
300
301   @Override /* Overridden from HtmlElement */
302   public Style onkeyup(String value) {
303      super.onkeyup(value);
304      return this;
305   }
306
307   @Override /* Overridden from HtmlElement */
308   public Style onload(String value) {
309      super.onload(value);
310      return this;
311   }
312
313   @Override /* Overridden from HtmlElement */
314   public Style onloadeddata(String value) {
315      super.onloadeddata(value);
316      return this;
317   }
318
319   @Override /* Overridden from HtmlElement */
320   public Style onloadedmetadata(String value) {
321      super.onloadedmetadata(value);
322      return this;
323   }
324
325   @Override /* Overridden from HtmlElement */
326   public Style onloadstart(String value) {
327      super.onloadstart(value);
328      return this;
329   }
330
331   @Override /* Overridden from HtmlElement */
332   public Style onmousedown(String value) {
333      super.onmousedown(value);
334      return this;
335   }
336
337   @Override /* Overridden from HtmlElement */
338   public Style onmouseenter(String value) {
339      super.onmouseenter(value);
340      return this;
341   }
342
343   @Override /* Overridden from HtmlElement */
344   public Style onmouseleave(String value) {
345      super.onmouseleave(value);
346      return this;
347   }
348
349   @Override /* Overridden from HtmlElement */
350   public Style onmousemove(String value) {
351      super.onmousemove(value);
352      return this;
353   }
354
355   @Override /* Overridden from HtmlElement */
356   public Style onmouseout(String value) {
357      super.onmouseout(value);
358      return this;
359   }
360
361   @Override /* Overridden from HtmlElement */
362   public Style onmouseover(String value) {
363      super.onmouseover(value);
364      return this;
365   }
366
367   @Override /* Overridden from HtmlElement */
368   public Style onmouseup(String value) {
369      super.onmouseup(value);
370      return this;
371   }
372
373   @Override /* Overridden from HtmlElement */
374   public Style onmousewheel(String value) {
375      super.onmousewheel(value);
376      return this;
377   }
378
379   @Override /* Overridden from HtmlElement */
380   public Style onpause(String value) {
381      super.onpause(value);
382      return this;
383   }
384
385   @Override /* Overridden from HtmlElement */
386   public Style onplay(String value) {
387      super.onplay(value);
388      return this;
389   }
390
391   @Override /* Overridden from HtmlElement */
392   public Style onplaying(String value) {
393      super.onplaying(value);
394      return this;
395   }
396
397   @Override /* Overridden from HtmlElement */
398   public Style onprogress(String value) {
399      super.onprogress(value);
400      return this;
401   }
402
403   @Override /* Overridden from HtmlElement */
404   public Style onratechange(String value) {
405      super.onratechange(value);
406      return this;
407   }
408
409   @Override /* Overridden from HtmlElement */
410   public Style onreset(String value) {
411      super.onreset(value);
412      return this;
413   }
414
415   @Override /* Overridden from HtmlElement */
416   public Style onresize(String value) {
417      super.onresize(value);
418      return this;
419   }
420
421   @Override /* Overridden from HtmlElement */
422   public Style onscroll(String value) {
423      super.onscroll(value);
424      return this;
425   }
426
427   @Override /* Overridden from HtmlElement */
428   public Style onseeked(String value) {
429      super.onseeked(value);
430      return this;
431   }
432
433   @Override /* Overridden from HtmlElement */
434   public Style onseeking(String value) {
435      super.onseeking(value);
436      return this;
437   }
438
439   @Override /* Overridden from HtmlElement */
440   public Style onselect(String value) {
441      super.onselect(value);
442      return this;
443   }
444
445   @Override /* Overridden from HtmlElement */
446   public Style onshow(String value) {
447      super.onshow(value);
448      return this;
449   }
450
451   @Override /* Overridden from HtmlElement */
452   public Style onstalled(String value) {
453      super.onstalled(value);
454      return this;
455   }
456
457   @Override /* Overridden from HtmlElement */
458   public Style onsubmit(String value) {
459      super.onsubmit(value);
460      return this;
461   }
462
463   @Override /* Overridden from HtmlElement */
464   public Style onsuspend(String value) {
465      super.onsuspend(value);
466      return this;
467   }
468
469   @Override /* Overridden from HtmlElement */
470   public Style ontimeupdate(String value) {
471      super.ontimeupdate(value);
472      return this;
473   }
474
475   @Override /* Overridden from HtmlElement */
476   public Style ontoggle(String value) {
477      super.ontoggle(value);
478      return this;
479   }
480
481   @Override /* Overridden from HtmlElement */
482   public Style onvolumechange(String value) {
483      super.onvolumechange(value);
484      return this;
485   }
486
487   @Override /* Overridden from HtmlElement */
488   public Style onwaiting(String value) {
489      super.onwaiting(value);
490      return this;
491   }
492
493   @Override /* Overridden from HtmlElement */
494   public Style spellcheck(Object value) {
495      super.spellcheck(value);
496      return this;
497   }
498
499   @Override /* Overridden from HtmlElement */
500   public Style style(String value) {
501      super.style(value);
502      return this;
503   }
504
505   @Override /* Overridden from HtmlElement */
506   public Style tabindex(Object value) {
507      super.tabindex(value);
508      return this;
509   }
510
511   @Override /* Overridden from HtmlElement */
512   public Style title(String value) {
513      super.title(value);
514      return this;
515   }
516
517   @Override /* Overridden from HtmlElement */
518   public Style translate(Object value) {
519      super.translate(value);
520      return this;
521   }
522
523   @Override /* Overridden from HtmlElementRawText */
524   public Style text(Object value) {
525      super.text(value);
526      return this;
527   }
528}