|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.avalon.framework.logger.AbstractLogEnabled org.apache.cocoon.matching.LocaleMatcher
public class LocaleMatcher
A matcher that locates and identifies to the pipeline a source document to be used as the content for an i18n site, based upon a locale provided in a range of ways.
A sample configuration (given in the <map:matchers> section of the sitemap) is given below. This configuration shows default values.
<map:matcher name="i18n" src="org.apache.cocoon.matching.LocaleMatcher"> <locale-attribute>locale</locale-attribute> <negotiate>false</negotiate> <use-locale>true</use-locale> <use-locales>false</use-locales> <use-blank-locale>true</use-blank-locale> <default-locale language="en" country="US"/> <store-in-request>false<store-in-request> <create-session>false<create-session> <store-in-session>false<store-in-session> <store-in-cookie>false<store-in-cookie> </map:matcher>
Above configuration parameters mean:
locale
)negotiate
is set to true
)This matcher will be used in a pipeline like so:
<map:match pattern="*.html"> <map:match type="i18n" pattern="xml/{1}.*.xml"> <map:generate src="{source}"/> ... </map:match> </map:match>
*
in the pattern identifies the place where locale should
be inserted. In case of a blank locale, if character before and after
*
is the same (like in example above), duplicate will
be removed (xml/{1}.*.xml
becomes xml/{1}.xml
).
Locales will be tested in following order:
use-locale
is set to true
use-locales
is set to true
.If negotiate
mode is set to true
, a source will
be looked up using each locale. Where the full locale (language, country,
variant) doesn't match, it will fall back first to language and country,
and then just language, before moving on to the next locale.
If negotiate
mode is set to false
(default),
first found locale will be returned.
Once a matching locale has been found, the following sitemap variables will be available to sitemap elements contained within the matcher:
Field Summary |
---|
Fields inherited from interface org.apache.cocoon.matching.Matcher |
---|
ROLE |
Constructor Summary | |
---|---|
LocaleMatcher()
|
Method Summary | |
---|---|
void |
configure(Configuration config)
|
void |
dispose()
|
Map |
match(String pattern,
Map objectModel,
Parameters parameters)
Matches the pattern against some Request values
and returns a Map object with replacements
for wildcards contained in the pattern. |
void |
service(ServiceManager manager)
|
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled |
---|
enableLogging, getLogger, setupLogger, setupLogger, setupLogger |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public LocaleMatcher()
Method Detail |
---|
public void service(ServiceManager manager) throws ServiceException
service
in interface Serviceable
ServiceException
public void configure(Configuration config)
configure
in interface Configurable
public void dispose()
dispose
in interface Disposable
public Map match(String pattern, Map objectModel, Parameters parameters) throws PatternException
Matcher
Request
values
and returns a Map
object with replacements
for wildcards contained in the pattern.
match
in interface Matcher
pattern
- The pattern to match against. Depending on the
implementation the pattern can contain wildcards
or regular expressions.objectModel
- The Map
with object of the
calling environment which can be used
to select values this matchers matches against.
Map
object with
replacements for wildcards/regular-expressions
contained in the pattern.
If the return value is null there was no match.
PatternException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |