Source Code Cross Referenced for IfCommand.java in  » Web-Server » Jigsaw » org » w3c » jigsaw » ssi » commands » 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 » Web Server » Jigsaw » org.w3c.jigsaw.ssi.commands 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        // DirectoryResource.java
002:        // $Id: IfCommand.java,v 1.6 2000/08/16 21:37:47 ylafon Exp $
003:        // (c) COPYRIGHT MIT and INRIA, 1996.
004:        // Please first read the full copyright statement in file COPYRIGHT.html
005:
006:        package org.w3c.jigsaw.ssi.commands;
007:
008:        import java.util.Dictionary;
009:        import java.util.Hashtable;
010:
011:        import org.w3c.www.http.HTTP;
012:
013:        import org.w3c.jigsaw.http.Reply;
014:        import org.w3c.jigsaw.http.Request;
015:
016:        import org.w3c.tools.resources.FramedResource;
017:        import org.w3c.tools.resources.Resource;
018:        import org.w3c.tools.resources.ResourceFrame;
019:
020:        import org.w3c.util.ArrayDictionary;
021:
022:        import org.w3c.jigsaw.ssi.SSIFrame;
023:
024:        /**
025:         * Implementation of the SSI <code>if</code> command.  
026:         * @author Benoit Mahe <bmahe@sophia.inria.fr>
027:         */
028:        public class IfCommand implements  ControlCommand {
029:            private final static String NAME = "if";
030:            private final static boolean debug = true;
031:
032:            private static final String keys[] = { "name", "command", "var",
033:                    "equals" };
034:
035:            protected static Hashtable ifstore = null;
036:
037:            static {
038:                ifstore = new Hashtable(23);
039:            }
040:
041:            /**
042:             * return true if reply can be cached.
043:             * @return a boolean.
044:             */
045:            public boolean acceptCaching() {
046:                return false;
047:            }
048:
049:            /**
050:             * Returns the (String) value of the given variable.
051:             * @return a String instance.
052:             */
053:            public String getValue(Dictionary variables, String var,
054:                    Request request) {
055:                return null;
056:            }
057:
058:            protected static int getPosition(String name)
059:                    throws ControlCommandException {
060:                Integer pos = (Integer) ifstore.get(name);
061:                if (pos == null)
062:                    throw new ControlCommandException(NAME, "Position unknown.");
063:                else
064:                    return pos.intValue();
065:            }
066:
067:            /**
068:             * register the command position in the structure
069:             * witch store the SSIFrame.
070:             */
071:            public void setPosition(SSIFrame ssiframe, Request request,
072:                    CommandRegistry registry, ArrayDictionary parameters,
073:                    Dictionary variables, int position) {
074:                Object values[] = parameters.getMany(keys);
075:                String name = (String) values[0];
076:                if (name != null)
077:                    ifstore.put(ssiframe.getResource().getURLPath() + ":"
078:                            + name, new Integer(position));
079:            }
080:
081:            /**
082:             * Executes this command. Might modify variables.
083:             * Must <em>not</em> modify the parameters.
084:             * <P> It may handle conditional requests, <em>except</em> that if
085:             * it replies with a status of HTTP.NOT_MODIFIED, it <em>must</em>
086:             * still reply with a content (the same content that it would have
087:             * returned for an inconditional request).  This is because
088:             * further SSI commands down the line may decide thay they have
089:             * been modified, and then a content must be emitted by SSIFrame.
090:             *
091:             * @param request the original HTTP request
092:             * @param parameters The parameters for this command
093:             * @param variables The global variables for the parse 
094:             * @return a Reply with the output from the command */
095:            public Reply execute(SSIFrame ssiframe, Request request,
096:                    ArrayDictionary parameters, Dictionary variables) {
097:                return ssiframe.createCommandReply(request, HTTP.OK);
098:            }
099:
100:            protected boolean check(CommandRegistry registry,
101:                    ArrayDictionary parameters, Dictionary variables,
102:                    Request request) {
103:                Object values[] = parameters.getMany(keys);
104:                String name = (String) values[0];
105:                String command = (String) values[1];
106:                String var = (String) values[2];
107:                String equals = (String) values[3];
108:
109:                if ((command == null) || (var == null) || (equals == null))
110:                    return false;
111:                Command cmd = registry.lookupCommand(command);
112:                String value = cmd.getValue(variables, var, request);
113:                return value.equals(equals);
114:            }
115:
116:            /**
117:             * Give the next position in the structure witch
118:             * store the SSIFrame.
119:             * @return An integer
120:             * @exception ControlCommandException if action failed.
121:             */
122:            public int jumpTo(SSIFrame ssiframe, Request request,
123:                    CommandRegistry registry, ArrayDictionary parameters,
124:                    Dictionary variables) throws ControlCommandException {
125:                Object values[] = parameters.getMany(keys);
126:                String name = (String) values[0];
127:                if (name != null) {
128:                    if (check(registry, parameters, variables, request))
129:                        return getPosition(ssiframe.getResource().getURLPath()
130:                                + ":" + name) + 1;
131:                    try {
132:                        return (ElseCommand.getPosition(ssiframe.getResource()
133:                                .getURLPath()
134:                                + ":" + name) + 1);
135:                    } catch (ControlCommandException ex) {
136:                        return (EndifCommand.getPosition(ssiframe.getResource()
137:                                .getURLPath()
138:                                + ":" + name) + 1);
139:                    }
140:                }
141:                throw new ControlCommandException(NAME, "name not initialized.");
142:            }
143:
144:            /** 
145:             * Returns the name of this command. <em>(Case sensitivity is up to
146:             * the <code>lookupCommand</code> method in the command registry.)</em>
147:             *
148:             * @return the name of the command
149:             * @see org.w3c.jigsaw.ssi.commands.CommandRegistry#lookupCommand
150:             */
151:            public String getName() {
152:                return NAME;
153:            }
154:
155:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.