Skip to content

Package: TagLibraryInfo

TagLibraryInfo

nameinstructionbranchcomplexitylinemethod
TagLibraryInfo(String, String)
M: 9 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
getFunction(String)
M: 36 C: 0
0%
M: 8 C: 0
0%
M: 5 C: 0
0%
M: 7 C: 0
0%
M: 1 C: 0
0%
getFunctions()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getInfoString()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getPrefixString()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getReliableURN()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getRequiredVersion()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getShortName()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getTag(String)
M: 31 C: 0
0%
M: 8 C: 0
0%
M: 5 C: 0
0%
M: 7 C: 0
0%
M: 1 C: 0
0%
getTagFile(String)
M: 31 C: 0
0%
M: 8 C: 0
0%
M: 5 C: 0
0%
M: 7 C: 0
0%
M: 1 C: 0
0%
getTagFiles()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getTags()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getURI()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*
2: * Copyright (c) 1997, 2020 Oracle and/or its affiliates and others.
3: * All rights reserved.
4: * Copyright 2004 The Apache Software Foundation
5: *
6: * Licensed under the Apache License, Version 2.0 (the "License");
7: * you may not use this file except in compliance with the License.
8: * You may obtain a copy of the License at
9: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing, software
13: * distributed under the License is distributed on an "AS IS" BASIS,
14: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15: * See the License for the specific language governing permissions and
16: * limitations under the License.
17: */
18:
19: package jakarta.servlet.jsp.tagext;
20:
21: /**
22: * Translation-time information associated with a taglib directive, and its underlying TLD file.
23: *
24: * Most of the information is directly from the TLD, except for the prefix and the uri values used in the taglib
25: * directive
26: */
27: abstract public class TagLibraryInfo {
28:
29: /**
30: * Constructor.
31: *
32: * @param prefix the prefix actually used by the taglib directive
33: * @param uri the URI actually used by the taglib directive
34: */
35: protected TagLibraryInfo(String prefix, String uri) {
36: this.prefix = prefix;
37: this.uri = uri;
38: }
39:
40: // ==== methods accessing taglib information =======
41:
42: /**
43: * The value of the uri attribute from the taglib directive for this library.
44: *
45: * @return the value of the uri attribute
46: */
47: public String getURI() {
48: return uri;
49: }
50:
51: /**
52: * The prefix assigned to this taglib from the taglib directive
53: *
54: * @return the prefix assigned to this taglib from the taglib directive
55: */
56: public String getPrefixString() {
57: return prefix;
58: }
59:
60: // ==== methods using the TLD data =======
61:
62: /**
63: * The preferred short name (prefix) as indicated in the TLD. This may be used by authoring tools as the preferred
64: * prefix to use when creating an taglib directive for this library.
65: *
66: * @return the preferred short name for the library
67: */
68: public String getShortName() {
69: return shortname;
70: }
71:
72: /**
73: * The "reliable" URN indicated in the TLD (the uri element). This may be used by authoring tools as a global
74: * identifier to use when creating a taglib directive for this library.
75: *
76: * @return a reliable URN to a TLD like this
77: */
78: public String getReliableURN() {
79: return urn;
80: }
81:
82: /**
83: * Information (documentation) for this TLD.
84: *
85: * @return the info string for this tag lib
86: */
87: public String getInfoString() {
88: return info;
89: }
90:
91: /**
92: * A string describing the required version of the JSP container.
93: *
94: * @return the (minimal) required version of the JSP container.
95: * @see jakarta.servlet.jsp.JspEngineInfo
96: */
97: public String getRequiredVersion() {
98: return jspversion;
99: }
100:
101: /**
102: * An array describing the tags that are defined in this tag library.
103: *
104: * @return the TagInfo objects corresponding to the tags defined by this tag library, or a zero length array if this
105: * tag library defines no tags
106: */
107: public TagInfo[] getTags() {
108: return tags;
109: }
110:
111: /**
112: * An array describing the tag files that are defined in this tag library.
113: *
114: * @return the TagFileInfo objects corresponding to the tag files defined by this tag library, or a zero length
115: * array if this tag library defines no tags files
116: * @since JSP 2.0
117: */
118: public TagFileInfo[] getTagFiles() {
119: return tagFiles;
120: }
121:
122: /**
123: * Get the TagInfo for a given tag name, looking through all the tags in this tag library.
124: *
125: * @param shortname The short name (no prefix) of the tag
126: * @return the TagInfo for the tag with the specified short name, or null if no such tag is found
127: */
128: public TagInfo getTag(String shortname) {
129: TagInfo tags[] = getTags();
130:
131:• if (tags == null || tags.length == 0) {
132: return null;
133: }
134:
135:• for (int i = 0; i < tags.length; i++) {
136:• if (tags[i].getTagName().equals(shortname)) {
137: return tags[i];
138: }
139: }
140: return null;
141: }
142:
143: /**
144: * Get the TagFileInfo for a given tag name, looking through all the tag files in this tag library.
145: *
146: * @param shortname The short name (no prefix) of the tag
147: * @return the TagFileInfo for the specified Tag file, or null if no Tag file is found
148: * @since JSP 2.0
149: */
150: public TagFileInfo getTagFile(String shortname) {
151: TagFileInfo tagFiles[] = getTagFiles();
152:
153:• if (tagFiles == null || tagFiles.length == 0) {
154: return null;
155: }
156:
157:• for (int i = 0; i < tagFiles.length; i++) {
158:• if (tagFiles[i].getName().equals(shortname)) {
159: return tagFiles[i];
160: }
161: }
162: return null;
163: }
164:
165: /**
166: * An array describing the functions that are defined in this tag library.
167: *
168: * @return the functions defined in this tag library, or a zero length array if the tag library defines no
169: * functions.
170: * @since JSP 2.0
171: */
172: public FunctionInfo[] getFunctions() {
173: return functions;
174: }
175:
176: /**
177: * Get the FunctionInfo for a given function name, looking through all the functions in this tag library.
178: *
179: * @param name The name (no prefix) of the function
180: * @return the FunctionInfo for the function with the given name, or null if no such function exists
181: * @since JSP 2.0
182: */
183: public FunctionInfo getFunction(String name) {
184:
185:• if (functions == null || functions.length == 0) {
186: System.err.println("No functions");
187: return null;
188: }
189:
190:• for (int i = 0; i < functions.length; i++) {
191:• if (functions[i].getName().equals(name)) {
192: return functions[i];
193: }
194: }
195: return null;
196: }
197:
198: /**
199: * Returns an array of TagLibraryInfo objects representing the entire set of tag libraries (including this
200: * TagLibraryInfo) imported by taglib directives in the translation unit that references this TagLibraryInfo.
201: *
202: * If a tag library is imported more than once and bound to different prefices, only the TagLibraryInfo bound to the
203: * first prefix must be included in the returned array.
204: *
205: * @return Array of TagLibraryInfo objects representing the entire set of tag libraries (including this
206: * TagLibraryInfo) imported by taglib directives in the translation unit that references this
207: * TagLibraryInfo.
208: *
209: * @since JSP 2.1
210: */
211: public abstract TagLibraryInfo[] getTagLibraryInfos();
212:
213: // Protected fields
214:
215: /**
216: * The prefix assigned to this taglib from the taglib directive.
217: */
218: protected String prefix;
219:
220: /**
221: * The value of the uri attribute from the taglib directive for this library.
222: */
223: protected String uri;
224:
225: /**
226: * An array describing the tags that are defined in this tag library.
227: */
228: protected TagInfo[] tags;
229:
230: /**
231: * An array describing the tag files that are defined in this tag library.
232: *
233: * @since JSP 2.0
234: */
235: protected TagFileInfo[] tagFiles;
236:
237: /**
238: * An array describing the functions that are defined in this tag library.
239: *
240: * @since JSP 2.0
241: */
242: protected FunctionInfo[] functions;
243:
244: // Tag Library Data
245:
246: /**
247: * The version of the tag library.
248: */
249: protected String tlibversion; // required
250:
251: /**
252: * The version of the JSP specification this tag library is written to.
253: */
254: protected String jspversion; // required
255:
256: /**
257: * The preferred short name (prefix) as indicated in the TLD.
258: */
259: protected String shortname; // required
260:
261: /**
262: * The "reliable" URN indicated in the TLD.
263: */
264: protected String urn; // required
265:
266: /**
267: * Information (documentation) for this TLD.
268: */
269: protected String info; // optional
270: }