本文整理了Java中javax.jcr.Session.getNamespacePrefixes()
方法的一些代码示例,展示了Session.getNamespacePrefixes()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Session.getNamespacePrefixes()
方法的具体详情如下:
包路径:javax.jcr.Session
类名称:Session
方法名:getNamespacePrefixes
[英]Returns all prefixes currently mapped to URIs in this Session
.
[中]返回当前映射到此[$0$]中URI的所有前缀。
代码示例来源:origin: org.apache.sling/org.apache.sling.jcr.resource
public String[] getNamespacePrefixes(final Session session)
throws RepositoryException {
if ( this.namespacePrefixes == null ) {
this.namespacePrefixes = session.getNamespacePrefixes();
}
return this.namespacePrefixes;
}
代码示例来源:origin: org.onehippo.cms7/hippo-repository-connector
/**
* Forwards the method call to the underlying session.
*/
public String[] getNamespacePrefixes() throws RepositoryException {
return session.getNamespacePrefixes();
}
代码示例来源:origin: net.adamcin.oakpal/oakpal-core
@Override
public String[] getNamespacePrefixes() throws RepositoryException {
return delegate.getNamespacePrefixes();
}
代码示例来源:origin: org.onehippo.cms7/hippo-cms-plugins
private List<String> getNsPrefixes(Session session) throws RepositoryException {
List<String> nsPrefixes = new ArrayList<String>();
String[] ns = session.getNamespacePrefixes();
for (int i = 0; i < ns.length; i++) {
// filter
if (!"".equals(ns[i])) {
nsPrefixes.add(ns[i]);
}
}
Collections.sort(nsPrefixes);
return nsPrefixes;
}
代码示例来源:origin: org.onehippo.cms7/hippo-cms-console-frontend
private List<String> getNsPrefixes(Session session) throws RepositoryException {
List<String> nsPrefixes = new ArrayList<String>();
String[] ns = session.getNamespacePrefixes();
for (int i = 0; i < ns.length; i++) {
// filter
if (!"".equals(ns[i])) {
nsPrefixes.add(ns[i]);
}
}
Collections.sort(nsPrefixes);
return nsPrefixes;
}
代码示例来源:origin: apache/jackrabbit
/**
* Returns a namespace prefix that is not in use.
*
* @return a namespace prefix that is not in use.
*/
private String getUnusedPrefix() throws RepositoryException {
Set<String> prefixes = new HashSet<String>();
prefixes.addAll(Arrays.asList(session.getNamespacePrefixes()));
String prefix = "myapp";
int count = 0;
while (prefixes.contains(prefix + count)) {
count++;
}
return prefix + count;
}
代码示例来源:origin: info.magnolia/magnolia-core
@Override
public String[] getNamespacePrefixes() throws RepositoryException {
return getWrappedSession().getNamespacePrefixes();
}
代码示例来源:origin: apache/jackrabbit
/** {@inheritDoc} */
public String[] getNamespacePrefixes()
throws RepositoryException, RemoteException {
try {
return session.getNamespacePrefixes();
} catch (RepositoryException ex) {
throw getRepositoryException(ex);
}
}
代码示例来源:origin: apache/jackrabbit
/***
* Utility method that returns the namespace mappings of the current
* session.
*
* @return namespace mappings (prefix -> uri)
* @throws RepositoryException if a repository error occurs
*/
private Map<String, String> getNamespaceMappings() throws RepositoryException {
Map<String, String> mappings = new HashMap<String, String>();
for (String prefix : session.getNamespacePrefixes()) {
mappings.put(prefix, session.getNamespaceURI(prefix));
}
return mappings;
}
代码示例来源:origin: apache/jackrabbit
/**
* Return namespace prefixes.
*/
public String[] getNamespacePrefixes()
throws RepositoryException {
return getSession().getNamespacePrefixes();
}
代码示例来源:origin: apache/jackrabbit
/**
* Returns a prefix that is unique among the already registered prefixes.
*
* @param session
* @return a unique prefix
*/
public static String getUniquePrefix(Session session) throws RepositoryException {
return "_pre" + (session.getNamespacePrefixes().length + 1);
}
}
代码示例来源:origin: org.apache.jackrabbit/jackrabbit-jca
/**
* Return namespace prefixes.
*/
public String[] getNamespacePrefixes()
throws RepositoryException {
return getSession().getNamespacePrefixes();
}
代码示例来源:origin: ModeShape/modeshape
@Override
public String[] getNamespacePrefixes() throws RepositoryException {
return session().getNamespacePrefixes();
}
代码示例来源:origin: org.apache.jackrabbit/jackrabbit-jcr2spi
/***
* Utility method that returns the namespace mappings of the current
* session.
*
* @return namespace mappings (prefix -> uri)
* @throws RepositoryException if a repository error occurs
*/
private Map<String, String> getNamespaceMappings() throws RepositoryException {
Map<String, String> mappings = new HashMap<String, String>();
for (String prefix : session.getNamespacePrefixes()) {
mappings.put(prefix, session.getNamespaceURI(prefix));
}
return mappings;
}
代码示例来源:origin: Adobe-Consulting-Services/acs-aem-commons
@Override
default String[] getNamespacePrefixes() throws RepositoryException {
return unwrapSession().getNamespacePrefixes();
}
代码示例来源:origin: brix-cms/brix-cms
public String[] getNamespacePrefixes() throws RepositoryException {
return getDelegate().getNamespacePrefixes();
}
代码示例来源:origin: apache/jackrabbit
/**
* Returns a map containing all prefix to namespace URI mappings of
* the current session. The returned map is newly allocated and can
* can be freely modified by the caller.
*
* @see Session#getNamespacePrefixes()
* @return namespace mappings
* @throws RepositoryException if the namespaces could not be retrieved
*/
public Map<String, String> getNamespaces() throws RepositoryException {
Map<String, String> namespaces = new HashMap<String, String>();
String[] prefixes = session.getNamespacePrefixes();
for (String prefixe : prefixes) {
namespaces.put(prefixe, session.getNamespaceURI(prefixe));
}
return namespaces;
}
代码示例来源:origin: net.adamcin.commons/net.adamcin.commons.jcr
public String[] getNamespacePrefixes() throws RepositoryException
{ return getSession().getNamespacePrefixes(); }
代码示例来源:origin: ModeShape/modeshape
Map<String, String> namespacesFor( ResolvedRequest request ) throws RepositoryException {
Session session = session(request);
Map<String, String> namespaces = new HashMap<String, String>();
for (String namespacePrefix : session.getNamespacePrefixes()) {
if (StringUtil.isBlank(namespacePrefix) || EXCLUDED_NAMESPACE_PREFIXES.contains(namespacePrefix.toLowerCase())) {
continue;
}
String namespaceURI = session.getNamespaceURI(namespacePrefix);
namespaces.put(namespaceURI, namespacePrefix);
}
return namespaces;
}
代码示例来源:origin: org.apache.sling/org.apache.sling.launchpad.test-services
@Override
protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response) throws ServletException,
IOException {
try {
response.setContentType("text/plain");
Session session = request.getResourceResolver().adaptTo(Session.class);
response.getWriter().printf("userid=%s", session.getUserID());
response.getWriter().println();
for (String prefix : session.getNamespacePrefixes()) {
response.getWriter().printf("%s=%s", prefix, session.getNamespaceURI(prefix));
response.getWriter().println();
}
response.getWriter().flush();
} catch (RepositoryException e) {
throw new ServletException("Unable to output namespace mappings", e);
}
}
内容来源于网络,如有侵权,请联系作者删除!