1 19 20 package com.sslexplorer.jdbc; 21 22 import java.io.File ; 23 24 import com.sslexplorer.boot.VersionInfo; 25 26 32 public class DBUpgradeOp implements Comparable { 33 private File file; 34 private VersionInfo.Version version; 35 private String name; 36 37 DBUpgradeOp(File file) throws IllegalArgumentException { 38 this.file = file; 39 String n = file.getName(); 40 int idx = n.indexOf('-'); 41 if (idx == -1) { 42 throw new IllegalArgumentException ("File name not in correct format."); 43 } 44 String ver = n.substring(0, idx); 45 version = new VersionInfo.Version(ver.replace('_', '.')); 46 name = n.substring(idx + 1); 47 if(!name.toLowerCase().endsWith(".sql")) { 48 throw new IllegalArgumentException ("File name not in correct format."); 49 } 50 name = name.substring(0, name.length() - 3); 51 } 52 53 58 public File getFile() { 59 return file; 60 } 61 62 67 public VersionInfo.Version getVersion() { 68 return version; 69 } 70 71 76 public String getName() { 77 return name; 78 } 79 80 86 public int compareTo(Object o) { 87 int i = getName().compareTo(((DBUpgradeOp)o).getName()); 88 return i == 0 ? getVersion().compareTo((((DBUpgradeOp)o).getVersion())) : i; 89 } 90 91 } | Popular Tags |