Source Code Cross Referenced for SyndCategoryImpl.java in  » RSS-RDF » Rome » com » sun » syndication » feed » synd » 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 » Rome » com.sun.syndication.feed.synd 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2004 Sun Microsystems, Inc.
003:         *
004:         * Licensed under the Apache License, Version 2.0 (the "License");
005:         * you may not use this file except in compliance with the License.
006:         * You may obtain a copy of the License at
007:         *
008:         *     http://www.apache.org/licenses/LICENSE-2.0
009:         *
010:         * Unless required by applicable law or agreed to in writing, software
011:         * distributed under the License is distributed on an "AS IS" BASIS,
012:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013:         * See the License for the specific language governing permissions and
014:         * limitations under the License.
015:         *
016:         */
017:        package com.sun.syndication.feed.synd;
018:
019:        import com.sun.syndication.feed.impl.ObjectBean;
020:        import com.sun.syndication.feed.module.DCSubjectImpl;
021:        import com.sun.syndication.feed.module.DCSubject;
022:
023:        import java.util.AbstractList;
024:        import java.util.List;
025:        import java.util.ArrayList;
026:        import java.io.Serializable;
027:
028:        /**
029:         * Bean for categories of SyndFeedImpl feeds and entries.
030:         * <p>
031:         * @author Alejandro Abdelnur
032:         *
033:         */
034:        public class SyndCategoryImpl implements  Serializable, SyndCategory {
035:            private ObjectBean _objBean;
036:            private DCSubject _subject;
037:
038:            /**
039:             * For implementations extending SyndContentImpl to be able to use the ObjectBean functionality
040:             * with extended interfaces.
041:             * <p>
042:             * @param subject the DC subject to wrap.
043:             */
044:            SyndCategoryImpl(DCSubject subject) {
045:                _objBean = new ObjectBean(SyndCategory.class, this );
046:                _subject = subject;
047:            }
048:
049:            /**
050:             * Creates a deep 'bean' clone of the object.
051:             * <p>
052:             * @return a clone of the object.
053:             * @throws CloneNotSupportedException thrown if an element of the object cannot be cloned.
054:             *
055:             */
056:            public Object clone() throws CloneNotSupportedException {
057:                return _objBean.clone();
058:            }
059:
060:            /**
061:             * Indicates whether some other object is "equal to" this one as defined by the Object equals() method.
062:             * <p>
063:             * @param other he reference object with which to compare.
064:             * @return <b>true</b> if 'this' object is equal to the 'other' object.
065:             *
066:             */
067:            public boolean equals(Object other) {
068:                return _objBean.equals(other);
069:            }
070:
071:            /**
072:             * Returns a hashcode value for the object.
073:             * <p>
074:             * It follows the contract defined by the Object hashCode() method.
075:             * <p>
076:             * @return the hashcode of the bean object.
077:             *
078:             */
079:            public int hashCode() {
080:                return _objBean.hashCode();
081:            }
082:
083:            /**
084:             * Returns the String representation for the object.
085:             * <p>
086:             * @return String representation for the object.
087:             *
088:             */
089:            public String toString() {
090:                return _objBean.toString();
091:            }
092:
093:            /**
094:             * Package private constructor, used by SyndCategoryListFacade.
095:             * <p>
096:             * @return the DC subject being wrapped.
097:             *
098:             */
099:            DCSubject getSubject() {
100:                return _subject;
101:            }
102:
103:            /**
104:             * Default constructor. All properties are set to <b>null</b>.
105:             * <p>
106:             *
107:             */
108:            public SyndCategoryImpl() {
109:                this (new DCSubjectImpl());
110:            }
111:
112:            /**
113:             * Returns the category name.
114:             * <p>
115:             * @return the category name, <b>null</b> if none.
116:             *
117:             */
118:            public String getName() {
119:                return _subject.getValue();
120:            }
121:
122:            /**
123:             * Sets the category name.
124:             * <p>
125:             * @param name the category name to set, <b>null</b> if none.
126:             *
127:             */
128:            public void setName(String name) {
129:                _subject.setValue(name);
130:            }
131:
132:            /**
133:             * Returns the category taxonomy URI.
134:             * <p>
135:             * @return the category taxonomy URI, <b>null</b> if none.
136:             *
137:             */
138:            public String getTaxonomyUri() {
139:                return _subject.getTaxonomyUri();
140:            }
141:
142:            /**
143:             * Sets the category taxonomy URI.
144:             * <p>
145:             * @param taxonomyUri the category taxonomy URI to set, <b>null</b> if none.
146:             *
147:             */
148:            public void setTaxonomyUri(String taxonomyUri) {
149:                _subject.setTaxonomyUri(taxonomyUri);
150:            }
151:
152:        }
153:
154:        /**
155:         * List implementation for SyndCategoryImpl elements. To be directly used by the SyndFeedImpl
156:         * and SyndEntryImpl classes only.
157:         * <p>
158:         * It acts as a facade on top of the DCSubjectImpl elements of the underlying list
159:         * and remains in synch with it. It is possible to work on either list, the categories
160:         * one or the subjects one and they remain in synch.
161:         * <p>
162:         * This is necessary because the SyndFeedImpl categories are just a convenience to access
163:         * the DublinCore subjects.
164:         * <P>
165:         * All this mess to avoid making DCSubjectImpl implement SyndCategory (which it would be odd).
166:         * <p>
167:         * @author Alejandro Abdelnur
168:         *
169:         */
170:        class SyndCategoryListFacade extends AbstractList {
171:            private List _subjects;
172:
173:            /**
174:             * Default constructor. Creates and empty list.
175:             */
176:            public SyndCategoryListFacade() {
177:                this (new ArrayList());
178:            }
179:
180:            /**
181:             * Creates a facade list of categories on top the given subject list.
182:             * <P>
183:             * @param subjects the list of subjects to create the facade.
184:             *
185:             */
186:            public SyndCategoryListFacade(List subjects) {
187:                _subjects = subjects;
188:            }
189:
190:            /**
191:             * Gets the category by index.
192:             * <p>
193:             * @param index the index position to retrieve the category.
194:             * @return the SyndCategoryImpl in position index, <b>null</b> if none.
195:             *
196:             */
197:            public Object get(int index) {
198:                return new SyndCategoryImpl((DCSubject) _subjects.get(index));
199:            }
200:
201:            /**
202:             * Returns the size of the list.
203:             * <p>
204:             * @return the size of the list.
205:             *
206:             */
207:            public int size() {
208:                return _subjects.size();
209:            }
210:
211:            /**
212:             * Sets a category in an existing position in the list.
213:             * <p>
214:             * @param index position to set the category.
215:             * @param obj the SyndCategoryImpl object to set.
216:             * @return the SyndCategoryImpl object that is being replaced, <b>null</b> if none.
217:             *
218:             */
219:            public Object set(int index, Object obj) {
220:                SyndCategoryImpl sCat = (SyndCategoryImpl) obj;
221:                DCSubject subject = (sCat != null) ? sCat.getSubject() : null;
222:                subject = (DCSubject) _subjects.set(index, subject);
223:                return (subject != null) ? new SyndCategoryImpl(subject) : null;
224:            }
225:
226:            /**
227:             * Adds a category to the list.
228:             * <p>
229:             * @param index position to add the category.
230:             * @param obj the SyndCategoryImpl object to add.
231:             *
232:             */
233:            public void add(int index, Object obj) {
234:                SyndCategoryImpl sCat = (SyndCategoryImpl) obj;
235:                DCSubject subject = (sCat != null) ? sCat.getSubject() : null;
236:                _subjects.add(index, subject);
237:            }
238:
239:            /**
240:             * Removes a category element from a specific position.
241:             * <p>
242:             * @param index position to remove the category from.
243:             * @return the SyndCategoryImpl being removed from position index, <b>null</b> if none.
244:             *
245:             */
246:            public Object remove(int index) {
247:                DCSubject subject = (DCSubject) _subjects.remove(index);
248:                return (subject != null) ? new SyndCategoryImpl(subject) : null;
249:            }
250:
251:            /**
252:             * Returns a list with the DCSubject elements of the SyndCategoryImpl list facade.
253:             * To be used by the SyndFeedImpl class only.
254:             * <p>
255:             * @param cList the list with SyndCategoryImpl elements to convert to subject list.
256:             * @return a list with DCSubject elements corresponding to the categories in the given list.
257:             *
258:             */
259:            public static List convertElementsSyndCategoryToSubject(List cList) {
260:                List sList = null;
261:                if (cList != null) {
262:                    sList = new ArrayList();
263:                    for (int i = 0; i < cList.size(); i++) {
264:                        SyndCategoryImpl sCat = (SyndCategoryImpl) cList.get(i);
265:                        DCSubject subject = null;
266:                        if (sCat != null) {
267:                            subject = sCat.getSubject();
268:                        }
269:                        sList.add(subject);
270:                    }
271:                }
272:                return sList;
273:            }
274:
275:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.