Dashboard > GeoTools 2.5 Users Guide > ... > 02 GeoAPI > Enum CodeList String and InternationalString
GeoTools 2.5 Users Guide
Enum CodeList String and InternationalString
Added by jgarnett , last edited by jgarnett on May 07, 2008
Labels: 
(None)

You may of noticed that good old-fashioned Java String has started to fall out of favour. This page goes over some of the options made available by the GeoAPI project.

Enum

An Enum, yes normal Java 5 Enum, is used to represent a frozen set of machine readable text.

The key idea here is:

  • this is machine readable; you don't need to show this to your end users
  • it is frozen; literally it is boiled into the jar you download and you cannot modify the list of defined codes in any way

If you are reading any of the ISO specifications you will find this concept is called an Enum there as well, our use agrees with typical Java practice.

CodeList

A CodeList is used to represent an extensible set of machine readable text.

In pragmatic terms this is behaves just like a Java 5 Enum, except that you can add to it at runtime.

The ISO specifications call this concept is a CodeList as well,

String

A String is used for free form machine readable text (for things like code and version).

Please note that we are not using Strings to communicate to the end user, we have a special class (InternationalString) to address Internationalization issues.

The ISO specifications call this concept a CharacterString, but you have to be careful and read how they are using it on a case by case basis. Our use does not agree with typical Java practice; we are reserving the use of String for machine readable text.

InternationalString

An org.opengis.util.InternationalString is used to represent free form human readable text.

The InternationalString interface makes every translation of the text available through one class.

To use an InternationalString with the current locale:

return internationalString.toString();

To use the InternationalString with a different locale:

return internationalString.toString( locale );

You will find this facility great when implementing a web application that is expected to communicate to requests coming from a number of locales.

We have a number of implementations available, backed on properties files and such like.

ISO specifications call this concept a CharacterString, but once again you need to check how they are using it.

Site running on a free Atlassian Confluence Open Source Project License granted to The Codehaus. Evaluate Confluence today.
Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.6.2 Build:#919 Nov 26, 2007) - Bug/feature request - Contact Administrators