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.atom;
014
015import static org.apache.juneau.xml.annotation.XmlFormat.*;
016
017import org.apache.juneau.annotation.*;
018import org.apache.juneau.xml.annotation.*;
019
020/**
021 * Represents an <c>atomTextConstruct</c> construct in the RFC4287 specification.
022 *
023 * <h5 class='figure'>Schema</h5>
024 * <p class='bcode w800'>
025 *    atomTextConstruct = atomPlainTextConstruct | atomXHTMLTextConstruct
026 *
027 *    atomPlainTextConstruct =
028 *       atomCommonAttributes,
029 *       attribute type { "text" | "html" }?,
030 *       text
031 *
032 *    atomXHTMLTextConstruct =
033 *       atomCommonAttributes,
034 *       attribute type { "xhtml" },
035 *       xhtmlDiv
036 *
037 *    xhtmlDiv = element xhtml:div {
038 *       (attribute * { text }
039 *       | text
040 *       | anyXHTML)*
041 *    }
042 * </p>
043 *
044 * <ul class='seealso'>
045 *    <li class='link'>{@doc juneau-dto.Atom}
046 *    <li class='jp'>{@doc package-summary.html#TOC}
047 * </ul>
048 */
049public class Text extends Common {
050
051   private String type;
052   private String text;
053
054   /**
055    * Normal content.
056    *
057    * @param type The content type of this content.
058    */
059   public Text(String type) {
060      type(type);
061   }
062
063   /** Bean constructor. */
064   public Text() {}
065
066
067   //-----------------------------------------------------------------------------------------------------------------
068   // Bean properties
069   //-----------------------------------------------------------------------------------------------------------------
070
071   /**
072    * Returns the content type of this content.
073    *
074    * @return The content type of this content.
075    */
076   @Xml(format=ATTR)
077   public String getType() {
078      return type;
079   }
080
081   /**
082    * Sets the content type of this content.
083    *
084    * <p>
085    * Must be one of the following:
086    * <ul>
087    *    <li><js>"text"</js>
088    *    <li><js>"html"</js>
089    *    <li><js>"xhtml"</js>
090    *    <li><jk>null</jk> (defaults to <js>"text"</js>)
091    * </ul>
092    *
093    * @param type The content type of this content.
094    * @return This object (for method chaining).
095    */
096   @BeanProperty("type")
097   public Text type(String type) {
098      this.type = type;
099      return this;
100   }
101
102   /**
103    * Returns the content of this content.
104    *
105    * @return The content of this content.
106    */
107   @Xml(format=XMLTEXT)
108   public String getText() {
109      return text;
110   }
111
112   /**
113    * Sets the content of this content.
114    *
115    * @param text The content of this content.
116    * @return This object (for method chaining).
117    */
118   @BeanProperty("text")
119   public Text text(String text) {
120      this.text = text;
121      return this;
122   }
123
124
125   //-----------------------------------------------------------------------------------------------------------------
126   // Overridden setters (to simplify method chaining)
127   //-----------------------------------------------------------------------------------------------------------------
128
129   @Override /* Common */
130   public Text base(Object base) {
131      super.base(base);
132      return this;
133   }
134
135   @Override /* Common */
136   public Text lang(String lang) {
137      super.lang(lang);
138      return this;
139   }
140}