public abstract class AbstractI18nContentSupport extends Object implements I18nContentSupport
I18nContentSupport
which stores the
locale specific content in node data having a local suffix:
<name>_<locale>.
The detection of the current locale, based on the URI for instance, is left to the concrete implementation.Modifier and Type | Field and Description |
---|---|
protected Locale |
defaultLocale
If no locale can be determined the default locale will be set.
|
Constructor and Description |
---|
AbstractI18nContentSupport() |
Modifier and Type | Method and Description |
---|---|
void |
addLocale(LocaleDefinition ld) |
Locale |
determineLocale()
Extracts the language from the uri.
|
protected static Locale |
determineLocalFromString(String localeStr) |
Locale |
getDefaultLocale() |
Locale |
getFallbackLocale()
The default locale to be used.
|
Locale |
getLocale()
Get the current locale used for rendering content.
|
Collection<Locale> |
getLocales()
Returns the available locales.
|
protected Locale |
getNextContentLocale(Locale locale,
Set<Locale> checkedLocales)
Uses
getNextLocale(Locale) to find the next locale. |
protected Locale |
getNextLocale(Locale locale)
Returns the closest locale for which
isLocaleSupported(Locale) is true. |
javax.jcr.Node |
getNode(javax.jcr.Node node,
String name)
Returns named localized child (if exists) of provided node (or non localized in case localized child doesn't exist).
|
NodeData |
getNodeData(Content node,
String name)
Returns the nodedata with the name <name>_<current language> or <name>_<fallback language>
otherwise returns <name>.
|
NodeData |
getNodeData(Content node,
String name,
Locale locale)
Returns the NodeData object based on the language passes.
|
javax.jcr.Property |
getProperty(javax.jcr.Node node,
String name)
Returns localized property of given name and current locale.
|
javax.jcr.Property |
getProperty(javax.jcr.Node node,
String name,
Locale locale)
Returns localized property of given named and given locale.
|
boolean |
hasProperty(javax.jcr.Node node,
String name)
Returns true if localized property or default property exists false if there is no variation of property for any locale.
|
protected boolean |
isEmpty(NodeData nd)
Deprecated.
since 4.5.4. Use
isEmpty(Property) instead. |
protected boolean |
isEmpty(javax.jcr.Property property)
Checks if the property field is empty.
|
boolean |
isEnabled() |
protected boolean |
isLocaleSupported(Locale locale) |
protected abstract Locale |
onDetermineLocale() |
void |
setDefaultLocale(Locale defaultLocale) |
void |
setEnabled(boolean enabled) |
void |
setFallbackLocale(Locale fallbackLocale) |
void |
setLocale(Locale locale) |
void |
setLocales(Map<String,Locale> locales) |
String |
toI18NURI(String uri)
Transform the internal uri to a i18n uri.
|
protected abstract String |
toI18NURI(String uri,
Locale locale) |
String |
toRawURI(String i18nURI)
Removes the prefix.
|
protected abstract String |
toRawURI(String i18nURI,
Locale locale) |
protected Locale defaultLocale
public Locale getLocale()
I18nContentSupport
getLocale
in interface I18nContentSupport
public void setLocale(Locale locale)
setLocale
in interface I18nContentSupport
public Locale getFallbackLocale()
I18nContentSupport
getFallbackLocale
in interface I18nContentSupport
public void setFallbackLocale(Locale fallbackLocale)
setFallbackLocale
in interface I18nContentSupport
protected Locale getNextLocale(Locale locale)
isLocaleSupported(Locale)
is true.
public Locale determineLocale()
determineLocale
in interface I18nContentSupport
protected abstract Locale onDetermineLocale()
public String toI18NURI(String uri)
I18nContentSupport
toI18NURI
in interface I18nContentSupport
public String toRawURI(String i18nURI)
toRawURI
in interface I18nContentSupport
public NodeData getNodeData(Content node, String name, Locale locale) throws javax.jcr.RepositoryException
I18nContentSupport
getNodeData
in interface I18nContentSupport
javax.jcr.RepositoryException
public NodeData getNodeData(Content node, String name)
getNodeData
in interface I18nContentSupport
public javax.jcr.Node getNode(javax.jcr.Node node, String name) throws javax.jcr.RepositoryException
I18nContentSupport
getNode
in interface I18nContentSupport
javax.jcr.RepositoryException
public boolean hasProperty(javax.jcr.Node node, String name) throws javax.jcr.RepositoryException
I18nContentSupport
hasProperty
in interface I18nContentSupport
javax.jcr.RepositoryException
public javax.jcr.Property getProperty(javax.jcr.Node node, String name) throws javax.jcr.RepositoryException
I18nContentSupport
getProperty
in interface I18nContentSupport
javax.jcr.RepositoryException
public javax.jcr.Property getProperty(javax.jcr.Node node, String name, Locale locale) throws javax.jcr.RepositoryException
I18nContentSupport
getProperty
in interface I18nContentSupport
javax.jcr.RepositoryException
protected Locale getNextContentLocale(Locale locale, Set<Locale> checkedLocales)
getNextLocale(Locale)
to find the next locale. If the returned locale is in the
checkedLocales set it falls back to the fall-back locale. If the fall-back locale itself is
passed to the method, the method returns null to signal the end of the chain.public boolean isEnabled()
isEnabled
in interface I18nContentSupport
public void setEnabled(boolean enabled)
public Collection<Locale> getLocales()
I18nContentSupport
getLocales
in interface I18nContentSupport
public void addLocale(LocaleDefinition ld)
protected boolean isLocaleSupported(Locale locale)
@Deprecated protected boolean isEmpty(NodeData nd)
isEmpty(Property)
instead.protected boolean isEmpty(javax.jcr.Property property)
public Locale getDefaultLocale()
getDefaultLocale
in interface I18nContentSupport
public void setDefaultLocale(Locale defaultLocale)
Copyright © 2003–2016 Magnolia International Ltd.. All rights reserved.