Source Code Cross Referenced for NonJsonNestedOutboundVariable.java in  » Ajax » dwr » org » directwebremoting » dwrp » 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 » Ajax » dwr » org.directwebremoting.dwrp 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2005 Joe Walker
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:        package org.directwebremoting.dwrp;
017:
018:        import java.util.Collection;
019:
020:        import org.directwebremoting.extend.JsonModeMarshallException;
021:        import org.directwebremoting.extend.NonNestedOutboundVariable;
022:        import org.directwebremoting.extend.OutboundContext;
023:        import org.directwebremoting.extend.OutboundVariable;
024:
025:        /**
026:         * A helper class for people that want to implement {@link OutboundVariable}.
027:         * @author Joe Walker [joe at getahead dot ltd dot uk]
028:         */
029:        public abstract class NonJsonNestedOutboundVariable implements 
030:                OutboundVariable {
031:            /**
032:             * @param outboundContext the OutboundContext to set
033:             */
034:            protected NonJsonNestedOutboundVariable(
035:                    OutboundContext outboundContext) {
036:                this .outboundContext = outboundContext;
037:            }
038:
039:            /**
040:             * We might want to force us into predefined mode.
041:             */
042:            protected void forceOutline() {
043:                // if we are in JSON mode then we are not allowed to be non-inline.
044:                if (outboundContext.isJsonMode()) {
045:                    throw new JsonModeMarshallException(
046:                            NonJsonNestedOutboundVariable.class,
047:                            "Outline in JSON mode is illegal");
048:                }
049:
050:                this .outline = true;
051:            }
052:
053:            /**
054:             * @return the outline
055:             */
056:            public boolean isOutline() {
057:                return outline;
058:            }
059:
060:            /* (non-Javadoc)
061:             * @see org.directwebremoting.OutboundVariable#getDeclareCode()
062:             */
063:            public String getDeclareCode() {
064:                if (declareCode == null || children == null) {
065:                    throw new NullPointerException();
066:                }
067:
068:                return declareCode + getChildDeclareCodes();
069:            }
070:
071:            /**
072:             * @param declareCode the declareCode to set
073:             */
074:            public void setBaseDeclareCode(String declareCode) {
075:                this .declareCode = declareCode;
076:            }
077:
078:            /* (non-Javadoc)
079:             * @see org.directwebremoting.OutboundVariable#getBuildCode()
080:             */
081:            public String getBuildCode() {
082:                if (declareCode == null || children == null) {
083:                    throw new NullPointerException();
084:                }
085:
086:                return buildCode + getChildBuildCodes();
087:            }
088:
089:            /**
090:             * @param buildCode the buildCode to set
091:             */
092:            public void setBaseBuildCode(String buildCode) {
093:                this .buildCode = buildCode;
094:            }
095:
096:            /* (non-Javadoc)
097:             * @see org.directwebremoting.OutboundVariable#getAssignCode()
098:             */
099:            public String getAssignCode() {
100:                return assignCode;
101:            }
102:
103:            /**
104:             * @param assignCode the assignCode to set
105:             */
106:            public void setAssignCode(String assignCode) {
107:                this .assignCode = assignCode;
108:            }
109:
110:            /* (non-Javadoc)
111:             * @see org.directwebremoting.OutboundVariable#getReference()
112:             */
113:            public OutboundVariable getReferenceVariable() {
114:                if (reference == null) {
115:                    reference = new NonNestedOutboundVariable(getVariableName());
116:                    forceOutline();
117:                }
118:
119:                return reference;
120:            }
121:
122:            /**
123:             * In JSON mode we need to recursively prepare assign codes because the
124:             * order in which they are created matters.
125:             */
126:            protected void prepareChildAssignCodes() {
127:                for (OutboundVariable child : children) {
128:                    child.prepareAssignCode();
129:                }
130:            }
131:
132:            /**
133:             * Grab all the build codes together
134:             * @return A build string
135:             */
136:            private String getChildBuildCodes() {
137:                if (children == null) {
138:                    return "";
139:                }
140:
141:                StringBuffer buffer = new StringBuffer();
142:
143:                // Make sure the nested things are declared
144:                for (OutboundVariable nested : children) {
145:                    buffer.append(nested.getBuildCode());
146:                }
147:
148:                return buffer.toString();
149:            }
150:
151:            /**
152:             * Grab all the declare codes together
153:             * @return A declare string
154:             */
155:            private String getChildDeclareCodes() {
156:                if (children == null) {
157:                    return "";
158:                }
159:
160:                StringBuffer buffer = new StringBuffer();
161:
162:                // Make sure the nested things are declared
163:                for (OutboundVariable nested : children) {
164:                    buffer.append(nested.getDeclareCode());
165:                }
166:
167:                return buffer.toString();
168:            }
169:
170:            /**
171:             * @return the varName
172:             */
173:            protected String getVariableName() {
174:                if (varName == null) {
175:                    varName = outboundContext.getNextVariableName();
176:                }
177:
178:                return varName;
179:            }
180:
181:            /**
182:             * When we create buildCode and declareCode, what do we need to add?
183:             * @param children The list of dependent {@link OutboundVariable}s
184:             */
185:            public void setChildren(Collection<OutboundVariable> children) {
186:                this .children = children;
187:            }
188:
189:            /**
190:             * Does anything refer to us?
191:             */
192:            private OutboundVariable reference;
193:
194:            /**
195:             * Are we known to be recursive
196:             */
197:            private boolean outline = false;
198:
199:            /**
200:             * The code to be executed to do basic initialization
201:             */
202:            private String declareCode;
203:
204:            /**
205:             * The code to be executed to setup the data structure
206:             */
207:            private String buildCode;
208:
209:            /**
210:             * The code to use to refer to this data structure
211:             */
212:            private String assignCode;
213:
214:            /**
215:             * If we get recursive, this is the variable name we declare
216:             */
217:            private String varName;
218:
219:            /**
220:             * When we create buildCode and declareCode, what do we need to add?
221:             */
222:            protected Collection<OutboundVariable> children;
223:
224:            /**
225:             * The conversion context
226:             */
227:            private OutboundContext outboundContext;
228:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.