com.google.sitebricks.compiler
Class Parsing

java.lang.Object
  extended by com.google.sitebricks.compiler.Parsing

public class Parsing
extends Object

Utility tokenizes text into expressions and raw text, and provides other text parsing tools.

Since:
1.0
Author:
Dhanji R. Prasanna (dhanji at gmail com)

Method Summary
static TypeConverter getTypeConverter()
           
static int indexOfMeta(String template)
           
static boolean isExpression(String attribute)
           
static boolean isValidURI(String uri)
           
static String render(List<Token> tokens, Map<String,Object> arguments)
          Converts the given token stream into a rendered output evaluating each expression against the provided context object which may be a regular Java POJO with getters and setters or a map of string/value pairs.
static void setTypeConverter(TypeConverter converter)
           
static String stripExpression(String expr)
           
static String stripQuotes(String var)
           
static Map<String,String> toBindMap(String expression)
           
static List<Token> tokenize(String warpRawText, EvaluatorCompiler compiler)
           
static boolean treatAsXml(String template)
          Remember this method is not so much about verifying something is XML as it is verifying that something is a NON-Xml template.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

toBindMap

public static Map<String,String> toBindMap(String expression)

tokenize

public static List<Token> tokenize(String warpRawText,
                                   EvaluatorCompiler compiler)
                            throws ExpressionCompileException
Throws:
ExpressionCompileException

stripExpression

public static String stripExpression(String expr)

isExpression

public static boolean isExpression(String attribute)

stripQuotes

public static String stripQuotes(String var)

treatAsXml

public static boolean treatAsXml(String template)
Remember this method is not so much about verifying something is XML as it is verifying that something is a NON-Xml template. In other words, read this as whether or not we should *treat* something as XML, then complain that it's malformed later (if necessary).

Parameters:
template - A fully loaded template as a string.
Returns:
Returns true if this template should be treated as an XML template. Templates that are not XML *MUST* begin with a @Meta annotation.

render

public static String render(List<Token> tokens,
                            Map<String,Object> arguments)
Converts the given token stream into a rendered output evaluating each expression against the provided context object which may be a regular Java POJO with getters and setters or a map of string/value pairs.


indexOfMeta

public static int indexOfMeta(String template)

isValidURI

public static boolean isValidURI(String uri)

getTypeConverter

public static TypeConverter getTypeConverter()

setTypeConverter

@Inject
public static void setTypeConverter(TypeConverter converter)


Copyright © 2014. All rights reserved.