/* * (non-Jsdoc) * * @see org.talend.dataquality.indicators.impl.IndicatorImpl#handle(java.lang.Object) */ @Override public boolean handle(Object data) { super.handle(data); if (data == null) { return false; } PhoneNumberUtil phoneUtil = PhoneNumberUtil.getInstance(); // } // the parameter defualtRegion is null at here, it will get an region code when the data is // guaranteed to // start with a '+' followed by the country calling code. e.g. "+86 13521588311", // "+8613521588311", // "+86 1352 1588 311". or else, it will throw Exception and as a invalid Region Code. boolean parseSuccess = true; String regionCodeForNumber = null; try { PhoneNumber phhoneNum = phoneUtil.parse(data.toString(), null); regionCodeForNumber = phoneUtil.getRegionCodeForNumber(phhoneNum); } catch (NumberParseException e) { parseSuccess = false; } Set<String> supportedCountries = phoneUtil.getSupportedRegions(); if (parseSuccess && supportedCountries.contains(regionCodeForNumber)) { this.validRegCount++; if (checkMustStoreCurrentRow() || checkMustStoreCurrentRow(drillDownValueCount)) { this.mustStoreRow = true; } } return true; }
@Override public boolean handle(Object data) { super.handle(data); if (data == null) { return false; } try { PhoneNumberUtil phoneUtil = PhoneNumberUtil.getInstance(); IndicatorParameters indParameters = this.getParameters(); TextParameters textParameters = indParameters == null ? null : indParameters.getTextParameter(); String country = IndicatorHelper.getCountryCodeByParameter(textParameters); PhoneNumber phoneNumeber = phoneUtil.parse(data.toString(), country); // It only checks the length of phone numbers. In particular, it doesn't check starting digits // of the // number. if (phoneUtil.isPossibleNumber(phoneNumeber)) { this.possiblePhoneCount++; if (checkMustStoreCurrentRow() || this.checkMustStoreCurrentRow(drillDownValueCount)) { this.mustStoreRow = true; } } } catch (NumberParseException e) { return false; } return true; }