⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 componenttag.java

📁 Wicket一个开发Java Web应用程序框架。它使得开发web应用程序变得容易而轻松。 Wicket利用一个POJO data beans组件使得它可以与任何持久层技术相结合。
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* * 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.lang.ref.WeakReference;import java.util.ArrayList;import java.util.Collection;import java.util.Collections;import java.util.HashMap;import java.util.Iterator;import java.util.List;import java.util.Map;import org.apache.wicket.Response;import org.apache.wicket.behavior.IBehavior;import org.apache.wicket.markup.parser.XmlTag;import org.apache.wicket.markup.parser.XmlTag.Type;import org.apache.wicket.markup.parser.filter.HtmlHandler;import org.apache.wicket.util.string.AppendingStringBuffer;import org.apache.wicket.util.string.StringValue;import org.apache.wicket.util.string.Strings;import org.apache.wicket.util.value.IValueMap;/** * 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 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.	 * 	 * @param name	 *            The name of html tag	 * @param type	 *            The type of tag	 */	public ComponentTag(final String name, final XmlTag.Type type)	{		final XmlTag tag = new XmlTag();		tag.setName(name);		tag.setType(type);		xmlTag = tag;	}	/**	 * Construct.	 * 	 * @param tag	 *            The underlying xml tag	 */	public ComponentTag(final XmlTag tag)	{		super();		xmlTag = tag;	}	/**	 * Adds a behavior to this component tag.	 * 	 * @param behavior	 */	public final void addBehavior(final IBehavior behavior)	{		if (behavior == null)		{			throw new IllegalArgumentException("Argument [behavior] cannot be null");		}		if (behaviors == null)		{			behaviors = new ArrayList();		}		behaviors.add(behavior);	}	/**	 * @return true if this tag has any behaviors added, false otherwise	 */	public final boolean hasBehaviors()	{		return behaviors != null;	}	/**	 * @return read only iterator over added behaviors	 */	public final Iterator getBehaviors()	{		if (behaviors == null)		{			List empty = EMPTY_LIST;			return empty.iterator();		}		Collection locked = Collections.unmodifiableCollection(behaviors);		return locked.iterator();	}	/**	 * Gets whether this tag closes the provided open tag.	 * 	 * @param open	 *            The open tag	 * @return True if this tag closes the given open tag	 */	public final boolean closes(final MarkupElement open)	{		if (open instanceof ComponentTag)		{			return (closes == open) || getXmlTag().closes(((ComponentTag)open).getXmlTag());		}		return false;	}	/**	 * If autolink is set to true, href attributes will automatically be converted into Wicket	 * bookmarkable URLs.	 * 	 * @param autolink	 *            enable/disable automatic href conversion	 */	public final void enableAutolink(final boolean autolink)	{		this.autolink = autolink;	}	/**	 * @see org.apache.wicket.markup.parser.XmlTag#getAttributes()	 * @return The tag#s attributes	 */	public final IValueMap getAttributes()	{		return xmlTag.getAttributes();	}	/**	 * Get the tag's component id	 * 	 * @return The component id attribute of this tag	 */	public final String getId()	{		return id;	}	/**	 * Gets the length of the tag in characters.	 * 	 * @return The tag's length	 */	public final int getLength()	{		return xmlTag.getLength();	}	/**	 * @see org.apache.wicket.markup.parser.XmlTag#getName()	 * @return The tag's name	 */	public final String getName()	{		return xmlTag.getName();	}	/**	 * @see org.apache.wicket.markup.parser.XmlTag#getNameChanged()	 * @return Returns true if the name of this component tag was changed	 */	public final boolean getNameChanged()	{		return xmlTag.getNameChanged();	}	/**	 * @see org.apache.wicket.markup.parser.XmlTag#getNamespace()	 * @return The tag's namespace	 */	public final String getNamespace()	{		return xmlTag.getNamespace();	}	/**	 * If set, return the corresponding open tag (ComponentTag).	 * 	 * @return The corresponding open tag	 */	public final ComponentTag getOpenTag()	{		return closes;	}	/**	 * @see org.apache.wicket.markup.parser.XmlTag#getPos()	 * @return Tag location (index in input string)	 */	public final int getPos()	{		return xmlTag.getPos();	}	/**	 * @see org.apache.wicket.markup.parser.XmlTag#getString(String)	 * @param key	 *            The key	 * @return The string value	 */	public final CharSequence getString(String key)	{		return xmlTag.getString(key);	}	/**	 * THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT CALL IT.	 * <p>	 * 	 * @see org.apache.wicket.markup.parser.XmlTag#getType()	 * @return the tag type (OPEN, CLOSE or OPEN_CLOSE).	 */	public final Type getType()	{		return xmlTag.getType();	}	/**	 * True if autolink is enabled and the tag contains a href attribute.	 * 	 * @return True, if the href contained should automatically be converted	 */	public final boolean isAutolinkEnabled()	{		return autolink;	}	/**	 * @see org.apache.wicket.markup.parser.XmlTag#isClose()	 * @return True if this tag is a close tag	 */	public final boolean isClose()	{		return xmlTag.isClose();	}	/**	 * @see org.apache.wicket.markup.parser.XmlTag#isOpen()	 * @return True if this tag is an open tag	 */	public final boolean isOpen()	{		return xmlTag.isOpen();	}	/**	 * @param id	 *            Required component id	 * @return True if this tag is an open tag with the given component name	 * @see org.apache.wicket.markup.parser.XmlTag#isOpen()	 */	public final boolean isOpen(String id)	{		return xmlTag.isOpen() && this.id.equals(id);	}	/**	 * @see org.apache.wicket.markup.parser.XmlTag#isOpenClose()	 * @return True if this tag is an open and a close tag	 */	public final boolean isOpenClose()	{		return xmlTag.isOpenClose();	}	/**	 * @param id	 *            Required component id	 * @return True if this tag is an openclose tag with the given component id	 * @see org.apache.wicket.markup.parser.XmlTag#isOpenClose()	 */	public final boolean isOpenClose(String id)	{		return xmlTag.isOpenClose() && this.id.equals(id);	}	/**	 * Compare tag name including namespace	 * 	 * @param tag	 * @return true if name and namespace are equal	 */	public boolean hasEqualTagName(final ComponentTag tag)	{		return xmlTag.hasEqualTagName(tag.getXmlTag());	}	/**	 * 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()	{		xmlTag.makeImmutable();	}	/**	 * Gets this tag if it is already mutable, or a mutable copy of this tag if it is immutable.	 * 	 * @return This tag if it is already mutable, or a mutable copy of this tag if it is immutable.	 */	public ComponentTag mutable()	{		if (xmlTag.isMutable())		{			return this;		}		else		{			final ComponentTag tag = new ComponentTag(xmlTag.mutable());			copyPropertiesTo(tag);			return tag;		}	}	/**	 * Copies all internal properties from this tag to <code>dest</code>. This is basically	 * cloning without instance creation.	 * 	 * @param dest	 *            tag whose properties will be set	 */	void copyPropertiesTo(final ComponentTag dest)	{		dest.id = id;		dest.setHasNoCloseTag(hasNoCloseTag);		dest.setPath(path);		dest.setAutoComponentTag(autoComponent);		if (markupClassRef != null)		{			dest.setMarkupClass((Class)markupClassRef.get());		}		if (behaviors != null)		{			dest.behaviors = new ArrayList(behaviors.size());			dest.behaviors.addAll(behaviors);		}	}	/**	 * @see org.apache.wicket.markup.parser.XmlTag#put(String, boolean)	 * @param key	 *            The key	 * @param value	 *            The value	 */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -