~james-page/ubuntu/natty/tomcat6/fix-662588

« back to all changes in this revision

Viewing changes to java/org/apache/jasper/compiler/TagPluginManager.java

  • Committer: Bazaar Package Importer
  • Author(s): Mathias Gug, Iulian Udrea
  • Date: 2009-06-09 12:35:19 UTC
  • mfrom: (1.2.1 upstream) (2.1.4 sid)
  • Revision ID: james.westby@ubuntu.com-20090609123519-7owjbso5ttnka6ur
Tags: 6.0.20-1ubuntu1
[ Iulian Udrea ]
* Merge from debian unstable (LP: #385262), remaining changes:
  - debian/control, debian/rules: Use default-jdk to build
  - debian/control: Run using default-jre-headless by default

Show diffs side-by-side

added added

removed removed

Lines of Context:
150
150
            n.setAtSTag(curNodes);
151
151
            n.setUseTagPlugin(true);
152
152
            pluginAttributes = new HashMap();
153
 
        }
154
 
 
155
 
        public TagPluginContext getParentContext() {
156
 
            Node parent = node.getParent();
157
 
            if (! (parent instanceof Node.CustomTag)) {
158
 
                return null;
159
 
            }
160
 
            return ((Node.CustomTag) parent).getTagPluginContext();
161
 
        }
162
 
 
163
 
        public void setPluginAttribute(String key, Object value) {
164
 
            pluginAttributes.put(key, value);
165
 
        }
166
 
 
167
 
        public Object getPluginAttribute(String key) {
168
 
            return pluginAttributes.get(key);
169
 
        }
170
 
 
171
 
        public boolean isScriptless() {
172
 
            return node.getChildInfo().isScriptless();
173
 
        }
174
 
 
175
 
        public boolean isConstantAttribute(String attribute) {
176
 
            Node.JspAttribute attr = getNodeAttribute(attribute);
177
 
            if (attr == null)
178
 
                return false;
179
 
            return attr.isLiteral();
180
 
        }
181
 
 
182
 
        public String getConstantAttribute(String attribute) {
183
 
            Node.JspAttribute attr = getNodeAttribute(attribute);
184
 
            if (attr == null)
185
 
                return null;
186
 
            return attr.getValue();
187
 
        }
188
 
 
189
 
        public boolean isAttributeSpecified(String attribute) {
190
 
            return getNodeAttribute(attribute) != null;
191
 
        }
192
 
 
193
 
        public String getTemporaryVariableName() {
194
 
            return JspUtil.nextTemporaryVariableName();
195
 
        }
196
 
 
197
 
        public void generateImport(String imp) {
198
 
            pageInfo.addImport(imp);
199
 
        }
200
 
 
201
 
        public void generateDeclaration(String id, String text) {
202
 
            if (pageInfo.isPluginDeclared(id)) {
203
 
                return;
204
 
            }
205
 
            curNodes.add(new Node.Declaration(text, node.getStart(), null));
206
 
        }
207
 
 
208
 
        public void generateJavaSource(String sourceCode) {
209
 
            curNodes.add(new Node.Scriptlet(sourceCode, node.getStart(),
210
 
                                            null));
211
 
        }
212
 
 
213
 
        public void generateAttribute(String attributeName) {
214
 
            curNodes.add(new Node.AttributeGenerator(node.getStart(),
215
 
                                                     attributeName,
216
 
                                                     node));
217
 
        }
218
 
 
219
 
        public void dontUseTagPlugin() {
220
 
            node.setUseTagPlugin(false);
221
 
        }
222
 
 
223
 
        public void generateBody() {
224
 
            // Since we'll generate the body anyway, this is really a nop, 
225
 
            // except for the fact that it lets us put the Java sources the
226
 
            // plugins produce in the correct order (w.r.t the body).
227
 
            curNodes = node.getAtETag();
228
 
        }
229
 
 
230
 
        private Node.JspAttribute getNodeAttribute(String attribute) {
231
 
            Node.JspAttribute[] attrs = node.getJspAttributes();
232
 
            for (int i=0; attrs != null && i < attrs.length; i++) {
233
 
                if (attrs[i].getName().equals(attribute)) {
234
 
                    return attrs[i];
235
 
                }
236
 
            }
237
 
            return null;
238
 
        }
 
153
        }
 
154
 
 
155
        public TagPluginContext getParentContext() {
 
156
            Node parent = node.getParent();
 
157
            if (! (parent instanceof Node.CustomTag)) {
 
158
                return null;
 
159
            }
 
160
            return ((Node.CustomTag) parent).getTagPluginContext();
 
161
        }
 
162
 
 
163
        public void setPluginAttribute(String key, Object value) {
 
164
            pluginAttributes.put(key, value);
 
165
        }
 
166
 
 
167
        public Object getPluginAttribute(String key) {
 
168
            return pluginAttributes.get(key);
 
169
        }
 
170
 
 
171
        public boolean isScriptless() {
 
172
            return node.getChildInfo().isScriptless();
 
173
        }
 
174
 
 
175
        public boolean isConstantAttribute(String attribute) {
 
176
            Node.JspAttribute attr = getNodeAttribute(attribute);
 
177
            if (attr == null)
 
178
                return false;
 
179
            return attr.isLiteral();
 
180
        }
 
181
 
 
182
        public String getConstantAttribute(String attribute) {
 
183
            Node.JspAttribute attr = getNodeAttribute(attribute);
 
184
            if (attr == null)
 
185
                return null;
 
186
            return attr.getValue();
 
187
        }
 
188
 
 
189
        public boolean isAttributeSpecified(String attribute) {
 
190
            return getNodeAttribute(attribute) != null;
 
191
        }
 
192
 
 
193
        public String getTemporaryVariableName() {
 
194
            return node.getRoot().nextTemporaryVariableName();
 
195
        }
 
196
 
 
197
        public void generateImport(String imp) {
 
198
            pageInfo.addImport(imp);
 
199
        }
 
200
 
 
201
        public void generateDeclaration(String id, String text) {
 
202
            if (pageInfo.isPluginDeclared(id)) {
 
203
                return;
 
204
            }
 
205
            curNodes.add(new Node.Declaration(text, node.getStart(), null));
 
206
        }
 
207
 
 
208
        public void generateJavaSource(String sourceCode) {
 
209
            curNodes.add(new Node.Scriptlet(sourceCode, node.getStart(),
 
210
                                            null));
 
211
        }
 
212
 
 
213
        public void generateAttribute(String attributeName) {
 
214
            curNodes.add(new Node.AttributeGenerator(node.getStart(),
 
215
                                                     attributeName,
 
216
                                                     node));
 
217
        }
 
218
 
 
219
        public void dontUseTagPlugin() {
 
220
            node.setUseTagPlugin(false);
 
221
        }
 
222
 
 
223
        public void generateBody() {
 
224
            // Since we'll generate the body anyway, this is really a nop, 
 
225
            // except for the fact that it lets us put the Java sources the
 
226
            // plugins produce in the correct order (w.r.t the body).
 
227
            curNodes = node.getAtETag();
 
228
        }
 
229
 
 
230
        private Node.JspAttribute getNodeAttribute(String attribute) {
 
231
            Node.JspAttribute[] attrs = node.getJspAttributes();
 
232
            for (int i=0; attrs != null && i < attrs.length; i++) {
 
233
                if (attrs[i].getName().equals(attribute)) {
 
234
                    return attrs[i];
 
235
                }
 
236
            }
 
237
            return null;
 
238
        }
239
239
    }
240
240
}