jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r158757 - in incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/xml: CommonFormat.java NodeDefFormat.java NodeTypeFormat.java PropDefFormat.java
Date Wed, 23 Mar 2005 12:33:12 GMT
Author: jukka
Date: Wed Mar 23 04:33:11 2005
New Revision: 158757

URL: http://svn.apache.org/viewcvs?view=rev&rev=158757
Log:
Use object arrays internally for better type safety (JCR-54)
 - suggested by Angela Schreiber

Modified:
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/xml/CommonFormat.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/xml/NodeDefFormat.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/xml/NodeTypeFormat.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/xml/PropDefFormat.java

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/xml/CommonFormat.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/xml/CommonFormat.java?view=diff&r1=158756&r2=158757
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/xml/CommonFormat.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/xml/CommonFormat.java
Wed Mar 23 04:33:11 2005
@@ -157,7 +157,7 @@
      * @param childName child element name
      * @return child element iterator
      */
-    protected Iterator getChildElements(String childName) {
+    protected Element[] getChildElements(String childName) {
         Vector children = new Vector();
 
         NodeList nodes = element.getChildNodes();
@@ -169,7 +169,7 @@
             }
         }
 
-        return children.iterator();
+        return (Element[]) children.toArray(new Element[0]);
     }
 
     /**
@@ -181,7 +181,7 @@
      * @param grandChildName grand child element name
      * @return grand child contents, or <code>null</code>
      */
-    protected Collection getGrandChildContents(
+    protected String[] getGrandChildContents(
             String childName, String grandChildName) {
         NodeList children = element.getChildNodes();
         for (int i = 0; i < children.getLength(); i++ ) {
@@ -199,7 +199,7 @@
                     }
                 }
 
-                return contents;
+                return (String[]) contents.toArray(new String[0]);
             }
         }
 

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/xml/NodeDefFormat.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/xml/NodeDefFormat.java?view=diff&r1=158756&r2=158757
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/xml/NodeDefFormat.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/xml/NodeDefFormat.java
Wed Mar 23 04:33:11 2005
@@ -16,8 +16,6 @@
  */
 package org.apache.jackrabbit.core.nodetype.xml;
 
-import java.util.Collection;
-import java.util.Iterator;
 import java.util.Vector;
 
 import org.apache.jackrabbit.core.NamespaceResolver;
