/** * returns an array of strings decomposed of the original string, split at * every occurrence of 'ch'. if 2 'ch' follow each other with no intermediate * characters, empty "" entries are avoided. * * @param str the string to decompose * @param ch the character to use a split pattern * @return an array of strings */ public static String[] explode(String str, int ch) { return explode(str, ch, false); }
/** * returns an array of strings decomposed of the original string, split at * every occurrence of 'ch'. if 2 'ch' follow each other with no intermediate * characters, empty "" entries are avoided. * * @param str the string to decompose * @param ch the character to use a split pattern * @return an array of strings */ public static String[] explode(String str, int ch) { return explode(str, ch, false); }
/** * returns an array of strings decomposed of the original string, split at * every occurrence of 'ch'. if 2 'ch' follow each other with no intermediate * characters, empty "" entries are avoided. * * @param str the string to decompose * @param ch the character to use a split pattern * @return an array of strings */ public static String[] explode(String str, int ch) { return explode(str, ch, false); }
/** * returns an array of strings decomposed of the original string, split at * every occurrence of 'ch'. if 2 'ch' follow each other with no intermediate * characters, empty "" entries are avoided. * * @param str the string to decompose * @param ch the character to use a split pattern * @return an array of strings */ public static String[] explode(String str, int ch) { return explode(str, ch, false); }
/** * returns an array of strings decomposed of the original string, split at * every occurance of 'ch'. if 2 'ch' follow each other with no intermediate * characters, empty "" entries are avoided. * * @param str the string to decompose * @param ch the character to use a split pattern * @return an array of strings */ public static String[] explode(String str, int ch) { return explode(str, ch, false); }
public String toMapName(String name, char delim) { StringBuffer ret = new StringBuffer(); String[] elems = Text.explode(name, delim); ret.append(elems[0]); for (int i=1; i<elems.length; i++) { ret.append(elems[i].substring(0, 1).toUpperCase()); ret.append(elems[i].substring(1)); } return ret.toString(); }
public String toMapName(String name, char delim) { StringBuffer ret = new StringBuffer(); String[] elems = Text.explode(name, delim); ret.append(elems[0]); for (int i=1; i<elems.length; i++) { ret.append(elems[i].substring(0, 1).toUpperCase()); ret.append(elems[i].substring(1)); } return ret.toString(); }
public String toMapName(String name, char delim) { StringBuffer ret = new StringBuffer(); String[] elems = Text.explode(name, delim); ret.append(elems[0]); for (int i=1; i<elems.length; i++) { ret.append(elems[i].substring(0, 1).toUpperCase()); ret.append(elems[i].substring(1)); } return ret.toString(); }
/** * Recursively creates nodes below the specified root node. * * @param root * @param relPath * @return the node corresponding to the last segment of the specified * relative path. * @throws RepositoryException */ public static Node mkDirs(Node root, String relPath, String dirNodeType) throws RepositoryException { for (String seg : Text.explode(relPath, '/')) { if (!root.hasNode(seg)) { root.addNode(seg, dirNodeType); } root = root.getNode(seg); } return root; } }
/** * * @param configParam * @return */ private static String[] split(String configParam) { List<String> nameList = new ArrayList<String>(); for (String pn : Text.explode(configParam, ',', false)) { String privName = pn.trim(); if (privName.length() > 0) { nameList.add(privName); } } return nameList.toArray(new String[nameList.size()]); } }
/** * * @param configParam * @return */ private static String[] split(String configParam) { List<String> nameList = new ArrayList<String>(); for (String pn : Text.explode(configParam, ',', false)) { String privName = pn.trim(); if (privName.length() > 0) { nameList.add(privName); } } return nameList.toArray(new String[nameList.size()]); } }
GroupEditor(@NotNull NodeBuilder builder, @NotNull String groupsPath) { this.state = new State(builder); this.groupsRoot = Text.explode(groupsPath, '/', false); // writer.setMembershipSizeThreshold(10); // uncomment to test different split sizes }
GroupEditor(@NotNull NodeBuilder builder, @NotNull String groupsPath) { this.state = new State(builder); this.groupsRoot = Text.explode(groupsPath, '/', false); // writer.setMembershipSizeThreshold(10); // uncomment to test different split sizes }
@Nullable private static String getQueryPath(@NotNull String relPath) { if (relPath.indexOf('/') == -1) { // just a single segment -> don't include the path in the query return null; } else { // compute the relative path excluding the trailing property name String[] segments = Text.explode(relPath, '/', false); StringBuilder sb = new StringBuilder(); for (int i = 0; i < segments.length - 1; i++) { if (!PathUtils.denotesCurrent(segments[i])) { if (i > 0) { sb.append('/'); } sb.append(segments[i]); } } return Strings.emptyToNull(sb.toString()); } }
@Nullable private static String getQueryPath(@NotNull String relPath) { if (relPath.indexOf('/') == -1) { // just a single segment -> don't include the path in the query return null; } else { // compute the relative path excluding the trailing property name String[] segments = Text.explode(relPath, '/', false); StringBuilder sb = new StringBuilder(); for (int i = 0; i < segments.length - 1; i++) { if (!PathUtils.denotesCurrent(segments[i])) { if (i > 0) { sb.append('/'); } sb.append(segments[i]); } } return Strings.emptyToNull(sb.toString()); } }
@SuppressWarnings("UnusedDeclaration") @Activate public void activate(Map<String, Object> properties) { ConfigurationParameters config = ConfigurationParameters.of(properties); for (String entry : config.getConfigValue("externalidentities", Collections.<String>emptySet())) { String[] strs = Text.explode(entry, ',', false); String uid = strs[0].trim(); Set<String> declaredGroups = new HashSet<String>(); if (strs.length > 1) { for (int i = 1; i < strs.length; i++) { groupIds.add(strs[i]); declaredGroups.add(strs[i]); } } userGroupMap.put(uid, declaredGroups); } log.info("activated IDP: " + getName()); }
public static String calculateFsBundleDigest(final PartialZipFile bundleZipFile, final WebFilesService webfilesService) throws IOException { final Map<String, String> jarBundle = new TreeMap<>(); final Enumeration<? extends ZipEntry> entries = bundleZipFile.entries(); while (entries.hasMoreElements()) { final ZipEntry zipEntry = entries.nextElement(); final boolean isDirectory = zipEntry.isDirectory(); final String path = zipEntry.getName(); final String[] names = Text.explode(path, '/'); if (names.length > 0 && isIncluded(names, isDirectory, zipEntry.getSize(), webfilesService)) { if (!isDirectory) { try (final InputStream inputStream = bundleZipFile.getInputStream(zipEntry)) { final String digest = DigestUtils.digestFromStream(inputStream); jarBundle.put(zipEntry.getName(), digest); } } } } final String jarChecksum = jarBundle.keySet().stream().map(jarBundle::get).collect(Collectors.joining()); return DigestUtils.computeManifestDigest(jarChecksum); }
@NotNull private static TreeLocation getLocation(@NotNull Tree tree, @NotNull String relativePath) { TreeLocation loc = TreeLocation.create(tree); for (String element : Text.explode(relativePath, '/', false)) { if (PathUtils.denotesParent(element)) { loc = loc.getParent(); } else if (!PathUtils.denotesCurrent(element)) { loc = loc.getChild(element); } // else . -> skip to next element } return loc; }
@Nonnull private static TreeLocation getLocation(@Nonnull Tree tree, @Nonnull String relativePath) { TreeLocation loc = TreeLocation.create(tree); for (String element : Text.explode(relativePath, '/', false)) { if (PathUtils.denotesParent(element)) { loc = loc.getParent(); } else if (!PathUtils.denotesCurrent(element)) { loc = loc.getChild(element); } // else . -> skip to next element } return loc; }
@NotNull private static TreeLocation getLocation(@NotNull Tree tree, @NotNull String relativePath) { TreeLocation loc = TreeLocation.create(tree); for (String element : Text.explode(relativePath, '/', false)) { if (PathUtils.denotesParent(element)) { loc = loc.getParent(); } else if (!PathUtils.denotesCurrent(element)) { loc = loc.getChild(element); } // else . -> skip to next element } return loc; }