From commits-return-11210-apmail-jackrabbit-commits-archive=jackrabbit.apache.org@jackrabbit.apache.org Tue Jun 7 09:42:21 2011 Return-Path: X-Original-To: apmail-jackrabbit-commits-archive@www.apache.org Delivered-To: apmail-jackrabbit-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 3B17769BA for ; Tue, 7 Jun 2011 09:42:21 +0000 (UTC) Received: (qmail 87657 invoked by uid 500); 7 Jun 2011 09:42:21 -0000 Delivered-To: apmail-jackrabbit-commits-archive@jackrabbit.apache.org Received: (qmail 87622 invoked by uid 500); 7 Jun 2011 09:42:20 -0000 Mailing-List: contact commits-help@jackrabbit.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@jackrabbit.apache.org Delivered-To: mailing list commits@jackrabbit.apache.org Received: (qmail 87615 invoked by uid 99); 7 Jun 2011 09:42:20 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 07 Jun 2011 09:42:20 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 07 Jun 2011 09:42:18 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 162C12388A2C; Tue, 7 Jun 2011 09:41:57 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1132927 - /jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/util/PathUtil.java Date: Tue, 07 Jun 2011 09:41:57 -0000 To: commits@jackrabbit.apache.org From: mduerig@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110607094157.162C12388A2C@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: mduerig Date: Tue Jun 7 09:41:56 2011 New Revision: 1132927 URL: http://svn.apache.org/viewvc?rev=1132927&view=rev Log: MicroKernel prototype (WIP) adding relativize method as inverse of concat method Modified: jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/util/PathUtil.java Modified: jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/util/PathUtil.java URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/util/PathUtil.java?rev=1132927&r1=1132926&r2=1132927&view=diff ============================================================================== --- jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/util/PathUtil.java (original) +++ jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/util/PathUtil.java Tue Jun 7 09:41:56 2011 @@ -72,4 +72,20 @@ public class PathUtil { buf.append(nameOrRelativePath); return buf.toString(); } + + /** + * relativize(path1, concat(path1, path2)) == path2 + */ + public static String relativize(String parentPath, String path) { + String prefix = parentPath.charAt(parentPath.length() - 1) == '/' + ? parentPath + : parentPath + '/'; + + if (path.startsWith(prefix)) { + return path.substring(prefix.length()); + } + else { + throw new IllegalAccessError("Cannot relativize " + path + " wrt. " + parentPath); + } + } }