|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.melati.util.HttpHeader org.melati.util.AcceptCharset
public class AcceptCharset
Representation of the Accept-Charset header fields.
Provides features for choosing a charset according to client or server preferences.
Nested Class Summary | |
---|---|
static class |
AcceptCharset.CharsetAndQValue
A charset and associated qvalue. |
class |
AcceptCharset.CharsetAndQValueIterator
Enumeration of AcceptCharset.CharsetAndQValue . |
protected static class |
AcceptCharset.Comparator<T>
Comparator for comparing AcceptCharset.CharsetAndQValue objects. |
Nested classes/interfaces inherited from class org.melati.util.HttpHeader |
---|
HttpHeader.FieldIterator, HttpHeader.HttpHeaderException, HttpHeader.TokenAndQValue, HttpHeader.TokenAndQValueIterator, HttpHeader.Tokenizer, HttpHeader.WordIterator |
Field Summary | |
---|---|
protected HashMap<String,AcceptCharset.CharsetAndQValue> |
supportedAcceptedOrPreferred
Charsets supported by the jvm and accepted by the client or preferred by the server. |
Fields inherited from class org.melati.util.HttpHeader |
---|
tokenizer |
Constructor Summary | |
---|---|
AcceptCharset(String values,
List<String> serverPreference)
Create an instance from the Accept-Charset header field values and a set of server preferred charset names. |
Method Summary | |
---|---|
AcceptCharset.CharsetAndQValueIterator |
charsetAndQValueIterator()
Factory method to create and return the next HttpHeader.TokenAndQValue . |
String |
choice(AcceptCharset.Comparator<AcceptCharset.CharsetAndQValue> comparator)
If there is none, return null, and the caller can either use an unacceptable character set or generate a 406 error. |
String |
clientChoice()
|
HttpHeader.TokenAndQValue |
nextTokenAndQValue()
Factory method to create and return the next HttpHeader.TokenAndQValue . |
String |
serverChoice()
|
Methods inherited from class org.melati.util.HttpHeader |
---|
tokenAndQValueIterator, wordIterator |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected HashMap<String,AcceptCharset.CharsetAndQValue> supportedAcceptedOrPreferred
Constructor Detail |
---|
public AcceptCharset(String values, List<String> serverPreference)
The field values might have appeared in a single Accept-Charset header or in several that were concatenated with comma separator in order. This concatenation is often done for the caller, by a servlet container or something, but it must be done.
null
is taken to mean there were no Accept-Charset header
fields.
If a client supported charset is unsupported by the JVM it is ignored. If the caller wants to ensure that there are none then it must check for itself.
If the same charset is specified more than once (perhaps under different names or aliases) then the first occurrence is significant.
The server preferences provides a list of charsets used if there is a wildcard specification. This class does not currently try other available charsets so to avoid 406 errors to reasonable clients, enough reasonable charsets must be listed in serverPreferences.
Method Detail |
---|
public HttpHeader.TokenAndQValue nextTokenAndQValue()
HttpHeader.TokenAndQValue
.
nextTokenAndQValue
in class HttpHeader
HttpHeader.nextTokenAndQValue()
public AcceptCharset.CharsetAndQValueIterator charsetAndQValueIterator()
HttpHeader.TokenAndQValue
.
public String clientChoice()
public String serverChoice()
public String choice(AcceptCharset.Comparator<AcceptCharset.CharsetAndQValue> comparator)
AcceptCharset.Comparator
|
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |