Source Code Cross Referenced for Entry.java in  » J2EE » OpenCore » org » opensubsystems » blog » data » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » J2EE » OpenCore » org.opensubsystems.blog.data 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (c) 2003 - 2007 OpenSubsystems s.r.o. Slovak Republic. All rights reserved.
003:         * 
004:         * Project: OpenChronicle
005:         * 
006:         * $Id: Entry.java,v 1.5 2007/02/20 02:10:00 bastafidli Exp $
007:         * 
008:         * This program is free software; you can redistribute it and/or modify
009:         * it under the terms of the GNU General Public License as published by
010:         * the Free Software Foundation; version 2 of the License. 
011:         * 
012:         * This program is distributed in the hope that it will be useful,
013:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
014:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
015:         * GNU General Public License for more details.
016:         * 
017:         * You should have received a copy of the GNU General Public License
018:         * along with this program; if not, write to the Free Software
019:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
020:         */
021:
022:        package org.opensubsystems.blog.data;
023:
024:        import java.sql.Timestamp;
025:
026:        import org.opensubsystems.core.data.DataConstant;
027:        import org.opensubsystems.core.data.DataObject;
028:        import org.opensubsystems.core.data.ModifiableDataObject;
029:        import org.opensubsystems.patterns.listdata.data.ListDefinition;
030:
031:        /**
032:         * Entry within a blog. Entry has caption, text and can have an image associated 
033:         * with it. Entry can also contain separate URL associated with the image.
034:         *
035:         * @version $Id: Entry.java,v 1.5 2007/02/20 02:10:00 bastafidli Exp $
036:         * @author Miro Halas
037:         * @code.reviewer Miro Halas
038:         * @code.reviewed Initial revision
039:         */
040:        public class Entry extends ModifiableDataObject {
041:            // Constants ////////////////////////////////////////////////////////////////
042:
043:            // List constants ///////////////////////////////////////////////////////////
044:
045:            /**
046:             * Code for table column.
047:             */
048:            public static final int COL_BLOGENTRY_ID = DataConstant.BLOGENTRY_DATA_TYPE + 1;
049:
050:            /**
051:             * Object code for table column.
052:             */
053:            public static final Integer COL_BLOGENTRY_ID_OBJ = new Integer(
054:                    COL_BLOGENTRY_ID);
055:
056:            /**
057:             * Code for table column.
058:             */
059:            public static final int COL_BLOGENTRY_DOMAIN_ID = DataConstant.BLOGENTRY_DATA_TYPE + 2;
060:
061:            /**
062:             * Code for table column.
063:             */
064:            public static final int COL_BLOGENTRY_PARENT_ID = DataConstant.BLOGENTRY_DATA_TYPE + 3;
065:
066:            /**
067:             * Code for table column.
068:             */
069:            public static final int COL_BLOGENTRY_CAPTION = DataConstant.BLOGENTRY_DATA_TYPE + 4;
070:
071:            /**
072:             * Object code for table column.
073:             */
074:            public static final Integer COL_BLOGENTRY_CAPTION_OBJ = new Integer(
075:                    COL_BLOGENTRY_CAPTION);
076:
077:            /**
078:             * Code for table column.
079:             */
080:            public static final int COL_BLOGENTRY_COMMENTS = DataConstant.BLOGENTRY_DATA_TYPE + 5;
081:
082:            /**
083:             * Object code for table column.
084:             */
085:            public static final Integer COL_BLOGENTRY_COMMENTS_OBJ = new Integer(
086:                    COL_BLOGENTRY_COMMENTS);
087:
088:            /**
089:             * Code for table column.
090:             */
091:            public static final int COL_BLOGENTRY_IMAGEURL = DataConstant.BLOGENTRY_DATA_TYPE + 6;
092:
093:            /**
094:             * Object code for table column.
095:             */
096:            public static final Integer COL_BLOGENTRY_IMAGEURL_OBJ = new Integer(
097:                    COL_BLOGENTRY_IMAGEURL);
098:
099:            /**
100:             * Code for table column.
101:             */
102:            public static final int COL_BLOGENTRY_TARGETURL = DataConstant.BLOGENTRY_DATA_TYPE + 7;
103:
104:            /**
105:             * Object code for table column.
106:             */
107:            public static final Integer COL_BLOGENTRY_TARGETURL_OBJ = new Integer(
108:                    COL_BLOGENTRY_TARGETURL);
109:
110:            /**
111:             * Code for table column.
112:             */
113:            public static final int COL_BLOGENTRY_CREATION_DATE = DataConstant.BLOGENTRY_DATA_TYPE + 8;
114:
115:            /**
116:             * Code for table column.
117:             */
118:            public static final int COL_BLOGENTRY_MODIFICATION_DATE = DataConstant.BLOGENTRY_DATA_TYPE + 9;
119:
120:            /**
121:             * Static variable for array of all columns codes.
122:             * The order is important since it is used to retrieve all data from the
123:             * persistence store efficiently so do not modify it unless you make
124:             * changes to other places as well.
125:             */
126:            public static final int[] ALL_COLUMNS = { COL_BLOGENTRY_ID,
127:                    COL_BLOGENTRY_DOMAIN_ID, COL_BLOGENTRY_PARENT_ID,
128:                    COL_BLOGENTRY_CAPTION, COL_BLOGENTRY_COMMENTS,
129:                    COL_BLOGENTRY_IMAGEURL, COL_BLOGENTRY_TARGETURL,
130:                    COL_BLOGENTRY_CREATION_DATE,
131:                    COL_BLOGENTRY_MODIFICATION_DATE, };
132:
133:            /**
134:             * Default columns to retrieve when asked for list of objects. 
135:             * These should be only columns visible to user on the screen and not any
136:             * internal columns. Also the columns should be retrievable efficiently so
137:             * that the default view is very quick. 
138:             */
139:            public static final int[] DEFAULT_LIST_COLUMNS = {
140:                    COL_BLOGENTRY_CAPTION, COL_BLOGENTRY_COMMENTS,
141:                    COL_BLOGENTRY_IMAGEURL, COL_BLOGENTRY_TARGETURL,
142:                    COL_BLOGENTRY_CREATION_DATE,
143:                    COL_BLOGENTRY_MODIFICATION_DATE, };
144:
145:            /**
146:             * Default columns to sort by when asked for list of objects. 
147:             */
148:            public static final int[] DEFAULT_LIST_SORT_COLUMNS = { COL_BLOGENTRY_CREATION_DATE };
149:
150:            /**
151:             * Default order in which the columns will be sorted. 
152:             */
153:            public static final String[] DEFAULT_LIST_SORT_ORDER = ListDefinition.ORDER_DESCENDING_ARRAY;
154:
155:            // Cached values ////////////////////////////////////////////////////////////
156:
157:            /**
158:             * Maximal length of the caption field. The value depends on the underlying
159:             * persistance mechanism and it is set once the persistance is initialized.
160:             */
161:            protected static int s_iCaptionMaxLength;
162:
163:            /**
164:             * Maximal length of the comments field. The value depends on the underlying
165:             * persistance mechanism and it is set once the persistance is initialized.
166:             */
167:            protected static int s_iCommentsMaxLength;
168:
169:            /**
170:             * Maximal length of the image URL field. The value depends on the underlying
171:             * persistance mechanism and it is set once the persistance is initialized.
172:             */
173:            protected static int s_iImageURLMaxLength;
174:
175:            /**
176:             * Maximal length of the target URL field. The value depends on the underlying
177:             * persistance mechanism and it is set once the persistance is initialized.
178:             */
179:            protected static int s_iTargetURLMaxLength;
180:
181:            /**
182:             * Flag signaling if the text contains formatting or not. Example of such 
183:             * formatting is a newline character.
184:             */
185:            protected Boolean m_bIsPreformated = null;
186:
187:            // Attributes ///////////////////////////////////////////////////////////////
188:
189:            /**
190:             * Generated serial version id for this class.
191:             */
192:            private static final long serialVersionUID = -2560701905097962342L;
193:
194:            /**
195:             * Parent ID is the ID of the blog this entry belongs to.
196:             */
197:            protected int m_iParentId;
198:
199:            /**
200:             * Caption is more descriptive name of the entry.
201:             */
202:            protected String m_strCaption;
203:
204:            /**
205:             * Comments is any additional text for the entry.
206:             */
207:            protected String m_strComments;
208:
209:            /**
210:             * Image URL of image associated with the entry. 
211:             */
212:            protected String m_strImageURL;
213:
214:            /**
215:             * Target URL for the image when user clicks on the image.
216:             */
217:            protected String m_strTargetURL;
218:
219:            // Constructors /////////////////////////////////////////////////////////////
220:
221:            static {
222:                DataConstant
223:                        .setDataTypeName(DataConstant.BLOGENTRY_DATA_TYPE_OBJ,
224:                                "Chronicle entry");
225:            }
226:
227:            /**
228:             * Empty entry initialized to default parameters
229:             */
230:            public Entry() {
231:                this (DataObject.NEW_ID, DataObject.NEW_ID, DataObject.NEW_ID,
232:                        "", "", "", "", null, null);
233:            }
234:
235:            /**
236:             * Empty entry for a specified domain initialized to default parameters
237:             *
238:             * @param iDomainId - Id of the domain this domain belongs to 
239:             */
240:            public Entry(int iDomainId) {
241:                this (DataObject.NEW_ID, iDomainId, DataObject.NEW_ID, "", "",
242:                        "", "", null, null);
243:            }
244:
245:            /**
246:             * Empty entry for a specified domain and parent initialized to default parameters
247:             *
248:             * @param iDomainId - Id of the domain this domain belongs to 
249:             * @param iParentId - Id of the parent this entry belongs to
250:             */
251:            public Entry(int iDomainId, int iParentId) {
252:                this (DataObject.NEW_ID, iDomainId, iParentId, "", "", "", "",
253:                        null, null);
254:            }
255:
256:            /**
257:             * Create entry from a given parameters.
258:             *
259:             * @param iId - Id of the entry 
260:             * @param iDomainId - Id of the domain this domain belongs to 
261:             * @param iParentId - Id of the parent this entry belongs to
262:             * @param strCaption - More descriptive name of the entry
263:             * @param strComments - Any additional text of the entry
264:             * @param strImageURL - Image URL of image associated with the entry
265:             * @param strTargetURL - Target URL for the image when user clicks on the image
266:             * @param creationTimestamp - Timestamp when the entry was created
267:             * @param modificationTimestamp - Timestamp when the entry was last time modified
268:             */
269:            public Entry(int iId, int iDomainId, int iParentId,
270:                    String strCaption, String strComments, String strImageURL,
271:                    String strTargetURL, Timestamp creationTimestamp,
272:                    Timestamp modificationTimestamp) {
273:                super (iId, iDomainId, creationTimestamp, modificationTimestamp);
274:
275:                m_iParentId = iParentId;
276:                m_strCaption = strCaption;
277:                m_strComments = strComments;
278:                m_strImageURL = strImageURL;
279:                m_strTargetURL = strTargetURL;
280:            }
281:
282:            // Accessors ////////////////////////////////////////////////////////////////
283:
284:            /**
285:             * Id of the parent this entry belongs to.
286:             *
287:             * @return int
288:             */
289:            public int getParentId() {
290:                return m_iParentId;
291:            }
292:
293:            /**
294:             * Id of the parent this entry belongs to.
295:             *
296:             * @param iParentId - if of the parent this entry belongs to
297:             */
298:            public void setParentId(int iParentId) {
299:                m_iParentId = iParentId;
300:            }
301:
302:            /**
303:             * Caption is more descriptive name of the entry.
304:             *
305:             * @return String
306:             */
307:            public String getCaption() {
308:                return m_strCaption;
309:            }
310:
311:            /**
312:             * Comments is any additional description of the entry.
313:             *
314:             * @return String
315:             */
316:            public String getComments() {
317:                return m_strComments;
318:            }
319:
320:            /**
321:             * Image URL of image associated with the entry. 
322:             *
323:             * @return String
324:             */
325:            public String getImageURL() {
326:                return m_strImageURL;
327:            }
328:
329:            /**
330:             * Target URL to display when user clicks on the image associated with this 
331:             * entry.
332:             *
333:             * @return String
334:             */
335:            public String getTargetURL() {
336:                return m_strTargetURL;
337:            }
338:
339:            /**
340:             * @return int
341:             */
342:            public static int getCaptionMaxLengthStatic() {
343:                return s_iCaptionMaxLength;
344:            }
345:
346:            /**
347:             * @return int
348:             */
349:            public int getCaptionMaxLength() {
350:                return s_iCaptionMaxLength;
351:            }
352:
353:            /**
354:             * @return int
355:             */
356:            public static int getCommentsMaxLengthStatic() {
357:                return s_iCommentsMaxLength;
358:            }
359:
360:            /**
361:             * @return int
362:             */
363:            public int getCommentsMaxLength() {
364:                return s_iCommentsMaxLength;
365:            }
366:
367:            /**
368:             * @param iCaptionMaxLength - maximal length for caption
369:             */
370:            public static void setCaptionMaxLength(int iCaptionMaxLength) {
371:                s_iCaptionMaxLength = iCaptionMaxLength;
372:            }
373:
374:            /**
375:             * @param iCommentsMaxLength - maximal length for comments
376:             */
377:            public static void setCommentsMaxLength(int iCommentsMaxLength) {
378:                s_iCommentsMaxLength = iCommentsMaxLength;
379:            }
380:
381:            /**
382:             * @return int - maximal length for image URL
383:             */
384:            public static int getImageURLMaxLengthStatic() {
385:                return s_iImageURLMaxLength;
386:            }
387:
388:            /**
389:             * @return int - maximal length for image URL
390:             */
391:            public int getImageURLMaxLength() {
392:                return s_iImageURLMaxLength;
393:            }
394:
395:            /**
396:             * @return int - maximal length for target URL
397:             */
398:            public static int getTargetURLMaxLengthStatic() {
399:                return s_iTargetURLMaxLength;
400:            }
401:
402:            /**
403:             * @return int - maximal length for target URL
404:             */
405:            public int getTargetURLMaxLength() {
406:                return s_iTargetURLMaxLength;
407:            }
408:
409:            /**
410:             * @param iImageURLMaxLength - maximal length for image URL
411:             */
412:            public static void setImageURLMaxLength(int iImageURLMaxLength) {
413:                s_iImageURLMaxLength = iImageURLMaxLength;
414:            }
415:
416:            /**
417:             * @param iTargetURLMaxLength - maximal length for target URL
418:             */
419:            public static void setTargetURLMaxLength(int iTargetURLMaxLength) {
420:                s_iTargetURLMaxLength = iTargetURLMaxLength;
421:            }
422:
423:            /**
424:             * Flag signaling if the text contains formatting or not. Example of such 
425:             * formatting is a newline character.
426:             * 
427:             * @return boolean
428:             */
429:            public boolean getIsPreformated() {
430:                if (m_bIsPreformated == null) {
431:                    if (m_strComments == null) {
432:                        m_bIsPreformated = Boolean.FALSE;
433:                    } else {
434:                        m_bIsPreformated = ((m_strComments.indexOf('\n') != -1) ? Boolean.TRUE
435:                                : Boolean.FALSE);
436:                    }
437:                }
438:
439:                return (m_bIsPreformated == Boolean.TRUE);
440:            }
441:
442:            /**
443:             * {@inheritDoc}
444:             */
445:            public boolean isSame(Object oObject) {
446:                boolean bReturn = false;
447:                Entry data;
448:
449:                if (oObject == this ) {
450:                    bReturn = true;
451:                } else {
452:                    if (oObject != null && oObject instanceof  Entry) {
453:                        data = (Entry) oObject;
454:                        bReturn = data.getParentId() == m_iParentId
455:                                && ((data.getCaption() == null && m_strCaption == null) || data
456:                                        .getCaption().equals(m_strCaption))
457:                                && ((data.getComments() == null && m_strComments == null) || data
458:                                        .getComments().equals(m_strComments))
459:                                && ((data.getImageURL() == null && m_strImageURL == null) || data
460:                                        .getImageURL().equals(m_strImageURL))
461:                                && ((data.getTargetURL() == null && m_strTargetURL == null) || data
462:                                        .getTargetURL().equals(m_strTargetURL));
463:                    }
464:                }
465:                return bReturn;
466:            }
467:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.