Class FieldReferenceConverter
- java.lang.Object
-
- com.google.gwt.uibinder.attributeparsers.FieldReferenceConverter
-
public class FieldReferenceConverter extends java.lang.Object
Deals with field references, e.g. the bits in braces here:<div class="{style.enabled} fancy {style.impressive}" />
, by converting them to java expressions (with the help of aDelegate
).A field reference is one or more segments separated by dots. The first segment is considered to be a reference to a ui field, and succeeding segments are method calls. So,
"{able.baker.charlie}"
becomes"able.baker().charlie()"
.A field reference starts with '{' and is followed immediately by a character that can legally start a java identifier—that is a letter, $, or underscore. Braces not followed by such a character are left in place.
For convenience when dealing with generated CssResources, field segments with dashes are converted to camel case. That is, {able.baker-charlie} is the same as {able.bakerCharlie}
Double mustaches (i.e. "{{..}}") are not matched as references to play well with modern templating systems.
Opening braces may be escape by slash. That is, "\{foo}" will converted to "{foo}", with no field reference detected.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static interface
FieldReferenceConverter.Delegate
Responsible for the bits around and between the field references.static class
FieldReferenceConverter.IllegalFieldReferenceException
May be thrown by theDelegate
for badly formatted input.
-
Constructor Summary
Constructors Constructor Description FieldReferenceConverter(com.google.gwt.uibinder.rebind.FieldManager fieldManager)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
convert(com.google.gwt.uibinder.rebind.XMLElement source, java.lang.String in, FieldReferenceConverter.Delegate delegate)
java.lang.String
convert(java.lang.String in, FieldReferenceConverter.Delegate delegate)
static int
countFieldReferences(java.lang.String string)
Returns the number of field references in the given string.static java.lang.String
expressionToPath(java.lang.String expression)
Reverses most of the work ofconvert(java.lang.String, com.google.gwt.uibinder.attributeparsers.FieldReferenceConverter.Delegate)
, turning a java expression back into a dotted path.static boolean
hasFieldReferences(java.lang.String string)
Returns true if the given string holds one or more field references.
-
-
-
Method Detail
-
countFieldReferences
public static int countFieldReferences(java.lang.String string)
Returns the number of field references in the given string.
-
expressionToPath
public static java.lang.String expressionToPath(java.lang.String expression)
Reverses most of the work ofconvert(java.lang.String, com.google.gwt.uibinder.attributeparsers.FieldReferenceConverter.Delegate)
, turning a java expression back into a dotted path.
-
hasFieldReferences
public static boolean hasFieldReferences(java.lang.String string)
Returns true if the given string holds one or more field references.
-
convert
public java.lang.String convert(java.lang.String in, FieldReferenceConverter.Delegate delegate)
- Throws:
FieldReferenceConverter.IllegalFieldReferenceException
- if the delegate does
-
convert
public java.lang.String convert(com.google.gwt.uibinder.rebind.XMLElement source, java.lang.String in, FieldReferenceConverter.Delegate delegate)
- Throws:
FieldReferenceConverter.IllegalFieldReferenceException
- if the delegate does
-
-