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.internal.StringUtils.*;
016import static org.apache.juneau.xml.annotation.XmlFormat.*;
017
018import java.net.*;
019import java.net.URI;
020
021import org.apache.juneau.*;
022import org.apache.juneau.annotation.*;
023import org.apache.juneau.xml.annotation.*;
024
025/**
026 * Represents an <c>atomGenerator</c> construct in the RFC4287 specification.
027 *
028 * <h5 class='figure'>Schema</h5>
029 * <p class='bcode w800'>
030 *    atomGenerator = element atom:generator {
031 *       atomCommonAttributes,
032 *       attribute uri { atomUri }?,
033 *       attribute version { text }?,
034 *       text
035 *    }
036 * </p>
037 *
038 * <ul class='seealso'>
039 *    <li class='link'>{@doc juneau-dto.Atom}
040 *    <li class='jp'>{@doc package-summary.html#TOC}
041 * </ul>
042 */
043@Bean(typeName="generator")
044public class Generator extends Common {
045
046   private URI uri;
047   private String version;
048   private String text;
049
050
051   /**
052    * Normal constructor.
053    *
054    * @param text The generator statement content.
055    */
056   public Generator(String text) {
057      this.text = text;
058   }
059
060   /** Bean constructor. */
061   public Generator() {}
062
063
064   //-----------------------------------------------------------------------------------------------------------------
065   // Bean properties
066   //-----------------------------------------------------------------------------------------------------------------
067
068   /**
069    * Returns the URI of this generator statement.
070    *
071    * @return The URI of this generator statement.
072    */
073   @Xml(format=ATTR)
074   public URI getUri() {
075      return uri;
076   }
077
078   /**
079    * Sets the URI of this generator statement.
080    *
081    * <p>
082    * The value can be of any of the following types: {@link URI}, {@link URL}, {@link String}.
083    * Strings must be valid URIs.
084    *
085    * <p>
086    * URIs defined by {@link UriResolver} can be used for values.
087    *
088    * @param uri The URI of this generator statement.
089    * @return This object (for method chaining).
090    */
091   @BeanProperty("uri")
092   public Generator uri(Object uri) {
093      this.uri = toURI(uri);
094      return this;
095   }
096
097   /**
098    * Returns the version of this generator statement.
099    *
100    * @return The version of this generator statement.
101    */
102   @Xml(format=ATTR)
103   public String getVersion() {
104      return version;
105   }
106
107   /**
108    * Sets the version of this generator statement.
109    *
110    * @param version The version of this generator statement.
111    * @return This object (for method chaining).
112    */
113   @BeanProperty("version")
114   public Generator version(String version) {
115      this.version = version;
116      return this;
117   }
118
119   /**
120    * Returns the content of this generator statement.
121    *
122    * @return The content of this generator statement.
123    */
124   @Xml(format=TEXT)
125   public String getText() {
126      return text;
127   }
128
129   /**
130    * Sets the content of this generator statement.
131    *
132    * @param text The content of this generator statement.
133    * @return This object (for method chaining).
134    */
135   @BeanProperty("text")
136   public Generator text(String text) {
137      this.text = text;
138      return this;
139   }
140
141
142   //-----------------------------------------------------------------------------------------------------------------
143   // Overridden setters (to simplify method chaining)
144   //-----------------------------------------------------------------------------------------------------------------
145
146   @Override /* Common */
147   public Generator base(Object base) {
148      super.base(base);
149      return this;
150   }
151
152   @Override /* Common */
153   public Generator lang(String lang) {
154      super.lang(lang);
155      return this;
156   }
157}