org.apache.wicket.markup
public class MarkupStream extends Object
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().
Constructor and Description |
---|
MarkupStream(IMarkupFragment markup)
Constructor
|
Modifier and Type | Method and Description |
---|---|
boolean |
atCloseTag() |
boolean |
atOpenCloseTag() |
boolean |
atOpenCloseTag(String componentId) |
boolean |
atOpenTag() |
boolean |
atOpenTag(String id) |
boolean |
atTag() |
boolean |
equalMarkup(MarkupStream markupStream)
True, if associate markup is the same.
|
boolean |
equalTo(MarkupStream that)
Compare this markup stream with another one
|
MarkupElement |
get() |
MarkupElement |
get(int index) |
Class<? extends Component> |
getContainerClass()
Get the component/container's Class which is directly associated with the stream.
|
int |
getCurrentIndex() |
String |
getEncoding()
Gets the markup encoding.
|
IMarkupFragment |
getMarkupFragment() |
ComponentTag |
getPreviousTag()
Sometime its necessary to get the previous markup element versus the current one.
|
IResourceStream |
getResource() |
ComponentTag |
getTag() |
String |
getTagAttribute(String name,
boolean withWicketNamespace)
Gets the attribute with 'name' for the tag at the current position
|
String |
getWicketNamespace()
Get the wicket namespace valid for this specific markup
|
boolean |
hasMore()
Deprecated.
use
isCurrentIndexInsideTheStream() instead |
boolean |
isCurrentIndexInsideTheStream() |
boolean |
isMergedMarkup() |
MarkupElement |
next()
Note:
|
MarkupElement |
nextOpenTag()
Note:
|
MarkupStream |
setCurrentIndex(int currentIndex) |
void |
skipComponent()
Skips this component and all nested components
|
void |
skipRawMarkup()
Skips any raw markup at the current position
|
void |
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 found
|
void |
skipUntil(String wicketTagName)
Skips any markup at the current position until the wicket tag name is found.
|
void |
throwMarkupException(String message)
Throws a new markup exception
|
String |
toHtmlDebugString() |
String |
toString() |
public MarkupStream(IMarkupFragment markup)
markup
- List of markup elementspublic boolean atCloseTag()
public boolean atOpenCloseTag()
public boolean atOpenCloseTag(String componentId)
componentId
- Required component name attributepublic boolean atOpenTag()
public boolean atOpenTag(String id)
id
- Required component id attributepublic boolean atTag()
public boolean equalTo(MarkupStream that)
that
- The other markup streampublic final boolean equalMarkup(MarkupStream markupStream)
markupStream
- The markup stream to compare with.public MarkupElement get()
public MarkupElement get(int index)
index
- The index of a markup elementpublic final Class<? extends Component> getContainerClass()
public int getCurrentIndex()
public final String getEncoding()
public IResourceStream getResource()
public ComponentTag getTag()
public final String getWicketNamespace()
public boolean isCurrentIndexInsideTheStream()
@Deprecated public boolean hasMore()
isCurrentIndexInsideTheStream()
insteadpublic final boolean isMergedMarkup()
public MarkupElement next()
public MarkupElement nextOpenTag()
public MarkupStream setCurrentIndex(int currentIndex)
currentIndex
- New current index in the streampublic final void skipComponent()
public void skipRawMarkup()
public boolean skipUntil(Class<? extends MarkupElement> clazz)
clazz
- public void skipUntil(String wicketTagName)
wicketTagName
- wicket tag name to seekpublic void skipToMatchingCloseTag(ComponentTag openTag)
openTag
- The open tagpublic final IMarkupFragment getMarkupFragment()
public final String getTagAttribute(String name, boolean withWicketNamespace)
name
- withWicketNamespace
- public final ComponentTag getPreviousTag()
public void throwMarkupException(String message)
message
- The exception messageMarkupException
public String toHtmlDebugString()
Copyright © 2006–2018 Apache Software Foundation. All rights reserved.