jrun.servlet
Class AcceptLanguage

java.lang.Object
  |
  +--jrun.servlet.AcceptLanguage

public class AcceptLanguage
extends java.lang.Object

The AcceptLanguage class parses the "Accept-Language" request header and returns a list of locales preferred by the client.

Author:
Clement Wong

Constructor Summary
AcceptLanguage(java.util.Enumeration headers)
          Constructs an AcceptLanguage object from an enumeration.
AcceptLanguage(java.lang.String header)
          Constructs an AcceptLanguage object from a comma-separated string.
AcceptLanguage(java.lang.String[] headers)
          Constructs an AcceptLanguage object from a string array.
 
Method Summary
 boolean exists()
           
 java.util.Locale getFirstLocale()
           
 java.util.Enumeration getLocales()
          Returns an enumeration of locales in the preferred order.
 double getSpecialRangeValue()
          Returns the q-value if "*;q=" is present.
 boolean isSpecialRangePresent()
          Returns true if * is present in the header.
static void main(java.lang.String[] args)
          Main method.
 void reset(java.util.Enumeration headers)
          Resets this object with a new header.
 void reset(java.lang.String header)
          Resets this object with a new header.
 void reset(java.lang.String[] headers)
          Resets this object with a new header.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AcceptLanguage

public AcceptLanguage(java.lang.String header)
Constructs an AcceptLanguage object from a comma-separated string.
Parameters:
header - a comma-separated string.

AcceptLanguage

public AcceptLanguage(java.lang.String[] headers)
Constructs an AcceptLanguage object from a string array.
Parameters:
headers - a string array.

AcceptLanguage

public AcceptLanguage(java.util.Enumeration headers)
Constructs an AcceptLanguage object from an enumeration.
Parameters:
headers - an enumeration.
Method Detail

reset

public void reset(java.lang.String header)
Resets this object with a new header.
Parameters:
a - comma-separated string.

reset

public void reset(java.lang.String[] headers)
Resets this object with a new header.
Parameters:
a - string array.

reset

public void reset(java.util.Enumeration headers)
Resets this object with a new header.
Parameters:
an - enumeration.

isSpecialRangePresent

public boolean isSpecialRangePresent()
Returns true if * is present in the header.
Returns:
true if * is present, otherwise false.

getSpecialRangeValue

public double getSpecialRangeValue()
Returns the q-value if "*;q=" is present.
Returns:
q-value (quality factor)

getLocales

public java.util.Enumeration getLocales()
Returns an enumeration of locales in the preferred order.

exists

public boolean exists()

getFirstLocale

public java.util.Locale getFirstLocale()

main

public static void main(java.lang.String[] args)
Main method. It's used to test the class from command-line.


Copyright � 2002 Macromedia Corporation. All Rights Reserved.