Allows Jmol to share cached files
[jalview.git] / src / jalview / datamodel / PDBEntry.java
index c1dc77c..407f87d 100755 (executable)
@@ -22,6 +22,7 @@ package jalview.datamodel;
 
 import jalview.util.CaseInsensitiveString;
 
+import java.io.File;
 import java.util.Collections;
 import java.util.Enumeration;
 import java.util.Hashtable;
@@ -38,7 +39,9 @@ public class PDBEntry
 
   private static final int PDB_ID_LENGTH = 4;
 
-  private String file;
+  private String fileName;
+  
+  private File file;
 
   private String type;
 
@@ -133,8 +136,8 @@ public class PDBEntry
      */
     boolean idMatches = id == o.id
             || (id != null && id.equalsIgnoreCase(o.id));
-    boolean fileMatches = file == o.file
-            || (file != null && file.equals(o.file));
+    boolean fileMatches = fileName == o.fileName
+            || (fileName != null && fileName.equals(o.fileName));
     boolean typeMatches = type == o.type
             || (type != null && type.equals(o.type));
     if (idMatches && fileMatches && typeMatches)
@@ -164,12 +167,12 @@ public class PDBEntry
    * @param entryType
    * @param filePath
    */
-  void init(String pdbId, String chain, PDBEntry.Type entryType,
+  private void init(String pdbId, String chain, PDBEntry.Type entryType,
           String filePath)
   {
     this.id = pdbId;
     this.type = entryType == null ? null : entryType.toString();
-    this.file = filePath;
+    this.fileName = filePath;
     setChainCode(chain);
   }
 
@@ -180,7 +183,7 @@ public class PDBEntry
    */
   public PDBEntry(PDBEntry entry)
   {
-    file = entry.file;
+    fileName = entry.fileName;
     type = entry.type;
     id = entry.id;
     if (entry.properties != null)
@@ -220,12 +223,22 @@ public class PDBEntry
 
   public void setFile(String f)
   {
+    this.fileName = f;
+  }
+
+  public void setFile(File f)
+  {
     this.file = f;
   }
 
   public String getFile()
   {
-    return file;
+    return (file != null ? file.getAbsolutePath() : fileName);
+  }
+
+  public File getFileF()
+  {
+    return (file == null ? new File(fileName) : file);
   }
 
   public void setType(String t)
@@ -420,6 +433,7 @@ public class PDBEntry
     {
       setFile(newFile);
       setType(newType);
+      setFile(newEntry.getFileF());
     }
 
     /*