Class DataBindingHelper

java.lang.Object
jaxx.compiler.binding.DataBindingHelper

public class DataBindingHelper
extends java.lang.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 - chemit@codelutin.com
  • Field Details

    • SHOW_LOG

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

      protected static final java.util.regex.Matcher leftBraceMatcher
      left brace matcher
    • rightBraceMatcher

      protected static final java.util.regex.Matcher rightBraceMatcher
      right brace matcher
    • dataBindings

      protected final java.util.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 java.util.List<DataBinding> simpleBindings
      Simpel bindings for the compiler
    • compiler

      protected final JAXXCompiler compiler
      Associated compiler
    • autoUnsafeGenIds

      protected final java.util.Map<java.lang.String,​java.lang.Integer> autoUnsafeGenIds
      Counter by unsafe type
  • Constructor Details

    • DataBindingHelper

      public DataBindingHelper​(JAXXCompiler compiler)
  • Method Details

    • processDataBindings

      public static java.lang.String processDataBindings​(java.lang.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​(java.lang.String id, java.lang.String binding, java.lang.String assignment)
    • registerDataBinding

      public void registerDataBinding​(DataBinding binding)
    • clear

      public void clear()
    • getSafeId

      public java.lang.String getSafeId​(java.lang.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​(java.lang.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​(java.lang.String string, int pos)
    • getNextRightBrace

      protected static int getNextRightBrace​(java.lang.String string, int pos)