use of org.apache.tapestry5.internal.plastic.asm.Type in project tapestry-5 by apache.
the class Remapper method mapValue.
/**
* Returns the given value, remapped with this remapper. Possible values are {@link Boolean},
* {@link Byte}, {@link Short}, {@link Character}, {@link Integer}, {@link Long}, {@link Double},
* {@link Float}, {@link String}, {@link Type}, {@link Handle}, {@link ConstantDynamic} or arrays
* of primitive types .
*
* @param value an object. Only {@link Type}, {@link Handle} and {@link ConstantDynamic} values
* are remapped.
* @return the given value, remapped with this remapper.
*/
public Object mapValue(final Object value) {
if (value instanceof Type) {
return mapType((Type) value);
}
if (value instanceof Handle) {
Handle handle = (Handle) value;
return new Handle(handle.getTag(), mapType(handle.getOwner()), mapMethodName(handle.getOwner(), handle.getName(), handle.getDesc()), handle.getTag() <= Opcodes.H_PUTSTATIC ? mapDesc(handle.getDesc()) : mapMethodDesc(handle.getDesc()), handle.isInterface());
}
if (value instanceof ConstantDynamic) {
ConstantDynamic constantDynamic = (ConstantDynamic) value;
int bootstrapMethodArgumentCount = constantDynamic.getBootstrapMethodArgumentCount();
Object[] remappedBootstrapMethodArguments = new Object[bootstrapMethodArgumentCount];
for (int i = 0; i < bootstrapMethodArgumentCount; ++i) {
remappedBootstrapMethodArguments[i] = mapValue(constantDynamic.getBootstrapMethodArgument(i));
}
String descriptor = constantDynamic.getDescriptor();
return new ConstantDynamic(mapInvokeDynamicMethodName(constantDynamic.getName(), descriptor), mapDesc(descriptor), (Handle) mapValue(constantDynamic.getBootstrapMethod()), remappedBootstrapMethodArguments);
}
return value;
}
use of org.apache.tapestry5.internal.plastic.asm.Type in project tapestry-5 by apache.
the class AnalyzerAdapter method pop.
private void pop(final String descriptor) {
char firstDescriptorChar = descriptor.charAt(0);
if (firstDescriptorChar == '(') {
int numSlots = 0;
Type[] types = Type.getArgumentTypes(descriptor);
for (Type type : types) {
numSlots += type.getSize();
}
pop(numSlots);
} else if (firstDescriptorChar == 'J' || firstDescriptorChar == 'D') {
pop(2);
} else {
pop(1);
}
}
use of org.apache.tapestry5.internal.plastic.asm.Type in project tapestry-5 by apache.
the class FieldValidatorSourceImpl method createValidator.
private FieldValidator createValidator(Field field, ValidatorSpecification spec, String overrideId, Messages overrideMessages) {
String validatorType = spec.getValidatorType();
assert InternalUtils.isNonBlank(validatorType);
Validator validator = validators.get(validatorType);
if (validator == null)
throw new IllegalArgumentException(String.format("Unknown validator type '%s'. Configured validators are %s.", validatorType, InternalUtils.join(InternalUtils.sortedKeys(validators))));
// I just have this thing about always treating parameters as finals, so
// we introduce a second variable to treat a mutable.
String formValidationid = formSupport.getFormValidationId();
Object coercedConstraintValue = computeConstraintValue(validatorType, validator, spec.getConstraintValue(), formValidationid, overrideId, overrideMessages);
MessageFormatter formatter = findMessageFormatter(formValidationid, overrideId, overrideMessages, validatorType, validator);
return new FieldValidatorImpl(field, coercedConstraintValue, formatter, validator, formSupport);
}
use of org.apache.tapestry5.internal.plastic.asm.Type in project tapestry-5 by apache.
the class SubmitTest method submit_form.
@Test
public void submit_form() {
Element submitButton = doc.getElementById("capitalize1");
assertEquals("submit", submitButton.getAttribute("type"));
fieldValues.put("t1", "hello");
doc = tester.clickSubmit(submitButton, fieldValues);
assertTrue(doc.toString().contains("Value is: HELLO"));
}
use of org.apache.tapestry5.internal.plastic.asm.Type in project tapestry-5 by apache.
the class SubmitTest method not_in_form.
@Test
public void not_in_form() {
try {
Element submitButton = doc.getElementById("orphanedSubmit");
tester.clickSubmit(submitButton, fieldValues);
throw new RuntimeException("Should not be reachable.");
} catch (RuntimeException ex) {
assertEquals(ex.getMessage(), "Could not locate an ancestor element of type 'form'.");
}
}
Aggregations