@Override public Object decode(String value) throws Exception { if (value == null) { throw new IllegalArgumentException("Unable to look up enum value from null"); } Method valueOf = getType().getMethod("valueOf", String.class); try { return valueOf.invoke(null, value); } catch (IllegalAccessException e) { // means we can't have access to the enum, fall back to literal return new LiteralPPIO(getType()).decode(value); } catch (Exception e) { // try upper case try { return valueOf.invoke(null, value.toUpperCase()); } catch (Exception e1) { // try lower case try { return valueOf.invoke(null, value.toLowerCase()); } catch (Exception e2) { // give up and throw back first exception throw e; } } } }
/** * Decodes the parameter (as a string) to its internal object implementation. */ public Object decode( String value ) throws Exception { return Converters.convert(value, getType()); }
public static ProcessParameterIO find(Parameter<?> p, ApplicationContext context, String mime) { return new LiteralPPIO(p.type);
if (!String.class.equals(lppio.getType())) { Class type = lppio.getType(); if (PRIMITIVE_TO_WRAPPER.containsKey(type)) { type = PRIMITIVE_TO_WRAPPER.get(type); Object[] optionsArray = options.toArray(new Object[options.size()]); addAllowedValues(literal, optionsArray); } else if (lppio.getType().isEnum()) { Object[] enumValues = lppio.getType().getEnumConstants(); addAllowedValues(literal, enumValues); } else { literal.setDefaultValue(lppio.encode(p.sample));
result = ((LiteralPPIO) ppio).decode(literal.getValue()); } else if (data.getComplexData() != null) { ComplexDataType complex = data.getComplexData();
data.setLiteralData(literal); literal.setValue(((LiteralPPIO) ppio).encode(o)); } else if (ppio instanceof BoundingBoxPPIO) { BoundingBoxType bbox = ((BoundingBoxPPIO) ppio).encode(o);
result.add(new LiteralPPIO(p.type)); return result;
value = ((LiteralPPIO) ppio).decode(literal.getValue()); } else if (data.getComplexData() != null) { ComplexDataType complex = data.getComplexData();
data.setLiteralData(literal); literal.setValue(((LiteralPPIO) ppio).encode(o)); } else if (ppio instanceof BoundingBoxPPIO) { BoundingBoxType bbox = ((BoundingBoxPPIO) ppio).encode(o);
LOGGER.log(Level.FINE, "Trying to find the PPIO for the Enum = " + p.type); return new LiteralPPIO(p.type);
/** Decodes the parameter (as a string) to its internal object implementation. */ public Object decode(String value) throws Exception { return Converters.convert(value, getType()); }
if ( !String.class.equals(lppio.getType()) ) { Class type = lppio.getType(); if(PRIMITIVE_TO_WRAPPER.containsKey(type)) { type = PRIMITIVE_TO_WRAPPER.get(type); if(lppio.getType().isEnum()) { Object[] enumValues = lppio.getType().getEnumConstants(); AllowedValuesType allowed = owsf.createAllowedValuesType(); for (Object value : enumValues) {