Skip to content

Commit

Permalink
+ pom.xml
Browse files Browse the repository at this point in the history
  • Loading branch information
delabassee committed Jul 31, 2018
1 parent c80a5c5 commit 5d317f6
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 20 deletions.
17 changes: 17 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.delabassee</groupId>
<artifactId>country</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>

<properties>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
</properties>

</project>
42 changes: 22 additions & 20 deletions src/main/java/com/delabassee/Countries.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,57 +30,59 @@ public String getName() {
public String toString() {
return iso + " - " + code + " - " + name;
}

}


public static List<Country> getAll() {
public static String getName(String countryCode) {

List<Country> countries = new ArrayList<Country>();
String[] isoCountries = Locale.getISOCountries();
String upperCode = countryCode.toUpperCase();

for (String country : isoCountries) {
Locale locale = new Locale("en", country);
String iso = locale.getISO3Country();
String code = locale.getCountry();
String name = locale.getDisplayCountry();

if (!"".equals(iso) && !"".equals(code) && !"".equals(name)) {
countries.add(new Country(iso, code, name));
if (country.equals(upperCode)) {
return locale.getDisplayCountry();
}
}

return countries;
return "not found";
}


public static String getName(String countryCode) {

public static String getCode(String countryName) {

String[] isoCountries = Locale.getISOCountries();
String upperCode = countryCode.toUpperCase();
String upperName = countryName.toUpperCase();

for (String country : isoCountries) {
Locale locale = new Locale("en", country);
if (country.equals(upperCode)) {
return locale.getDisplayCountry();
if (locale.getDisplayCountry().toUpperCase().equals(upperName)) {
return locale.getCountry();
}
}
return "not found";
}


public static String getCode(String countryName) {
public static List<Country> getAllCountries() {

List<Country> countries = new ArrayList<Country>();
String[] isoCountries = Locale.getISOCountries();
String upperName = countryName.toUpperCase();

for (String country : isoCountries) {
Locale locale = new Locale("en", country);
if (locale.getDisplayCountry().toUpperCase().equals(upperName)) {
return locale.getCountry();
String iso = locale.getISO3Country();
String code = locale.getCountry();
String name = locale.getDisplayCountry();

if (!"".equals(iso) && !"".equals(code) && !"".equals(name)) {
countries.add(new Country(iso, code, name));
}
}
return "not found";

return countries;

}


}

0 comments on commit 5d317f6

Please sign in to comment.