|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.jackrabbit.commons.NamespaceHelper
public class NamespaceHelper
Helper class for working with JCR namespaces.
| Field Summary | |
|---|---|
static String |
JCR
The jcr namespace URI. |
static String |
MIX
The mix namespace URI. |
static String |
NT
The nt namespace URI. |
| Constructor Summary | |
|---|---|
NamespaceHelper(Session session)
Creates a namespace helper for the given session. |
|
| Method Summary | |
|---|---|
String |
getJcrName(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. |
String |
getJcrName(String uri,
String name)
Returns the prefixed JCR name for the given namespace URI and local name in the current session. |
Map |
getNamespaces()
Returns a map containing all prefix to namespace URI mappings of the current session. |
String |
getPrefix(String uri)
Returns the prefix mapped to the given namespace URI in the current session, or null if the namespace does not exist. |
String |
getURI(String prefix)
Returns the namespace URI mapped to the given prefix in the current session, or null if the namespace does not exist. |
String |
registerNamespace(String prefix,
String uri)
Safely registers the given namespace. |
void |
registerNamespaces(Map namespaces)
Safely registers all namespaces in the given map from prefixes to namespace URIs. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String JCR
jcr namespace URI.
public static final String NT
nt namespace URI.
public static final String MIX
mix namespace URI.
| Constructor Detail |
|---|
public NamespaceHelper(Session session)
session - current session| Method Detail |
|---|
public Map getNamespaces()
throws RepositoryException
RepositoryException - if the namespaces could not be retrievedSession.getNamespacePrefixes()
public String getPrefix(String uri)
throws RepositoryException
null if the namespace does not exist.
uri - namespace URI
null
RepositoryException - if the namespace could not be retrievedSession.getNamespacePrefix(String)
public String getURI(String prefix)
throws RepositoryException
null if the namespace does not exist.
uri - namespace URI
null
RepositoryException - if the namespace could not be retrievedSession.getNamespaceURI(String)
public String getJcrName(String uri,
String name)
throws NamespaceException,
RepositoryException
uri - namespace URIname - local name
NamespaceException - if the namespace does not exist
RepositoryException - if the namespace could not be retrieved
public String getJcrName(String name)
throws 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 prefixes
IllegalArgumentException - if the prefix is unknown
RepositoryException - if the namespace could not be retrieved
public String registerNamespace(String prefix,
String uri)
throws RepositoryException
prefix - namespace prefixuri - namespace URI
RepositoryException - if the namespace could not be registeredNamespaceRegistry.registerNamespace(String, String)
public void registerNamespaces(Map namespaces)
throws RepositoryException
namespaces - namespace mappings
RepositoryException - if the namespaces could not be registered
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||