Class Context


  • public class Context
    extends Object
    Wraps up locally scoped variables used in creating a xtemplate method. Can be nested, to allow for local scopes that shouldn't affect outer scopes.
    • Constructor Detail

      • Context

        public Context​(Context parent,
                       String childDeref,
                       com.google.gwt.core.ext.typeinfo.JType childType)
      • Context

        public Context​(com.google.gwt.core.ext.GeneratorContext ctx,
                       com.google.gwt.core.ext.TreeLogger l,
                       Map<String,​com.google.gwt.core.ext.typeinfo.JType> params,
                       FormatCollector formatters)
    • Method Detail

      • declareLocalVariable

        public String declareLocalVariable​(String name)
      • deref

        public String deref​(String localName)
                     throws com.google.gwt.core.ext.UnableToCompleteException
        Gets a java expression that will return a value for the local name from within the current context, including any formatting.
        Parameters:
        localName - the name of the content
        Returns:
        the Java expression that returns the value
        Throws:
        com.google.gwt.core.ext.UnableToCompleteException - if the Java expression cannot be returned
      • derefCount

        public String derefCount​(String localName)
                          throws com.google.gwt.core.ext.UnableToCompleteException
        Gets a java expression for the number of items in the given localName, assuming it is an Array or List
        Parameters:
        localName - the name of the content
        Returns:
        number of items in localName
        Throws:
        com.google.gwt.core.ext.UnableToCompleteException - if the number of items cannot be returned
      • getType

        public com.google.gwt.core.ext.typeinfo.JType getType​(String localName)
                                                       throws com.google.gwt.core.ext.UnableToCompleteException
        Gets the type of content available at this path, within the current context.
        Parameters:
        localName - the name of the content
        Returns:
        the type of the content
        Throws:
        com.google.gwt.core.ext.UnableToCompleteException - if the type cannot be returned
      • setCountVar

        public void setCountVar​(String countVar)
        Explicitly set the local count variable. This can (must) be set for each context, and can be referenced with the # magic variable.
        Parameters:
        countVar - the local count variable