in SdmxDataParser/src/main/java/org/sdmxsource/sdmx/dataparser/engine/impl/DeepDataValidationEngine.java [338:443]
private List<String> validateTextType(ComponentBean component, TEXT_TYPE textType, String value, List<String> errorMessages) {
switch (textType) {
case DOUBLE:
try {
Double.parseDouble(value);
} catch (NumberFormatException e) {
errorMessages = addErrorMessage(component, value, "' is not of expected type 'Double'", errorMessages);
}
break;
case BIG_INTEGER:
try {
new BigInteger(value);
} catch (NumberFormatException e) {
errorMessages = addErrorMessage(component, value, "' is not of expected type 'Big Integer'", errorMessages);
}
break;
case INTEGER:
try {
new Integer(value);
} catch (NumberFormatException e) {
errorMessages = addErrorMessage(component, value, "' is not of expected type 'Integer'", errorMessages);
}
break;
case LONG:
try {
new Long(value);
} catch (NumberFormatException e) {
errorMessages = addErrorMessage(component, value, "' is not of expected type 'Long'", errorMessages);
}
break;
case SHORT:
try {
new Short(value);
} catch (NumberFormatException e) {
errorMessages = addErrorMessage(component, value, "' is not of expected type 'Short'", errorMessages);
}
break;
case DECIMAL:
try {
new BigDecimal(value);
} catch (NumberFormatException e) {
errorMessages = addErrorMessage(component, value, "' is not of expected type 'Decimal'", errorMessages);
}
break;
case FLOAT:
try {
new Float(value);
} catch (NumberFormatException e) {
errorMessages = addErrorMessage(component, value, "' is not of expected type 'Float'", errorMessages);
}
break;
case BOOLEAN:
if (!value.equalsIgnoreCase("true") && !value.equalsIgnoreCase("false")) {
errorMessages = addErrorMessage(component, value, "' is not of expected type 'Boolean'", errorMessages);
}
break;
case DATE:
try {
DateUtil.getTimeFormatOfDate(value);
} catch (Throwable e) {
errorMessages = addErrorMessage(component, value, "' is not of expected type 'Date'", errorMessages);
}
break;
case DATE_TIME:
try {
DateUtil.getTimeFormatOfDate(value);
} catch (Throwable e) {
errorMessages = addErrorMessage(component, value, "' is not of expected type 'Date'", errorMessages);
}
break;
case YEAR:
try {
if (value.length() != 4) {
errorMessages = addErrorMessage(component, value, "' is not of expected type 'Year', expected year length of 4", errorMessages);
}
new Integer(value);
} catch (Throwable e) {
errorMessages = addErrorMessage(component, value, "' is not of expected type 'Year'", errorMessages);
}
break;
case TIME:
try {
DateUtil.getTimeFormatOfDate(value);
} catch (Throwable e) {
errorMessages = addErrorMessage(component, value, "' is not of expected type 'Date'", errorMessages);
}
break;
case IDENTIFIABLE_REFERENCE:
try {
SDMX_STRUCTURE_TYPE targetStructure = UrnUtil.getIdentifiableType(value);
UrnUtil.validateURN(value, targetStructure);
} catch (Throwable e) {
errorMessages = addErrorMessage(component, value, "' is not of expected type 'Identifiable Reference' a valid URN is expected", errorMessages);
}
break;
case URI:
try {
new URI(value);
} catch (URISyntaxException e) {
errorMessages = addErrorMessage(component, value, "is not of expected type 'URI'", errorMessages);
}
break;
}
return errorMessages;
}