Source Code Cross Referenced for WeblogEntry.java in  » Blogger-System » apache-roller-3.1 » org » apache » roller » webservices » adminapi » sdk » 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 » Blogger System » apache roller 3.1 » org.apache.roller.webservices.adminapi.sdk 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         *  contributor license agreements.  The ASF licenses this file to You
004:         * under the Apache License, Version 2.0 (the "License"); you may not
005:         * 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.  For additional information regarding
015:         * copyright in this work, please see the NOTICE file in the top level
016:         * directory of this distribution.
017:         */
018:        package org.apache.roller.webservices.adminapi.sdk;
019:
020:        /*
021:         * WeblogEntry.java
022:         *
023:         * Created on January 17, 2006, 12:44 PM
024:         */
025:
026:        import java.io.IOException;
027:        import java.io.InputStream;
028:        import java.util.Date;
029:        import java.util.Locale;
030:        import java.util.TimeZone;
031:        import org.jdom.Document;
032:        import org.jdom.Element;
033:        import org.jdom.JDOMException;
034:        import org.jdom.Text;
035:        import org.jdom.input.SAXBuilder;
036:        import org.apache.roller.webservices.adminapi.sdk.Entry.Attributes;
037:        import org.apache.roller.webservices.adminapi.sdk.Entry.Types;
038:
039:        /**
040:         * This class describes a weblog entry.
041:         */
042:        public class WeblogEntry extends Entry {
043:            static interface Tags {
044:                public static final String WEBLOG = "weblog";
045:                public static final String HANDLE = "handle";
046:                public static final String NAME = "name";
047:                public static final String DESCRIPTION = "description";
048:                public static final String LOCALE = "locale";
049:                public static final String TIMEZONE = "timezone";
050:                public static final String DATE_CREATED = "date-created";
051:                public static final String CREATING_USER = "creating-user";
052:                public static final String EMAIL_ADDRESS = "email-address";
053:                public static final String APP_ENTRIES_URL = "app-entries-url";
054:                public static final String APP_RESOURCES_URL = "app-resources-url";
055:                public static final String ENABLED = "enabled";
056:            }
057:
058:            private String handle;
059:            private String name;
060:            private String description;
061:            private Locale locale;
062:            private TimeZone timezone;
063:            private Date dateCreated;
064:            private String creatingUser;
065:            private String emailAddress;
066:            private String appEntriesUrl;
067:            private String appResourcesUrl;
068:            private Boolean enabled;
069:
070:            public WeblogEntry(Element e, String urlPrefix) {
071:                populate(e, urlPrefix);
072:            }
073:
074:            public WeblogEntry(InputStream stream, String urlPrefix)
075:                    throws JDOMException, IOException {
076:                SAXBuilder sb = new SAXBuilder();
077:                Document d = sb.build(stream);
078:                Element e = d.detachRootElement();
079:
080:                populate(e, urlPrefix);
081:            }
082:
083:            private void populate(Element e, String urlPrefix) {
084:                // handle (required)
085:                Element handleElement = e.getChild(Tags.HANDLE,
086:                        Service.NAMESPACE);
087:                if (handleElement != null) {
088:                    setHandle(handleElement.getText());
089:                }
090:
091:                // href
092:                String href = urlPrefix + "/" + EntrySet.Types.WEBLOGS + "/"
093:                        + getHandle();
094:                setHref(href);
095:
096:                // name
097:                Element nameElement = e.getChild(Tags.NAME, Service.NAMESPACE);
098:                if (nameElement != null) {
099:                    setName(nameElement.getText());
100:                }
101:
102:                // description
103:                Element descElement = e.getChild(Tags.DESCRIPTION,
104:                        Service.NAMESPACE);
105:                if (descElement != null) {
106:                    setDescription(descElement.getText());
107:                }
108:
109:                // locale
110:                Element localeElement = e.getChild(Tags.LOCALE,
111:                        Service.NAMESPACE);
112:                if (localeElement != null) {
113:                    setLocale(localeElement.getText());
114:                }
115:
116:                // timezone
117:                Element tzElement = e
118:                        .getChild(Tags.TIMEZONE, Service.NAMESPACE);
119:                if (tzElement != null) {
120:                    setTimezone(tzElement.getText());
121:                }
122:
123:                // creator
124:                Element creatorElement = e.getChild(Tags.CREATING_USER,
125:                        Service.NAMESPACE);
126:                if (creatorElement != null) {
127:                    setCreatingUser(creatorElement.getText());
128:                }
129:
130:                // email address
131:                Element emailElement = e.getChild(Tags.EMAIL_ADDRESS,
132:                        Service.NAMESPACE);
133:                if (emailElement != null) {
134:                    setEmailAddress(emailElement.getText());
135:                }
136:
137:                // created
138:                Element createdElement = e.getChild(Tags.DATE_CREATED,
139:                        Service.NAMESPACE);
140:                if (createdElement != null) {
141:                    setDateCreated(new Date(Long.valueOf(
142:                            createdElement.getText()).longValue()));
143:                }
144:
145:                // APP entries URL
146:                Element appEntriesUrlElement = e.getChild(Tags.APP_ENTRIES_URL,
147:                        Service.NAMESPACE);
148:                if (appEntriesUrlElement != null) {
149:                    setAppEntriesUrl(appEntriesUrlElement.getText());
150:                }
151:
152:                // APP resources URL
153:                Element appResourcesUrlElement = e.getChild(
154:                        Tags.APP_RESOURCES_URL, Service.NAMESPACE);
155:                if (appResourcesUrlElement != null) {
156:                    setAppResourcesUrl(appResourcesUrlElement.getText());
157:                }
158:
159:                // enabled
160:                Element enabledElement = e.getChild(Tags.ENABLED,
161:                        Service.NAMESPACE);
162:                if (enabledElement != null) {
163:                    setEnabled(Boolean.valueOf(enabledElement.getText()));
164:                }
165:            }
166:
167:            public WeblogEntry(String handle, String urlPrefix) {
168:                String href = urlPrefix + "/" + EntrySet.Types.WEBLOGS + "/"
169:                        + handle;
170:                setHref(href);
171:                setHandle(handle);
172:            }
173:
174:            public String getType() {
175:                return Types.WEBLOG;
176:            }
177:
178:            public Document toDocument() {
179:                Element weblog = new Element(Tags.WEBLOG, Service.NAMESPACE);
180:                Document doc = new Document(weblog);
181:
182:                // link
183:                weblog.setAttribute(Attributes.HREF, getHref());
184:
185:                // handle (required)
186:                String handle = getHandle();
187:                if (handle != null && handle.length() > 0) {
188:                    Element handleElement = new Element(Tags.HANDLE,
189:                            Service.NAMESPACE);
190:                    Text handleText = new Text(handle);
191:                    handleElement.addContent(handleText);
192:                    weblog.addContent(handleElement);
193:                }
194:
195:                // name
196:                String name = getName();
197:                if (name != null) {
198:                    Element nameElement = new Element(Tags.NAME,
199:                            Service.NAMESPACE);
200:                    Text nameText = new Text(name);
201:                    nameElement.addContent(nameText);
202:                    weblog.addContent(nameElement);
203:                }
204:
205:                // description
206:                String desc = getDescription();
207:                if (desc != null) {
208:                    Element descElement = new Element(Tags.DESCRIPTION,
209:                            Service.NAMESPACE);
210:                    Text descText = new Text(desc);
211:                    descElement.addContent(descText);
212:                    weblog.addContent(descElement);
213:                }
214:
215:                // locale
216:                Locale locale = getLocale();
217:                if (locale != null) {
218:                    Element localeElement = new Element(Tags.LOCALE,
219:                            Service.NAMESPACE);
220:                    Text localeText = new Text(locale.toString());
221:                    localeElement.addContent(localeText);
222:                    weblog.addContent(localeElement);
223:                }
224:
225:                // timezone
226:                TimeZone tz = getTimezone();
227:                if (tz != null) {
228:                    Element tzElement = new Element(Tags.TIMEZONE,
229:                            Service.NAMESPACE);
230:                    Text tzText = new Text(tz.getID());
231:                    tzElement.addContent(tzText);
232:                    weblog.addContent(tzElement);
233:                }
234:
235:                // creating user
236:                String creator = getCreatingUser();
237:                if (creator != null) {
238:                    Element creatorElement = new Element(Tags.CREATING_USER,
239:                            Service.NAMESPACE);
240:                    Text creatorText = new Text(creator);
241:                    creatorElement.addContent(creatorText);
242:                    weblog.addContent(creatorElement);
243:                }
244:
245:                // email address
246:                String email = getEmailAddress();
247:                if (email != null) {
248:                    Element emailElement = new Element(Tags.EMAIL_ADDRESS,
249:                            Service.NAMESPACE);
250:                    Text emailText = new Text(email);
251:                    emailElement.addContent(emailText);
252:                    weblog.addContent(emailElement);
253:                }
254:
255:                // creation date
256:                Element dateCreatedElement = new Element(Tags.DATE_CREATED,
257:                        Service.NAMESPACE);
258:                Date datedCreated = getDateCreated();
259:                if (dateCreated != null) {
260:                    Text createdText = new Text(String.valueOf(dateCreated
261:                            .getTime()));
262:                    dateCreatedElement.addContent(createdText);
263:                    weblog.addContent(dateCreatedElement);
264:                }
265:
266:                // APP entries URL
267:                Element appEntriesUrlElement = new Element(
268:                        Tags.APP_ENTRIES_URL, Service.NAMESPACE);
269:                String appEntriesUrl = getAppEntriesUrl();
270:                if (appEntriesUrl != null) {
271:                    Text appEntriesUrlText = new Text(appEntriesUrl);
272:                    appEntriesUrlElement.addContent(appEntriesUrlText);
273:                    weblog.addContent(appEntriesUrlElement);
274:                }
275:
276:                // APP entries URL
277:                Element appResourcesUrlElement = new Element(
278:                        Tags.APP_RESOURCES_URL, Service.NAMESPACE);
279:                String appResourcesUrl = getAppResourcesUrl();
280:                if (appResourcesUrl != null) {
281:                    Text appResourcesUrlText = new Text(appResourcesUrl);
282:                    appResourcesUrlElement.addContent(appResourcesUrlText);
283:                    weblog.addContent(appResourcesUrlElement);
284:                }
285:
286:                // enabled
287:                Element enabledElement = new Element(Tags.ENABLED,
288:                        Service.NAMESPACE);
289:                Boolean enabled = getEnabled();
290:                if (enabled != null) {
291:                    Text enabledText = new Text(getEnabled().toString());
292:                    enabledElement.addContent(enabledText);
293:                    weblog.addContent(enabledElement);
294:                }
295:
296:                return doc;
297:            }
298:
299:            /** Test if a user entry is equal to this user entry. */
300:            public boolean equals(Object o) {
301:                if (o == null || o.getClass() != this .getClass()) {
302:                    return false;
303:                }
304:
305:                WeblogEntry other = (WeblogEntry) o;
306:
307:                if (!areEqual(getEmailAddress(), other.getEmailAddress())) {
308:                    return false;
309:                }
310:                if (!areEqual(getHandle(), other.getHandle())) {
311:                    return false;
312:                }
313:                if (!areEqual(getLocale(), other.getLocale())) {
314:                    return false;
315:                }
316:                if (!areEqual(getName(), other.getName())) {
317:                    return false;
318:                }
319:                if (!areEqual(getDescription(), other.getDescription())) {
320:                    return false;
321:                }
322:                if (!areEqual(getTimezone(), other.getTimezone())) {
323:                    return false;
324:                }
325:                if (!areEqual(getEnabled(), other.getEnabled())) {
326:                    return false;
327:                }
328:
329:                return super .equals(o);
330:            }
331:
332:            public String getHandle() {
333:                return handle;
334:            }
335:
336:            public void setHandle(String handle) {
337:                this .handle = handle;
338:            }
339:
340:            public String getDescription() {
341:                return description;
342:            }
343:
344:            public void setDescription(String description) {
345:                this .description = description;
346:            }
347:
348:            public Locale getLocale() {
349:                return locale;
350:            }
351:
352:            public void setLocale(Locale locale) {
353:                this .locale = locale;
354:            }
355:
356:            public void setLocale(String localeString) {
357:                this .locale = new LocaleString(localeString).getLocale();
358:            }
359:
360:            public TimeZone getTimezone() {
361:                return timezone;
362:            }
363:
364:            public void setTimezone(TimeZone timezone) {
365:                this .timezone = timezone;
366:            }
367:
368:            public void setTimezone(String timezoneString) {
369:                this .timezone = TimeZone.getTimeZone(timezoneString);
370:            }
371:
372:            public String getName() {
373:                return name;
374:            }
375:
376:            public void setName(String name) {
377:                this .name = name;
378:            }
379:
380:            public Date getDateCreated() {
381:                return dateCreated;
382:            }
383:
384:            public void setDateCreated(Date dateCreated) {
385:                this .dateCreated = dateCreated;
386:            }
387:
388:            public String getCreatingUser() {
389:                return creatingUser;
390:            }
391:
392:            public void setCreatingUser(String creatingUser) {
393:                this .creatingUser = creatingUser;
394:            }
395:
396:            public String getEmailAddress() {
397:                return emailAddress;
398:            }
399:
400:            public void setEmailAddress(String emailAddress) {
401:                this .emailAddress = emailAddress;
402:            }
403:
404:            public String getAppEntriesUrl() {
405:                return appEntriesUrl;
406:            }
407:
408:            public void setAppEntriesUrl(String appEntriesUrl) {
409:                this .appEntriesUrl = appEntriesUrl;
410:            }
411:
412:            public String getAppResourcesUrl() {
413:                return appResourcesUrl;
414:            }
415:
416:            public void setAppResourcesUrl(String appResourcesUrl) {
417:                this .appResourcesUrl = appResourcesUrl;
418:            }
419:
420:            public Boolean getEnabled() {
421:                return enabled;
422:            }
423:
424:            public void setEnabled(Boolean enabled) {
425:                this.enabled = enabled;
426:            }
427:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.