jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1167122 - /jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/ChildNodeEntriesImpl.java
Date Fri, 09 Sep 2011 12:08:44 GMT
Author: mduerig
Date: Fri Sep  9 12:08:43 2011
New Revision: 1167122

URL: http://svn.apache.org/viewvc?rev=1167122&view=rev
Log:
Microkernel based Jackrabbit prototype (WIP) 
refactor: remove suppress unchecked

Modified:
    jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/ChildNodeEntriesImpl.java

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/ChildNodeEntriesImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/ChildNodeEntriesImpl.java?rev=1167122&r1=1167121&r2=1167122&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/ChildNodeEntriesImpl.java
(original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/ChildNodeEntriesImpl.java
Fri Sep  9 12:08:43 2011
@@ -719,7 +719,7 @@ final class ChildNodeEntriesImpl impleme
          * @return a single {@code NodeEntry} or a {@code List} of
          * NodeEntry objects.
          */
-        private Object get(Name qName) {
+        private Object get0(Name qName) {
             LinkedEntries.LinkNode val = nameMap.get(qName);
             if (val != null) {
                 return val.getNodeEntry();
@@ -737,6 +737,32 @@ final class ChildNodeEntriesImpl impleme
         }
 
         /**
+         * Returns a single {@code NodeEntry} or an unmodifiable
+         * {@code List} of NodeEntry objects.
+         *
+         *
+         * @param qName
+         * @return a single {@code NodeEntry} or a {@code List} of
+         * NodeEntry objects.
+         */
+        private List<NodeEntry> get(Name qName) {
+            LinkedEntries.LinkNode val = nameMap.get(qName);
+            if (val != null) {
+                return Collections.singletonList(val.getNodeEntry());
+            } else {
+                List<LinkedEntries.LinkNode> l = snsMap.get(qName);
+                if (l != null) {
+                    List<NodeEntry> nodeEntries = new ArrayList<NodeEntry>(l.size());
+                    for (LinkedEntries.LinkNode ln : l) {
+                        nodeEntries.add(ln.getNodeEntry());
+                    }
+                    return nodeEntries;
+                }
+            }
+            return null;
+        }
+
+        /**
          * Returns a unmodifiable List of NodeEntry objects even if the name map
          * only contains a single entry for the given name. If no matching entry
          * exists for the given {@code Name} an empty list is returned.
@@ -744,36 +770,20 @@ final class ChildNodeEntriesImpl impleme
          * @param name
          * @return list of entries or an empty list.
          */
-        @SuppressWarnings("unchecked")
         public List<NodeEntry> getList(Name name) {
-            Object obj = get(name);
-            if (obj == null) {
+            List<NodeEntry> nodeEntries = get(name);
+            if (nodeEntries == null) {
                 return Collections.emptyList();
-            } else if (obj instanceof List) {
-                List<NodeEntry> l = new ArrayList<NodeEntry>((List<NodeEntry>)
obj);
-                return Collections.unmodifiableList(l);
-            } else {
-                // NodeEntry
-                return Collections.singletonList((NodeEntry)obj);
+            } else  {
+                return Collections.unmodifiableList(new ArrayList<NodeEntry>(nodeEntries));
             }
         }
 
-        @SuppressWarnings("unchecked")
         public NodeEntry getNodeEntry(Name name, int index) {
-            Object obj = get(name);
-            if (obj == null) {
-                return null;
-            }
-            if (obj instanceof List) {
-                // map entry is a list of siblings
-                return findMatchingEntry((List<NodeEntry>) obj, index);
-            } else {
-                // map entry is a single child node entry
-                if (index == Path.INDEX_DEFAULT) {
-                    return (NodeEntry) obj;
-                }
-            }
-            return null;
+            List<NodeEntry> obj = get(name);
+            return obj == null
+                ? null
+                : findMatchingEntry(obj, index);
         }
 
         public LinkedEntries.LinkNode getLinkNode(Name name, int index) {



Mime
View raw message