net.aethersanctum.curlyml
Class DocumentLoader

java.lang.Object
  extended by net.aethersanctum.curlyml.DocumentLoader
All Implemented Interfaces:
ParseEventHandler

public class DocumentLoader
extends java.lang.Object
implements ParseEventHandler

Creates a Document tree by intercepting events from the parsing of a stream. Not threadsafe. Use once to load a single document, from a file or reader then throw away.

Author:
ben

Constructor Summary
DocumentLoader()
           
 
Method Summary
 void handleLeaf(java.lang.String name)
          handle leaf node creation events from parser, add them as children to whoever's top of the stack
 void handleParentBegin(java.lang.String name)
          handle parent node creation events from parser, add them as children to whoever's top of the stack, and push them onto the top of the stack
 void handleParentEnd(boolean hasKids)
          handle end-of-parent events from parser, just take 'em off the stack
 Document load(java.io.Reader s)
          load document from anything that reads
 Document load(java.lang.String filename)
          load Document from a file
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DocumentLoader

public DocumentLoader()
Method Detail

load

public Document load(java.lang.String filename)
              throws java.io.IOException,
                     SyntaxException
load Document from a file

Parameters:
filename -
Returns:
Throws:
java.io.IOException
SyntaxException

load

public Document load(java.io.Reader s)
              throws java.io.IOException,
                     SyntaxException
load document from anything that reads

Parameters:
s -
Returns:
Throws:
java.io.IOException
SyntaxException

handleLeaf

public void handleLeaf(java.lang.String name)
handle leaf node creation events from parser, add them as children to whoever's top of the stack

Specified by:
handleLeaf in interface ParseEventHandler

handleParentBegin

public void handleParentBegin(java.lang.String name)
handle parent node creation events from parser, add them as children to whoever's top of the stack, and push them onto the top of the stack

Specified by:
handleParentBegin in interface ParseEventHandler

handleParentEnd

public void handleParentEnd(boolean hasKids)
handle end-of-parent events from parser, just take 'em off the stack

Specified by:
handleParentEnd in interface ParseEventHandler
Parameters:
hasKids - will be true if the parent had any children or false if it was empty