Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * 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.wicket.markup;
 
 import java.util.List;
 import java.util.Map;
 
A subclass of MarkupElement which represents a "significant" markup tag, such as a component open tag. Insignificant markup tags (those which are merely concerned with markup formatting operations and do not denote components or component nesting) are coalesced into instances of RawMarkup (also a subclass of MarkupElement).

Author(s):
Jonathan Locke
 
 public class ComponentTag extends MarkupElement
 {
Standard component id attribute always available for components regardless of user ApplicationSettings for id attribute; value == 'wicket'.
 
 	public static final String DEFAULT_WICKET_NAMESPACE = "wicket";

an empty list
 
 	private static final List EMPTY_LIST = new ArrayList();

Assuming this is a open (or open-close) tag, 'closes' refers to the ComponentTag which closes it.
 
 	private ComponentTag closes;

The underlying xml tag
 
 	protected final XmlTag xmlTag;

True if a href attribute is available and autolinking is on
 
 	private boolean autolink = false;

By default this is equal to the wicket:id="xxx" attribute value, but may be provided e.g. for auto-tags
 
 	private String id;

The component's path in the markup
 
 	private String path;

True, if attributes have been modified or added
 
 	private boolean modified = false;

If true, than the MarkupParser will ignore (remove) it. Temporary working variable
 
 	private transient boolean ignore = false;

If true, than the tag contain an automatically created wicket id
 
 	private boolean autoComponent = false;

In case of inherited markup, the base and the extended markups are merged and the information about the tags origin is lost. In some cases like wicket:head and wicket:link this information however is required.
 
 	private WeakReference/* <Class> */markupClassRef = null;

Tags which are detected to have only an open tag, which is allowed with some HTML tags like 'br' for example
	private boolean hasNoCloseTag = false;

added behaviors
	private List behaviors;

Filters and Handlers may add their own attributes to the tag
	private Map userData;

Automatically create a XmlTag, assign the name and the type, and construct a ComponentTag based on this XmlTag.

Parameters:
name The name of html tag
type The type of tag
	public ComponentTag(final String namefinal XmlTag.Type type)
	{
		final XmlTag tag = new XmlTag();
		tag.setName(name);
		tag.setType(type);
		 = tag;
	}

Construct.

Parameters:
tag The underlying xml tag
	public ComponentTag(final XmlTag tag)
	{
		super();
		 = tag;
	}

Adds a behavior to this component tag.

Parameters:
behavior
	public final void addBehavior(final IBehavior behavior)
	{
		if (behavior == null)
		{
			throw new IllegalArgumentException("Argument [behavior] cannot be null");
		}
		if ( == null)
		{
			 = new ArrayList();
		}
		.add(behavior);
	}

Returns:
true if this tag has any behaviors added, false otherwise
	public final boolean hasBehaviors()
	{
		return  != null;
	}

Returns:
read only iterator over added behaviors
	public final Iterator getBehaviors()
	{
		if ( == null)
		{
			List empty = ;
			return empty.iterator();
		}
		return locked.iterator();
	}

Gets whether this tag closes the provided open tag.

Parameters:
open The open tag
Returns:
True if this tag closes the given open tag
	public final boolean closes(final MarkupElement open)
	{
		if (open instanceof ComponentTag)
		{
			return ( == open) || getXmlTag().closes(((ComponentTag)open).getXmlTag());
		}
		return false;
	}

If autolink is set to true, href attributes will automatically be converted into Wicket bookmarkable URLs.

Parameters:
autolink enable/disable automatic href conversion
	public final void enableAutolink(final boolean autolink)
	{
		this. = autolink;
	}

Returns:
The tag#s attributes
See also:
org.apache.wicket.markup.parser.XmlTag.getAttributes()
	public final IValueMap getAttributes()
	{
	}

Get the tag's component id

Returns:
The component id attribute of this tag
	public final String getId()
	{
		return ;
	}

Gets the length of the tag in characters.

Returns:
The tag's length
	public final int getLength()
	{
		return .getLength();
	}

Returns:
The tag's name
See also:
org.apache.wicket.markup.parser.XmlTag.getName()
	public final String getName()
	{
		return .getName();
	}

Returns:
Returns true if the name of this component tag was changed
See also:
org.apache.wicket.markup.parser.XmlTag.getNameChanged()
	public final boolean getNameChanged()
	{
	}

Returns:
The tag's namespace
See also:
org.apache.wicket.markup.parser.XmlTag.getNamespace()
	public final String getNamespace()
	{
	}

If set, return the corresponding open tag (ComponentTag).

Returns:
The corresponding open tag
	public final ComponentTag getOpenTag()
	{
		return ;
	}

Returns:
Tag location (index in input string)
See also:
org.apache.wicket.markup.parser.XmlTag.getPos()
	public final int getPos()
	{
		return .getPos();
	}

Parameters:
key The key
Returns:
The string value
See also:
org.apache.wicket.markup.parser.XmlTag.getString(java.lang.String)
	public final CharSequence getString(String key)
	{
		return .getString(key);
	}

THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT CALL IT.

Returns:
the tag type (OPEN, CLOSE or OPEN_CLOSE).
See also:
org.apache.wicket.markup.parser.XmlTag.getType()
	public final Type getType()
	{
		return .getType();
	}

True if autolink is enabled and the tag contains a href attribute.

Returns:
True, if the href contained should automatically be converted
	public final boolean isAutolinkEnabled()
	{
		return ;
	}

Returns:
True if this tag is a close tag
See also:
org.apache.wicket.markup.parser.XmlTag.isClose()
	public final boolean isClose()
	{
		return .isClose();
	}

Returns:
True if this tag is an open tag
See also:
org.apache.wicket.markup.parser.XmlTag.isOpen()
	public final boolean isOpen()
	{
		return .isOpen();
	}

Parameters:
id Required component id
Returns:
True if this tag is an open tag with the given component name
See also:
org.apache.wicket.markup.parser.XmlTag.isOpen()
	public final boolean isOpen(String id)
	{
		return .isOpen() && this..equals(id);
	}

Returns:
True if this tag is an open and a close tag
See also:
org.apache.wicket.markup.parser.XmlTag.isOpenClose()
	public final boolean isOpenClose()
	{
	}

Parameters:
id Required component id
Returns:
True if this tag is an openclose tag with the given component id
See also:
org.apache.wicket.markup.parser.XmlTag.isOpenClose()
	public final boolean isOpenClose(String id)
	{
		return .isOpenClose() && this..equals(id);
	}

Compare tag name including namespace

Parameters:
tag
Returns:
true if name and namespace are equal
	public boolean hasEqualTagName(final ComponentTag tag)
	{
	}

Makes this tag object immutable by making the attribute map unmodifiable. Immutable tags cannot be made mutable again. They can only be copied into new mutable tag objects.
	public final void makeImmutable()
	{
	}

Gets this tag if it is already mutable, or a mutable copy of this tag if it is immutable.

Returns:
This tag if it is already mutable, or a mutable copy of this tag if it is immutable.
	{
		{
			return this;
		}
		else
		{
			final ComponentTag tag = new ComponentTag(.mutable());
			return tag;
		}
	}

Copies all internal properties from this tag to dest. This is basically cloning without instance creation.

Parameters:
dest tag whose properties will be set
	void copyPropertiesTo(final ComponentTag dest)
	{
		dest.id = ;
		if ( != null)
		{
		}
		if ( != null)
		{
			dest.behaviors = new ArrayList(.size());
			dest.behaviors.addAll();
		}
	}

Parameters:
key The key
value The value
See also:
org.apache.wicket.markup.parser.XmlTag.put(java.lang.String,boolean)
	public final void put(final String keyfinal boolean value)
	{
		.put(keyvalue);
	}

Parameters:
key The key
value The value
See also:
org.apache.wicket.markup.parser.XmlTag.put(java.lang.String,int)
	public final void put(final String keyfinal int value)
	{
		.put(keyvalue);
	}

	public final void put(String keyCharSequence value)
	{
		.put(keyvalue);
	}

	public final void put(String keyStringValue value)
	{
		.put(keyvalue);
	}

Parameters:
map a key/value map
See also:
org.apache.wicket.markup.parser.XmlTag.putAll(java.util.Map)
	public final void putAll(final Map map)
	{
	}

Parameters:
key The key to remove
See also:
org.apache.wicket.markup.parser.XmlTag.remove(java.lang.String)
	public final void remove(String key)
	{
	}

Gets whether this tag does not require a closing tag.

Returns:
True if this tag does not require a closing tag
	public final boolean requiresCloseTag()
	{
		if (getNamespace() == null)
		{
			return HtmlHandler.requiresCloseTag(getName());
		}
		else
		{
			return HtmlHandler.requiresCloseTag(getNamespace() + ":" + getName());
		}
	}

Set the component's id. The value is usually taken from the tag's id attribute, e.g. wicket:id="componentId".

Parameters:
id The component's id assigned to the tag.
	public final void setId(final String id)
	{
		this. = id;
	}

	public final void setName(String name)
	{
	}

Parameters:
namespace New tag name namespace
See also:
org.apache.wicket.markup.parser.XmlTag.setNamespace(java.lang.String)
	public final void setNamespace(String namespace)
	{
		.setNamespace(namespace);
	}

Assuming this is a close tag, assign it's corresponding open tag.

Parameters:
tag the open-tag
Throws:
java.lang.RuntimeException if 'this' is not a close tag
	public final void setOpenTag(final ComponentTag tag)
	{
		 = tag;
	}

THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT CALL IT.

Parameters:
type The new type
	public final void setType(final Type type)
	{
	}

Returns:
A synthetic close tag for this tag
	{
		buf.append("</");
		if (getNamespace() != null)
		{
		}
		buf.append(getName()).append(">");
		return buf;
	}

	{
	}

Converts this object to a string representation.

Returns:
String version of this object
	public final String toString()
	{
	}

Write the tag to the response

Parameters:
response The response to write to
stripWicketAttributes if true, wicket:id are removed from output
namespace Wicket's namespace to use
	public final void writeOutput(final Response responsefinal boolean stripWicketAttributes,
			final String namespace)
	{
		response.write("<");
		if (getType() == .)
		{
			response.write("/");
		}
		if (getNamespace() != null)
		{
			response.write(getNamespace());
			response.write(":");
		}
		response.write(getName());
		String namespacePrefix = null;
		if (stripWicketAttributes == true)
		{
			namespacePrefix = namespace + ":";
		}
		if (getAttributes().size() > 0)
		{
			final Iterator iterator = getAttributes().keySet().iterator();
			while (iterator.hasNext())
			{
				final String key = (String)iterator.next();
				if (key == null)
				{
					continue;
				}
				if ((namespacePrefix == null) || (key.startsWith(namespacePrefix) == false))
				{
					response.write(" ");
					response.write(key);
					CharSequence value = getString(key);
					// attributes without values are possible, e.g. 'disabled'
					if (value != null)
					{
						response.write("=\"");
						value = Strings.replaceAll(value"\"""&#34;");
						response.write(value);
						response.write("\"");
					}
				}
			}
		}
		{
			response.write("/");
		}
		response.write(">");
	}

Converts this object to a string representation including useful information for debugging

Returns:
String version of this object
	public final String toUserDebugString()
	{
	}

Returns:
Returns the underlying xml tag.
	final XmlTag getXmlTag()
	{
		return ;
	}

Manually mark the ComponentTag being modified. Flagging the tag being modified does not happen automatically.

Parameters:
modified
	public final void setModified(final boolean modified)
	{
		this. = modified;
	}


Returns:
True, if the component tag has been marked modified
	public final boolean isModified()
	{
		return ;
	}

Gets the component path of wicket elements

Returns:
path
	public String getPath()
	{
		return ;
	}

Sets the component path of wicket elements

Parameters:
path path
	void setPath(final String path)
	{
		this. = path;
	}

Returns:
True if the HTML tag (e.g. br) has no close tag
	public boolean hasNoCloseTag()
	{
	}

True if the HTML tag (e.g. br) has no close tag

Parameters:
hasNoCloseTag
	public void setHasNoCloseTag(boolean hasNoCloseTag)
	{
		this. = hasNoCloseTag;
	}

In case of inherited markup, the base and the extended markups are merged and the information about the tags origin is lost. In some cases like wicket:head and wicket:link this information however is required.

Returns:
wicketHeaderClass
	{
		return ( == null ? null : (Class).get());
	}

Set the class of wicket component which contains the wicket:head tag.

Parameters:
wicketHeaderClass wicketHeaderClass
	public void setMarkupClass(Class wicketHeaderClass)
	{
		if (wicketHeaderClass == null)
		{
		}
		else
		{
			 = new WeakReference(wicketHeaderClass);
		}
	}

	public boolean equalTo(final MarkupElement element)
	{
		if (element instanceof ComponentTag)
		{
			final ComponentTag that = (ComponentTag)element;
			return getXmlTag().equalTo(that.getXmlTag());
		}
		return false;
	}

Gets ignore.

Returns:
If true than MarkupParser will remove it from the markup
	public boolean isIgnore()
	{
		return ;
	}

Sets ignore.

Parameters:
ignore If true than MarkupParser will remove it from the markup
	public void setIgnore(boolean ignore)
	{
		this. = ignore;
	}

Returns:
True, if wicket:id has been automatically created (internal component)
	public boolean isAutoComponentTag()
	{
	}

Parameters:
auto True, if wicket:id has been automatically created (internal component)
	public void setAutoComponentTag(boolean auto)
	{
		 = auto;
	}

Gets userData.

Parameters:
key The key to store and retrieve the value
Returns:
userData
	public Object getUserData(final String key)
	{
		if ( == null)
		{
			return null;
		}
		return .get(key);
	}

Sets userData.

Parameters:
key The key to store and retrieve the value
value The user specific value to store
	public void setUserData(final String keyfinal Object value)
	{
		if ( == null)
		{
			 = new HashMap();
		}
		.put(keyvalue);
	}
New to GrepCode? Check out our FAQ X