jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From resc...@apache.org
Subject svn commit: r816246 - in /jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml: DocViewImportHandler.java Importer.java SessionImporter.java SysViewImportHandler.java
Date Thu, 17 Sep 2009 15:55:52 GMT
Author: reschke
Date: Thu Sep 17 15:55:52 2009
New Revision: 816246

URL: http://svn.apache.org/viewvc?rev=816246&view=rev
Log:
JCR-2087: parametrize generic types

Modified:
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/DocViewImportHandler.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/Importer.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/SessionImporter.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/SysViewImportHandler.java

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/DocViewImportHandler.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/DocViewImportHandler.java?rev=816246&r1=816245&r2=816246&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/DocViewImportHandler.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/DocViewImportHandler.java
Thu Sep 17 15:55:52 2009
@@ -33,6 +33,7 @@
 import java.io.IOException;
 import java.io.Reader;
 import java.util.ArrayList;
+import java.util.List;
 import java.util.Stack;
 
 /**
@@ -49,7 +50,7 @@
      * in the startElement method and is popped from the stack in the
      * endElement method.
      */
-    private final Stack stack = new Stack();
+    private final Stack<Importer.NodeInfo> stack = new Stack<Importer.NodeInfo>();
     // buffer used to merge adjacent character data
     private BufferedStringValue textHandler = new BufferedStringValue();
 
@@ -133,7 +134,7 @@
                         new Importer.NodeInfo(NameConstants.JCR_XMLTEXT, null, null, null);
                 Importer.TextValue[] values =
                         new Importer.TextValue[]{textHandler};
-                ArrayList props = new ArrayList();
+                List<Importer.PropInfo> props = new ArrayList<Importer.PropInfo>();
                 Importer.PropInfo prop =
                         new Importer.PropInfo(NameConstants.JCR_XMLCHARACTERS, PropertyType.STRING,
values);
                 props.add(prop);
@@ -177,7 +178,7 @@
             Name nodeTypeName = null;
             Name[] mixinTypes = null;
 
