Source Code Cross Referenced for NextPreviousContainer.java in  » Blogger-System » thingamablog » net » sf » thingamablog » generator » 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 » thingamablog » net.sf.thingamablog.generator 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Created on Feb 19, 2005
003:         *
004:         */
005:        package net.sf.thingamablog.generator;
006:
007:        import java.util.ArrayList;
008:        import java.util.Hashtable;
009:        import java.util.List;
010:
011:        import net.sf.thingamablog.blog.ArchiveRange;
012:        import net.sf.thingamablog.blog.BlogEntry;
013:        import net.sf.thingamablog.blog.TBWeblog;
014:
015:        /**
016:         * @author BT
017:         *
018:         */
019:        public class NextPreviousContainer implements  TemplateContainer {
020:            public static final int NEXT = -1;
021:            public static final int PREV = -2;
022:
023:            private int dir = NEXT;
024:            private long entryID = -1;
025:            private ArchiveRange arc = null;
026:            private String cat = null;
027:
028:            private TBWeblog blog = null;
029:
030:            private boolean exists = true;
031:
032:            private HyperTextTag pageTitleTag = new HyperTextTag("PageName");
033:            private TextTag pageLinkTag = new TextTag("PageLink");
034:
035:            private String pageTitle;
036:            private String pageLink;
037:
038:            public NextPreviousContainer(int dir) {
039:                this .dir = dir;
040:            }
041:
042:            public NextPreviousContainer(TBWeblog blog, String cat, int dir) {
043:                this (dir);
044:                this .cat = cat;
045:                this .blog = blog;
046:            }
047:
048:            public NextPreviousContainer(TBWeblog blog, ArchiveRange arc,
049:                    int dir) {
050:                this (dir);
051:                this .arc = arc;
052:                this .blog = blog;
053:            }
054:
055:            public NextPreviousContainer(TBWeblog blog, long id, int dir) {
056:                this (dir);
057:                this .entryID = id;
058:                this .blog = blog;
059:            }
060:
061:            public List getContainers() {
062:                ArrayList list = new ArrayList(2);
063:                list.add(new IfPageExists());
064:                list.add(new IfNoPageExists());
065:                return list;
066:            }
067:
068:            public List getTags() {
069:                //return tags;
070:                return null;
071:            }
072:
073:            public Hashtable getDefaultAttributes() {
074:                return null;
075:            }
076:
077:            /* (non-Javadoc)
078:             * @see net.sf.thingamablog.generator1.TemplateContainer#processAgain()
079:             */
080:            public boolean processAgain() {
081:                return false;
082:            }
083:
084:            /* (non-Javadoc)
085:             * @see net.sf.thingamablog.generator1.TemplateContainer#prefix()
086:             */
087:            public String prefix() {
088:                return null;
089:            }
090:
091:            /* (non-Javadoc)
092:             * @see net.sf.thingamablog.generator1.TemplateContainer#postfix()
093:             */
094:            public String postfix() {
095:                return null;
096:            }
097:
098:            public void initialize(Hashtable attribs) {
099:                if (blog == null) {
100:                    exists = false;
101:                    return;
102:                }
103:
104:                if (cat != null) {
105:                    try {
106:                        String cats[] = blog.getCategories();
107:                        Object o = getNextOrPrev(cat, cats);
108:                        if (o != null) {
109:                            String c = o.toString();
110:                            pageTitle = c;
111:                            pageLink = blog.getArchiveUrl()
112:                                    + blog.getCategoryFileName(c);
113:                            exists = true;
114:                        } else
115:                            exists = false;
116:                    } catch (Exception ex) {
117:                        exists = false;
118:                    }
119:                } else if (arc != null) {
120:                    try {
121:                        ArchiveRange arcs[] = blog.getArchives();
122:                        Object o = getNextOrPrev(arc, arcs);
123:                        if (o != null) {
124:                            ArchiveRange a = (ArchiveRange) o;
125:                            pageTitle = a.getFormattedRange();
126:                            pageLink = blog.getArchiveUrl()
127:                                    + blog.getArchiveFileName(a);
128:                            exists = true;
129:                        } else
130:                            exists = false;
131:                    } catch (Exception ex) {
132:                        exists = false;
133:                    }
134:                } else if (entryID > -1) {
135:                    try {
136:                        BlogEntry be = blog.getEntry(entryID);
137:                        if (dir == NEXT)
138:                            be = blog.getEntryAfter(be.getDate());
139:                        else
140:                            be = blog.getEntryBefore(be.getDate());
141:                        if (be != null) {
142:                            pageTitle = be.getTitle();
143:                            pageLink = blog.getUrlForEntry(be);
144:                        } else
145:                            exists = false;
146:                    } catch (Exception ex) {
147:                        exists = false;
148:                    }
149:                }
150:
151:            }
152:
153:            private Object getNextOrPrev(Object o, Object ar[]) {
154:                if (ar.length == 0)
155:                    return null;
156:
157:                int i;
158:                for (i = 0; i < ar.length; i++) {
159:                    if (ar[i].equals(o))
160:                        break;
161:                }
162:
163:                if (dir == NEXT) {
164:                    if (i < ar.length - 1)
165:                        return ar[i + 1];
166:                } else {
167:                    if (i > 0)
168:                        return ar[i - 1];
169:                }
170:
171:                return null;
172:            }
173:
174:            public String getName() {
175:                if (dir == NEXT)
176:                    return "NextPage";
177:                return "PreviousPage";
178:            }
179:
180:            public boolean isVisible() {
181:                return true;
182:            }
183:
184:            public Object getValueForTag(TemplateTag tag) {
185:                return "";
186:            }
187:
188:            private class IfPageExists extends BasicContainer {
189:                public IfPageExists() {
190:                    super ("IfPageExists");
191:                    registerTag(pageTitleTag);
192:                    registerTag(pageLinkTag);
193:                }
194:
195:                public boolean isVisible() {
196:                    return exists;
197:                }
198:
199:                public Object getValueForTag(TemplateTag tag) {
200:                    if (tag == pageLinkTag)
201:                        return pageLink;
202:                    if (tag == pageTitleTag)
203:                        return pageTitle;
204:                    return "";
205:                }
206:            }
207:
208:            private class IfNoPageExists extends BasicContainer {
209:                public IfNoPageExists() {
210:                    super ("IfNoPageExists");
211:                }
212:
213:                public boolean isVisible() {
214:                    return !exists;
215:                }
216:
217:                public Object getValueForTag(TemplateTag tag) {
218:                    return "";
219:                }
220:            }
221:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.