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