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

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


  public Object coerce(Object original, Class target) {
    if (original instanceof CharSequence) {
      String url = String.valueOf( original );
      if (url.startsWith("file:/")) {
        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();
      if (original instanceof IVirtualDirectory && !url.endsWith("/")) url += "/";
     
View Full Code Here


     
      if ( urlPath.startsWith("file:") ) urlPath = urlPath.substring(5);
      if ( urlPath.indexOf('!')>0 ) urlPath = urlPath.substring(0, urlPath.indexOf('!'));
     
      File file = new File(urlPath);
      return file.isDirectory() ? new SystemDirectory(file) : new ZippedDirectory(new SystemFile(file));
    } catch (UnsupportedEncodingException e) {
      throw ThrowableManagerRegistry.caught(e);
    }
  }
View Full Code Here

  /**
   * @param artifact The artifact in question
   * @return A {@link SystemFile} or a {@link SystemDirectory} wrapper depending on the type of the file
   */
  public static ISystemArtifact getSystemArtifact (File artifact) {
    return artifact.isFile() ? new SystemFile(artifact) : new SystemDirectory(artifact);
  }
View Full Code Here

 
  /**
   * @param file The file for which a {@link ISystemArtifact} is desired
   * @return A valid system artifact wrapper
   */
  public static ISystemArtifact toSystem (File file) { return file.isDirectory() ? new SystemDirectory(file) : new SystemFile(file); }
View Full Code Here

  public ClassSource getAdditionalClassSources () throws Exception {
    String libdirs = this.getSetting(LIBDIRS_PROPERTY);
    if (libdirs == null) return null;
   
    String[] libs = libdirs.split(";");
    if (libs.length == 1) return new LibDirectoryClassSource(new SystemDirectory(libs[0]), true);
    else {
      CompositeClassSource ccs = new CompositeClassSource();
      for (String lib : libs) ccs.add(new LibDirectoryClassSource(new SystemDirectory(lib), true));
      return ccs;
    }
  }
View Full Code Here

    String location = System.getProperty(LOCAL_DEFAULT_OVERRIDE);
    if (location == null) {
      location = MavenLocalSettings.getDefaultInstance().getLocalRepository();
      if (location == null) location = System.getProperty("user.home") + File.separator + ".m2/repository";
    }
    return new SystemDirectory(location);
  }
View Full Code Here

  }

  public IClassPackageRepositoryLocalImportable getDefaultLocalRepository() {
    String local = MavenLocalSettings.getDefaultInstance().getLocalRepository();
    if (local == null) local = MavenLocalSettings.DEFAULT_LOCATION;
    return getLocalRepository( new SystemDirectory( local ) );
  }
View Full Code Here

    this.resolver = MavenRepositoryUtil.createStandardResolver();
   
    String[] mps = mp.split(";");
   
    for (String mpd : mps) {
      ((ClassPackageResolverImpl)this.resolver).addLocalRepository(new MavenRepositoryLocalProject( new SystemDirectory(mpd) ));
    }
   
    ((ClassPackageResolverImpl)this.resolver).addLocalRepository(new MavenRepositoryClassLoader());
   
    context = cs != null ?
View Full Code Here

        va = new ZippedDirectory(new SystemFile(path));
      } else if (url.getProtocol().equals("file")) {
        String path = url.getPath();
        File target = new File(path);
        if (target.isDirectory()) {
          va = new SystemDirectory(target);
        } else {
          if (ArchiveUtil.isArchive(target)) {
            va = new ZippedDirectory(new SystemFile(target));
          }
        }
View Full Code Here

    if (args.length != 2) {
      System.err.println("Please provide the library directory and the resource name to search for.");
    } else {
     
      System.out.println("Searching for " + args[1] + " in " + args[0]);
      LibDirectoryClassSource lib = new LibDirectoryClassSource(new SystemDirectory(args[0]), true);
      List<ClassSource> sources = lib.getAllNonCompositeSources();
     
      for (ClassSource source : sources) {
        for (String name : source.getResourceNames()) {
          if (name.contains(args[1])) {
View Full Code Here

TOP

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

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.