org.sitemesh.content.tagrules.html
Class ExportTagToContentRule

java.lang.Object
  extended by org.sitemesh.tagprocessor.BasicRule
      extended by org.sitemesh.tagprocessor.BasicBlockRule
          extended by org.sitemesh.content.tagrules.html.ExportTagToContentRule
All Implemented Interfaces:
TagRule

public class ExportTagToContentRule
extends BasicBlockRule

Exports the contents of a match tag to property of the passed in ContentProperty. Additionally, if this tag has attributes, they will be written as child properties.

Example

 // Java
 myState.addRule("foo", new ExportTagToContentRule(content, "bar");

 // Input
 <foo x=1 b=2>hello</foo>

 // Exported properties of Content
 bar=hello
 bar.x=1
 bar.b=2
 

Author:
Joe Walnes

Field Summary
 
Fields inherited from class org.sitemesh.tagprocessor.BasicRule
tagProcessorContext
 
Constructor Summary
ExportTagToContentRule(ContentProperty targetProperty, boolean includeInContent)
           
 
Method Summary
protected  void processEnd(Tag tag, Object data)
          Called when a block is ended (i.e.
protected  Object processStart(Tag tag)
          Called when a block is started (i.e.
 
Methods inherited from class org.sitemesh.tagprocessor.BasicBlockRule
process
 
Methods inherited from class org.sitemesh.tagprocessor.BasicRule
setTagProcessorContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExportTagToContentRule

public ExportTagToContentRule(ContentProperty targetProperty,
                              boolean includeInContent)
Parameters:
targetProperty - ContentProperty to export tag contents to.
includeInContent - Whether the tag should be included in the content (if false, it will be stripped from the current ContentProperty that is being written to.
See Also:
ExportTagToContentRule
Method Detail

processStart

protected Object processStart(Tag tag)
                       throws IOException
Description copied from class: BasicBlockRule
Called when a block is started (i.e. <opening> tag is encountered).

Specified by:
processStart in class BasicBlockRule
Parameters:
tag - Opening tag.
Returns:
Any data that needs to be passed to BasicBlockRule.processEnd(Tag, Object). May be null.
Throws:
IOException

processEnd

protected void processEnd(Tag tag,
                          Object data)
                   throws IOException
Description copied from class: BasicBlockRule
Called when a block is ended (i.e. </closing> tag is encountered).

Specified by:
processEnd in class BasicBlockRule
Parameters:
tag - Closing tag. This will not have any attributes available (as they are associated with an opening tag. To get access to the attributes, the BasicBlockRule.processStart(Tag) method should access them and return them as data.
data - Data returned from BasicBlockRule.processStart(Tag). May be null.
Throws:
IOException


Copyright © 2011. All Rights Reserved.