    001    package javafe;
    002
    003    import java.util.ArrayList;
    004    import java.util.Iterator;
    005
    006    import javafe.filespace.StringUtil;
    007
    008    public class InputEntry {
    009      public InputEntry(String n) { name = n; }
    010      public String name;
    011      public ArrayList contents;
    012      public boolean auto = false;
    013      public String toString() { return name; }
    014      public String type() { return ""; }
    015      public String typeOption() { return ""; }
    016      public String verify() { return null; }
    017      public String savedString() {
    018        String q = "";
    019        if (name.indexOf(' ') != -1) q = "\"";
    020        String t = typeOption();
    021        if (auto) t = "";
    022        else if (t.length() != 0) t = "-"+t+" ";
    023        return t + q + name + q;
    024      }
    025      static public void clear(ArrayList a) {
    026        Iterator i = a.iterator();
    027        while (i.hasNext()) {
    028          InputEntry ie = (InputEntry)i.next();
    029          ie.clear();
    030        }
    031      }
    032      public void clear() { contents = null; }
    033
    034      static public InputEntry make(String type, String name) {
    035        if (type == null) return make(name);
    036        if (type.equals("file")) return new FileInputEntry(name);
    037        if (type.equals("dir")) return new DirInputEntry(name);
    038        if (type.equals("package")) return new PackageInputEntry(name);
    039        if (type.equals("class")) return new ClassInputEntry(name);
    040        if (type.equals("list")) return new ListInputEntry(name);
    041        return null;
    042      }
    043
    044      static public InputEntry make(String name) {
    045        java.io.File f = new java.io.File(name);
    046        InputEntry ie = null;
    047
    048        if (FileInputEntry.verify(name) == null)
    049          ie = new FileInputEntry(name);
    050        else if (DirInputEntry.verify(name) == null)
    051          ie = new DirInputEntry(name);
    052        else if (PackageInputEntry.verify(name) == null)
    053          ie = new PackageInputEntry(name);
    054        else if (ClassInputEntry.verify(name) == null)
    055          ie = new ClassInputEntry(name);
    056        else if (ListInputEntry.verify(name) == null)
    057          ie = new ListInputEntry(name);
    058
    059        if (ie == null) ie = new UnknownInputEntry(name);
    060        ie.auto = true;
    061        return ie;
    062      }
    063
    064      public InputEntry resolve() { return this; }
    065
    066      public boolean match(InputEntry ie) {
    067        return getClass() == ie.getClass() && name.equals(ie.name);
    068      }
    069    }