wicket.markup
Class MarkupStream

java.lang.Object
  extended bywicket.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
MarkupStream(Markup markup)
          Constructor
 
Method Summary
 boolean atCloseTag()
           
 boolean atOpenCloseTag()
           
 boolean atOpenCloseTag(java.lang.String componentId)
           
 boolean atOpenTag()
           
 boolean atOpenTag(java.lang.String componentId)
           
 boolean atTag()
           
 MarkupElement get()
           
 int getCurrentIndex()
           
 java.lang.String getEncoding()
          Gets the markup encoding.
 IResourceStream getResource()
           
 ComponentTag getTag()
           
 java.lang.String getXmlDeclaration()
          Return the XML declaration string, in case if found in the markup.
 boolean hasMore()
           
 MarkupElement next()
           
 void setCurrentIndex(int currentIndex)
           
 void skipComponent()
          Skips this component and all nested components
 void skipRawMarkup()
          Skips any raw markup at the current position
 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

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 componentId)
Parameters:
componentId - Required component name 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()
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


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()
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 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


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