wicket.markup
Class MarkupStream

java.lang.Object
  extended by wicket.markup.MarkupStream

public final class MarkupStream
extends java.lang.Object

A stream of MarkupElements, subclases 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 seeked 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
protected MarkupStream()
          DO NOT YOU THIS CONSTRUCTOR.
  MarkupStream(Markup markup)
          Constructor
 
Method Summary
 boolean atCloseTag()
           
 boolean atOpenCloseTag()
           
 boolean atOpenCloseTag(java.lang.String componentId)
           
 boolean atOpenTag()
           
 boolean atOpenTag(java.lang.String id)
           
 boolean atTag()
           
 java.util.Iterator componentTagIterator()
          Create an iterator for the component tags in the stream.
 boolean equalMarkup(MarkupStream markupStream)
          True, if associate markup is the same.
 int findComponentIndex(java.lang.String path, java.lang.String id)
          Find the markup element index of the component with 'path'
 MarkupElement get()
           
 java.lang.Class getContainerClass()
          Get the component/container's Class which is directly associated with the stream.
 int getCurrentIndex()
           
 java.lang.String getEncoding()
          Gets the markup encoding.
 IResourceStream getResource()
           
 ComponentTag getTag()
           
 java.lang.String getWicketNamespace()
          Get the wicket namespace valid for this specific markup
 java.lang.String getXmlDeclaration()
          Return the XML declaration string, in case if found in the markup.
 boolean hasMore()
           
 boolean isMergedMarkup()
           
 MarkupElement next()
          Note:
 void setCurrentIndex(int currentIndex)
           
 void skipComponent()
          Skips this component and all nested components
 void skipRawMarkup()
          Skips any raw markup at the current position
 void skipUntil(java.lang.String wicketTagName)
          Skips any markup at the current position until the wicket tag name is found.
 void throwMarkupException(java.lang.String message)
          Throws a new markup exception
 java.lang.String toHtmlDebugString()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MarkupStream

protected MarkupStream()
DO NOT YOU THIS CONSTRUCTOR. IT WILL MOST LIKELY BE REPLACED IN THE NEAR FUTURE.


MarkupStream

public MarkupStream(Markup markup)
Constructor

Parameters:
markup - List of markup elements
Method Detail

atCloseTag

public boolean atCloseTag()
Returns:
True if current markup element is a close tag

atOpenCloseTag

public boolean atOpenCloseTag()
Returns:
True if current markup element is an openclose tag

atOpenCloseTag

public boolean atOpenCloseTag(java.lang.String componentId)
Parameters:
componentId - Required component name attribute
Returns:
True if the current markup element is an openclose tag with the given component name

atOpenTag

public boolean atOpenTag()
Returns:
True if current markup element is an open tag

atOpenTag

public boolean atOpenTag(java.lang.String id)
Parameters:
id - Required component id attribute
Returns:
True if the current markup element is an open tag with the given component name

atTag

public boolean atTag()
Returns:
True if current markup element is a tag

get

public MarkupElement get()
Returns:
The current markup element

getCurrentIndex

public int getCurrentIndex()
Returns:
Current index in markup stream

getResource

public IResourceStream getResource()
Returns:
The resource where this markup stream came from

getTag

public ComponentTag getTag()
Returns:
The current markup element as a markup tag

hasMore

public boolean hasMore()
Returns:
True if this markup stream has more MarkupElement elements

next

public MarkupElement next()
Note:

Returns:
The next markup element in the stream

setCurrentIndex

public void setCurrentIndex(int currentIndex)
Parameters:
currentIndex - New current index in the stream

skipComponent

public final void skipComponent()
Skips this component and all nested components


skipRawMarkup

public void skipRawMarkup()
Skips any raw markup at the current position


skipUntil

public void skipUntil(java.lang.String wicketTagName)
Skips any markup at the current position until the wicket tag name is found.

Parameters:
wicketTagName - wicket tag name to seek

throwMarkupException

public void throwMarkupException(java.lang.String message)
Throws a new markup exception

Parameters:
message - The exception message
Throws:
MarkupException

toHtmlDebugString

public java.lang.String toHtmlDebugString()
Returns:
An HTML string highlighting the current position in the markup stream

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
Returns:
String representation of markup stream

getXmlDeclaration

public java.lang.String getXmlDeclaration()
Return the XML declaration string, in case if found in the markup.

Returns:
Null, if not found.

getEncoding

public final java.lang.String 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

getContainerClass

public final java.lang.Class getContainerClass()
Get the component/container's Class which is directly associated with the stream.

Returns:
The component's class

getWicketNamespace

public final java.lang.String getWicketNamespace()
Get the wicket namespace valid for this specific markup

Returns:
wicket namespace

equalMarkup

public final boolean equalMarkup(MarkupStream markupStream)
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

findComponentIndex

public final int findComponentIndex(java.lang.String path,
                                    java.lang.String id)
Find the markup element index of the component with 'path'

Parameters:
path - The component path expression
id - The component's id to search for
Returns:
-1, if not found

componentTagIterator

public final java.util.Iterator componentTagIterator()
Create an iterator for the component tags in the stream.

Note: it will not modify the current index of the underlying markup stream

Returns:
ComponentTagIterator

isMergedMarkup

public final boolean isMergedMarkup()
Returns:
true, if underlying markup has been merged (inheritance)


Copyright © 2004-2007 Wicket developers. All Rights Reserved.