@@ -94,17 +92,13 @@
      *                                    definition element is invalid
      */
     private void readRequiredPrimaryTypes() throws InvalidNodeTypeDefException {
-        Collection types = getGrandChildContents(
+        String[] types = getGrandChildContents(
                 REQUIREDPRIMARYTYPES_ELEMENT, REQUIREDPRIMARYTYPE_ELEMENT);
         if (types != null) {
             Vector vector = new Vector();
-
-            Iterator iterator = types.iterator();
-            while (iterator.hasNext()) {
-                String type = (String) iterator.next();
-                vector.add(fromJCRName(type));
+            for (int i = 0; i < types.length; i++) {
+                vector.add(fromJCRName(types[i]));
             }
-
             def.setRequiredPrimaryTypes((QName[]) vector.toArray(new QName[0]));
         } else {
             /* Default to nt:base?

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/xml/NodeTypeFormat.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/xml/NodeTypeFormat.java?view=diff&r1=158756&r2=158757
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/xml/NodeTypeFormat.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/xml/NodeTypeFormat.java
Wed Mar 23 04:33:11 2005
@@ -16,8 +16,6 @@
  */
 package org.apache.jackrabbit.core.nodetype.xml;
 
-import java.util.Collection;
-import java.util.Iterator;
 import java.util.Vector;
 
 import org.apache.jackrabbit.core.NamespaceResolver;
@@ -125,16 +123,13 @@
      *                                    definition element is invalid
      */
     private void readSupertypes() throws InvalidNodeTypeDefException {
-        Collection types =
+        String[] types =
             getGrandChildContents(SUPERTYPES_ELEMENT, SUPERTYPE_ELEMENT);
         if (types != null) {
             Vector vector = new Vector();
-
-            Iterator iterator = types.iterator();
-            while (iterator.hasNext()) {
-                vector.add(fromJCRName((String) iterator.next()));
+            for (int i = 0; i < types.length; i++) {
+                vector.add(fromJCRName(types[i]));
             }
-
             def.setSupertypes((QName[]) vector.toArray(new QName[0]));
         }
     }
@@ -232,12 +227,11 @@
     private void readPropertyDefinitions() throws InvalidNodeTypeDefException {
         Vector vector = new Vector();
 
-        Iterator iterator = getChildElements(PROPERTYDEF_ELEMENT);
-        while (iterator.hasNext()) {
+        Element[] elements = getChildElements(PROPERTYDEF_ELEMENT);
+        for (int i = 0; i < elements.length; i++) {
             PropDef property = new PropDef();
-            Element element = (Element) iterator.next();
-            PropDefFormat format =
-                new PropDefFormat(getNamespaceResolver(), element, property);
+            PropDefFormat format = new PropDefFormat(
+                    getNamespaceResolver(), elements[i], property);
             format.read(def.getName());
             vector.add(property);
         }
@@ -272,12 +266,11 @@
     private void readChildNodeDefinitions() throws InvalidNodeTypeDefException {
         Vector vector = new Vector();
 
-        Iterator iterator = getChildElements(CHILDNODEDEF_ELEMENT);
-        while (iterator.hasNext()) {
+        Element[] elements = getChildElements(CHILDNODEDEF_ELEMENT);
+        for (int i = 0; i < elements.length; i++) {
             ChildNodeDef node = new ChildNodeDef();
-            Element element = (Element) iterator.next();
             NodeDefFormat format =
-                new NodeDefFormat(getNamespaceResolver(), element, node);
+                new NodeDefFormat(getNamespaceResolver(), elements[i], node);
             format.read(def.getName());
             vector.add(node);
         }

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/xml/PropDefFormat.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/xml/PropDefFormat.java?view=diff&r1=158756&r2=158757
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/xml/PropDefFormat.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/xml/PropDefFormat.java
Wed Mar 23 04:33:11 2005
@@ -16,8 +16,6 @@
  */
 package org.apache.jackrabbit.core.nodetype.xml;
 
-import java.util.Collection;
-import java.util.Iterator;
 import java.util.Vector;
 
 import javax.jcr.PropertyType;
@@ -124,21 +122,19 @@
      *                                      definition element is invalid
      */
     private void readValueConstraints() throws InvalidNodeTypeDefException {
-        Collection constraints = getGrandChildContents(
+        String[] constraints = getGrandChildContents(
                 VALUECONSTRAINTS_ELEMENT, VALUECONSTRAINT_ELEMENT);
         if (constraints != null) {
             Vector vector = new Vector();
 
             int type = def.getRequiredType();
-            Iterator iterator = constraints.iterator();
-            while (iterator.hasNext()) {
-                String constraint = (String) iterator.next();
+            for (int i = 0; i < constraints.length; i++) {
                 try {
                     vector.add(ValueConstraint.create(
-                            type, constraint, getNamespaceResolver()));
+                            type, constraints[i], getNamespaceResolver()));
                 } catch (InvalidConstraintException e) {
                     throw new InvalidNodeTypeDefException(
-                            "Invalid value constraint " + constraint, e);
+                            "Invalid value constraint " + constraints[i], e);
                 }
             }
 
@@ -166,7 +162,7 @@
      * Reads and sets the default values of the property definition.
      */
     private void readDefaultValues() {
-        Collection defaults = getGrandChildContents(
+        String[] defaults = getGrandChildContents(
                 DEFAULTVALUES_ELEMENT, DEFAULTVALUE_ELEMENT);
         if (defaults != null) {
             Vector vector = new Vector();
@@ -175,10 +171,8 @@
             if (type == PropertyType.UNDEFINED) {
                 type = PropertyType.STRING;
             }
-            Iterator iterator = defaults.iterator();
-            while (iterator.hasNext()) {
-                String value = (String) iterator.next();
-                vector.add(InternalValue.valueOf(value, type));
+            for (int i = 0; i < defaults.length; i++) {
+                vector.add(InternalValue.valueOf(defaults[i], type));
             }
 
             def.setDefaultValues(



Mime
View raw message