-            ArrayList props = new ArrayList(atts.getLength());
+            List<Importer.PropInfo> props = new ArrayList<Importer.PropInfo>(atts.getLength());
             for (int i = 0; i < atts.getLength(); i++) {
                 if (atts.getURI(i).equals(Name.NS_XMLNS_URI)) {
                     // skip namespace declarations reported as attributes
@@ -287,7 +288,7 @@
         // process buffered character data
         processCharacters();
 
-        Importer.NodeInfo node = (Importer.NodeInfo) stack.peek();
+        Importer.NodeInfo node = stack.peek();
         try {
             // call Importer
             importer.endNode(node);

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/Importer.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/Importer.java?rev=816246&r1=816245&r2=816246&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/Importer.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/Importer.java
Thu Sep 17 15:55:52 2009
@@ -41,7 +41,7 @@
      * context.
      * @throws RepositoryException
      */
-    void startNode(NodeInfo nodeInfo, List propInfos, NamePathResolver resolver)
+    void startNode(NodeInfo nodeInfo, List<PropInfo> propInfos, NamePathResolver resolver)
             throws RepositoryException;
 
     /**

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/SessionImporter.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/SessionImporter.java?rev=816246&r1=816245&r2=816246&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/SessionImporter.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/SessionImporter.java
Thu Sep 17 15:55:52 2009
@@ -68,7 +68,6 @@
 import java.io.Reader;
 import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Stack;
 import java.util.UUID;
@@ -86,7 +85,7 @@
     private final SessionImpl session;
     private final SessionItemStateManager stateMgr;
 
-    private final Stack parents;
+    private final Stack<NodeState> parents;
 
     private boolean importerClosed;
     private boolean sessionClosed;
@@ -131,7 +130,7 @@
             session.getValidator().checkIsWritable(importTarget, options);
 
             refTracker = new ReferenceChangeTracker();
-            parents = new Stack();
+            parents = new Stack<NodeState>();
             parents.push(importTarget);
         } catch (ItemNotFoundException e) {
             throw new PathNotFoundException(LogUtil.safeGetJCRPath(parentPath, session.getPathResolver()));
@@ -143,21 +142,21 @@
      * {@inheritDoc}
      */
     public void start() throws RepositoryException {
-        // explicitely set status of importer and start listening on session
+        // explicitly set status of importer and start listening on session
         setClosed(false);
     }
 
    /**
      * {@inheritDoc}
      */
-    public void startNode(NodeInfo nodeInfo, List propInfos, NamePathResolver resolver)
+    public void startNode(NodeInfo nodeInfo, List<PropInfo> propInfos, NamePathResolver
resolver)
             throws RepositoryException {
        if (isClosed()) {
            // workspace-importer only: ignore if import has been aborted before.
            return;
        }
        checkSession();
-       NodeState parent = (NodeState) parents.peek();
+       NodeState parent = parents.peek();
        if (parent == null) {
            // parent node was skipped, skip this child node also
            parents.push(null); // push null onto stack for skipped node
@@ -226,9 +225,7 @@
        // node state may be 'null' if applicable def is protected
        if (nodeState != null) {
            // process properties
-           Iterator iter = propInfos.iterator();
-           while (iter.hasNext()) {
-               PropInfo pi = (PropInfo) iter.next();
+    	   for (PropInfo pi : propInfos) {
                importProperty(pi, nodeState, resolver);
            }
        }
@@ -632,7 +629,7 @@
      * @throws RepositoryException
      */
     private void checkIncludesMixReferenceable(Importer.NodeInfo nodeInfo) throws RepositoryException
{
-        List l = new ArrayList();
+        List<Name> l = new ArrayList<Name>();
         l.add(nodeInfo.getNodeTypeName());
         Name[] mixinNames = nodeInfo.getMixinNames();
         if (mixinNames != null && mixinNames.length > 0) {
@@ -642,7 +639,7 @@
             // shortcut
             return;
         }
-        Name[] ntNames = (Name[]) l.toArray(new Name[l.size()]);
+        Name[] ntNames = l.toArray(new Name[l.size()]);
         EffectiveNodeType ent = session.getEffectiveNodeTypeProvider().getEffectiveNodeType(ntNames);
         if (!ent.includesNodeType(NameConstants.MIX_REFERENCEABLE)) {
             throw new ConstraintViolationException("XML defines jcr:uuid without defining
import node to be referenceable.");

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/SysViewImportHandler.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/SysViewImportHandler.java?rev=816246&r1=816245&r2=816246&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/SysViewImportHandler.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/SysViewImportHandler.java
Thu Sep 17 15:55:52 2009
@@ -29,7 +29,7 @@
 import javax.jcr.RepositoryException;
 import java.io.IOException;
 import java.util.ArrayList;
-import java.util.Iterator;
+import java.util.List;
 import java.util.Stack;
 
 /**
@@ -58,7 +58,7 @@
      * the same instance is popped from the stack in the endElement method
      * when the corresponding sv:node element is encountered.
      */
-    private final Stack stack = new Stack();
+    private final Stack<ImportState> stack = new Stack<ImportState>();
 
     /**
      * fields used temporarily while processing sv:property and sv:value elements
@@ -66,7 +66,7 @@
     private Name currentPropName;
     private int currentPropType = PropertyType.UNDEFINED;
     // list of AppendableValue objects
-    private ArrayList currentPropValues = new ArrayList();
+    private List<Importer.TextValue> currentPropValues = new ArrayList<Importer.TextValue>();
     private AppendableValue currentPropValue;
 
     /**
@@ -86,7 +86,7 @@
         }
         Name[] mixins = null;
         if (state.mixinNames != null) {
-            mixins = (Name[]) state.mixinNames.toArray(new Name[state.mixinNames.size()]);
+            mixins = state.mixinNames.toArray(new Name[state.mixinNames.size()]);
         }
         Importer.NodeInfo nodeInfo = new Importer.NodeInfo(state.nodeName, state.nodeTypeName,
mixins, state.uuid);
 
@@ -98,8 +98,7 @@
             if (start) {
                 importer.startNode(nodeInfo, state.props, resolver);
                 // dispose temporary property values
-                for (Iterator iter = state.props.iterator(); iter.hasNext();) {
-                    Importer.PropInfo pi = (Importer.PropInfo) iter.next();
+                for (Importer.PropInfo pi : state.props) {
                     disposePropertyValues(pi);
                 }
             }
@@ -136,7 +135,7 @@
 
             if (!stack.isEmpty()) {
                 // process current node first
-                ImportState current = (ImportState) stack.peek();
+                ImportState current = stack.peek();
                 // need to start current node
                 if (!current.started) {
                     processNode(current, true, false);
@@ -232,7 +231,7 @@
     public void endElement(String namespaceURI, String localName, String qName)
             throws SAXException {
         // check element name
-        ImportState state = (ImportState) stack.peek();
+        ImportState state = stack.peek();
         if (NODE.equals(localName)) {
             // sv:node element
             if (!state.started) {
@@ -265,7 +264,7 @@
                 }
             } else if (currentPropName.equals(NameConstants.JCR_MIXINTYPES)) {
                 if (state.mixinNames == null) {
-                    state.mixinNames = new ArrayList(currentPropValues.size());
+                    state.mixinNames = new ArrayList<Name>(currentPropValues.size());
                 }
                 for (int i = 0; i < currentPropValues.size(); i++) {
                     AppendableValue val =
@@ -291,7 +290,7 @@
                     throw new SAXException("error while retrieving value", ioe);
                 }
             } else {
-                Importer.TextValue[] values = (Importer.TextValue[]) currentPropValues.toArray(new
Importer.TextValue[currentPropValues.size()]);
+                Importer.TextValue[] values = currentPropValues.toArray(new Importer.TextValue[currentPropValues.size()]);
                 Importer.PropInfo prop = new Importer.PropInfo(currentPropName, currentPropType,
values);
                 state.props.add(prop);
             }
@@ -320,7 +319,7 @@
         /**
          * list of mixin types of current node
          */
-        ArrayList mixinNames;
+        List<Name> mixinNames;
         /**
          * uuid of current node
          */
@@ -329,7 +328,7 @@
         /**
          * list of PropInfo instances representing properties of current node
          */
-        ArrayList props = new ArrayList();
+        List<Importer.PropInfo> props = new ArrayList<Importer.PropInfo>();
 
         /**
          * flag indicating whether startNode() has been called for current node



Mime
View raw message