org.codehaus.plexus.i18n

Class I18NTokenizer

public class I18NTokenizer extends Object implements Iterator

Parses the HTTP Accept-Language header as per section 14.4 of RFC 2068 (HTTP 1.1 header field definitions).

Version: $Id: I18NTokenizer.java 1031 2004-09-23 18:42:42Z jvanzyl $

Author: Daniel Rall

UNKNOWN: Move this class out of here as its purely web related.

Nested Class Summary
classI18NTokenizer.AcceptLanguage
Struct representing an element of the HTTP Accept-Language header.
Field Summary
static FloatDEFAULT_QUALITY
The default quality value for an AcceptLanguage object.
ArrayListlocales
The parsed locales.
static StringLOCALE_SEPARATOR
Separates elements of the Accept-Language HTTP header.
static charQUALITY_SEPARATOR
Separates locale from quality within elements.
Constructor Summary
I18NTokenizer(String header)
Parses the Accept-Language header.
Method Summary
booleanhasNext()
Objectnext()
Creates a Locale from the next element of the Accept-Language header.
voidremove()
Not implemented.

Field Detail

DEFAULT_QUALITY

private static final Float DEFAULT_QUALITY
The default quality value for an AcceptLanguage object.

locales

private ArrayList locales
The parsed locales.

LOCALE_SEPARATOR

private static final String LOCALE_SEPARATOR
Separates elements of the Accept-Language HTTP header.

QUALITY_SEPARATOR

private static final char QUALITY_SEPARATOR
Separates locale from quality within elements.

Constructor Detail

I18NTokenizer

public I18NTokenizer(String header)
Parses the Accept-Language header.

Parameters: header The Accept-Language header (i.e. en, es;q=0.8, zh-TW;q=0.1).

Method Detail

hasNext

public boolean hasNext()

Returns: Whether there are more locales.

next

public Object next()
Creates a Locale from the next element of the Accept-Language header.

Returns: The next highest-rated Locale.

Throws: NoSuchElementException No more locales.

remove

public final void remove()
Not implemented.