felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rickh...@apache.org
Subject svn commit: r375903 - in /incubator/felix/trunk/org.apache.felix.framework/src/main/java/org/apache/felix/moduleloader: ContentDirectoryContent.java JarContent.java
Date Wed, 08 Feb 2006 09:10:14 GMT
Author: rickhall
Date: Wed Feb  8 01:10:13 2006
New Revision: 375903

URL: http://svn.apache.org/viewcvs?rev=375903&view=rev
Log:
Modified ContentDirectoryContent.getEntryPaths() to return entry paths
as if the path associated with the object is the root of the content; this
makes logical sense, but it really doesn't matter since no one should
actually use this method for this type of content.

Modified:
    incubator/felix/trunk/org.apache.felix.framework/src/main/java/org/apache/felix/moduleloader/ContentDirectoryContent.java
    incubator/felix/trunk/org.apache.felix.framework/src/main/java/org/apache/felix/moduleloader/JarContent.java

Modified: incubator/felix/trunk/org.apache.felix.framework/src/main/java/org/apache/felix/moduleloader/ContentDirectoryContent.java
URL: http://svn.apache.org/viewcvs/incubator/felix/trunk/org.apache.felix.framework/src/main/java/org/apache/felix/moduleloader/ContentDirectoryContent.java?rev=375903&r1=375902&r2=375903&view=diff
==============================================================================
--- incubator/felix/trunk/org.apache.felix.framework/src/main/java/org/apache/felix/moduleloader/ContentDirectoryContent.java
(original)
+++ incubator/felix/trunk/org.apache.felix.framework/src/main/java/org/apache/felix/moduleloader/ContentDirectoryContent.java
Wed Feb  8 01:10:13 2006
@@ -23,14 +23,14 @@
 public class ContentDirectoryContent implements IContent
 {
     private IContent m_content = null;
-    private String m_path = null;
+    private String m_rootPath = null;
     private boolean m_opened = false;
 
     public ContentDirectoryContent(IContent content, String path)
     {
         m_content = content;
         // Add a '/' to the end if not present.
-        m_path = (path.length() > 0) && (path.charAt(path.length() - 1) != '/')
+        m_rootPath = (path.length() > 0) && (path.charAt(path.length() - 1) !=
'/')
             ? path + "/" : path;
     }
 
@@ -78,7 +78,7 @@
             name = name.substring(1);
         }
 
-        return m_content.hasEntry(m_path + name);
+        return m_content.hasEntry(m_rootPath + name);
     }
 
     public synchronized byte[] getEntry(String name) throws IllegalStateException
@@ -93,7 +93,7 @@
             name = name.substring(1);
         }
 
-        return m_content.getEntry(m_path + name);
+        return m_content.getEntry(m_rootPath + name);
     }
 
     public synchronized InputStream getEntryAsStream(String name)
@@ -109,7 +109,7 @@
             name = name.substring(1);
         }
 
-        return m_content.getEntryAsStream(m_path + name);
+        return m_content.getEntryAsStream(m_rootPath + name);
     }
 
     public synchronized Enumeration getEntryPaths(String path)
@@ -124,11 +124,38 @@
             path = path.substring(1);
         }
 
-        return m_content.getEntryPaths(m_path + path);
+System.out.println("GET ENTRY PATHS FOR " + m_rootPath + path);
+        return new WrappedEnumeration(m_content.getEntryPaths(m_rootPath + path), m_rootPath);
     }
 
     public String toString()
     {
-        return "CONTENT DIR " + m_path + " (" + m_content + ")";
+        return "CONTENT DIR " + m_rootPath + " (" + m_content + ")";
+    }
+
+    private static class WrappedEnumeration implements Enumeration
+    {
+        private Enumeration m_enumeration = null;
+        private String m_rootPath = null;
+
+        public WrappedEnumeration(Enumeration enumeration, String rootPath)
+        {
+            m_enumeration = enumeration;
+            m_rootPath = rootPath;
+        }
+
+        public boolean hasMoreElements()
+        {
+            return m_enumeration.hasMoreElements();
+        }
+
+        public Object nextElement()
+        {
+            // We need to treat the specified path as the root of the
+            // content, so we need to strip off the leading path from
+            // each entry because it is automatically added back on
+            // in the other calls above.
+            return ((String) m_enumeration.nextElement()).substring(m_rootPath.length());
+        }
     }
 }

Modified: incubator/felix/trunk/org.apache.felix.framework/src/main/java/org/apache/felix/moduleloader/JarContent.java
URL: http://svn.apache.org/viewcvs/incubator/felix/trunk/org.apache.felix.framework/src/main/java/org/apache/felix/moduleloader/JarContent.java?rev=375903&r1=375902&r2=375903&view=diff
==============================================================================
--- incubator/felix/trunk/org.apache.felix.framework/src/main/java/org/apache/felix/moduleloader/JarContent.java
(original)
+++ incubator/felix/trunk/org.apache.felix.framework/src/main/java/org/apache/felix/moduleloader/JarContent.java
Wed Feb  8 01:10:13 2006
@@ -123,7 +123,7 @@
             }
             catch (IOException ex)
             {
-                System.err.println("JarResourceSource: " + ex);
+                System.err.println("JarContent: " + ex);
                 return null;
             }
         }
@@ -194,7 +194,7 @@
             }
             catch (IOException ex)
             {
-                System.err.println("JarResourceSource: " + ex);
+                System.err.println("JarContent: " + ex);
                 return null;
             }
         }
@@ -239,7 +239,7 @@
             }
             catch (IOException ex)
             {
-                System.err.println("JarResourceSource: " + ex);
+                System.err.println("JarContent: " + ex);
                 return null;
             }
         }



Mime
View raw message