Author: spagop
Date: 2008-08-28 15:46:29 -0400 (Thu, 28 Aug 2008)
New Revision: 477
Added:
trunk/dna-common/src/main/java/org/jboss/dna/common/util/JcrUtil.java
Log:
JcrUtils - createPathWithIndex ans createPath without index
Added: trunk/dna-common/src/main/java/org/jboss/dna/common/util/JcrUtil.java
===================================================================
--- trunk/dna-common/src/main/java/org/jboss/dna/common/util/JcrUtil.java
(rev 0)
+++ trunk/dna-common/src/main/java/org/jboss/dna/common/util/JcrUtil.java 2008-08-28
19:46:29 UTC (rev 477)
@@ -0,0 +1,61 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.dna.common.util;
+
+/**
+ * @author Serge Pagop
+ *
+ */
+public class JcrUtil {
+
+ /**
+ * Create a path for the tree with index.
+ *
+ * @param path the path.
+ * @param index the index begin with 1.
+ * @return the string
+ * @throws IllegalArgumentException if the path is null, blank or empty, or if the
index is not a positive value
+ */
+ public static String createPathWithIndex( String path,
+ int index ) {
+ ArgCheck.isNotEmpty(path, "path");
+ ArgCheck.isPositive(index, "index");
+ return path + "[" + index + "]";
+ }
+
+ /**
+ * Create a path for the tree without index.
+ *
+ * @param path - the path.
+ * @return the string
+ * @throws IllegalArgumentException if the path is null, blank or empty
+ */
+ public static String createPath( String path ) {
+ ArgCheck.isNotEmpty(path, "path");
+ return path;
+ }
+
+ private JcrUtil() {
+ // prevent construction
+ }
+
+}