MCPcopy Index your code
hub / github.com/apache/tomcat / parseCustomTag

Method parseCustomTag

java/org/apache/jasper/compiler/Parser.java:1043–1139  ·  view source on GitHub ↗
(Node parent)

Source from the content-addressed store, hash-verified

1041 * CustomActionScriptlessContent ::= ScriptlessOptionalBody
1042 */
1043 @SuppressWarnings("null") // tagFileInfo can't be null after initial test
1044 private boolean parseCustomTag(Node parent) throws JasperException {
1045
1046 if (reader.peekChar() != '<') {
1047 return false;
1048 }
1049
1050 // Parse 'CustomAction' production (tag prefix and custom action name)
1051 reader.nextChar(); // skip '<'
1052 String tagName = reader.parseToken(false);
1053 int i = tagName.indexOf(':');
1054 if (i == -1) {
1055 reader.reset(start);
1056 return false;
1057 }
1058
1059 String prefix = tagName.substring(0, i);
1060 String shortTagName = tagName.substring(i + 1);
1061
1062 // Check if this is a user-defined tag.
1063 String uri = pageInfo.getURI(prefix);
1064 if (uri == null) {
1065 if (pageInfo.isErrorOnUndeclaredNamespace()) {
1066 err.jspError(start, "jsp.error.undeclared_namespace", prefix);
1067 } else {
1068 reader.reset(start);
1069 // Remember the prefix for later error checking
1070 pageInfo.putNonCustomTagPrefix(prefix, reader.mark());
1071 return false;
1072 }
1073 }
1074
1075 TagLibraryInfo tagLibInfo = pageInfo.getTaglib(uri);
1076 TagInfo tagInfo = tagLibInfo.getTag(shortTagName);
1077 TagFileInfo tagFileInfo = tagLibInfo.getTagFile(shortTagName);
1078 if (tagInfo == null && tagFileInfo == null) {
1079 err.jspError(start, "jsp.error.bad_tag", shortTagName, prefix);
1080 }
1081 Class<?> tagHandlerClass = null;
1082 if (tagInfo != null) {
1083 // Must be a classic tag, load it here.
1084 // tag files will be loaded later, in TagFileProcessor
1085 String handlerClassName = tagInfo.getTagClassName();
1086 try {
1087 tagHandlerClass = ctxt.getClassLoader().loadClass(handlerClassName);
1088 } catch (Exception e) {
1089 err.jspError(start, "jsp.error.loadclass.taghandler", handlerClassName, tagName);
1090 }
1091 }
1092
1093 // Parse 'CustomActionBody' production:
1094 // At this point we are committed - if anything fails, we produce
1095 // a translation error.
1096
1097 // Parse 'Attributes' production:
1098 Attributes attrs = parseAttributes();
1099 reader.skipSpaces();
1100

Callers 3

parseElementsMethod · 0.95

Calls 15

getTagMethod · 0.95
getTagFileMethod · 0.95
getTagClassNameMethod · 0.95
parseAttributesMethod · 0.95
getBodyContentMethod · 0.95
getTagInfoMethod · 0.95
parseOptionalBodyMethod · 0.95
peekCharMethod · 0.80
putNonCustomTagPrefixMethod · 0.80
getTaglibMethod · 0.80
resetMethod · 0.65
getURIMethod · 0.65

Tested by

no test coverage detected