@Test public void getSanitizedId() { final String modelName = "MODEL_NAME"; String id = "2"; String expected = String.format(SEGMENTID_TEMPLATE, modelName, id); String retrieved = KiePMMLUtil.getSanitizedId(id, modelName); assertEquals(expected,retrieved); id = "34.5"; expected = String.format(SEGMENTID_TEMPLATE, modelName, id); retrieved = KiePMMLUtil.getSanitizedId(id, modelName); assertEquals(expected,retrieved); id = "3,45"; expected = String.format(SEGMENTID_TEMPLATE, modelName, id); retrieved = KiePMMLUtil.getSanitizedId(id, modelName); assertEquals(expected,retrieved); }
static String getSanitizedId(String id, String modelName) { String toReturn = id.replace(".", "") .replace(",", ""); try { Integer.parseInt(toReturn); toReturn = String.format(SEGMENTID_TEMPLATE, modelName, id); } catch (NumberFormatException e) { } return toReturn; }
KiePMMLUtil { static String getSanitizedId(String id, String modelName) { String toReturn = id.replace(".", "") .replace(",", ""); try { Integer.parseInt(toReturn); toReturn = String.format(SEGMENTID_TEMPLATE, modelName, id); } catch (NumberFormatException e) { } return toReturn; } }
KiePMMLUtil { static String getSanitizedId(String id, String modelName) { String toReturn = id.replace(".", "") .replace(",", ""); try { Integer.parseInt(toReturn); toReturn = String.format(SEGMENTID_TEMPLATE, modelName, id); } catch (NumberFormatException e) { } return toReturn; } private  KiePMMLUtil(); }
KiePMMLUtil { static String getSanitizedId(String id, String modelName) { String toReturn = id.replace(".", "") .replace(",", ""); try { Integer.parseInt(toReturn); toReturn = String.format(SEGMENTID_TEMPLATE, modelName, id); } catch (NumberFormatException e) { } return toReturn; } private  KiePMMLUtil(); static PMML load(String source); static PMML load(final InputStream is, final String fileName); }
KiePMMLUtil { static String getSanitizedId(String id, String modelName) { String toReturn = id.replace(".", "") .replace(",", ""); try { Integer.parseInt(toReturn); toReturn = String.format(SEGMENTID_TEMPLATE, modelName, id); } catch (NumberFormatException e) { } return toReturn; } private  KiePMMLUtil(); static PMML load(String source); static PMML load(final InputStream is, final String fileName); static final String SEGMENTID_TEMPLATE; }