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.commons.bean.*; 020import org.apache.juneau.marshall.xml.*; 021 022/** 023 * A subclass of HTML elements that contain text only. 024 * 025 * <h5 class='section'>See Also:</h5><ul> 026 * <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/JuneauBeanHtml5">juneau-bean-html5</a> 027 * </ul> 028 * 029 * @param <SELF> The self type for fluent setters. 030 */ 031@SuppressWarnings({ 032 "java:S119" // 'SELF' (CRTP self-type) is intentional and clearer than a single-letter name. 033}) 034public abstract class HtmlElementText<SELF extends HtmlElementText<SELF>> extends HtmlElement<SELF> { 035 036 private Object text; 037 038 /** 039 * Returns the inner text of this element. 040 * 041 * @return The inner text of this element, or <jk>null</jk> if no text is set. 042 */ 043 @Xml(format = XmlFormat.TEXT) 044 @BeanProp("c") 045 public Object getText() { return text; } 046 047 /** 048 * Sets the inner text of this element. 049 * 050 * @param text The inner text of this element, or <jk>null</jk> if no text is set. 051 * @return This object. 052 */ 053 @BeanProp("c") 054 public SELF setText(Object text) { 055 this.text = text; 056 return self(); 057 } 058 059 /** 060 * Sets the text node on this element. 061 * 062 * @param value The text node to add to this element. Can be <jk>null</jk> to leave the text unset. 063 * @return This object. 064 */ 065 public SELF text(Object value) { 066 text = value; 067 return self(); 068 } 069}