jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r915835 - in /jackrabbit/trunk: jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/ jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/ jackrabbit-spi-commons/src/main/java/org/apache/jackra...
Date Wed, 24 Feb 2010 15:49:32 GMT
Author: angela
Date: Wed Feb 24 15:49:32 2010
New Revision: 915835

URL: http://svn.apache.org/viewvc?rev=915835&view=rev
Log:
simplify by using foreach

Modified:
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeManagerImpl.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/AbstractNodeType.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/ValueFormat.java

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeManagerImpl.java?rev=915835&r1=915834&r2=915835&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeManagerImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeManagerImpl.java
Wed Feb 24 15:49:32 2010
@@ -305,8 +305,8 @@
     public NodeTypeIterator getAllNodeTypes() throws RepositoryException {
         Name[] ntNames = ntReg.getRegisteredNodeTypes();
         ArrayList<NodeType> list = new ArrayList<NodeType>(ntNames.length);
-        for (int i = 0; i < ntNames.length; i++) {
-            list.add(getNodeType(ntNames[i]));
+        for (Name ntName : ntNames) {
+            list.add(getNodeType(ntName));
         }
         return new NodeTypeIteratorAdapter(list);
     }
@@ -317,8 +317,8 @@
     public NodeTypeIterator getPrimaryNodeTypes() throws RepositoryException {
         Name[] ntNames = ntReg.getRegisteredNodeTypes();
         ArrayList<NodeType> list = new ArrayList<NodeType>(ntNames.length);
-        for (int i = 0; i < ntNames.length; i++) {
-            NodeType nt = getNodeType(ntNames[i]);
+        for (Name ntName : ntNames) {
+            NodeType nt = getNodeType(ntName);
             if (!nt.isMixin()) {
                 list.add(nt);
             }
@@ -332,8 +332,8 @@
     public NodeTypeIterator getMixinNodeTypes() throws RepositoryException {
         Name[] ntNames = ntReg.getRegisteredNodeTypes();
         ArrayList<NodeType> list = new ArrayList<NodeType>(ntNames.length);
-        for (int i = 0; i < ntNames.length; i++) {
-            NodeType nt = getNodeType(ntNames[i]);
+        for (Name ntName : ntNames) {
+            NodeType nt = getNodeType(ntName);
             if (nt.isMixin()) {
                 list.add(nt);
             }
@@ -387,8 +387,8 @@
         getNodeTypeRegistry().registerNodeTypes(defs, allowUpdate);
 
         List<NodeType> nts = new ArrayList<NodeType>();
-        for (Iterator<QNodeTypeDefinition> it = defs.iterator(); it.hasNext();) {
-            nts.add(getNodeType(it.next().getName()));
+        for (QNodeTypeDefinition def : defs) {
+            nts.add(getNodeType(def.getName()));
         }
         return new NodeTypeIteratorAdapter(nts);
 
@@ -419,73 +419,70 @@
             while (iter.hasNext()) {
                 NodeType nt = iter.nextNodeType();
                 ps.println(nt.getName());
-                NodeType[] supertypes = nt.getSupertypes();
                 ps.println("\tSupertypes");
-                for (int i = 0; i < supertypes.length; i++) {
-                    ps.println("\t\t" + supertypes[i].getName());
+                for (NodeType supertype : nt.getSupertypes()) {
+                    ps.println("\t\t" + supertype.getName());
                 }
                 ps.println("\tMixin\t" + nt.isMixin());
                 ps.println("\tOrderableChildNodes\t" + nt.hasOrderableChildNodes());
                 ps.println("\tPrimaryItemName\t" + (nt.getPrimaryItemName() == null ? "<null>"
: nt.getPrimaryItemName()));
-                PropertyDefinition[] pd = nt.getPropertyDefinitions();
-                for (int i = 0; i < pd.length; i++) {
+                for (PropertyDefinition aPd : nt.getPropertyDefinitions()) {
                     ps.print("\tPropertyDefinition");
-                    ps.println(" (declared in " + pd[i].getDeclaringNodeType().getName()
+ ") ");
-                    ps.println("\t\tName\t\t" + (pd[i].getName()));
-                    String type = pd[i].getRequiredType() == 0 ? "null" : PropertyType.nameFromValue(pd[i].getRequiredType());
+                    ps.println(" (declared in " + aPd.getDeclaringNodeType().getName() +
") ");
+                    ps.println("\t\tName\t\t" + (aPd.getName()));
+                    String type = aPd.getRequiredType() == 0 ? "null" : PropertyType.nameFromValue(aPd.getRequiredType());
                     ps.println("\t\tRequiredType\t" + type);
-                    String[] vca = pd[i].getValueConstraints();
+                    String[] vca = aPd.getValueConstraints();
                     StringBuffer constraints = new StringBuffer();
                     if (vca == null) {
                         constraints.append("<null>");
                     } else {
-                        for (int n = 0; n < vca.length; n++) {
+                        for (String aVca : vca) {
                             if (constraints.length() > 0) {
                                 constraints.append(", ");
                             }
-                            constraints.append(vca[n]);
+                            constraints.append(aVca);
                         }
                     }
                     ps.println("\t\tValueConstraints\t" + constraints.toString());
-                    Value[] defVals = pd[i].getDefaultValues();
+                    Value[] defVals = aPd.getDefaultValues();
                     StringBuffer defaultValues = new StringBuffer();
                     if (defVals == null) {
                         defaultValues.append("<null>");
                     } else {
-                        for (int n = 0; n < defVals.length; n++) {
+                        for (Value defVal : defVals) {
                             if (defaultValues.length() > 0) {
                                 defaultValues.append(", ");
                             }
-                            defaultValues.append(defVals[n].getString());
+                            defaultValues.append(defVal.getString());
                         }
                     }
                     ps.println("\t\tDefaultValue\t" + defaultValues.toString());
-                    ps.println("\t\tAutoCreated\t" + pd[i].isAutoCreated());
-                    ps.println("\t\tMandatory\t" + pd[i].isMandatory());
-                    ps.println("\t\tOnVersion\t" + OnParentVersionAction.nameFromValue(pd[i].getOnParentVersion()));
-                    ps.println("\t\tProtected\t" + pd[i].isProtected());
-                    ps.println("\t\tMultiple\t" + pd[i].isMultiple());
+                    ps.println("\t\tAutoCreated\t" + aPd.isAutoCreated());
+                    ps.println("\t\tMandatory\t" + aPd.isMandatory());
+                    ps.println("\t\tOnVersion\t" + OnParentVersionAction.nameFromValue(aPd.getOnParentVersion()));
+                    ps.println("\t\tProtected\t" + aPd.isProtected());
+                    ps.println("\t\tMultiple\t" + aPd.isMultiple());
                 }
-                NodeDefinition[] nd = nt.getChildNodeDefinitions();
-                for (int i = 0; i < nd.length; i++) {
+                for (NodeDefinition aNd : nt.getChildNodeDefinitions()) {
                     ps.print("\tNodeDefinition");
-                    ps.println(" (declared in " + nd[i].getDeclaringNodeType() + ") ");
-                    ps.println("\t\tName\t\t" + nd[i].getName());
-                    NodeType[] reqPrimaryTypes = nd[i].getRequiredPrimaryTypes();
+                    ps.println(" (declared in " + aNd.getDeclaringNodeType() + ") ");
+                    ps.println("\t\tName\t\t" + aNd.getName());
+                    NodeType[] reqPrimaryTypes = aNd.getRequiredPrimaryTypes();
                     if (reqPrimaryTypes != null && reqPrimaryTypes.length > 0)
{
-                        for (int n = 0; n < reqPrimaryTypes.length; n++) {
-                            ps.print("\t\tRequiredPrimaryType\t" + reqPrimaryTypes[n].getName());
+                        for (NodeType reqPrimaryType : reqPrimaryTypes) {
+                            ps.print("\t\tRequiredPrimaryType\t" + reqPrimaryType.getName());
                         }
                     }
-                    NodeType defPrimaryType = nd[i].getDefaultPrimaryType();
+                    NodeType defPrimaryType = aNd.getDefaultPrimaryType();
                     if (defPrimaryType != null) {
                         ps.print("\n\t\tDefaultPrimaryType\t" + defPrimaryType.getName());
                     }
-                    ps.println("\n\t\tAutoCreated\t" + nd[i].isAutoCreated());
-                    ps.println("\t\tMandatory\t" + nd[i].isMandatory());
-                    ps.println("\t\tOnVersion\t" + OnParentVersionAction.nameFromValue(nd[i].getOnParentVersion()));
-                    ps.println("\t\tProtected\t" + nd[i].isProtected());
-                    ps.println("\t\tAllowsSameNameSiblings\t" + nd[i].allowsSameNameSiblings());
+                    ps.println("\n\t\tAutoCreated\t" + aNd.isAutoCreated());
+                    ps.println("\t\tMandatory\t" + aNd.isMandatory());
+                    ps.println("\t\tOnVersion\t" + OnParentVersionAction.nameFromValue(aNd.getOnParentVersion()));
+                    ps.println("\t\tProtected\t" + aNd.isProtected());
+                    ps.println("\t\tAllowsSameNameSiblings\t" + aNd.allowsSameNameSiblings());
                 }
             }
             ps.println();

Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/AbstractNodeType.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/AbstractNodeType.java?rev=915835&r1=915834&r2=915835&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/AbstractNodeType.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/AbstractNodeType.java
Wed Feb 24 15:49:32 2010
@@ -267,9 +267,8 @@
             if (!nt.getName().equals(thisName)) {
                 if (directOnly) {
                     // direct subtypes only
-                    String[] names = nt.getDeclaredSupertypeNames();
-                    for (int i = 0; i < names.length; i++) {
-                        if (names[i].equals(thisName)) {
+                    for (String name : nt.getDeclaredSupertypeNames()) {
+                        if (name.equals(thisName)) {
                             result.add(nt);
                             break;
                         }
@@ -284,4 +283,4 @@
         }
         return new NodeTypeIteratorAdapter(result);
     }
-}
\ No newline at end of file
+}

Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/ValueFormat.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/ValueFormat.java?rev=915835&r1=915834&r2=915835&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/ValueFormat.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/ValueFormat.java
Wed Feb 24 15:49:32 2010
@@ -84,13 +84,13 @@
         if (jcrValues == null) {
             throw new IllegalArgumentException("null value");
         }
-        List qValues = new ArrayList();
-        for (int i = 0; i < jcrValues.length; i++) {
-            if (jcrValues[i] != null) {
-                qValues.add(getQValue(jcrValues[i], resolver, factory));
+        List<QValue> qValues = new ArrayList<QValue>();
+        for (Value jcrValue : jcrValues) {
+            if (jcrValue != null) {
+                qValues.add(getQValue(jcrValue, resolver, factory));
             }
         }
-        return (QValue[]) qValues.toArray(new QValue[qValues.size()]);
+        return qValues.toArray(new QValue[qValues.size()]);
     }
 
     /**
@@ -231,4 +231,4 @@
         }
         return jcrString;
     }
-}
\ No newline at end of file
+}



Mime
View raw message