Structured Text Toolkit

com.saelist.stx.parser
Class LstxParser

java.lang.Object
  extended bycom.saelist.stx.parser.LstxParser

public class LstxParser
extends java.lang.Object

Parses a text that is structured by indentation.

Each level of indentation must be exactly two spaces. The only significant characters are leading spaces and new-lines. Other characters don't influence the parsing at all. However, a warning is logged if the ends with a tab. Any escaping, trimming and so on must be done on the resulting Pair hierarchy. That is what @{link com.saelist.stx.operator.Operator}s are for.


Field Summary
static Logger logger
           
 
Constructor Summary
LstxParser()
           
 
Method Summary
static void applyBasicProfile(Pair pair)
          Split on '=' and remove comments.
static Pair parse(java.io.File file)
          Parses the text from file into a structure of @link{com.saelist.stx.Pair}s based on the indentation of the text.
static Pair parse(java.io.Reader in)
          Parses the text from in into a structure of @link{com.saelist.stx.Pair}s based on the indentation of the text.
static Pair parse(java.lang.String text)
          Parses text into a structure of @link{com.saelist.stx.Pair}s based on the indentation of the text.
static void unParse(java.io.Writer out, Pair pair)
          Writer the pair to out.
static void unParse(java.io.Writer out, Pair pair, boolean join)
          Writes the pair to out, joining single children on the parents' line after a "=".
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

public static Logger logger
Constructor Detail

LstxParser

public LstxParser()
Method Detail

parse

public static Pair parse(java.lang.String text)
Parses text into a structure of @link{com.saelist.stx.Pair}s based on the indentation of the text.

Parameters:
text - to be parsed.
Returns:
a pseudo-root containing all the top level entries in text.

parse

public static Pair parse(java.io.File file)
                  throws java.io.IOException
Parses the text from file into a structure of @link{com.saelist.stx.Pair}s based on the indentation of the text.

Parameters:
file - contains text to be parsed.
Returns:
a pseudo-root containing all the top level entries in text.
Throws:
java.io.IOException

parse

public static Pair parse(java.io.Reader in)
                  throws java.io.IOException
Parses the text from in into a structure of @link{com.saelist.stx.Pair}s based on the indentation of the text.

Parameters:
in - provides the text to be parsed.
Returns:
a pseudo-root containing all the top level entries in text.
Throws:
java.io.IOException

unParse

public static void unParse(java.io.Writer out,
                           Pair pair)
                    throws java.io.IOException
Writer the pair to out.

Parameters:
out - receives the result.
pair - to be written.
Throws:
java.io.IOException - on problems with out.

unParse

public static void unParse(java.io.Writer out,
                           Pair pair,
                           boolean join)
                    throws java.io.IOException
Writes the pair to out, joining single children on the parents' line after a "=".

Parameters:
out - receives the result.
pair - to be written.
join - weather to append the text of single children (with no siblings or children of their own) to their parents' line after a "=".
Throws:
java.io.IOException - on problems with out.

applyBasicProfile

public static void applyBasicProfile(Pair pair)
Split on '=' and remove comments.


Structured Text Toolkit