public class NamespaceHelper
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
JCR
The
jcr namespace URI. |
static java.lang.String |
MIX
The
mix namespace URI. |
static java.lang.String |
NT
The
nt namespace URI. |
Constructor and Description |
---|
NamespaceHelper(Session session)
Creates a namespace helper for the given session.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getJcrName(java.lang.String name)
Replaces the standard
jcr , nt , or
mix prefix in the given name with the prefix
mapped to that namespace in the current session. |
java.lang.String |
getJcrName(java.lang.String uri,
java.lang.String name)
Returns the prefixed JCR name for the given namespace URI and local
name in the current session.
|
java.util.Map<java.lang.String,java.lang.String> |
getNamespaces()
Returns a map containing all prefix to namespace URI mappings of
the current session.
|
java.lang.String |
getPrefix(java.lang.String uri)
Returns the prefix mapped to the given namespace URI in the current
session, or
null if the namespace does not exist. |
java.lang.String |
getURI(java.lang.String prefix)
Returns the namespace URI mapped to the given prefix in the current
session, or
null if the namespace does not exist. |
java.lang.String |
registerNamespace(java.lang.String prefix,
java.lang.String uri)
Safely registers the given namespace.
|
void |
registerNamespaces(java.util.Map<java.lang.String,java.lang.String> namespaces)
Safely registers all namespaces in the given map from
prefixes to namespace URIs.
|
public static final java.lang.String JCR
jcr
namespace URI.public static final java.lang.String NT
nt
namespace URI.public static final java.lang.String MIX
mix
namespace URI.public NamespaceHelper(Session session)
session
- current sessionpublic java.util.Map<java.lang.String,java.lang.String> getNamespaces() throws RepositoryException
RepositoryException
- if the namespaces could not be retrievedSession.getNamespacePrefixes()
public java.lang.String getPrefix(java.lang.String uri) throws RepositoryException
null
if the namespace does not exist.uri
- namespace URInull
RepositoryException
- if the namespace could not be retrievedSession.getNamespacePrefix(String)
public java.lang.String getURI(java.lang.String prefix) throws RepositoryException
null
if the namespace does not exist.prefix
- namespace prefixnull
RepositoryException
- if the namespace could not be retrievedSession.getNamespaceURI(String)
public java.lang.String getJcrName(java.lang.String uri, java.lang.String name) throws NamespaceException, RepositoryException
uri
- namespace URIname
- local nameNamespaceException
- if the namespace does not existRepositoryException
- if the namespace could not be retrievedpublic java.lang.String getJcrName(java.lang.String name) throws java.lang.IllegalArgumentException, RepositoryException
jcr
, nt
, or
mix
prefix in the given name with the prefix
mapped to that namespace in the current session.
The purpose of this method is to make it easier to write namespace-aware code that uses names in the standard JCR namespaces. For example:
node.getProperty(helper.getName("jcr:data"));
name
- prefixed name using the standard JCR prefixesjava.lang.IllegalArgumentException
- if the prefix is unknownRepositoryException
- if the namespace could not be retrievedpublic java.lang.String registerNamespace(java.lang.String prefix, java.lang.String uri) throws RepositoryException
prefix
- namespace prefixuri
- namespace URIRepositoryException
- if the namespace could not be registeredNamespaceRegistry.registerNamespace(String, String)
public void registerNamespaces(java.util.Map<java.lang.String,java.lang.String> namespaces) throws RepositoryException
namespaces
- namespace mappingsRepositoryException
- if the namespaces could not be registeredCopyright © 2010 - 2020 Adobe. All Rights Reserved