|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectsimple.util.parse.Parser
simple.util.parse.LanguageParser
public class LanguageParser
LanguageParser is used to parse the HTTP Accept-Language
header. This takes in an Accept-Language
header and parses
it according the RFC 2616 BNF for the Accept-Language
header.
This also has the ability to sequence the language tokens in terms of
the most preferred and the least preferred.
This uses the qvalues outlined by RFC 2616 to order the language tokens by preference. Typically the language tokens will not have qvalues with the language. However when a language tag has the qvalue parameter then this tag will be ordered based on the value of that parameter. A language tag without the qvalue parameter is considered to have a qvalue of 1 and is ordered accordingly.
Field Summary |
---|
Fields inherited from class simple.util.parse.Parser |
---|
buf, count, off |
Constructor Summary | |
---|---|
LanguageParser()
Used to create a language parser for the Accept-Language HTTP header value. |
|
LanguageParser(java.lang.String value)
This is used to create a language parser for the Accept-Language HTTP header value. |
Method Summary | |
---|---|
java.util.Locale |
getLocale()
This will return the preferred Locale for this
header. |
java.util.Locale[] |
getLocales()
This will order the tokens based on the preference of the language. |
protected void |
init()
This will initialize the parser when it is ready to parse a new String . |
protected void |
parse()
This will iteratively take language tokens from the HTTP header list. |
Methods inherited from class simple.util.parse.Parser |
---|
digit, ensureCapacity, parse, skip, space, toLower |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public LanguageParser()
Accept-Language
HTTP header value. This will
parse a set of language tokens and there parameters. The
languages will be ordered on preference.
public LanguageParser(java.lang.String value)
Accept-Language
HTTP header value. This will
parse a set of language tokens and there parameters. The
languages will be ordered on preference. This constructor
will parse the value given using parse(String)
.
value
- value of a Accept-Language
headerMethod Detail |
---|
public java.util.Locale getLocale()
Locale
for this
header. The preferred Locale
may be any of the
Locale
s given in the header with a qvalue
parameter value of 1.
Locale
public java.util.Locale[] getLocales()
Locale[]
objects extracted from the
Accept-Language header. The array returned is sorted using the
qvalue preferences within the Accept-Language header.
Locale
objectsprotected void parse()
parse
in class Parser
protected void init()
String
. This will reset the parser to a ready
state. The init
method is invoked by the parser
when the parse
method is invoked.
init
in class Parser
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |