Created
June 15, 2018 06:12
-
-
Save visparashar/45c6a25d825b62f06ab461876fbb718b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// convinient methods | |
public HashMap getAddressMap() { | |
final String KEY="1"; | |
HashMap map = new HashMap(); | |
if(AdminAreaLevel1!=null) | |
map.put(AdminAreaLevel1.toLowerCase(), KEY); | |
if(AdminAreaLevel2!=null) | |
map.put(AdminAreaLevel2.toLowerCase(),KEY); | |
if(postcode!=null) | |
map.put(postcode,KEY); | |
if(country!=null) | |
map.put(country.toLowerCase(),KEY); | |
if(locality!=null) | |
map.put(locality.toLowerCase(),KEY); | |
if(subLocality1!=null) | |
map.put(subLocality1.toLowerCase(),KEY); | |
if(subLocality2!=null) | |
map.put(subLocality2.toLowerCase(),KEY); | |
return map; | |
} | |
public static Address fillObject(Address address) | |
{ | |
if(address.getFullAddress()!=null){ | |
String fullAddress = address.getFullAddress(); | |
if(fullAddress.contains(address.getLocality())) { | |
System.out.println(fullAddress.indexOf(address.getLocality())); | |
System.out.println(fullAddress.substring(0, 27)); | |
String preLocalityAddress =fullAddress.substring(0, fullAddress.indexOf(address.getLocality())); | |
String[] preAddrss =preLocalityAddress.split(","); | |
if(preAddrss.length==4) { | |
System.out.println(preAddrss[2]); | |
address.setSubLocality1(preAddrss[2].trim().toLowerCase()); | |
address.setSubLocality2(preAddrss[1].trim().toLowerCase()); | |
System.out.println(preAddrss[1]); | |
System.out.println(preAddrss[0]); | |
} | |
} | |
// String[] addressComponent = fullAddress.split(","); | |
// | |
// for(int i =addressComponent.length;i>0;i--) { | |
// String comp = addressComponent[i]; | |
// comp =comp.trim(); | |
// if(!address.getAddressMap().containsKey(comp.toLowerCase())) { | |
// | |
// } | |
// | |
// | |
// } | |
} | |
return address; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment