Permalink
Browse files

[maven-scm] copy for tag 2.0.0.Beta7

  • Loading branch information...
1 parent 6a63ba4 commit d452d0f90d8f8ef8ca8d57964924aa2aebe41bad @alesj alesj committed Jan 17, 2008
Showing with 340 additions and 225 deletions.
  1. +4 −4 pom.xml
  2. +24 −4 src/main/java/org/jboss/virtual/VFS.java
  3. +1 −1 src/main/java/org/jboss/virtual/VFSUtils.java
  4. +27 −4 src/main/java/org/jboss/virtual/VirtualFile.java
  5. +3 −4 src/main/java/org/jboss/virtual/plugins/context/AbstractVFSContext.java
  6. +10 −10 src/main/java/org/jboss/virtual/plugins/context/AbstractVirtualFileHandler.java
  7. +2 −2 src/main/java/org/jboss/virtual/plugins/context/DelegatingHandler.java
  8. +5 −5 src/main/java/org/jboss/virtual/plugins/context/file/FileHandler.java
  9. +20 −22 src/main/java/org/jboss/virtual/plugins/context/file/LinkHandler.java
  10. +31 −33 src/main/java/org/jboss/virtual/plugins/context/jar/AbstractStructuredJarHandler.java
  11. +1 −1 src/main/java/org/jboss/virtual/plugins/context/jar/JarContext.java
  12. +24 −5 src/main/java/org/jboss/virtual/plugins/context/jar/JarEntryContents.java
  13. +23 −7 src/main/java/org/jboss/virtual/plugins/context/jar/JarEntryHandler.java
  14. +2 −2 src/main/java/org/jboss/virtual/plugins/context/jar/NestedJarFromStream.java
  15. +2 −2 src/main/java/org/jboss/virtual/plugins/context/jar/NoCopyNestedJarHandler.java
  16. +26 −8 src/main/java/org/jboss/virtual/plugins/context/jar/SynthenticDirEntryHandler.java
  17. +1 −1 src/main/java/org/jboss/virtual/plugins/context/memory/MemoryContextFactory.java
  18. +6 −10 src/main/java/org/jboss/virtual/plugins/context/memory/MemoryContextHandler.java
  19. +1 −1 src/main/java/org/jboss/virtual/plugins/context/vfs/AssembledDirectory.java
  20. +7 −10 src/main/java/org/jboss/virtual/plugins/context/vfs/AssembledDirectoryHandler.java
  21. +1 −1 src/main/java/org/jboss/virtual/plugins/context/vfs/AssembledFileHandler.java
  22. +1 −1 src/main/java/org/jboss/virtual/plugins/context/vfs/AssembledUrlStreamHandler.java
  23. +1 −1 src/main/java/org/jboss/virtual/plugins/context/vfs/ByteArrayHandler.java
  24. +1 −1 src/main/java/org/jboss/virtual/plugins/vfs/VirtualFileUrlStreamHandler.java
  25. +1 −1 src/main/java/org/jboss/virtual/protocol/vfsmemory/Handler.java
  26. +5 −5 src/main/java/org/jboss/virtual/spi/VFSContext.java
  27. +5 −5 src/main/java/org/jboss/virtual/spi/VirtualFileHandler.java
  28. +2 −2 src/test/java/org/jboss/test/virtual/support/MockSimpleVirtualFileHandler.java
  29. +6 −6 src/test/java/org/jboss/test/virtual/support/MockStructuredVirtualFileHandler.java
  30. +1 −1 src/test/java/org/jboss/test/virtual/test/AbstractMockVFSTest.java
  31. +8 −9 src/test/java/org/jboss/test/virtual/test/AbstractVFSContextTest.java
  32. +37 −37 src/test/java/org/jboss/test/virtual/test/AbstractVirtualFileHandlerTest.java
  33. +4 −7 src/test/java/org/jboss/test/virtual/test/AssembledContextTest.java
  34. +5 −5 src/test/java/org/jboss/test/virtual/test/FileVFSUnitTestCase.java
  35. +1 −1 src/test/java/org/jboss/test/virtual/test/MemoryTestCase.java
  36. +40 −5 src/test/java/org/jboss/test/virtual/test/VFSUnitTestCase.java
  37. +1 −1 src/test/java/org/jboss/test/virtual/test/VirtualFileUnitTestCase.java
View
@@ -8,14 +8,14 @@
<groupId>org.jboss</groupId>
<artifactId>jboss-vfs</artifactId>
<packaging>jar</packaging>
- <version>2.0.0-SNAPSHOT</version>
+ <version>2.0.0.Beta7</version>
<name>JBoss VFS</name>
<url>http://www.jboss.org</url>
<description>A VFS library</description>
<scm>
- <connection>scm:svn:https://svn.jboss.org/repos/jbossas/projects/vfs/tags/2.0.0.Beta6</connection>
- <developerConnection>scm:svn:https://svn.jboss.org/repos/jbossas/projects/vfs/tags/2.0.0.Beta6</developerConnection>
- <url>https://svn.jboss.org/repos/jbossas/projects/vfs/tags/2.0.0.Beta6</url>
+ <connection>scm:svn:https://svn.jboss.org/repos/jbossas/projects/vfs/tags/2.0.0.Beta7</connection>
+ <developerConnection>scm:svn:https://svn.jboss.org/repos/jbossas/projects/vfs/tags/2.0.0.Beta7</developerConnection>
+ <url>https://svn.jboss.org/repos/jbossas/projects/vfs/tags/2.0.0.Beta7</url>
</scm>
<licenses>
<license>
@@ -192,27 +192,47 @@ public VirtualFile getRoot() throws IOException
/**
* Find a child from the root
- *
+ *
* @param path the child path
* @return the child
* @throws IOException for any problem accessing the VFS (including the child does not exist)
* @throws IllegalArgumentException if the path is null
+ * @deprecated use getChild, and handle null if not found
*/
+ @Deprecated
public VirtualFile findChild(String path) throws IOException
{
if (path == null)
throw new IllegalArgumentException("Null path");
VirtualFileHandler handler = context.getRoot();
- path = VFSUtils.fixName(path);
- VirtualFileHandler result = context.findChild(handler, path);
+ VirtualFileHandler result = context.getChild(handler, VFSUtils.fixName(path));
+ if (result == null)
+ throw new IOException("Child not found " + path + " for " + handler);
return result.getVirtualFile();
}
/**
+ * Get a child
+ *
+ * @param path the child path
+ * @return the child or <code>null</code> if not found
+ * @throws IOException if a real problem occurs
+ */
+ public VirtualFile getChild(String path) throws IOException
+ {
+ if (path == null)
+ throw new IllegalArgumentException("Null path");
+
+ VirtualFileHandler handler = context.getRoot();
+ VirtualFileHandler result = context.getChild(handler, VFSUtils.fixName(path));
+ return result != null ? result.getVirtualFile() : null;
+ }
+
+ /**
* Find a child from the root
*
- * @Deprecated use {@link #findChild(String)}
+ * @deprecated use {@link #findChild(String)}
* @param path the child path
* @return the child
* @throws IOException for any problem accessing the VFS (including the child does not exist)
@@ -177,7 +177,7 @@ public static Manifest getManifest(VirtualFile archive) throws IOException
VirtualFile manifest;
try
{
- manifest = archive.findChild(JarFile.MANIFEST_NAME);
+ manifest = archive.findChild(JarFile.MANIFEST_NAME);
}
catch (IOException ignored)
{
@@ -371,19 +371,43 @@ public void visit(VirtualFileVisitor visitor) throws IOException
* @throws IOException for any problem accessing the VFS (including the child does not exist)
* @throws IllegalArgumentException if the path is null
* @throws IllegalStateException if the file is closed or it is a leaf node
+ * @deprecated use getChild, and handle null if not found
*/
+ @Deprecated
public VirtualFile findChild(String path) throws IOException
{
- VirtualFileHandler handler = getHandler();
+ if (path == null)
+ throw new IllegalArgumentException("Null path");
+ VirtualFileHandler handler = getHandler();
if (handler.isLeaf())
throw new IllegalStateException("File cannot contain children: " + this);
- path = VFSUtils.fixName(path);
- VirtualFileHandler child = handler.findChild(path);
+ VirtualFileHandler child = handler.getChild(VFSUtils.fixName(path));
+ if (child == null)
+ throw new IOException("Child not found " + path + " for " + handler);
return child.getVirtualFile();
}
+ /**
+ * Get a child
+ *
+ * @param path the path
+ * @return the child or <code>null</code> if not found
+ * @throws IOException for any problem accessing the VFS
+ * @throws IllegalArgumentException if the path is null
+ * @throws IllegalStateException if the file is closed or it is a leaf node
+ */
+ public VirtualFile getChild(String path) throws IOException
+ {
+ if (path == null)
+ throw new IllegalArgumentException("Null path");
+
+ VirtualFileHandler handler = getHandler();
+ VirtualFileHandler child = handler.getChild(VFSUtils.fixName(path));
+ return child != null ? child.getVirtualFile() : null;
+ }
+
@Override
public String toString()
{
@@ -406,5 +430,4 @@ public boolean equals(Object obj)
VirtualFile other = (VirtualFile) obj;
return handler.equals(other.handler);
}
-
}
@@ -116,13 +116,13 @@ protected void addOption(String key, String value)
return parent.getChildren(ignoreErrors);
}
- public VirtualFileHandler findChild(VirtualFileHandler parent, String path) throws IOException
+ public VirtualFileHandler getChild(VirtualFileHandler parent, String path) throws IOException
{
if (parent == null)
throw new IllegalArgumentException("Null parent");
if (path == null)
throw new IllegalArgumentException("Null path");
- return parent.findChild(path);
+ return parent.getChild(path);
}
public void visit(VirtualFileHandler handler, VirtualFileHandlerVisitor visitor) throws IOException
@@ -138,8 +138,7 @@ public void visit(VirtualFileHandler handler, VirtualFileHandlerVisitor visitor)
boolean ignoreErrors = attributes.isIgnoreErrors();
boolean includeHidden = attributes.isIncludeHidden();
VirtualFileFilter recurseFilter = attributes.getRecurseFilter();
- visit(handler, visitor, includeRoot, leavesOnly, ignoreErrors,
- includeHidden, recurseFilter);
+ visit(handler, visitor, includeRoot, leavesOnly, ignoreErrors, includeHidden, recurseFilter);
}
/**
@@ -321,10 +321,10 @@ protected void doClose()
}
/**
- * Structured implementation of find child
- *
+ * Structured implementation of get child
+ *
* @param path the path
- * @return the handler
+ * @return the handler or <code>null</code> if it doesn't exist
* @throws IOException for any error accessing the virtual file system
* @throws IllegalArgumentException for a null name
*/
@@ -337,18 +337,18 @@ public VirtualFileHandler structuredFindChild(String path) throws IOException
if (tokens == null || tokens.length == 0)
return this;
- // Go through each context starting from ours
+ // Go through each context starting from ours
// check the parents are not leaves.
VirtualFileHandler current = this;
for (int i = 0; i < tokens.length; ++i)
{
- if (current.isLeaf())
- throw new IOException("File cannot have children: " + current);
+ if (current == null || current.isLeaf())
+ return null;
if (PathTokenizer.isReverseToken(tokens[i]))
{
VirtualFileHandler parent = current.getParent();
- if (parent == null)
+ if (parent == null) // TODO - still IOE or null?
throw new IOException("Using reverse path on top file handler: " + current + ", " + path);
else
current = parent;
@@ -361,10 +361,10 @@ else if (current instanceof StructuredVirtualFileHandler)
else
{
String remainingPath = PathTokenizer.getRemainingPath(tokens, i);
- return current.findChild(remainingPath);
+ return current.getChild(remainingPath);
}
}
-
+
// The last one is the result
return current;
}
@@ -393,7 +393,7 @@ public VirtualFileHandler simpleFindChild(String path) throws IOException
if (child.getName().equals(appliedPath))
return child;
}
- throw new IOException("Child not found " + path + " for " + this);
+ return null;
}
@Override
@@ -65,9 +65,9 @@ public DelegatingHandler(VFSContext context, VirtualFileHandler parent, String n
this.delegate = delegate;
}
- public VirtualFileHandler findChild(String path) throws IOException
+ public VirtualFileHandler getChild(String path) throws IOException
{
- return delegate.findChild(path);
+ return delegate.getChild(path);
}
public List<VirtualFileHandler> getChildren(boolean ignoreErrors) throws IOException
@@ -192,11 +192,6 @@ public boolean isHidden()
return result;
}
- public VirtualFileHandler findChild(String path) throws IOException
- {
- return structuredFindChild(path);
- }
-
public VirtualFileHandler createChildHandler(String name) throws IOException
{
FileSystemContext context = getVFSContext();
@@ -217,6 +212,11 @@ public VirtualFileHandler createChildHandler(String name) throws IOException
return handler;
}
+ public VirtualFileHandler getChild(String path) throws IOException
+ {
+ return structuredFindChild(path);
+ }
+
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException
{
in.defaultReadObject();
@@ -21,12 +21,11 @@
*/
package org.jboss.virtual.plugins.context.file;
-import java.io.FileNotFoundException;
import java.io.IOException;
+import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
-import java.net.MalformedURLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -80,14 +79,14 @@ void addChild(VirtualFileHandler child, String name)
children.put(name, child);
}
- public VirtualFileHandler findChild(String path) throws IOException
+ public VirtualFileHandler createChildHandler(String name) throws IOException
{
- return structuredFindChild(path);
+ return children.get(name);
}
- public VirtualFileHandler createChildHandler(String name) throws IOException
+ public VirtualFileHandler getChild(String path) throws IOException
{
- return children.get(name);
+ return structuredFindChild(path);
}
public List<VirtualFileHandler> getChildren(boolean ignoreErrors) throws IOException
@@ -133,16 +132,16 @@ public LinkHandler(FileSystemContext context, VirtualFileHandler parent, URI uri
int n = 0;
VirtualFileHandler linkParent = this;
String atom;
- // Look for an existing parent
+ // Look for an existing parent
+ VirtualFileHandler previous;
for(; n < paths.length-1; n ++)
{
+ previous = linkParent;
atom = paths[n];
- try
- {
- linkParent = linkParent.findChild(atom);
- }
- catch(IOException e)
+ linkParent = previous.getChild(atom);
+ if (linkParent == null)
{
+ linkParent = previous;
break;
}
}
@@ -156,11 +155,15 @@ public LinkHandler(FileSystemContext context, VirtualFileHandler parent, URI uri
{
linkTargets.put(atom, pol);
}
- else
+ else if (linkParent instanceof ParentOfLink)
{
ParentOfLink prevPOL = (ParentOfLink) linkParent;
prevPOL.addChild(pol, atom);
}
+ else
+ {
+ throw new IOException("Link parent not ParentOfLink.");
+ }
linkParent = pol;
}
@@ -190,19 +193,14 @@ public boolean isLeaf()
return new ArrayList<VirtualFileHandler>(linkTargets.values());
}
- public VirtualFileHandler findChild(String path) throws IOException
+ public VirtualFileHandler createChildHandler(String name) throws IOException
{
- return structuredFindChild(path);
+ return linkTargets.get(name);
}
- public VirtualFileHandler createChildHandler(String name) throws IOException
+ public VirtualFileHandler getChild(String path) throws IOException
{
- VirtualFileHandler handler = linkTargets.get(name);
- if( handler == null )
- {
- throw new FileNotFoundException("Failed to find link for: "+name+", parent: "+this);
- }
- return handler;
+ return structuredFindChild(path);
}
@Override
Oops, something went wrong.

0 comments on commit d452d0f

Please sign in to comment.