1 21 22 package org.opensubsystems.blog.data; 23 24 import java.sql.Timestamp ; 25 26 import org.opensubsystems.core.data.DataConstant; 27 import org.opensubsystems.core.data.DataObject; 28 import org.opensubsystems.core.data.ModifiableDataObject; 29 30 39 public class Entry extends ModifiableDataObject 40 { 41 43 47 protected static int s_iCaptionMaxLength; 48 49 53 protected static int s_iCommentsMaxLength; 54 55 59 protected static int s_iImageURLMaxLength; 60 61 65 protected static int s_iTargetURLMaxLength; 66 67 71 protected Boolean m_bIsPreformated = null; 72 73 75 78 private static final long serialVersionUID = -2560701905097962342L; 79 80 83 protected int m_iParentId; 84 85 88 protected String m_strCaption; 89 90 93 protected String m_strComments; 94 95 98 protected String m_strImageURL; 99 100 103 protected String m_strTargetURL; 104 105 107 static 108 { 109 DataConstant.setDataTypeName(DataConstant.BLOGENTRY_DATA_TYPE_OBJ, 110 "Chronicle entry"); 111 } 112 113 116 public Entry( 117 ) 118 { 119 this(DataObject.NEW_ID, DataObject.NEW_ID, DataObject.NEW_ID, "", "", "", 120 "", null, null); 121 } 122 123 128 public Entry( 129 int iDomainId 130 ) 131 { 132 this(DataObject.NEW_ID, iDomainId, DataObject.NEW_ID, "", "", "", "", null, null); 133 } 134 135 141 public Entry( 142 int iDomainId, 143 int iParentId 144 ) 145 { 146 this(DataObject.NEW_ID, iDomainId, iParentId, "", "", "", "", null, null); 147 } 148 149 162 public Entry( 163 int iId, 164 int iDomainId, 165 int iParentId, 166 String strCaption, 167 String strComments, 168 String strImageURL, 169 String strTargetURL, 170 Timestamp creationTimestamp, 171 Timestamp modificationTimestamp 172 ) 173 { 174 super(iId, iDomainId, creationTimestamp, modificationTimestamp); 175 176 m_iParentId = iParentId; 177 m_strCaption = strCaption; 178 m_strComments = strComments; 179 m_strImageURL = strImageURL; 180 m_strTargetURL = strTargetURL; 181 } 182 183 185 190 public int getParentId( 191 ) 192 { 193 return m_iParentId; 194 } 195 196 201 public void setParentId( 202 int iParentId 203 ) 204 { 205 m_iParentId = iParentId; 206 } 207 208 213 public String getCaption( 214 ) 215 { 216 return m_strCaption; 217 } 218 219 224 public String getComments( 225 ) 226 { 227 return m_strComments; 228 } 229 230 235 public String getImageURL( 236 ) 237 { 238 return m_strImageURL; 239 } 240 241 247 public String getTargetURL( 248 ) 249 { 250 return m_strTargetURL; 251 } 252 253 256 public static int getCaptionMaxLengthStatic( 257 ) 258 { 259 return s_iCaptionMaxLength; 260 } 261 262 265 public int getCaptionMaxLength( 266 ) 267 { 268 return s_iCaptionMaxLength; 269 } 270 271 274 public static int getCommentsMaxLengthStatic( 275 ) 276 { 277 return s_iCommentsMaxLength; 278 } 279 280 283 public int getCommentsMaxLength( 284 ) 285 { 286 return s_iCommentsMaxLength; 287 } 288 289 292 public static void setCaptionMaxLength( 293 int iCaptionMaxLength 294 ) 295 { 296 s_iCaptionMaxLength = iCaptionMaxLength; 297 } 298 299 302 public static void setCommentsMaxLength( 303 int iCommentsMaxLength 304 ) 305 { 306 s_iCommentsMaxLength = iCommentsMaxLength; 307 } 308 309 312 public static int getImageURLMaxLengthStatic( 313 ) 314 { 315 return s_iImageURLMaxLength; 316 } 317 318 321 public int getImageURLMaxLength( 322 ) 323 { 324 return s_iImageURLMaxLength; 325 } 326 327 330 public static int getTargetURLMaxLengthStatic() 331 { 332 return s_iTargetURLMaxLength; 333 } 334 335 338 public int getTargetURLMaxLength() 339 { 340 return s_iTargetURLMaxLength; 341 } 342 343 346 public static void setImageURLMaxLength( 347 int iImageURLMaxLength 348 ) 349 { 350 s_iImageURLMaxLength = iImageURLMaxLength; 351 } 352 353 356 public static void setTargetURLMaxLength( 357 int iTargetURLMaxLength 358 ) 359 { 360 s_iTargetURLMaxLength = iTargetURLMaxLength; 361 } 362 363 369 public boolean getIsPreformated() 370 { 371 if (m_bIsPreformated == null) 372 { 373 if (m_strComments == null) 374 { 375 m_bIsPreformated = Boolean.FALSE; 376 } 377 else 378 { 379 m_bIsPreformated = ((m_strComments.indexOf('\n') != -1) ? Boolean.TRUE 380 : Boolean.FALSE); 381 } 382 } 383 384 return (m_bIsPreformated == Boolean.TRUE); 385 } 386 387 390 public boolean isSame( 391 Object oObject 392 ) 393 { 394 boolean bReturn = false; 395 Entry data; 396 397 if (oObject == this) 398 { 399 bReturn = true; 400 } 401 else 402 { 403 if (oObject != null && oObject instanceof Entry) 404 { 405 data = (Entry) oObject; 406 bReturn = data.getParentId() == m_iParentId 407 && ((data.getCaption() == null && m_strCaption == null) 408 || data.getCaption().equals(m_strCaption)) 409 && ((data.getComments() == null && m_strComments == null) 410 || data.getComments().equals(m_strComments)) 411 && ((data.getImageURL() == null && m_strImageURL == null) 412 || data.getImageURL().equals(m_strImageURL)) 413 && ((data.getTargetURL() == null && m_strTargetURL == null) 414 || data.getTargetURL().equals(m_strTargetURL)); 415 } 416 } 417 return bReturn; 418 } 419 } 420 | Popular Tags |