Is there a java enum of European countries and languages?

Is there any java (> 5) enum for listing European countries and languages? If they are not, I will probably write them from this list: http://www.nationsonline.org/oneworld/european_languages.htm

But if I could escape this burden, that would be great!

PS: Finally, I am starting to use the geoNames web service on geonames.org. For countries, I use this snippet in Groovy:

import org.geonames.*

ToponymSearchCriteria sc = new ToponymSearchCriteria()
sc.setContinentCode("eu")
sc.setFeatureCode("PCLI")
def res = WebService.search(sc)
def countries = res.getToponyms().collect{it.countryName}.sort()
+5
source share
4 answers

, Enum, ( ) . Youd , Enum , , , , Enum.

+14

. , XML? ? ( huuuge hassle)? ?

; , , , -, - ! Hurray.

. , , , .

, . ? , , Java. , , noooooo.

, , , ( ), , , ?

.

+8

, Locale.getISOCountries() Locale.getISOLanguages() .

+7

At the very least, I would automatically generate an enum class from this URL. You can parse HTML, extract values, and write a java file that defines an enumeration.

And whenever the contents of this URL change, you can re-run the autogenerator and create a new enum class.

But keep in mind - every change in enumeration can introduce errors into the rest of the code.

+1
source

All Articles