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.atom; 018 019import static org.apache.juneau.commons.utils.StringUtils.*; 020 021import java.net.*; 022 023/** 024 * Represents a person, corporation, or similar entity in an Atom document. 025 * 026 * <p> 027 * Person constructs are used to describe authors, contributors, and other people or entities 028 * associated with a feed or entry. Each person construct contains a name and optionally a URI 029 * and email address. 030 * 031 * <p> 032 * Person constructs appear in several places: 033 * <ul class='spaced-list'> 034 * <li><c>atom:author</c> - Indicates the author(s) of a feed or entry 035 * <li><c>atom:contributor</c> - Indicates those who contributed to a feed or entry 036 * </ul> 037 * 038 * <h5 class='figure'>Schema</h5> 039 * <p class='bschema'> 040 * atomPersonConstruct = 041 * atomCommonAttributes, 042 * (element atom:name { text } 043 * & element atom:uri { atomUri }? 044 * & element atom:email { atomEmailAddress }? 045 * & extensionElement*) 046 * </p> 047 * 048 * <h5 class='section'>Example:</h5> 049 * <p class='bjava'> 050 * <jc>// Create an author</jc> 051 * Person <jv>author</jv> = <jk>new</jk> Person(<js>"Jane Doe"</js>) 052 * .setEmail(<js>"jane@example.org"</js>) 053 * .setUri(<js>"http://example.org/~jane"</js>); 054 * 055 * <jc>// Add to entry</jc> 056 * Entry <jv>entry</jv> = <jk>new</jk> Entry(...) 057 * .setAuthors(<jv>author</jv>); 058 * </p> 059 * 060 * <h5 class='section'>Specification:</h5> 061 * <p> 062 * Represents an <c>atomPersonConstruct</c> in the 063 * <a class="doclink" href="https://tools.ietf.org/html/rfc4287#section-3.2">RFC 4287 - Section 3.2</a> specification. 064 * 065 * <h5 class='section'>See Also:</h5><ul> 066 * <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/JuneauBeanAtom">juneau-bean-atom</a> 067 * <li class='extlink'><a class="doclink" href="https://tools.ietf.org/html/rfc4287">RFC 4287 - The Atom Syndication Format</a> 068 * </ul> 069 */ 070public class Person extends Common { 071 072 private String name; 073 private URI uri; 074 private String email; 075 076 /** Bean constructor. */ 077 public Person() {} 078 079 /** 080 * Normal constructor. 081 * 082 * @param name The name of the person. 083 */ 084 public Person(String name) { 085 setName(name); 086 } 087 088 /** 089 * Bean property getter: <property>email</property>. 090 * 091 * <p> 092 * Returns the email address associated with the person. 093 * 094 * @return The property value, or <jk>null</jk> if it is not set. 095 */ 096 public String getEmail() { return email; } 097 098 /** 099 * Bean property getter: <property>name</property>. 100 * 101 * <p> 102 * Returns the human-readable name for the person (required). 103 * 104 * @return The property value, or <jk>null</jk> if it is not set. 105 */ 106 public String getName() { return name; } 107 108 /** 109 * Bean property getter: <property>uri</property>. 110 * 111 * <p> 112 * Returns a URI associated with the person. 113 * 114 * <p> 115 * Typically this is a personal website or profile page. 116 * 117 * @return The property value, or <jk>null</jk> if it is not set. 118 */ 119 public URI getUri() { return uri; } 120 121 @Override /* Overridden from Common */ 122 public Person setBase(Object value) { 123 super.setBase(value); 124 return this; 125 } 126 127 /** 128 * Bean property setter: <property>email</property>. 129 * 130 * <p> 131 * Sets the email address associated with the person. 132 * 133 * <h5 class='section'>Example:</h5> 134 * <p class='bjava'> 135 * Person <jv>person</jv> = <jk>new</jk> Person(<js>"Jane Doe"</js>) 136 * .setEmail(<js>"jane@example.org"</js>); 137 * </p> 138 * 139 * @param value 140 * The new value for this property. 141 * <br>Can be <jk>null</jk> to unset the property. 142 * @return This object. 143 */ 144 public Person setEmail(String value) { 145 email = value; 146 return this; 147 } 148 149 @Override /* Overridden from Common */ 150 public Person setLang(String value) { 151 super.setLang(value); 152 return this; 153 } 154 155 /** 156 * Bean property setter: <property>name</property>. 157 * 158 * <p> 159 * Sets the human-readable name for the person (required). 160 * 161 * <h5 class='section'>Example:</h5> 162 * <p class='bjava'> 163 * Person <jv>person</jv> = <jk>new</jk> Person(<js>"Jane Doe"</js>); 164 * </p> 165 * 166 * @param value 167 * The new value for this property. 168 * <br>Can be <jk>null</jk> to unset the property. 169 * @return This object. 170 */ 171 public Person setName(String value) { 172 name = value; 173 return this; 174 } 175 176 /** 177 * Bean property setter: <property>uri</property>. 178 * 179 * <p> 180 * Sets a URI associated with the person (typically a website or profile page). 181 * 182 * <p> 183 * The value can be of any of the following types: {@link URI}, {@link URL}, {@link String}. 184 * Strings must be valid URIs. 185 * 186 * <h5 class='section'>Example:</h5> 187 * <p class='bjava'> 188 * Person <jv>person</jv> = <jk>new</jk> Person(<js>"Jane Doe"</js>) 189 * .setUri(<js>"http://example.org/~jane"</js>); 190 * </p> 191 * 192 * @param value 193 * The new value for this property. 194 * <br>Can be <jk>null</jk> to unset the property. 195 * @return This object. 196 */ 197 public Person setUri(Object value) { 198 this.uri = toUri(value); 199 return this; 200 } 201}