Package net.sourceforge.javautil.common.io.impl

Examples of net.sourceforge.javautil.common.io.impl.SimplePath


        return url.endsWith("/") || IVirtualDirectory.class.isAssignableFrom(target) ? new SystemDirectory( url.substring(6) ) : new SystemFile( url.substring(6) );
      } else if (url.startsWith(VirtualArtifactSystem.VAS_PROTOCOL + ":")) {
        String host = url.split(":")[1];
        String path = url.substring((VirtualArtifactSystem.VAS_PROTOCOL + ":" + host + ":").length());
        VirtualArtifactSystem vas = VirtualArtifactSystem.get(host, true);
        return url.endsWith("/") ? vas.getDirectory(new SimplePath(path), true) : vas.getFile(new SimplePath(path), true);
      } else {
        return url.endsWith("/") || IVirtualDirectory.class.isAssignableFrom(target) ? new SystemDirectory(url) : new SystemFile(url);
      }
    } else if (original instanceof IVirtualArtifact) {
      String url = ((IVirtualArtifact)original).getURL().toExternalForm();
View Full Code Here


   * @param url The URL to use for lookup
   * @return The artifact pointed to by the URL, or null if it is not a VAS url or could not be found
   */
  public static IVirtualArtifact getArtifactFor (URL url) {
    if (url.getProtocol().equals( VAS_PROTOCOL )) {
      IVirtualPath path = new SimplePath(url.getPath());
      if (path.getPartCount() == 0) return null;
     
      VirtualArtifactSystem vas = get(path.getPart(0), false);
      if (vas != null) {
        try {
          return vas.getArtifact(new SimplePath( CollectionUtil.shift(path.getParts()) ));
        } catch (VirtualArtifactException e) {
          return null;
        }
      }
    }
View Full Code Here

   * @return A resource wrapper for accessing the origin of the class
   */
  public static ClassLoaderResource getClassResource (Class clazz) {
    URL url = clazz.getResource("/" + ClassNameUtil.toRelativeClassPath(clazz.getName()));
    IVirtualDirectory archive = createFor(url, ClassNameUtil.toRelativeClassPath(clazz.getName()));
    return new ClassLoaderResource(clazz.getClassLoader(), new SimplePath(ClassNameUtil.toRelativeClassPath(clazz.getName())), archive);
  }
View Full Code Here

   */
  public static ClassLoaderResource getResource (String name) {
    URL url = Thread.currentThread().getContextClassLoader().getResource(name);
    if (url == null) return null;
    IVirtualDirectory archive = createFor(url, name);
    return new ClassLoaderResource(Thread.currentThread().getContextClassLoader(), new SimplePath(name), archive);
  }
View Full Code Here

    }
    return file;
  }

  public IVirtualFile createFile(IVirtualPath path) {
    return this.createDirectory(new SimplePath(CollectionUtil.pop(path.getParts()))).createFile(path.getPart(path.getPartCount()-1));
  }
View Full Code Here

    return directory;
  }

  public IVirtualFile getFile(IVirtualPath path, boolean create) throws VirtualArtifactNotFoundException {
    if (!create) return this.getFile(path);
    return this.getDirectory(new SimplePath(CollectionUtil.pop(path.getParts())), true).getFile(path.getPart(path.getPartCount()-1), true);
  }
View Full Code Here

      while (artifact.getOwner() != null) {
        String name = (artifact = artifact.getOwner()).getName();
        if (!this.isRootPathPart(name)) parts.add(0, name);
      }
     
      this.path = new SimplePath(parts.toArray(new String[parts.size()]));
    }
   
    return path;
  }
View Full Code Here

        return VirtualArtifactURLStreamHandler.this.artifact;
      } else {
        VirtualArtifactSystem vas = VirtualArtifactSystem.get(url.getHost(), false);
        if (vas == null) throw new IllegalArgumentException("No mounted VAS by the name: " + url.getHost() + " could be found.");
       
        return vas.getArtifact( new SimplePath(url.getPath()) );
      }
    }
View Full Code Here

        parts.add(0, artifact.getPath().replaceAll("[\\\\/]", ""));
      } else
        parts.add(0, artifact.getName());
    }
   
    return new SimplePath( parts.toArray(new String[parts.size()]) );
  }
View Full Code Here

   * @return The {@link #rootPrefix}
   */
  public String getRootPrefix() { return rootPrefix; }
  public void setRootPrefix(String rootPrefix) {
    this.rootPrefix = rootPrefix;
    this.root = new SecureFTPDirectory(this, null, new SimplePath(""), getFiles(new SimplePath(".")).firstElement().getAttrs());
  }
View Full Code Here

TOP

Related Classes of net.sourceforge.javautil.common.io.impl.SimplePath

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.