1 18 package org.columba.core.scripting.model; 19 20 import java.io.File ; 21 22 25 public class ColumbaScript 26 { 27 28 private final File scriptFile; 29 30 private String 31 name = "", 32 author = "", 33 description = "", 34 extension = ""; 35 36 public ColumbaScript(File file) 37 { 38 scriptFile = file; 39 extension = extractExtensionFromFilename(); 40 } 41 42 private String extractExtensionFromFilename() 43 { 44 45 String name = scriptFile.getName(); 46 int pos = name.lastIndexOf('.'); 47 if (pos == -1 || pos + 1 == name.length()) return null; 48 49 return name.substring(pos + 1); 50 51 } 52 53 public String getExtension() 54 { 55 return extension; 56 } 57 58 public void setMetadata(String name, String author, String desc) 59 { 60 this.name = name; 61 this.author = author; 62 this.description = desc; 63 } 64 65 public String getName() 66 { 67 if (name.equals("")) return scriptFile.getName(); 68 else return name; 69 70 } 71 72 public String getAuthor() 73 { 74 return author; 75 } 76 77 public String getDescription() 78 { 79 return description; 80 } 81 82 public long getLastModified() 83 { 84 return scriptFile.lastModified(); 85 } 86 87 public String getPath() 88 { 89 return scriptFile.getPath(); 90 } 91 92 public boolean exists() 93 { 94 return scriptFile.exists(); 95 } 96 97 public boolean deleteFromDisk() 98 { 99 return scriptFile.delete(); 100 } 101 } 102 | Popular Tags |