/home/gshute/netbeans/Toolkit/src/vfs/VFSFile.java
package vfs;

import java.net.MalformedURLException;
import java.net.URL;

/**
 * A VFSFile is a leaf item in a virtual file
 * system.
 * <p>
 * This is a Leaf class in the Composite
 * design pattern whose other classes are
 * VFSItem (Component) and VFSDirectory
 * (Composite).
 * </p>
 * 
 * @author gshute
 */
public class VFSFile
        implements VFSItem {

  private String name;
  private URL url;

  public VFSFile(String nm, VFSDirectory par) {
    super();
    name = nm;
    if (par != null) {
      try {
        url = new URL(par.getURL(), nm);
      } catch (MalformedURLException ex) {
        throw new Error("Bad name: " + nm, ex);
      }
    }
  }

  public String getName() {
    return name;
  }

  public URL getURL() {
    return url;
  }

  public String getSuffix() {
    int dotPosition = name.lastIndexOf(".");
    if (dotPosition < 0) {
      return null;
    }
    return name.substring(dotPosition + 1);
  }
  
}  // public class VFSFile