jaxx.compiler.binding
Class DataBindingHelper

java.lang.Object
  extended by 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:
tchemit

Field Summary
protected  java.util.Map<java.lang.String,java.lang.Integer> autoUnsafeGenIds
          Counter by unsafe type
protected  JAXXCompiler compiler
          Associated compiler
protected  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.
protected static java.util.regex.Matcher leftBraceMatcher
          left brace matcher
protected static java.util.regex.Matcher rightBraceMatcher
          right brace matcher
static boolean SHOW_LOG
          To debug binding without any log interference
protected  java.util.List<DataBinding> simpleBindings
          Simpel bindings for the compiler
 
Constructor Summary
DataBindingHelper(JAXXCompiler compiler)
           
 
Method Summary
 void clear()
           
 void finalizeBindings()
          Compile all binding discovered previously.
 DataBinding[] getDataBindings()
           
protected static int getNextLeftBrace(java.lang.String string, int pos)
           
protected static int getNextRightBrace(java.lang.String string, int pos)
           
 java.lang.String getSafeId(java.lang.String id)
          Obtain the next safe id for the given binding id.
 DataBinding[] getSimpleBindings()
           
static java.lang.String processDataBindings(java.lang.String stringValue)
          Examine an attribute value for data binding expressions.
 void registerDataBinding(DataBinding binding)
           
 void registerDataBinding(java.lang.String id, java.lang.String binding, java.lang.String assignment)
           
 void revertSafeId(java.lang.String id)
          Revert a previous computed safe id.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

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 Detail

DataBindingHelper

public DataBindingHelper(JAXXCompiler compiler)
Method Detail

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)


Copyright © 2008-2010 CodeLutin. All Rights Reserved.