public class CodecUtils extends Object
Modifier and Type | Field and Description |
---|---|
static String |
ENCODING_DISPLAY |
static String |
ENCODING_NODE |
static org.slf4j.Logger |
log |
Constructor and Description |
---|
CodecUtils() |
Modifier and Type | Method and Description |
---|---|
static StringCodec |
getDisplayNameCodec(IPluginContext context)
Lookup a
StringCodec 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 property
HippoTranslationNodeType.LOCALE for the first translated node found. |
static StringCodec |
getNodeNameCodec(IPluginContext context,
javax.jcr.Node node)
Lookup a
StringCodec for encoding/decoding a node name. |
static StringCodec |
getNodeNameCodec(IPluginContext context,
String locale)
Lookup a
StringCodec for encoding/decoding a node name for a specific locale (optional). |
static org.apache.wicket.model.IModel<StringCodec> |
getNodeNameCodecModel(IPluginContext context,
String locale)
Convenience method for wrapping a
StringCodec in a LoadableDetachableModel . |
static StringCodecFactory |
getStringCodecFactory(IPluginContext context)
Return a
StringCodecFactory from the ISettingsService or throw an IllegalStateException
if not found. |
public static final org.slf4j.Logger log
public static final String ENCODING_NODE
public static final String ENCODING_DISPLAY
public static StringCodecFactory getStringCodecFactory(IPluginContext context)
StringCodecFactory
from the ISettingsService
or throw an IllegalStateException
if not found.context
- The IPluginContext
should contain a reference to the ISettingsService
, otherwise
an IllegalStateException
is thrown.StringCodecFactory
if found, otherwise an IllegalStateException
is thrown.public static StringCodec getDisplayNameCodec(IPluginContext context)
StringCodec
for encoding/decoding a display name.context
- Used for retrieving the StringCodecFactory
, see getStringCodecFactory(org.hippoecm.frontend.plugin.IPluginContext)
StringCodec
for encoding/decoding a display name.public static StringCodec getNodeNameCodec(IPluginContext context, String locale)
StringCodec
for encoding/decoding a node name for a specific locale (optional).context
- Used for retrieving the StringCodecFactory
, see getStringCodecFactory(org.hippoecm.frontend.plugin.IPluginContext)
locale
- Simplified string representation of a locale like en_US or deStringCodec
for encoding/decoding a node name.public static StringCodec getNodeNameCodec(IPluginContext context, javax.jcr.Node node)
StringCodec
for encoding/decoding a node name. The Node
is used for retrieving an
optional locale.context
- Used for retrieving the StringCodecFactory
, see getStringCodecFactory(org.hippoecm.frontend.plugin.IPluginContext)
node
- If the node or any of its parents have property HippoTranslationNodeType.LOCALE
set, the
value is used to localize the StringCodec
.StringCodec
for encoding/decoding a node name.public static org.apache.wicket.model.IModel<StringCodec> getNodeNameCodecModel(IPluginContext context, String locale)
StringCodec
in a LoadableDetachableModel
. See
getNodeNameCodec(IPluginContext, String)
context
- Used for retrieving the StringCodecFactory
, see getStringCodecFactory(org.hippoecm.frontend.plugin.IPluginContext)
locale
- Simplified string representation of a locale like en_US or deLoadableDetachableModel
wrapping a StringCodec
for encoding/decoding a node name.public static String getLocaleFromNodeAndAncestors(javax.jcr.Node node)
HippoTranslationNodeType.LOCALE
for the first translated node found. If
the provided node is a handle, start with the first child to check whether there is a HippoTranslationNodeType.LOCALE
property
Traverse up the ancestor tree until a locale is found.node
- Node to start traversal withpublic static String getLocaleFromNode(javax.jcr.Node node)
public static String getLocaleFromDocumentOrFolder(javax.jcr.Node document, javax.jcr.Node folder)
Copyright © 2007–2017 Hippo B.V. (http://www.onehippo.com). All rights reserved.