Source Code Cross Referenced for Item.java in  » RSS-RDF » informa » de » nava » informa » impl » hibernate » 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 » RSS RDF » informa » de.nava.informa.impl.hibernate 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        //
002:        // Informa -- RSS Library for Java
003:        // Copyright (c) 2002 by Niko Schmuck
004:        //
005:        // Niko Schmuck
006:        // http://sourceforge.net/projects/informa
007:        // mailto:niko_schmuck@users.sourceforge.net
008:        //
009:        // This library is free software.
010:        //
011:        // You may redistribute it and/or modify it under the terms of the GNU
012:        // Lesser General Public License as published by the Free Software Foundation.
013:        //
014:        // Version 2.1 of the license should be included with this distribution in
015:        // the file LICENSE. If the license is not included with this distribution,
016:        // you may find a copy at the FSF web site at 'www.gnu.org' or 'www.fsf.org',
017:        // or you may write to the Free Software Foundation, 675 Mass Ave, Cambridge,
018:        // MA 02139 USA.
019:        //
020:        // This library is distributed in the hope that it will be useful,
021:        // but WITHOUT ANY WARRANTY; without even the implied waranty of
022:        // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
023:        // Lesser General Public License for more details.
024:        //
025:
026:        // $Id: Item.java,v 1.27 2006/12/04 23:43:27 italobb Exp $
027:
028:        package de.nava.informa.impl.hibernate;
029:
030:        import java.net.MalformedURLException;
031:        import java.net.URL;
032:        import java.util.ArrayList;
033:        import java.util.Collection;
034:        import java.util.Date;
035:
036:        import org.jdom.Element;
037:
038:        import de.nava.informa.core.CategoryIF;
039:        import de.nava.informa.core.ChannelIF;
040:        import de.nava.informa.core.ItemEnclosureIF;
041:        import de.nava.informa.core.ItemGuidIF;
042:        import de.nava.informa.core.ItemIF;
043:        import de.nava.informa.core.ItemSourceIF;
044:        import de.nava.informa.utils.XmlPathUtils;
045:
046:        /**
047:         * Hibernate implementation of the ItemIF interface.
048:         *
049:         * @author Niko Schmuck (niko@nava.de)
050:         */
051:        public class Item implements  ItemIF {
052:
053:            private static final long serialVersionUID = 899115671959509447L;
054:
055:            private long id = -1;
056:            private String title;
057:            private String description;
058:            private URL link;
059:            private Collection<CategoryIF> categories;
060:            private String creator;
061:            private String subject;
062:            private Date date;
063:            private Date found;
064:            private ItemGuidIF guid;
065:            private URL comments;
066:            private ItemEnclosureIF enclosure;
067:            private ItemSourceIF source;
068:            private ChannelIF channel;
069:            private Element itemElement;
070:            private boolean unRead;
071:
072:            public Item() {
073:                this (null, null, "[Unnamed item]", null, null);
074:            }
075:
076:            public Item(String title, String description, URL link) {
077:                this (null, null, title, description, link);
078:            }
079:
080:            public Item(ChannelIF channel, String title, String description,
081:                    URL link) {
082:                this (null, channel, title, description, link);
083:            }
084:
085:            public Item(Element itemElement, String title, String description,
086:                    URL link) {
087:                this (itemElement, null, title, description, link);
088:            }
089:
090:            public Item(Element itemElement, ChannelIF channel, String title,
091:                    String description, URL link) {
092:                this .itemElement = itemElement;
093:                this .channel = channel;
094:                this .title = title;
095:                this .description = description;
096:                this .link = link;
097:                this .categories = new ArrayList<CategoryIF>();
098:                this .unRead = true;
099:            }
100:
101:            // --------------------------------------------------------------
102:            // implementation of ItemIF interface
103:            // --------------------------------------------------------------
104:
105:            /**
106:             * @return integer representation of identity.
107:             */
108:            public long getId() {
109:                return id;
110:            }
111:
112:            public void setId(long id) {
113:                this .id = id;
114:            }
115:
116:            /**
117:             * @return parent channel.
118:             */
119:            public ChannelIF getChannel() {
120:                return channel;
121:            }
122:
123:            public void setChannel(ChannelIF parentChannel) {
124:                this .channel = parentChannel;
125:            }
126:
127:            /**
128:             * @return title.
129:             */
130:            public String getTitle() {
131:                return title;
132:            }
133:
134:            public void setTitle(String aTitle) {
135:                this .title = aTitle;
136:            }
137:
138:            /**
139:             * @return description.
140:             */
141:            public String getDescription() {
142:                return description;
143:            }
144:
145:            public void setDescription(String aDescription) {
146:                this .description = aDescription;
147:            }
148:
149:            /**
150:             * @return unread flag.
151:             */
152:            public boolean getUnRead() {
153:                return unRead;
154:            }
155:
156:            public void setUnRead(boolean val) {
157:                this .unRead = val;
158:            }
159:
160:            /**
161:             * @return link to original article.
162:             */
163:            public String getLinkString() {
164:                return (link == null) ? null : link.toString();
165:            }
166:
167:            public void setLinkString(String linkStr) {
168:                if (linkStr == null || linkStr.trim().length() == 0) {
169:                    link = null;
170:                    return;
171:                } else {
172:                    try {
173:                        this .link = new URL(linkStr);
174:                    } catch (MalformedURLException e) {
175:                        e.printStackTrace();
176:                    }
177:                }
178:            }
179:
180:            public URL getLink() {
181:                return link;
182:            }
183:
184:            public void setLink(URL aLink) {
185:                this .link = aLink;
186:            }
187:
188:            /**
189:             * @return categories.
190:             */
191:            public Collection getCategories() {
192:                return categories;
193:            }
194:
195:            public void setCategories(Collection<CategoryIF> aCategories) {
196:                this .categories = aCategories;
197:            }
198:
199:            public void addCategory(CategoryIF category) {
200:                categories.add(category);
201:            }
202:
203:            public void removeCategory(CategoryIF category) {
204:                categories.remove(category);
205:            }
206:
207:            /**
208:             * @return creator.
209:             */
210:            public String getCreator() {
211:                return creator;
212:            }
213:
214:            public void setCreator(String aCreator) {
215:                this .creator = aCreator;
216:            }
217:
218:            /**
219:             * @return subject.
220:             */
221:            public String getSubject() {
222:                return subject;
223:            }
224:
225:            public void setSubject(String aSubject) {
226:                this .subject = aSubject;
227:            }
228:
229:            /**
230:             * @return date.
231:             */
232:            public Date getDate() {
233:                return date;
234:            }
235:
236:            public void setDate(Date aDate) {
237:                this .date = aDate;
238:            }
239:
240:            /**
241:             * @return date when item was found.
242:             */
243:            public Date getFound() {
244:                return found;
245:            }
246:
247:            public void setFound(Date foundDate) {
248:                this .found = foundDate;
249:            }
250:
251:            /**
252:             * @return guid.
253:             */
254:            public ItemGuidIF getGuid() {
255:                return guid;
256:            }
257:
258:            public void setGuid(ItemGuidIF guid) {
259:                this .guid = guid;
260:            }
261:
262:            /**
263:             * @return comments.
264:             */
265:            public String getCommentsString() {
266:                return (comments == null) ? null : comments.toExternalForm();
267:            }
268:
269:            public void setCommentsString(String commentsStr) {
270:                if (commentsStr == null || commentsStr.trim().length() == 0) {
271:                    comments = null;
272:                    return;
273:                } else {
274:                    try {
275:                        this .comments = new URL(commentsStr);
276:                    } catch (MalformedURLException e) {
277:                        e.printStackTrace();
278:                        this .comments = null;
279:                    }
280:                }
281:            }
282:
283:            public URL getComments() {
284:                return comments;
285:            }
286:
287:            public void setComments(URL comments) {
288:                this .comments = comments;
289:            }
290:
291:            /**
292:             * @return source.
293:             */
294:            public ItemSourceIF getSource() {
295:                return source;
296:            }
297:
298:            public void setSource(ItemSourceIF aSource) {
299:                this .source = aSource;
300:            }
301:
302:            /**
303:             * @return enclosure.
304:             */
305:            public ItemEnclosureIF getEnclosure() {
306:                return enclosure;
307:            }
308:
309:            public void setEnclosure(ItemEnclosureIF anEnclosure) {
310:                this .enclosure = anEnclosure;
311:            }
312:
313:            public String getElementValue(final String path) {
314:                return XmlPathUtils.getElementValue(itemElement, path);
315:            }
316:
317:            public String[] getElementValues(final String path,
318:                    final String[] elements) {
319:                return XmlPathUtils.getElementValues(itemElement, path,
320:                        elements);
321:            }
322:
323:            public String getAttributeValue(final String path,
324:                    final String attribute) {
325:                return XmlPathUtils.getAttributeValue(itemElement, path,
326:                        attribute);
327:            }
328:
329:            public String[] getAttributeValues(final String path,
330:                    final String[] attributes) {
331:                return XmlPathUtils.getAttributeValues(itemElement, path,
332:                        attributes);
333:            }
334:
335:            // ----------------------------------------------------------------------
336:            // overwrite default method implementation from Object
337:            // ----------------------------------------------------------------------
338:
339:            /**
340:             * Returns a string representation of the object.
341:             *
342:             * @return  a string representation of the object.
343:             */
344:            public String toString() {
345:                return "[Item (" + id + "): " + title + "]";
346:            }
347:
348:            // ----------------------------------------------------------------------
349:            // overwrite default method implementation from Object
350:            // ----------------------------------------------------------------------
351:
352:            /**
353:             * Indicates whether some other object is "equal to" this one.
354:             *
355:             * @param   o the reference object with which to compare.
356:             *
357:             * @return  <code>true</code> if this object is the same as the obj
358:             *          argument; <code>false</code> otherwise.
359:             *
360:             * NOTE: Please keep this code in sync with de.nava.informa.impl.hibernate.Item.equals().
361:             *
362:             * @see     #hashCode()
363:             */
364:            public boolean equals(Object o) {
365:                if (this  == o)
366:                    return true;
367:                if (!(o instanceof  ItemIF))
368:                    return false;
369:
370:                final ItemIF item = (ItemIF) o;
371:
372:                final String itemTitle = item.getTitle();
373:                if (title != null ? !title.equals(itemTitle)
374:                        : itemTitle != null)
375:                    return false;
376:
377:                // Comparison of links uses synchronized code of Java-NET.
378:                // This may hurt multi-threaded applications. So, please think twice
379:                // before using direct comparison of links.
380:                final URL itemLink = item.getLink();
381:                if (link != null ? itemLink == null
382:                        || !link.toString().equalsIgnoreCase(
383:                                itemLink.toString()) : itemLink != null)
384:                    return false;
385:
386:                final String itemDescription = item.getDescription();
387:                if (description != null ? !description.equals(itemDescription)
388:                        : itemDescription != null)
389:                    return false;
390:
391:                return true;
392:            }
393:
394:            /**
395:             * Returns a hash code value for the object. This method is
396:             * supported for the benefit of hashtables such as those provided by
397:             * <code>java.util.Hashtable</code>.
398:             *
399:             * NOTE: Please keep this code in sync with de.nava.informa.impl.basic.Item.hashCode().
400:             *
401:             * @return a hash code value for this object.
402:             */
403:            public int hashCode() {
404:                StringBuffer sb = new StringBuffer(64);
405:                // This looks like a bug because it is not symmetrical with the accompanying equals().
406:                // sb.append(title).append(description).append(link);
407:                sb.append(title).append(description).append(link);
408:                return sb.toString().hashCode();
409:            }
410:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.