public static Object convertStringToPrimitive(String value, Class<?> cls) { return convertStringToPrimitive(value, cls, new Annotation[]{}); } public static Object convertStringToPrimitive(String value, Class<?> cls, Annotation[] anns) {
public static Object convertStringToPrimitive(String value, Class<?> cls) { return convertStringToPrimitive(value, cls, new Annotation[]{}); } public static Object convertStringToPrimitive(String value, Class<?> cls, Annotation[] anns) {
private <T> Object readPrimitiveValue(Node node, Class<T> cls) { if (String.class == cls) { if (node.getNodeType() == Node.ELEMENT_NODE) { return StaxUtils.toString((Element)node); } return cls.cast(node.getNodeValue()); } return InjectionUtils.convertStringToPrimitive(node.getNodeValue(), cls); }
/** * Find the attribute or simple/text node and convert the string value to the * instance of the provided class, example, Integer.class. * @param expression the XPath expression * @param namespaces the namespaces map, prefixes which are used in the XPath expression * are the keys, namespace URIs are the values; note, the prefixes do not have to match * the actual ones used in the XML instance. * @param cls the class of the response * @return the value */ @SuppressWarnings("unchecked") public <T> T getValue(String expression, Map<String, String> namespaces, Class<T> cls) { Object result = evaluate(expression, namespaces, XPathConstants.STRING); return result == null ? null : (T)InjectionUtils.convertStringToPrimitive(result.toString(), cls); }
private <T> Object readPrimitiveValue(Node node, Class<T> cls) { if (String.class == cls) { if (node.getNodeType() == Node.ELEMENT_NODE) { ByteArrayOutputStream bos = new ByteArrayOutputStream(); XMLUtils.writeTo(new DOMSource(node), bos, 0, "", "yes"); try { return cls.cast(bos.toString("UTF-8")); } catch (UnsupportedEncodingException ex) { // won't happen } } else { return cls.cast(node.getNodeValue()); } } return InjectionUtils.convertStringToPrimitive(node.getNodeValue(), cls); }
/** * Find the attribute or simple/text node and convert the string value to the * instance of the provided class, example, Integer.class. * @param expression the XPath expression * @param namespaces the namespaces map, prefixes which are used in the XPath expression * are the keys, namespace URIs are the values; note, the prefixes do not have to match * the actual ones used in the XML instance. * @param cls the class of the response * @return the value */ @SuppressWarnings("unchecked") public <T> T getValue(String expression, Map<String, String> namespaces, Class<T> cls) { Object result = evaluate(expression, namespaces, XPathConstants.STRING); return result == null ? null : (T)InjectionUtils.convertStringToPrimitive(result.toString(), cls); }
Object o = InjectionUtils.handleParameter(value, decoded, valueType, paramAnns, pathParam, message); theValues.add(convertStringToPrimitive(processedValuesEntry.getKey(), keyType), o); decoded, valueType, paramAnns, pathParam, message); theValues.put( convertStringToPrimitive(processedValuesEntry.getKey(), keyType), o);
Object o = InjectionUtils.handleParameter(value, decoded, valueType, valueType, paramAnns, pathParam, message); theValues.add(convertStringToPrimitive(processedValuesEntry.getKey(), keyType), o); decoded, valueType, valueType, paramAnns, pathParam, message); theValues.put( convertStringToPrimitive(processedValuesEntry.getKey(), keyType), o);
CollectionCheck collCheck = getCollectionCheck(originalPropName, isCollection, actualType); if (collCheck == null) { castedValue = InjectionUtils.convertStringToPrimitive(value, actualType); nextObject = isPrimitive ? InjectionUtils.convertStringToPrimitive(value, returnType) : convertToDate(returnType, value); } else {
CollectionCheck collCheck = getCollectionCheck(originalPropName, isCollection, actualType); if (collCheck == null) { castedValue = InjectionUtils.convertStringToPrimitive(value, actualType); nextObject = isPrimitive ? InjectionUtils.convertStringToPrimitive(value, returnType) : convertToDate(returnType, value); } else {
CollectionCheck collCheck = getCollectionCheck(originalPropName, isCollection, actualType); if (collCheck == null) { castedValue = InjectionUtils.convertStringToPrimitive(value, actualType); nextObject = isPrimitive ? InjectionUtils.convertStringToPrimitive(value, returnType) : convertToDate(returnType, value); } else {