org.apache.jackrabbit.util.Text.getLocalName()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(7.7k)|赞(0)|评价(0)|浏览(96)

本文整理了Java中org.apache.jackrabbit.util.Text.getLocalName()方法的一些代码示例,展示了Text.getLocalName()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Text.getLocalName()方法的具体详情如下:
包路径:org.apache.jackrabbit.util.Text
类名称:Text
方法名:getLocalName

Text.getLocalName介绍

[英]Returns the local name of the given qname. Please note, that this method does not validate the name.

The qname has the format: qname := [prefix ':'] local;
[中]返回给定qname的本地名称。请注意,此方法不会验证名称。
qname的格式为:qname:=[前缀]:']local;

代码示例

代码示例来源:origin: org.apache.jackrabbit/jackrabbit-spi-commons

private Name getName(String jcrName, Map<String,String> namespaces) {
  String prefix = Text.getNamespacePrefix(jcrName);
  String uri = (Name.NS_EMPTY_PREFIX.equals(prefix)) ? Name.NS_DEFAULT_URI : namespaces.get(prefix);
  return NAME_FACTORY.create(uri, Text.getLocalName(jcrName));
}

代码示例来源:origin: apache/jackrabbit

private Name getName(String jcrName, Map<String,String> namespaces) {
  String prefix = Text.getNamespacePrefix(jcrName);
  String uri = (Name.NS_EMPTY_PREFIX.equals(prefix)) ? Name.NS_DEFAULT_URI : namespaces.get(prefix);
  return NAME_FACTORY.create(uri, Text.getLocalName(jcrName));
}

代码示例来源:origin: org.apache.jackrabbit/jackrabbit-jcr-commons

/**
 * Write the name and updated the namespace declarations if needed.
 * 
 * @param name name to write
 * @throws IOException if an I/O error occurs
 */
private void writeJcrName(String name) throws IOException {
  if (name == null) {
    return;
  }
  String prefix = Text.getNamespacePrefix(name);
  if (!prefix.equals(NamespaceRegistry.PREFIX_EMPTY)) {
    // update namespace declaration
    writeNamespaceDeclaration(prefix);
    prefix += ":";
  }
  String localName = Text.getLocalName(name);
  String encLocalName = (ANY.equals(localName)) ? ANY : ISO9075.encode(Text.getLocalName(name));
  String resolvedName = prefix + encLocalName;
  // check for '-' and '+'
  boolean quotesNeeded = (name.indexOf('-') >= 0 || name.indexOf('+') >= 0);
  if (quotesNeeded) {
    out.write("'");
    out.write(resolvedName);
    out.write("'");
  } else {
    out.write(resolvedName);
  }
}

代码示例来源:origin: apache/jackrabbit

/**
 * Write the name and updated the namespace declarations if needed.
 * 
 * @param name name to write
 * @throws IOException if an I/O error occurs
 */
private void writeJcrName(String name) throws IOException {
  if (name == null) {
    return;
  }
  String prefix = Text.getNamespacePrefix(name);
  if (!prefix.equals(NamespaceRegistry.PREFIX_EMPTY)) {
    // update namespace declaration
    writeNamespaceDeclaration(prefix);
    prefix += ":";
  }
  String localName = Text.getLocalName(name);
  String encLocalName = (ANY.equals(localName)) ? ANY : ISO9075.encode(Text.getLocalName(name));
  String resolvedName = prefix + encLocalName;
  // check for '-' and '+'
  boolean quotesNeeded = (name.indexOf('-') >= 0 || name.indexOf('+') >= 0);
  if (quotesNeeded) {
    out.write("'");
    out.write(resolvedName);
    out.write("'");
  } else {
    out.write(resolvedName);
  }
}

代码示例来源:origin: org.apache.sling/org.apache.sling.testing.sling-mock-oak

/**
 * Write the name and updated the namespace declarations if needed.
 * 
 * @param name name to write
 * @throws IOException if an I/O error occurs
 */
private void writeJcrName(String name) throws IOException {
  if (name == null) {
    return;
  }
  String prefix = Text.getNamespacePrefix(name);
  if (!prefix.equals(NamespaceRegistry.PREFIX_EMPTY)) {
    // update namespace declaration
    writeNamespaceDeclaration(prefix);
    prefix += ":";
  }
  String localName = Text.getLocalName(name);
  String encLocalName = (ANY.equals(localName)) ? ANY : ISO9075.encode(Text.getLocalName(name));
  String resolvedName = prefix + encLocalName;
  // check for '-' and '+'
  boolean quotesNeeded = (name.indexOf('-') >= 0 || name.indexOf('+') >= 0);
  if (quotesNeeded) {
    out.write("'");
    out.write(resolvedName);
    out.write("'");
  } else {
    out.write(resolvedName);
  }
}

代码示例来源:origin: apache/jackrabbit

