public E remove(String path) { Node<E> n = get(path, false); if (n == null) { return null; } E previous = n.elem; n.elem = null; n.prune(); return previous; }
/** * 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); }
/** * Formats the given jcr property to the enhanced docview syntax. * @param prop the jcr property * @return the formatted string * @throws RepositoryException if a repository error occurs */ public static String format(Property prop) throws RepositoryException { return format(prop, false, false); }
/** * Returns the name part of the path. If the given path is already a name * (i.e. contains no slashes) it is returned. * * @param path the path * @return the name part or {@code null} if {@code path} is {@code null}. */ public static String getName(String path) { return getName(path, '/'); }
/** * Returns the platform path for the given repository one. * @param repoPath the repository path * @return the platform path */ public static String getPlatformPath(String repoPath) { String[] elems = Text.explode(repoPath, '/', true); for (int i=0; i<elems.length; i++) { if (elems[i].length() > 0) { elems[i] = getPlatformName(elems[i]); } } return Text.implode(elems, "/"); }
/** * Retrieve the mimetype for the given extension or name * @param name the name * @return the mimetype or {@code null} */ public static String getMimeType(String name) { return getMimeType(name, null); }
public static String getRelativeFilePath(String cwd, String path) { return getRelativeFilePath(cwd, path, Constants.FS_NATIVE); }
/** * Does a URL encoding of the {@code string}. The characters that * don't need encoding are those defined 'unreserved' in section 2.3 of * the 'URI generic syntax' RFC 2396. * * @param string the string to encode * @return the escaped string * @throws NullPointerException if {@code string} is {@code null}. */ public static String escape(String string) { return escape(string, '%'); }
private ImportedPrincipalSet(DocViewNode node) { // don't change the status as a cug policy may not have child nodes. // just collect the rep:principalNames property // any subsequent state would indicate an error principalNames = node.getValues("rep:principalNames"); }
public void setMd5(MD5 md5) { if (this.md5 == null && md5 != null || this.md5 != null && !this.md5.equals(md5)) { this.md5 = md5; dirty = true; } }
public int read() throws IOException { final byte[] one = new byte[1]; if (read(one) == -1) { return -1; } return one[0]; }
public void onMessage(Mode mode, String action, String path) { print(mode, action, path, null); }
public E get(String path) { Node<E> n = get(path, false); return n == null ? null : n.elem; }
private Node<E> get(String path, boolean create) { String[] segs = Text.explode(path, separator); Node<E> n = root; for (String name: segs) { Node<E> c = n.get(name, create); if (c == null) { return null; } n = c; } return n; }
/** * Does a URL encoding of the {@code path}. The characters that * don't need encoding are those defined 'unreserved' in section 2.3 of * the 'URI generic syntax' RFC 2396. In contrast to the * {@link #escape(String)} method, not the entire path string is escaped, * but every individual part (i.e. the slashes are not escaped). * * @param path the path to encode * @return the escaped path * @throws NullPointerException if {@code path} is {@code null}. */ public static String escapePath(String path) { return escape(path, '%', true); }
public E put(String path, E elem) { E previous; Node<E> n = get(path, true); previous = n.elem; n.elem = elem; return previous; }
public void removeChildren(String path) { Node<E> n = get(path, false); if (n != null) { n.removeChildren(); } }