Package org.nuiton.jaxx.compiler.binding
Class DataBindingHelper
- java.lang.Object
-
- org.nuiton.jaxx.compiler.binding.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
JAXXCompilermore simple and clear.Created: 27 nov. 2009
- Since:
- 2.0.0
- Author:
- Tony Chemit - dev@tchemit.fr
-
-
Field Summary
Fields Modifier and Type Field Description protected Map<String,Integer>autoUnsafeGenIdsCounter by unsafe typeprotected JAXXCompilercompilerAssociated compilerprotected List<DataBinding>dataBindingsRegistred data binding for the compiler, then after the invocation of methodfinalizeBindings()only the real data bindings, the simple bindings will be moved tosimpleBindings.protected static MatcherleftBraceMatcherleft brace matcherprotected static MatcherrightBraceMatcherright brace matcherstatic booleanSHOW_LOGTo debug binding without any log interferenceprotected List<DataBinding>simpleBindingsSimpel bindings for the compiler
-
Constructor Summary
Constructors Constructor Description DataBindingHelper(JAXXCompiler compiler)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()voidfinalizeBindings()Compile all binding discovered previously.DataBinding[]getDataBindings()protected static intgetNextLeftBrace(String string, int pos)protected static intgetNextRightBrace(String string, int pos)StringgetSafeId(String id)Obtain the next safe id for the given binding id.DataBinding[]getSimpleBindings()StringprocessDataBindings(String stringValue)Examine an attribute value for data binding expressions.voidregisterDataBinding(String id, String binding, String assignment)voidregisterDataBinding(DataBinding binding)voidrevertSafeId(String id)Revert a previous computed safe id.
-
-
-
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 methodfinalizeBindings()only the real data bindings, the simple bindings will be moved tosimpleBindings.
-
simpleBindings
protected final List<DataBinding> simpleBindings
Simpel bindings for the compiler
-
compiler
protected final JAXXCompiler compiler
Associated compiler
-
-
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 toregisterDataBinding(java.lang.String, java.lang.String, java.lang.String). If the attribute value does not invoke data binding, this method returnsnull- 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(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
_XXXuntil 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
dataBindingstosimpleBindings.
-
getNextLeftBrace
protected static int getNextLeftBrace(String string, int pos)
-
getNextRightBrace
protected static int getNextRightBrace(String string, int pos)
-
-