use of org.apache.tapestry5.ioc.annotations.Order in project tapestry-5 by apache.
the class TemplateParserImplTest method component_with_parameters.
@Test
public void component_with_parameters() {
List<TemplateToken> tokens = tokens("componentWithParameters.tml");
assertEquals(tokens.size(), 9);
TemplateToken templateToken = get(tokens, 2);
Location l = templateToken.getLocation();
AttributeToken t1 = get(tokens, 3);
// TODO: Not sure what order the attributes appear in. Order in the XML? Sorted
// alphabetically? Random 'cause they're hashed?
assertEquals(t1.name, "cherry");
assertEquals(t1.value, "bomb");
assertSame(t1.getLocation(), l);
AttributeToken t2 = get(tokens, 4);
assertEquals(t2.name, "align");
assertEquals(t2.value, "right");
assertSame(t2.getLocation(), l);
TextToken t3 = get(tokens, 5);
assertEquals(t3.text.trim(), "fred's body");
get(tokens, 6);
}
use of org.apache.tapestry5.ioc.annotations.Order in project tapestry-5 by apache.
the class GeneratorAdapter method tableSwitch.
/**
* Generates the instructions for a switch statement.
*
* @param keys the switch case keys.
* @param generator a generator to generate the code for the switch cases.
* @param useTable {@literal true} to use a TABLESWITCH instruction, or {@literal false} to use a
* LOOKUPSWITCH instruction.
*/
public void tableSwitch(final int[] keys, final TableSwitchGenerator generator, final boolean useTable) {
for (int i = 1; i < keys.length; ++i) {
if (keys[i] < keys[i - 1]) {
throw new IllegalArgumentException("keys must be sorted in ascending order");
}
}
Label defaultLabel = newLabel();
Label endLabel = newLabel();
if (keys.length > 0) {
int numKeys = keys.length;
if (useTable) {
int min = keys[0];
int max = keys[numKeys - 1];
int range = max - min + 1;
Label[] labels = new Label[range];
Arrays.fill(labels, defaultLabel);
for (int i = 0; i < numKeys; ++i) {
labels[keys[i] - min] = newLabel();
}
mv.visitTableSwitchInsn(min, max, defaultLabel, labels);
for (int i = 0; i < range; ++i) {
Label label = labels[i];
if (label != defaultLabel) {
mark(label);
generator.generateCase(i + min, endLabel);
}
}
} else {
Label[] labels = new Label[numKeys];
for (int i = 0; i < numKeys; ++i) {
labels[i] = newLabel();
}
mv.visitLookupSwitchInsn(defaultLabel, keys, labels);
for (int i = 0; i < numKeys; ++i) {
mark(labels[i]);
generator.generateCase(keys[i], endLabel);
}
}
}
mark(defaultLabel);
generator.generateDefault();
mark(endLabel);
}
use of org.apache.tapestry5.ioc.annotations.Order in project tapestry-5 by apache.
the class ToDoDatabaseImpl method add.
private void add(String title, Urgency urgency, int order) {
ToDoItem item = new ToDoItem();
item.setTitle(title);
item.setUrgency(urgency);
item.setOrder(order);
add(item);
}
use of org.apache.tapestry5.ioc.annotations.Order in project tapestry-5 by apache.
the class MixinWorker method replaceFieldWithMixin.
private void replaceFieldWithMixin(MutableComponentModel model, PlasticField field) {
Mixin annotation = field.getAnnotation(Mixin.class);
field.claim(annotation);
String mixinType = annotation.value();
String[] order = annotation.order();
String fieldType = field.getTypeName();
String mixinClassName = InternalUtils.isBlank(mixinType) ? fieldType : resolver.resolveMixinTypeToClassName(mixinType);
model.addMixinClassName(mixinClassName, order);
replaceFieldAccessWithMixin(field, mixinClassName);
}
use of org.apache.tapestry5.ioc.annotations.Order in project tapestry-5 by apache.
the class ToDoList method onSuccess.
void onSuccess() {
int order = 0;
for (ToDoItem item : items) {
item.setOrder(order++);
database.update(item);
}
}
Aggregations