Package org.hippoecm.frontend.util
Class CodecUtils
- java.lang.Object
-
- org.hippoecm.frontend.util.CodecUtils
-
public class CodecUtils extends Object
-
-
Field Summary
Fields Modifier and Type Field Description static String
ENCODING_DISPLAY
static String
ENCODING_NODE
static org.slf4j.Logger
log
-
Constructor Summary
Constructors Constructor Description CodecUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static StringCodec
getDisplayNameCodec(IPluginContext context)
Lookup aStringCodec
for encoding/decoding a display name.static String
getLocaleFromDocumentOrFolder(javax.jcr.Node document, javax.jcr.Node folder)
Helper method for fetching a locale for a document or a folder.static String
getLocaleFromNode(javax.jcr.Node node)
static String
getLocaleFromNodeAndAncestors(javax.jcr.Node node)
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, javax.jcr.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 Detail
-
log
public static final org.slf4j.Logger log
-
ENCODING_NODE
public static final String ENCODING_NODE
- See Also:
- Constant Field Values
-
ENCODING_DISPLAY
public static final String ENCODING_DISPLAY
- See Also:
- Constant Field Values
-
-
Method Detail
-
getStringCodecFactory
public static StringCodecFactory getStringCodecFactory(IPluginContext context)
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
public static StringCodec getDisplayNameCodec(IPluginContext context)
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
public static StringCodec getNodeNameCodec(IPluginContext context, String locale)
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
public static StringCodec getNodeNameCodec(IPluginContext context, javax.jcr.Node node)
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
public static String getLocaleFromNodeAndAncestors(javax.jcr.Node node)
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
public static String getLocaleFromNode(javax.jcr.Node node)
-
getLocaleFromDocumentOrFolder
public static String getLocaleFromDocumentOrFolder(javax.jcr.Node document, javax.jcr.Node folder)
Helper method for fetching a locale for a document or a folder.
-
-