public CurrentUserPrivilegeSetProperty asDavProperty() throws RepositoryException {
    List<Privilege> davPrivs = new ArrayList<Privilege>();
    for (javax.jcr.security.Privilege privilege : session.getAccessControlManager().getPrivileges(absPath)) {
      String privilegeName = privilege.getName();

      String prefix = Text.getNamespacePrefix(privilegeName);
      Namespace ns = (prefix.isEmpty()) ? Namespace.EMPTY_NAMESPACE : Namespace.getNamespace(prefix, session.getNamespaceURI(prefix));
      davPrivs.add(Privilege.getPrivilege(Text.getLocalName(privilegeName), ns));
    }

    return new CurrentUserPrivilegeSetProperty(davPrivs.toArray(new Privilege[davPrivs.size()]));
  }
}

代码示例来源:origin: apache/jackrabbit

private SupportedPrivilege createSupportedPrivilege(Privilege privilege) throws RepositoryException {
  String privilegeName = privilege.getName();
  String localName = Text.getLocalName(privilegeName);
  String prefix = Text.getNamespacePrefix(privilegeName);
  Namespace ns = (prefix.isEmpty()) ? Namespace.EMPTY_NAMESPACE : Namespace.getNamespace(prefix, session.getNamespaceURI(prefix));
  org.apache.jackrabbit.webdav.security.Privilege davPrivilege = org.apache.jackrabbit.webdav.security.Privilege.getPrivilege(localName, ns);
  SupportedPrivilege[] aggregates = (privilege.isAggregate()) ? getDeclaredAggregates(privilege) : null;
  SupportedPrivilege sp = new SupportedPrivilege(davPrivilege, null, null, privilege.isAbstract(), aggregates);
  if (!aggregated.contains(privilegeName)) {
    supportedPrivileges.put(privilegeName, sp);
  }
  return sp;
}

代码示例来源:origin: apache/jackrabbit

String prefix = Text.getNamespacePrefix(priv.getName());
if (lookup.containsKey(prefix)) {
  Name n = NAME_FACTORY.create(lookup.get(prefix), Text.getLocalName(priv.getName()));
  if (PRIVILEGE_NAMES.containsKey(n)) {
    bits |= PRIVILEGE_NAMES.get(n);

代码示例来源:origin: org.apache.jackrabbit/jackrabbit-core

String prefix = Text.getNamespacePrefix(priv.getName());
if (lookup.containsKey(prefix)) {
  Name n = NAME_FACTORY.create(lookup.get(prefix), Text.getLocalName(priv.getName()));
  if (PRIVILEGE_NAMES.containsKey(n)) {
    bits |= PRIVILEGE_NAMES.get(n);

代码示例来源:origin: apache/jackrabbit

/**
 * Builds a webdav property name from the given jcrName. In case the jcrName
 * contains a namespace prefix that would conflict with any of the predefined
 * webdav namespaces a new prefix is assigned.<br>
 * Please note, that the local part of the jcrName is checked for XML
 * compatibility by calling {@link ISO9075#encode(String)}
 *
 * @param jcrName name of the jcr property
 * @param session session
 * @return a <code>DavPropertyName</code> for the given jcr name.
 * @throws RepositoryException if an error during repository access occurs.
 */
private DavPropertyName getDavName(String jcrName, Session session) throws RepositoryException {
  // make sure the local name is xml compliant
  String localName = ISO9075.encode(Text.getLocalName(jcrName));
  String prefix = Text.getNamespacePrefix(jcrName);
  String uri = session.getNamespaceURI(prefix);
  Namespace namespace = Namespace.getNamespace(prefix, uri);
  DavPropertyName name = DavPropertyName.create(localName, namespace);
  return name;
}

代码示例来源:origin: org.apache.jackrabbit/jackrabbit-core

/**
   * Returns the local name of the node denoted by the given score node
   * <code>sn</code>.
   *
   * @param sn      the score node.
   * @param context the evaluation context.
   * @return the local node name.
   * @throws RepositoryException if an error occurs while reading the local
   *                             name.
   */
  public Value[] getValues(ScoreNode sn, EvaluationContext context)
      throws RepositoryException {
    SessionImpl session = context.getSession();
    try {
      String name = session.getNodeById(sn.getNodeId()).getName();
      return new Value[]{session.getValueFactory().createValue(
          Text.getLocalName(name))};
    } catch (ItemNotFoundException e) {
      // access denied to score node
      return new Value[0];
    }
  }
}

代码示例来源:origin: apache/jackrabbit

/**
   * Returns the local name of the node denoted by the given score node
   * <code>sn</code>.
   *
   * @param sn      the score node.
   * @param context the evaluation context.
   * @return the local node name.
   * @throws RepositoryException if an error occurs while reading the local
   *                             name.
   */
  public Value[] getValues(ScoreNode sn, EvaluationContext context)
      throws RepositoryException {
    SessionImpl session = context.getSession();
    try {
      String name = session.getNodeById(sn.getNodeId()).getName();
      return new Value[]{session.getValueFactory().createValue(
          Text.getLocalName(name))};
    } catch (ItemNotFoundException e) {
      // access denied to score node
      return new Value[0];
    }
  }
}

相关文章