/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.
*/ package org.apache.jasper.compiler;
PageInfo(BeanRepository beanRepository, JspCompilationContext ctxt) {
isTagFile = ctxt.isTagFile();
jspFile = ctxt.getJspFile();
defaultExtends = ctxt.getOptions().getJspServletBase(); this.beanRepository = beanRepository; this.varInfoNames = new HashSet<>(); this.taglibsMap = new HashMap<>(); this.jspPrefixMapper = new HashMap<>(); this.xmlPrefixMapper = new HashMap<>(); this.nonCustomTagPrefixMap = new HashMap<>(); this.dependants = new HashMap<>(); this.includePrelude = new ArrayList<>(); this.includeCoda = new ArrayList<>(); this.pluginDcls = new ArrayList<>(); this.prefixes = new HashSet<>();
// Enter standard imports this.imports = new ArrayList<>(Constants.STANDARD_IMPORTS);
}
publicboolean isTagFile() { return isTagFile;
}
/** * Check if the plugin ID has been previously declared. Make a note * that this Id is now declared. * * @param id The plugin ID to check * * @return true if Id has been declared.
*/ publicboolean isPluginDeclared(String id) { if (pluginDcls.contains(id)) { returntrue;
}
pluginDcls.add(id); returnfalse;
}
/* * Adds the given prefix to the set of prefixes of this translation unit. * * @param prefix The prefix to add
*/ publicvoid addPrefix(String prefix) {
prefixes.add(prefix);
}
/* * Checks to see if this translation unit contains the given prefix. * * @param prefix The prefix to check * * @return true if this translation unit contains the given prefix, false * otherwise
*/ publicboolean containsPrefix(String prefix) { return prefixes.contains(prefix);
}
/* * Maps the given URI to the given tag library. * * @param uri The URI to map * @param info The tag library to be associated with the given URI
*/ publicvoid addTaglib(String uri, TagLibraryInfo info) {
taglibsMap.put(uri, info);
}
/* * Gets the tag library corresponding to the given URI. * * @return Tag library corresponding to the given URI
*/ public TagLibraryInfo getTaglib(String uri) { return taglibsMap.get(uri);
}
/* * Gets the collection of tag libraries that are associated with a URI * * @return Collection of tag libraries that are associated with a URI
*/ public Collection<TagLibraryInfo> getTaglibs() { return taglibsMap.values();
}
/* * Checks to see if the given URI is mapped to a tag library. * * @param uri The URI to map * * @return true if the given URI is mapped to a tag library, false * otherwise
*/ publicboolean hasTaglib(String uri) { return taglibsMap.containsKey(uri);
}
/* * Maps the given prefix to the given URI. * * @param prefix The prefix to map * @param uri The URI to be associated with the given prefix
*/ publicvoid addPrefixMapping(String prefix, String uri) {
jspPrefixMapper.put(prefix, uri);
}
/* * Pushes the given URI onto the stack of URIs to which the given prefix * is mapped. * * @param prefix The prefix whose stack of URIs is to be pushed * @param uri The URI to be pushed onto the stack
*/ publicvoid pushPrefixMapping(String prefix, String uri) { // Must be LinkedList as it needs to accept nulls
xmlPrefixMapper.computeIfAbsent(prefix, k -> new LinkedList<>()).addFirst(uri);
}
/* * Removes the URI at the top of the stack of URIs to which the given * prefix is mapped. * * @param prefix The prefix whose stack of URIs is to be popped
*/ publicvoid popPrefixMapping(String prefix) {
Deque<String> stack = xmlPrefixMapper.get(prefix);
stack.removeFirst();
}
/* * Returns the URI to which the given prefix maps. * * @param prefix The prefix whose URI is sought * * @return The URI to which the given prefix maps
*/ public String getURI(String prefix) {
String uri = null;
Deque<String> stack = xmlPrefixMapper.get(prefix); if (stack == null || stack.size() == 0) {
uri = jspPrefixMapper.get(prefix);
} else {
uri = stack.getFirst();
}
return uri;
}
/* Page/Tag directive attributes */
/* * language
*/ publicvoid setLanguage(String value, Node n, ErrorDispatcher err, boolean pagedir) throws JasperException {
if (!"java".equalsIgnoreCase(value)) { if (pagedir) {
err.jspError(n, "jsp.error.page.language.nonjava");
} else {
err.jspError(n, "jsp.error.tag.language.nonjava");
}
}
/** * Gets the value of the 'extends' page directive attribute. * * @param useDefault TRUE if the default * (org.apache.jasper.runtime.HttpJspBase) should be returned if this * attribute has not been set, FALSE otherwise * * @return The value of the 'extends' page directive attribute, or the * default (org.apache.jasper.runtime.HttpJspBase) if this attribute has * not been set and useDefault is TRUE
*/ public String getExtends(boolean useDefault) { return (xtends == null && useDefault ? defaultExtends : xtends);
}
/** * Gets the value of the 'extends' page directive attribute. * * @return The value of the 'extends' page directive attribute, or the * default (org.apache.jasper.runtime.HttpJspBase) if this attribute has * not been set
*/ public String getExtends() { return getExtends(true);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.