|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.infohazard.maverick.shunt.LanguageShuntFactory
LanguageShuntFactory produces Shunts which determine mode based on the Accept-Language header submitted by the user agent.
Modes can be specified as "en", "fr", "zh-hk", and the like. Multiple modes can be assigned to the same view by comma-delimiting them ("en,fr"). In addition, a view can leave its mode unspecified to be a "default" view which will apply when no other mode is appropriate.
Choosing mode from the Accept-Language header follows the way browsers actually work rather than the HTTP spec. Go figure. There is no support for quality levels and preference is determined by simple order in the string. Furthermore, there is some magic regarding prefixed languages: After trying each of the languages specified, any prefixed languages are chopped one level and tried again. This process is repeated until nothing is left to try but the null mode.
For an example Accept-Language header "fr,zh-tw,zh-hk,no-nynorsk", the Shunt will check for modes in this order:
Hopefully this produces useful behavior.
Constructor Summary | |
LanguageShuntFactory()
|
Method Summary | |
Shunt |
createShunt()
Merely creates a shunt object. |
void |
init(org.jdom.Element factoryNode,
javax.servlet.ServletConfig servletCfg)
Does nothing. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public LanguageShuntFactory()
Method Detail |
public void init(org.jdom.Element factoryNode, javax.servlet.ServletConfig servletCfg)
init
in interface ShuntFactory
factoryNode
- The XML element (and child nodes) configured in the Maverick
configuration file.servletCfg
- So that the factory can get information from the container.public Shunt createShunt() throws ConfigException
createShunt
in interface ShuntFactory
ConfigException
- If something is wrong with the configuration.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |