001: /*
002: * $Id: WicketTag.java 460194 2006-04-10 12:11:31Z jdonnerstag $ $Revision: 460194 $
003: * $Date: 2006-04-10 14:11:31 +0200 (Mon, 10 Apr 2006) $
004: *
005: * ==============================================================================
006: * Licensed under the Apache License, Version 2.0 (the "License"); you may not
007: * use this file except in compliance with the License. You may obtain a copy of
008: * the License at
009: *
010: * http://www.apache.org/licenses/LICENSE-2.0
011: *
012: * Unless required by applicable law or agreed to in writing, software
013: * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
014: * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
015: * License for the specific language governing permissions and limitations under
016: * the License.
017: */
018: package wicket.markup;
019:
020: import wicket.markup.parser.XmlTag;
021:
022: /**
023: * WicketTag extends ComponentTag and will be created by a MarkupParser whenever
024: * it parses a tag in the wicket namespace. By default, this namespace is
025: * "wicket", so wicket tags are then of the form <wicket:*>
026: * <p>
027: * Note 1: you need to add an XHTML doctype to your markup and use <html
028: * xmlns:wicket> to create a XHTML conformant namespace for such tags.
029: * <p>
030: * Note 2: The namespace name is configurable. E.g. <html
031: * xmlns:wcn="http://wicket.sourcefourge.net">
032: *
033: * @author Juergen Donnerstag
034: */
035: public class WicketTag extends ComponentTag {
036: /**
037: * Constructor
038: *
039: * @param tag
040: * The XML tag which this component tag is based upon.
041: */
042: public WicketTag(final XmlTag tag) {
043: super (tag);
044: }
045:
046: /**
047: * Get the tag's name attribute: e.g. <wicket:region name=panel>
048: *
049: * @return The tag's name attribute
050: */
051: public final String getNameAttribute() {
052: return this .getAttributes().getString("name");
053: }
054:
055: /**
056: * @return True, if tag name equals 'wicket:component'
057: */
058: public final boolean isComponentTag() {
059: return "component".equalsIgnoreCase(getName());
060: }
061:
062: /**
063: * @return True, if tag name equals 'wicket:link'
064: */
065: public final boolean isLinkTag() {
066: return "link".equalsIgnoreCase(getName());
067: }
068:
069: /**
070: * @return True, if tag name equals 'wicket:remove'
071: */
072: public final boolean isRemoveTag() {
073: return "remove".equalsIgnoreCase(getName());
074: }
075:
076: /**
077: * @return True, if tag name equals 'wicket:body'
078: */
079: public final boolean isBodyTag() {
080: return "body".equalsIgnoreCase(getName());
081: }
082:
083: /**
084: * @return True, if tag name equals 'wicket:child'
085: */
086: public final boolean isChildTag() {
087: return "child".equalsIgnoreCase(getName());
088: }
089:
090: /**
091: * @return True, if tag name equals 'wicket:extend'
092: */
093: public final boolean isExtendTag() {
094: return "extend".equalsIgnoreCase(getName());
095: }
096:
097: /**
098: * @return True, if tag name equals 'wicket:extend'
099: */
100: public final boolean isHeadTag() {
101: return "head".equalsIgnoreCase(getName());
102: }
103:
104: /**
105: * @return True, if tag name equals 'wicket:message'
106: */
107: public final boolean isMessageTag() {
108: return "message".equalsIgnoreCase(getName());
109: }
110:
111: /**
112: * @return True, if tag name equals 'wicket:panel'
113: */
114: public final boolean isPanelTag() {
115: return "panel".equalsIgnoreCase(getName());
116: }
117:
118: /**
119: * @return True, if tag name equals 'wicket:border'
120: */
121: public final boolean isBorderTag() {
122: return "border".equalsIgnoreCase(getName());
123: }
124:
125: /**
126: * @return True if <wicket:fragment>
127: */
128: public final boolean isFragementTag() {
129: return "fragment".equalsIgnoreCase(getName());
130: }
131:
132: /**
133: * @return True if <wicket:panel>, <wicket:border>, <wicket:ex
134: */
135: public final boolean isMajorWicketComponentTag() {
136: return isPanelTag() || isBorderTag() || isExtendTag();
137: }
138:
139: /**
140: * Gets this tag if it is already mutable, or a mutable copy of this tag if
141: * it is immutable.
142: *
143: * @return This tag if it is already mutable, or a mutable copy of this tag
144: * if it is immutable.
145: */
146: public ComponentTag mutable() {
147: if (xmlTag.isMutable()) {
148: return this ;
149: } else {
150: final WicketTag tag = new WicketTag(xmlTag.mutable());
151: tag.setId(getId());
152: return tag;
153: }
154: }
155: }
|