Package org.opencms.i18n
Class CmsRemoveInnerNameFallback
- java.lang.Object
-
- org.opencms.i18n.CmsRemoveInnerNameFallback
-
- All Implemented Interfaces:
CmsMultiMessages.I_KeyFallbackHandler
,I_CmsRegexSubstitution
public class CmsRemoveInnerNameFallback extends java.lang.Object implements CmsMultiMessages.I_KeyFallbackHandler, I_CmsRegexSubstitution
Message key fallback handler used to enable reuse of localization keys for editor labels.This handler, when given a key of the form label.foo.bar (starting with 'label' and containing at least three dot-separated components), removes the second component (in the example, this results in the key label.bar).
This can be useful if you want to reuse the same key for fields of multiple content types.
-
-
Constructor Summary
Constructors Constructor Description CmsRemoveInnerNameFallback(java.lang.String config)
Creates a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description com.google.common.base.Optional<java.lang.String>
getFallbackKey(java.lang.String key)
Gets the fallback key for the given key, or the absent value if there is no fallback key.java.lang.String
substituteMatch(java.lang.String string, java.util.regex.Matcher matcher)
Should return the substitution for the current match of the matcher.
-
-
-
Field Detail
-
REGEX_STR
public static final java.lang.String REGEX_STR
Regex string.- See Also:
- Constant Field Values
-
PATTERN
public static final java.util.regex.Pattern PATTERN
Regex pattern instance.
-
-
Constructor Detail
-
CmsRemoveInnerNameFallback
public CmsRemoveInnerNameFallback(java.lang.String config)
Creates a new instance.- Parameters:
config
- the configuration (ignored)
-
-
Method Detail
-
getFallbackKey
public com.google.common.base.Optional<java.lang.String> getFallbackKey(java.lang.String key)
Description copied from interface:CmsMultiMessages.I_KeyFallbackHandler
Gets the fallback key for the given key, or the absent value if there is no fallback key.- Specified by:
getFallbackKey
in interfaceCmsMultiMessages.I_KeyFallbackHandler
- Parameters:
key
- the original key- Returns:
- the fallback key
- See Also:
CmsMultiMessages.I_KeyFallbackHandler.getFallbackKey(java.lang.String)
-
substituteMatch
public java.lang.String substituteMatch(java.lang.String string, java.util.regex.Matcher matcher)
Description copied from interface:I_CmsRegexSubstitution
Should return the substitution for the current match of the matcher.- Specified by:
substituteMatch
in interfaceI_CmsRegexSubstitution
- Parameters:
string
- the base string in which the match occurredmatcher
- the matcher which is currently being used- Returns:
- the substitution which should be used for the current match of the matcher
- See Also:
I_CmsRegexSubstitution.substituteMatch(java.lang.String, java.util.regex.Matcher)
-
-