jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1126926 - /jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/ItemInfoBuilder.java
Date Tue, 24 May 2011 08:36:42 GMT
Author: mduerig
Date: Tue May 24 08:36:41 2011
New Revision: 1126926

URL: http://svn.apache.org/viewvc?rev=1126926&view=rev
Log:
JCR-2972: Allow name to be set in PropertyInfoBuilder and NodeInfoBuilder

Modified:
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/ItemInfoBuilder.java

Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/ItemInfoBuilder.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/ItemInfoBuilder.java?rev=1126926&r1=1126925&r2=1126926&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/ItemInfoBuilder.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/ItemInfoBuilder.java
Tue May 24 08:36:41 2011
@@ -147,9 +147,9 @@ public final class ItemInfoBuilder {
      */
     public static class NodeInfoBuilder {
         private final NodeInfoBuilder parent;
-        private final String name;
         private final Listener listener;
 
+        private String name;
         private int index = Path.INDEX_DEFAULT;
         private Name primaryTypeName = NameConstants.NT_UNSTRUCTURED;
         private final List<Name> mixins = new ArrayList<Name>();
@@ -193,6 +193,15 @@ public final class ItemInfoBuilder {
         }
 
         /**
+         * Create a new child {@link PropertyInfo} on this {@link NodeInfo}.
+         *
+         * @return  <code>this</code>
+         */
+        public PropertyInfoBuilder createPropertyInfo() {
+            return new PropertyInfoBuilder(this, null, listener);
+        }
+
+        /**
          * Create a new child {@link NodeInfo} on this NodeInfo with a given <code>name</code>.
          * @param name
          * @return  <code>this</code>
@@ -202,6 +211,25 @@ public final class ItemInfoBuilder {
         }
 
         /**
+         * Create a new child {@link NodeInfo} on this NodeInfo.
+
+         * @return  <code>this</code>
+         */
+        public NodeInfoBuilder createNodeInfo() {
+            return new NodeInfoBuilder(this, null, listener);
+        }
+
+        /**
+         * Set the name of the node
+
+         * @param name
+         * @return
+         */
+        public NodeInfoBuilder setName(String name) {
+            this.name = name;
+            return this;
+        }
+        /**
          * Set the index.
          * @see NodeInfo#getIndex()
          *
@@ -325,6 +353,10 @@ public final class ItemInfoBuilder {
         }
 
         private Path getPath() throws RepositoryException {
+            if (this.name == null) {
+                throw new IllegalStateException("Name not set");
+            }
+            
             if (parent == null) {
                 return PathFactoryImpl.getInstance().getRootPath();
             }
@@ -367,9 +399,9 @@ public final class ItemInfoBuilder {
      */
     public static class PropertyInfoBuilder {
         private final NodeInfoBuilder parent;
-        private final String name;
         private final Listener listener;
 
+        private String name;
         private final List<QValue> values = new ArrayList<QValue>();
         private int type = PropertyType.UNDEFINED;
         private boolean isMultivalued = true;
@@ -385,6 +417,17 @@ public final class ItemInfoBuilder {
         }
 
         /**
+         * Set the name of this property
+         *
+         * @param name
+         * @return
+         */
+        public PropertyInfoBuilder setName(String name) {
+            this.name = name;
+            return this;
+        }
+
+        /**
          * Set the <code>{@link PropertyType type}</code> of this property
          *
          * @param type
@@ -601,6 +644,9 @@ public final class ItemInfoBuilder {
             else if (type == PropertyType.UNDEFINED) {
                 throw new IllegalStateException("Type not set");
             }
+            else if (this.name == null) {
+                throw new IllegalStateException("Name not set");
+            }
             else {
                 stale = true;
 



Mime
View raw message