View Javadoc

1   /*
2    * Copyright 2004 Sun Microsystems, Inc.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   *
16   */
17  package com.sun.syndication.feed.atom;
18  
19  import com.sun.syndication.feed.impl.ObjectBean;
20  
21  import java.io.Serializable;
22  
23  /***
24   * Bean for person elements of Atom feeds.
25   * <p>
26   * @author Alejandro Abdelnur
27   * @author Dave Johnson (updated for Atom 1.0)
28   */
29  public class Person implements Cloneable,Serializable  {
30      
31      private ObjectBean _objBean;
32      
33      private String _name;
34      private String _uri;  // since Atom 1.0 (was called url)
35      private String _uriResolved; 
36      private String _email;
37  
38      /***
39       * Default constructor. All properties are set to <b>null</b>.
40       * <p>
41       *
42       */
43      public Person() {
44          _objBean = new ObjectBean(this.getClass(),this);
45      }
46  
47      /***
48       * Creates a deep 'bean' clone of the object.
49       * <p>
50       * @return a clone of the object.
51       * @throws CloneNotSupportedException thrown if an element of the object cannot be cloned.
52       *
53       */
54      public Object clone() throws CloneNotSupportedException {
55          return _objBean.clone();
56      }
57  
58      /***
59       * Indicates whether some other object is "equal to" this one as defined by the Object equals() method.
60       * <p>
61       * @param other he reference object with which to compare.
62       * @return <b>true</b> if 'this' object is equal to the 'other' object.
63       *
64       */
65      public boolean equals(Object other) {
66          return _objBean.equals(other);
67      }
68  
69      /***
70       * Returns a hashcode value for the object.
71       * <p>
72       * It follows the contract defined by the Object hashCode() method.
73       * <p>
74       * @return the hashcode of the bean object.
75       *
76       */
77      public int hashCode() {
78          return _objBean.hashCode();
79      }
80  
81      /***
82       * Returns the String representation for the object.
83       * <p>
84       * @return String representation for the object.
85       *
86       */
87      public String toString() {
88          return _objBean.toString();
89      }
90  
91      /***
92        * Returns the person name.
93        * <p>
94        * @return the person name, <b>null</b> if none.
95        *
96        */
97      public String getName() {
98          return _name;
99      }
100 
101     /***
102       * Sets the personname.
103       * <p>
104       * @param name the person name, <b>null</b> if none.
105       *
106       */
107     public void setName(String name) {
108         _name = name;
109     }
110 
111     /***
112       * Returns the person URL (same as {@link getUri()})
113       * <p>
114       * @return the person URL, <b>null</b> if none.
115       */
116     public String getUrl() {
117         return _uri;
118     }
119 
120     /***
121       * Sets the person URL (same as {@link setUri()})
122       * <p>
123       * @param url the person URL, <b>null</b> if none.
124       */
125     public void setUrl(String url) {
126         _uri = url;
127     }
128 
129     public void setUriResolved(String uriResolved) {
130         _uriResolved = uriResolved;
131     }
132 
133     public String getUriResolved(String resolveURI) {
134         return _uriResolved != null ? _uriResolved : _uri;
135     }
136 
137     /***
138       * Returns the person email.
139       * <p>
140       * @return the person email, <b>null</b> if none.
141       *
142       */
143     public String getEmail() {
144         return _email;
145     }
146 
147     /***
148       * Sets the person email.
149       * <p>
150       * @param email the person email, <b>null</b> if none.
151       *
152       */
153     public void setEmail(String email) {
154         _email = email;
155     }
156 
157     /***
158      * Returns the uri
159      * <p>
160      * @return Returns the uri.
161      * @since Atom 1.0
162      */
163     public String getUri() {
164         return _uri;
165     }
166     
167     /***
168      * Set the uri
169      * <p>
170      * @param uri The uri to set.
171      * @since Atom 1.0
172      */
173     public void setUri(String uri) {
174         _uri = uri;
175     }
176 }