Package org.hippoecm.frontend.util
Class CodecUtils
java.lang.Object
org.hippoecm.frontend.util.CodecUtils
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringCodec
getDisplayNameCodec
(IPluginContext context) Lookup aStringCodec
for encoding/decoding a display name.static String
getLocaleFromDocumentOrFolder
(Node document, Node folder) Helper method for fetching a locale for a document or a folder.static String
getLocaleFromNode
(Node node) static String
Return the value of propertyHippoTranslationNodeType.LOCALE
for the first translated node found.static StringCodec
getNodeNameCodec
(IPluginContext context, String locale) Lookup aStringCodec
for encoding/decoding a node name for a specific locale (optional).static StringCodec
getNodeNameCodec
(IPluginContext context, Node node) Lookup aStringCodec
for encoding/decoding a node name.static org.apache.wicket.model.IModel<StringCodec>
getNodeNameCodecModel
(IPluginContext context, String locale) Convenience method for wrapping aStringCodec
in aLoadableDetachableModel
.static StringCodecFactory
getStringCodecFactory
(IPluginContext context) Return aStringCodecFactory
from theISettingsService
or throw anIllegalStateException
if not found.
-
Field Details
-
log
public static final org.slf4j.Logger log -
ENCODING_NODE
- See Also:
-
ENCODING_DISPLAY
- See Also:
-
-
Constructor Details
-
CodecUtils
public CodecUtils()
-
-
Method Details
-
getStringCodecFactory
Return aStringCodecFactory
from theISettingsService
or throw anIllegalStateException
if not found.- Parameters:
context
- TheIPluginContext
should contain a reference to theISettingsService
, otherwise anIllegalStateException
is thrown.- Returns:
- a
StringCodecFactory
if found, otherwise anIllegalStateException
is thrown.
-
getDisplayNameCodec
Lookup aStringCodec
for encoding/decoding a display name.- Parameters:
context
- Used for retrieving theStringCodecFactory
, seegetStringCodecFactory(org.hippoecm.frontend.plugin.IPluginContext)
- Returns:
- a
StringCodec
for encoding/decoding a display name.
-
getNodeNameCodec
Lookup aStringCodec
for encoding/decoding a node name for a specific locale (optional).- Parameters:
context
- Used for retrieving theStringCodecFactory
, seegetStringCodecFactory(org.hippoecm.frontend.plugin.IPluginContext)
locale
- Simplified string representation of a locale like en_US or de- Returns:
- a
StringCodec
for encoding/decoding a node name.
-
getNodeNameCodec
Lookup aStringCodec
for encoding/decoding a node name. TheNode
is used for retrieving an optional locale.- Parameters:
context
- Used for retrieving theStringCodecFactory
, seegetStringCodecFactory(org.hippoecm.frontend.plugin.IPluginContext)
node
- If the node or any of its parents have propertyHippoTranslationNodeType.LOCALE
set, the value is used to localize theStringCodec
.- Returns:
- a
StringCodec
for encoding/decoding a node name.
-
getNodeNameCodecModel
public static org.apache.wicket.model.IModel<StringCodec> getNodeNameCodecModel(IPluginContext context, String locale) Convenience method for wrapping aStringCodec
in aLoadableDetachableModel
. SeegetNodeNameCodec(IPluginContext, String)
- Parameters:
context
- Used for retrieving theStringCodecFactory
, seegetStringCodecFactory(org.hippoecm.frontend.plugin.IPluginContext)
locale
- Simplified string representation of a locale like en_US or de- Returns:
- A
LoadableDetachableModel
wrapping aStringCodec
for encoding/decoding a node name.
-
getLocaleFromNodeAndAncestors
Return the value of propertyHippoTranslationNodeType.LOCALE
for the first translated node found. If the provided node is a handle, start with the first child to check whether there is aHippoTranslationNodeType.LOCALE
property Traverse up the ancestor tree until a locale is found.- Parameters:
node
- Node to start traversal with- Returns:
- String representation of locale associated with subtree
-
getLocaleFromNode
-
getLocaleFromDocumentOrFolder
Helper method for fetching a locale for a document or a folder.
-