Wraps any SimpleTag and exposes it using a Tag interface. This is used to allow collaboration between classic Tag handlers and SimpleTag handlers. Because SimpleTag does not extend Tag, and because Tag.setParent() only accepts a Tag instance, a classic tag handler (one that implements Tag) canno
| 31 | * @since JSP 2.0 |
| 32 | */ |
| 33 | public class TagAdapter implements Tag { |
| 34 | /** The simple tag that's being adapted. */ |
| 35 | private final SimpleTag simpleTagAdaptee; |
| 36 | |
| 37 | /** The parent, of this tag, converted (if necessary) to be of type Tag. */ |
| 38 | private Tag parent; |
| 39 | |
| 40 | // Flag indicating whether we have already determined the parent |
| 41 | private boolean parentDetermined; |
| 42 | |
| 43 | /** |
| 44 | * Creates a new TagAdapter that wraps the given SimpleTag and returns the parent tag when getParent() is called. |
| 45 | * |
| 46 | * @param adaptee The SimpleTag being adapted as a Tag. |
| 47 | */ |
| 48 | public TagAdapter(SimpleTag adaptee) { |
| 49 | if (adaptee == null) { |
| 50 | // Cannot wrap a null adaptee. |
| 51 | throw new IllegalArgumentException(); |
| 52 | } |
| 53 | this.simpleTagAdaptee = adaptee; |
| 54 | } |
| 55 | |
| 56 | /** |
| 57 | * Must not be called. |
| 58 | * |
| 59 | * @param pc ignored. |
| 60 | * |
| 61 | * @throws UnsupportedOperationException Must not be called |
| 62 | */ |
| 63 | @Override |
| 64 | public void setPageContext(PageContext pc) { |
| 65 | throw new UnsupportedOperationException("Illegal to invoke setPageContext() on TagAdapter wrapper"); |
| 66 | } |
| 67 | |
| 68 | /** |
| 69 | * Must not be called. The parent of this tag is always getAdaptee().getParent(). |
| 70 | * |
| 71 | * @param parentTag ignored. |
| 72 | * |
| 73 | * @throws UnsupportedOperationException Must not be called. |
| 74 | */ |
| 75 | @Override |
| 76 | public void setParent(Tag parentTag) { |
| 77 | throw new UnsupportedOperationException("Illegal to invoke setParent() on TagAdapter wrapper"); |
| 78 | } |
| 79 | |
| 80 | /** |
| 81 | * Returns the parent of this tag, which is always getAdaptee().getParent(). This will either be the enclosing Tag |
| 82 | * (if getAdaptee().getParent() implements Tag), or an adapter to the enclosing Tag (if getAdaptee().getParent() |
| 83 | * does not implement Tag). |
| 84 | * |
| 85 | * @return The parent of the tag being adapted. |
| 86 | */ |
| 87 | @Override |
| 88 | public Tag getParent() { |
| 89 | if (!parentDetermined) { |
| 90 | JspTag adapteeParent = simpleTagAdaptee.getParent(); |
nothing calls this directly
no outgoing calls
no test coverage detected