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