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

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

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

Text.escapeIllegalJcrChars介绍

[英]Escapes all illegal JCR name characters of a string. The encoding is loosely modeled after URI encoding, but only encodes the characters it absolutely needs to in order to make the resulting string a valid JCR name. Use #unescapeIllegalJcrChars(String) for decoding.

QName EBNF:

simplename ::= onecharsimplename | twocharsimplename | threeormorecharname 
onecharsimplename ::= (* Any Unicode character except: '.', '/', ':', '[', ']', '*', '|' or any whitespace character *) 
twocharsimplename ::= '.' onecharsimplename | onecharsimplename '.' | onecharsimplename onecharsimplename 
threeormorecharname ::= nonspace string nonspace 
string ::= char | string char 
char ::= nonspace | ' ' 
nonspace ::= (* Any Unicode character except: '/', ':', '[', ']', '*', '|' or any whitespace character *)

[中]转义字符串中所有非法的JCR名称字符。该编码松散地模仿URI编码,但只对它绝对需要的字符进行编码,以使生成的字符串成为有效的JCR名称。使用#unescapeillegaljcars(字符串)进行解码。
QName EBNF:

simplename ::= onecharsimplename | twocharsimplename | threeormorecharname 
onecharsimplename ::= (* Any Unicode character except: '.', '/', ':', '[', ']', '*', '|' or any whitespace character *) 
twocharsimplename ::= '.' onecharsimplename | onecharsimplename '.' | onecharsimplename onecharsimplename 
threeormorecharname ::= nonspace string nonspace 
string ::= char | string char 
char ::= nonspace | ' ' 
nonspace ::= (* Any Unicode character except: '/', ':', '[', ']', '*', '|' or any whitespace character *)

代码示例

代码示例来源:origin: pentaho/pentaho-platform

public static String idEncode( String id ) {
 return Text.escapeIllegalJcrChars( id );
}

代码示例来源:origin: sinnerschrader/aem-react

public static void main(String[] args) {
 System.out.println(Text.escapeIllegalJcrChars("[]"));
}

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

@Override
  @NotNull
  public String generateNodeName(@NotNull String authorizableId) {
    return Text.escapeIllegalJcrChars(authorizableId);
  }
}

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

@Override
  @Nonnull
  public String generateNodeName(@Nonnull String authorizableId) {
    return Text.escapeIllegalJcrChars(authorizableId);
  }
}

代码示例来源:origin: pentaho/pentaho-platform

/**
 * 
 * @param fileName
 * @param useMultiByte
 * @return
 */
public static String fileNameEncode( String fileName, boolean useMultiByte ) {
 if ( useMultiByte ) {
  return Text.escapeIllegalJcrChars( ISO9075.encode( fileName ) );
 } else {
  return Text.escapeIllegalJcrChars( fileName );
 }
}

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

AcEntry(@NotNull NodeState node, @NotNull String accessControlledPath, int index,
    boolean isAllow, @NotNull PrivilegeBits privilegeBits,
    @NotNull Set<Restriction> restrictions) {
  this.accessControlledPath = accessControlledPath;
  this.index = index;
  this.principalName = Text.escapeIllegalJcrChars(node.getString(REP_PRINCIPAL_NAME));
  this.privilegeBits = privilegeBits;
  this.isAllow = isAllow;
  this.restrictions = restrictions;
}

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

AcEntry(@NotNull NodeState node, @NotNull String accessControlledPath, int index,
    boolean isAllow, @NotNull PrivilegeBits privilegeBits,
    @NotNull Set<Restriction> restrictions) {
  this.accessControlledPath = accessControlledPath;
  this.index = index;
  this.principalName = Text.escapeIllegalJcrChars(node.getString(REP_PRINCIPAL_NAME));
  this.privilegeBits = privilegeBits;
  this.isAllow = isAllow;
  this.restrictions = restrictions;
}

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

private AcEntry(@Nonnull NodeState node, @Nonnull String accessControlledPath, int index,
        boolean isAllow, @Nonnull PrivilegeBits privilegeBits,
        @Nonnull Set<Restriction> restrictions) {
  this.accessControlledPath = accessControlledPath;
  this.index = index;
  this.principalName = Text.escapeIllegalJcrChars(node.getString(REP_PRINCIPAL_NAME));
  this.privilegeBits = privilegeBits;
  this.isAllow = isAllow;
  this.restrictions = restrictions;
}

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

