001 package org.rakeshv.xml.album;
002
003 /**
004 * A Java bean that represents a photo. Bean fields map all the
005 * first-level child elements under the <code>photo</code> node in
006 * the XML tree.
007 *
008 * <p>© Copyright 2003 Rakesh Vidyadharan</p>
009 *
010 * @author Rakesh Vidyadharan 2003 October 31
011 * @version $Id: Photo.java,v 1.2 2004/05/26 11:42:40 rakesh Exp $
012 */
013 public class Photo extends Object implements java.io.Serializable
014 {
015 /**
016 * The <code>photoId</code> value that is used as the primary key
017 * for each photo.
018 */
019 private Integer photoId;
020
021 /**
022 * The <code>title</code> value that is used to identify a photo.
023 */
024 private String title = "";
025
026 /**
027 * The <code>fullImage</code> element value that is stored as an
028 * instance of the {@link Image} java bean.
029 */
030 private Image fullImage = null;
031
032 /**
033 * The <code>thumbnail</code> element value that is stored as an
034 * instance of the {@link Image} java bean.
035 */
036 private Image thumbnail = null;
037
038 /**
039 * The <code>description</code> element value that is used to
040 * describe the photo.
041 */
042 private String description = "";
043
044 /**
045 * Creates a new instance of the bean using the specified value
046 * as the primary key value for this photo.
047 *
048 * @param photoId - The unique identified used for each photo.
049 */
050 public Photo( int photoId )
051 {
052 super();
053 this.photoId = new Integer( photoId );
054 }
055
056 /**
057 * Creates a new instance of the bean using the specified value
058 * as the primary key value for this photo. The {@link #photoId}
059 * instance variable is set to a new Integer object having the same
060 * underlying <code>int</code> value as the object passed in.
061 *
062 * @param photoId - The unique identified used for each photo.
063 */
064 public Photo( Integer photoId )
065 {
066 super();
067 this.photoId = new Integer( photoId.intValue() );
068 }
069
070 /**
071 * Indicates whether some other object is "equal to" this one.
072 * Returns <code>true</code> if the specified object is an instance
073 * of {@link Photo}, and the values of {@link Photo#photoId}
074 * are the same.
075 *
076 * @param object - The object that is to be compared with
077 * this instance.
078 */
079 public boolean equals( Object object )
080 {
081 if ( this.getClass().equals( object.getClass() ) )
082 {
083 Photo that = (Photo) object;
084 return ( this.photoId.equals( that.photoId ) );
085 }
086
087 return false;
088 }
089
090 /**
091 * Returns a hash code value for the object. Returns the hash code
092 * associated with the {@link #photoId} instance variable.
093 *
094 * @return int - The hash code value.
095 */
096 public int hashCode()
097 {
098 return photoId.hashCode();
099 }
100
101 /**
102 * Returns a string representation of the object. Return the value
103 * of {@link #title} if it is not empty, else if returns the value
104 * as returned by the method defined in the super class.
105 *
106 * @return String - The string represenetation of this instance.
107 */
108 public String toString()
109 {
110 if ( title != null && ! title.equals( "" ) )
111 {
112 return title;
113 }
114 else
115 {
116 return super.toString();
117 }
118 }
119
120 /**
121 * Returns {@link #photoId}.
122 *
123 * @return Integer - The value/reference of/to photoId.
124 */
125 public final Integer getPhotoId()
126 {
127 return photoId;
128 }
129
130 /**
131 * Returns {@link #title}.
132 *
133 * @return String - The value/reference of/to title.
134 */
135 public final String getTitle()
136 {
137 return title;
138 }
139
140 /**
141 * Set {@link #title}.
142 *
143 * @param title - The value to set.
144 */
145 public final void setTitle( String title )
146 {
147 this.title = title;
148 }
149
150 /**
151 * Returns {@link #fullImage}.
152 *
153 * @return Image - The value/reference of/to fullImage.
154 */
155 public final Image getFullImage()
156 {
157 return fullImage;
158 }
159
160 /**
161 * Set {@link #fullImage}.
162 *
163 * @param fullImage - The value to set.
164 */
165 public final void setFullImage( Image fullImage )
166 {
167 this.fullImage = fullImage;
168 }
169
170 /**
171 * Returns {@link #thumbnail}.
172 *
173 * @return Image - The value/reference of/to thumbnail.
174 */
175 public final Image getThumbnail()
176 {
177 return thumbnail;
178 }
179
180 /**
181 * Set {@link #thumbnail}.
182 *
183 * @param thumbnail - The value to set.
184 */
185 public final void setThumbnail( Image thumbnail )
186 {
187 this.thumbnail = thumbnail;
188 }
189
190 /**
191 * Returns {@link #description}.
192 *
193 * @return String - The value/reference of/to description.
194 */
195 public final String getDescription()
196 {
197 return description;
198 }
199
200 /**
201 * Set {@link #description}.
202 *
203 * @param description - The value to set.
204 */
205 public final void setDescription( String description )
206 {
207 this.description = description;
208 }
209 }