java.lang.Object
org.apache.wicket.markup.MarkupStream
A stream of
MarkupElement
s, subclasses of which are
ComponentTag
and RawMarkup
. A
markup stream has a current index in the list of markup elements. The next markup element can be
retrieved and the index advanced by calling next(). If the index hits the end, hasMore() will
return false.
The current markup element can be accessed with get() and as a ComponentTag with getTag().
The stream can be sought to a particular location with setCurrentIndex().
Convenience methods also exist to skip component tags (and any potentially nested markup) or raw markup.
Several boolean methods of the form at*() return true if the markup stream is positioned at a tag with a given set of characteristics.
The resource from which the markup was loaded can be retrieved with getResource().
- Author:
- Jonathan Locke
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
boolean
boolean
atOpenCloseTag
(String componentId) boolean
boolean
boolean
atTag()
final boolean
equalMarkup
(MarkupStream markupStream) True, if associate markup is the same.boolean
equalTo
(MarkupStream that) Compare this markup stream with another oneget()
get
(int index) Get the component/container's Class which is directly associated with the stream.int
final String
Gets the markup encoding.final IMarkupFragment
final ComponentTag
Sometime its necessary to get the previous markup element versus the current one.getTag()
final String
getTagAttribute
(String name, boolean withWicketNamespace) Gets the attribute with 'name' for the tag at the current positionfinal String
Get the wicket namespace valid for this specific markupboolean
hasMore()
boolean
final boolean
next()
Note:Note:setCurrentIndex
(int currentIndex) final void
Skips this component and all nested componentsvoid
Skips any raw markup at the current positionvoid
skipToMatchingCloseTag
(ComponentTag openTag) Renders markup until a closing tag for openTag is reached.boolean
skipUntil
(Class<? extends MarkupElement> clazz) Skip until an element of type 'clazz' is foundvoid
Skips any markup at the current position until the wicket tag name is found.void
throwMarkupException
(String message) Throws a new markup exceptiontoString()
-
Constructor Details
-
MarkupStream
Constructor- Parameters:
markup
- List of markup elements
-
-
Method Details
-
atCloseTag
- Returns:
- True if current markup element is a close tag
-
atOpenCloseTag
- Returns:
- True if current markup element is an openclose tag
-
atOpenCloseTag
- Parameters:
componentId
- Required component name attribute- Returns:
- True if the current markup element is an openclose tag with the given component name
-
atOpenTag
- Returns:
- True if current markup element is an open tag
-
atOpenTag
- Parameters:
id
- Required component id attribute- Returns:
- True if the current markup element is an open tag with the given component name
-
atTag
- Returns:
- True if current markup element is a tag
-
equalTo
Compare this markup stream with another one- Parameters:
that
- The other markup stream- Returns:
- True if each MarkupElement in this matches each element in that
-
equalMarkup
True, if associate markup is the same. It will change e.g. if the markup file has been re-loaded or the locale has been changed.- Parameters:
markupStream
- The markup stream to compare with.- Returns:
- true, if markup has not changed
-
get
- Returns:
- The current markup element
-
get
- Parameters:
index
- The index of a markup element- Returns:
- The MarkupElement element
-
getContainerClass
Get the component/container's Class which is directly associated with the stream.- Returns:
- The component's class
-
getCurrentIndex
- Returns:
- Current index in markup stream
-
getEncoding
Gets the markup encoding. A markup encoding may be specified in a markup file with an XML encoding specifier of the form <?xml ... encoding="..." ?>.- Returns:
- The encoding, or null if not found
-
getResource
- Returns:
- The resource where this markup stream came from
-
getTag
- Returns:
- The current markup element as a markup tag
-
getWicketNamespace
Get the wicket namespace valid for this specific markup- Returns:
- wicket namespace
-
isCurrentIndexInsideTheStream
- Returns:
- True if this markup stream is moved to a MarkupElement element
-
hasMore
- Returns:
- True if this markup stream has more MarkupElement elements
-
isMergedMarkup
- Returns:
- true, if underlying markup has been merged (inheritance)
-
next
Note:- Returns:
- The next markup element in the stream
-
nextOpenTag
Note:- Returns:
- The next markup element in the stream
-
setCurrentIndex
- Parameters:
currentIndex
- New current index in the stream- Returns:
- this
-
skipComponent
Skips this component and all nested components -
skipRawMarkup
Skips any raw markup at the current position -
skipUntil
Skip until an element of type 'clazz' is found- Parameters:
clazz
-- Returns:
- true if found
-
skipUntil
Skips any markup at the current position until the wicket tag name is found.- Parameters:
wicketTagName
- wicket tag name to seek
-
skipToMatchingCloseTag
Renders markup until a closing tag for openTag is reached.- Parameters:
openTag
- The open tag
-
getMarkupFragment
- Returns:
- A markup fragment starting at the current position
-
getTagAttribute
Gets the attribute with 'name' for the tag at the current position- Parameters:
name
-withWicketNamespace
-- Returns:
- null, if not found
-
getPreviousTag
Sometime its necessary to get the previous markup element versus the current one.- Returns:
- The previous element (currentIndex - 1)
-
throwMarkupException
Throws a new markup exception- Parameters:
message
- The exception message- Throws:
MarkupException
-
toHtmlDebugString
- Returns:
- An HTML string highlighting the current position in the markup stream
-
toString
-