@NotNull
public static Tree getPrincipalRoot(@NotNull Tree permissionsTree, @NotNull String principalName) {
  return permissionsTree.getChild(Text.escapeIllegalJcrChars(principalName));
}

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

@NotNull
public static Tree getPrincipalRoot(@NotNull Tree permissionsTree, @NotNull String principalName) {
  return permissionsTree.getChild(Text.escapeIllegalJcrChars(principalName));
}

代码示例来源:origin: org.apache.james/james-server-data-jcr

protected String toSafeName(String key) {
  return ISO9075.encode(Text.escapeIllegalJcrChars(key));
}

代码示例来源:origin: org.apache.james/james-server-jcr

protected String toSafeName(String key) {
  String name = ISO9075.encode(Text.escapeIllegalJcrChars(key));
  return name;
}

代码示例来源:origin: org.apache.james/james-server-jcr

protected String toSafeName(String key) {
  String name = ISO9075.encode(Text.escapeIllegalJcrChars(key));
  return name;
}

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

@Nonnull
public static Tree getPrincipalRoot(@Nonnull Tree permissionsTree, @Nonnull String principalName) {
  return permissionsTree.getChild(Text.escapeIllegalJcrChars(principalName));
}

代码示例来源:origin: org.apache.james/james-server-data-jcr

protected String toSafeName(String key) {
  return ISO9075.encode(Text.escapeIllegalJcrChars(key));
}

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

/**
 *
 * @param principal the principal
 * @return the path
 * @throws RepositoryException if an error occurs
 */
String getPathToAcNode(Principal principal) throws RepositoryException {
  StringBuffer princPath = new StringBuffer(acRootPath);
  if (principal instanceof ItemBasedPrincipal) {
    princPath.append(((ItemBasedPrincipal) principal).getPath());
  } else {
    princPath.append("/");
    princPath.append(Text.escapeIllegalJcrChars(principal.getName()));
  }
  return princPath.toString();
}

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

/**
 *
 * @param principal the principal
 * @return the path
 * @throws RepositoryException if an error occurs
 */
String getPathToAcNode(Principal principal) throws RepositoryException {
  StringBuffer princPath = new StringBuffer(acRootPath);
  if (principal instanceof ItemBasedPrincipal) {
    princPath.append(((ItemBasedPrincipal) principal).getPath());
  } else {
    princPath.append("/");
    princPath.append(Text.escapeIllegalJcrChars(principal.getName()));
  }
  return princPath.toString();
}

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

/**
 * Makes the intermediate path of an DN by splitting along the RDNs
 * @param dn the dn of the identity
 * @return the intermediate path or {@code null} if disabled by config
 */
private static String createDNPath(Dn dn) {
  StringBuilder path = new StringBuilder();
  for (Rdn rnd: dn.getRdns()) {
    if (path.length() > 0) {
      path.append('/');
    }
    path.append(Text.escapeIllegalJcrChars(rnd.toString()));
  }
  return path.toString();
}

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

@Test
public void testIllegalChars() throws Exception {
  UserProvider userProvider = createUserProvider();
  Map<String, String> m = new HashMap<String, String>();
  m.put("z[x]", "/z/" + Text.escapeIllegalJcrChars("z[") + '/' + Text.escapeIllegalJcrChars("z[x]"));
  m.put("z*x", "/z/" + Text.escapeIllegalJcrChars("z*") + '/' + Text.escapeIllegalJcrChars("z*x"));
  m.put("z/x", "/z/" + Text.escapeIllegalJcrChars("z/") + '/' + Text.escapeIllegalJcrChars("z/x"));
  m.put("%\r|", '/' +Text.escapeIllegalJcrChars("%")+ '/' + Text.escapeIllegalJcrChars("%\r") + '/' + Text.escapeIllegalJcrChars("%\r|"));
  for (String uid : m.keySet()) {
    Tree user = userProvider.createUser(uid, null);
    root.commit();
    assertEquals(defaultUserPath + m.get(uid), user.getPath());
    assertEquals(uid, UserUtil.getAuthorizableId(user));
    Tree ath = userProvider.getAuthorizable(uid);
    assertNotNull("Tree with id " + uid + " must exist.", ath);
  }
}

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

@Test
  public void testDefault() {

    String[] hints = new String[] {"abc", "ABC", "[abc]", "abc[]", "a/b/c", "a,b,*","\\'\".;:abc", "{abc}", "a:bc"};
    for (String hint : hints) {
      assertEquals(Text.escapeIllegalJcrChars(hint), AuthorizableNodeName.DEFAULT.generateNodeName(hint));
    }

  }
}

相关文章