Package net.sourceforge.javautil.common.io

Examples of net.sourceforge.javautil.common.io.IVirtualArtifact


     
      if ( urlPath.startsWith("vas:") || urlPath.startsWith("virtual:") ) {
        try {
          URLConnection connection = new URL(urlPath).openConnection();
          if (connection instanceof VirtualArtifactURLConnection) {
            IVirtualArtifact artifact = ((VirtualArtifactURLConnection)connection).getArtifact();
            if (artifact instanceof IVirtualDirectory) return (IVirtualDirectory) artifact;
          }
        } catch (IOException e) {
          throw ThrowableManagerRegistry.caught(e);
        }
View Full Code Here


  public boolean isReadOnly() { return false; }

  public <T extends IVirtualArtifact> T getArtifact(Class<T> type, IVirtualPath path) {
    try {
      IVirtualArtifact artifact = path == null ? this : this.getArtifact(path);
      if (type.isAssignableFrom(artifact.getClass())) return (T) artifact;
      else if (artifact instanceof VirtualArtifactWrapped) { return (T) ((VirtualArtifactWrapped)artifact).unwrap(type); }
      if (artifact instanceof Directory) return this.resolve(type, (Directory) artifact);
    } catch (VirtualArtifactNotFoundException e) {}
    return null;
  }
View Full Code Here

  public List<LinkedDirectory> getLinkedDirectories () {
    return new ArrayList<LinkedDirectory>( this.getLinkedRoots() );
  }

  public IVirtualArtifact getArtifact(IVirtualPath path) {
    IVirtualArtifact artifact = this;
   
    int idx = 0;
    while (path.getPartCount() > idx && artifact instanceof IVirtualDirectory) {
      if ("".equals(path.getPart(idx))) { idx++; continue; }
     
View Full Code Here

    this.artifacts.put(name, linked);
    return linked;
  }

  public IVirtualArtifact getArtifact(String name) {
    IVirtualArtifact artifact = artifacts.get(name);
   
    if (artifact == null) {
      for (LinkedDirectory linked : this.getLinkedRoots()) {
        artifact = linked.getArtifact(name);
        if (artifact != null)
View Full Code Here

    return artifact;
  }

  public Directory createDirectory(String name) {
    Directory dir = null;
    IVirtualArtifact artifact = this.artifacts.get(name);
    if (artifact instanceof IVirtualFile) {
      throw new VirtualArtifactException(this, "A file already exists by this name: " + name);
    } else if (artifact != null) {
      dir = (Directory) artifact;
    } else {
View Full Code Here

    Set<IVirtualArtifact> artifacts = new LinkedHashSet<IVirtualArtifact>(this.artifacts.values());
   
    for (LinkedDirectory root : this.getLinkedRoots()) {
      Iterator<IVirtualArtifact> ra = root.getArtifacts();
      while (ra.hasNext()) {
        IVirtualArtifact artifact = ra.next();
       
        if (artifact instanceof LinkedDirectory) {
          artifacts.add(this.getDirectory(artifact.getName(), true));
        } else
          artifacts.add(artifact);
      }
    }
   
View Full Code Here

  public Iterator<IVirtualArtifact> getArtifacts() {
    Set<IVirtualArtifact> artifacts = new LinkedHashSet<IVirtualArtifact>();
   
    Iterator<IVirtualArtifact> das = delegate.getArtifacts();
    while (das.hasNext()) {
      IVirtualArtifact artifact = das.next();
      artifacts.add( wrap( artifact ) );
    }
   
    return artifacts.iterator();
  }
View Full Code Here

  }

  public List<String> getResourcePaths(String path) {
    Set<String> set = new LinkedHashSet<String>();
    try {
      IVirtualArtifact artifact = directory.getArtifact(new SimplePath(path));
     
      if (artifact instanceof IVirtualDirectory) {
        Iterator<IVirtualArtifact> subs = ((IVirtualDirectory)artifact).getArtifacts();
        while (subs.hasNext()) {
          IVirtualArtifact sub = subs.next();
          String subp = this.path.getRelativePath( sub.getPath() ).toString("/");
          if (sub instanceof IVirtualDirectory) {
            if (!subp.endsWith("/")) subp += "/";
          }
          add(set, subp);
        }
View Full Code Here

  /**
   * @param url The URL in question
   * @return An appropriate class source for this URL, or null if the URL cannot be translated into a class source
   */
  public static ClassSource getFor (URL url) {
    IVirtualArtifact va = VirtualArtifactSystem.getArtifactFor(url);
    if (va == null) {
      if (url.getProtocol().equals("jar")) {
        String path = url.getPath();
        if (path.startsWith("file://")) path = path.substring(7);
        va = new ZippedDirectory(new SystemFile(path));
View Full Code Here

  @Override public Collection<String> getClassNames() {
    return directory.accept(new ClassFileVisitor(true)).names;
  }

  @Override public List<String> getClassNamesForPackage(PackageSearchInfo info) {
    IVirtualArtifact pkgdir = this.getPathedArtifact(info.getPackagePath());
    List<String> classNames = new ArrayList<String>();
   
    if (pkgdir instanceof IVirtualDirectory) {
      Iterator<IVirtualArtifact> artifacts = ((IVirtualDirectory)pkgdir).getArtifacts();
      while (artifacts.hasNext()) {
        IVirtualArtifact artifact = artifacts.next();
        if (ClassNameUtil.isClassSource( artifact.getName() )) {
          IVirtualPath relative = directory.getRelativePath(artifact);
          classNames.add( ClassNameUtil.toClassName(relative.toString("/")) );
        }
      }
    }
View Full Code Here

TOP

Related Classes of net.sourceforge.javautil.common.io.IVirtualArtifact

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.