Class DataBindingHelper


  • public class DataBindingHelper
    extends Object
    Helper to be used by compiler to treate data bindings.

    Note : The code in this class was previously directly in JAXXCompiler, now prefer have a separate class to make JAXXCompiler more simple and clear.

    Created: 27 nov. 2009

    Since:
    2.0.0
    Author:
    Tony Chemit - dev@tchemit.fr
    • Field Detail

      • SHOW_LOG

        public static boolean SHOW_LOG
        To debug binding without any log interference
      • leftBraceMatcher

        protected static final Matcher leftBraceMatcher
        left brace matcher
      • rightBraceMatcher

        protected static final Matcher rightBraceMatcher
        right brace matcher
      • dataBindings

        protected final List<DataBinding> dataBindings
        Registred data binding for the compiler, then after the invocation of method finalizeBindings() only the real data bindings, the simple bindings will be moved to simpleBindings.
      • simpleBindings

        protected final List<DataBinding> simpleBindings
        Simpel bindings for the compiler
      • compiler

        protected final JAXXCompiler compiler
        Associated compiler
      • autoUnsafeGenIds

        protected final Map<String,​Integer> autoUnsafeGenIds
        Counter by unsafe type
    • Constructor Detail

      • DataBindingHelper

        public DataBindingHelper​(JAXXCompiler compiler)
    • Method Detail

      • processDataBindings

        public String processDataBindings​(String stringValue)
                                   throws CompilerException
        Examine an attribute value for data binding expressions. Returns a 'cooked' expression which can be used to determine the resulting value. It is expected that this expression will be used as the source expression in a call to registerDataBinding(java.lang.String, java.lang.String, java.lang.String). If the attribute value does not invoke data binding, this method returns null
        Parameters:
        stringValue - the string value of the property from the XML
        Returns:
        a processed version of the expression
        Throws:
        CompilerException - ?
      • getDataBindings

        public DataBinding[] getDataBindings()
      • getSimpleBindings

        public DataBinding[] getSimpleBindings()
      • registerDataBinding

        public void registerDataBinding​(String id,
                                        String binding,
                                        String assignment)
      • registerDataBinding

        public void registerDataBinding​(DataBinding binding)
      • clear

        public void clear()
      • getSafeId

        public String getSafeId​(String id)
        Obtain the next safe id for the given binding id.

        With css, we can obtain the same binding id, so we must check for unicity each time we want a new binding id.

        If an id is already taken, we suffix by _XXX until found a free id.

        Parameters:
        id - the id of the binding
        Returns:
        the safe id of the binding
      • revertSafeId

        public void revertSafeId​(String id)
        Revert a previous computed safe id.

        This is needed when a binding compiled is not an data binding, we want to free the safe id to avoid hole in numbers.

        Parameters:
        id - the original id to revert in counter.
      • finalizeBindings

        public void finalizeBindings()
        Compile all binding discovered previously.

        If a binding is not a dataBinding, then move it from the list dataBindings to simpleBindings.

      • getNextLeftBrace

        protected static int getNextLeftBrace​(String string,
                                              int pos)
      • getNextRightBrace

        protected static int getNextRightBrace​(String string,
                                               int pos)