1 21 22 package org.apache.derby.ui.properties; 23 24 import org.apache.derby.ui.common.CommonNames; 25 import org.eclipse.core.resources.IProject; 26 import org.eclipse.core.runtime.CoreException; 27 import org.eclipse.core.runtime.QualifiedName; 28 import org.eclipse.jdt.core.IJavaProject; 29 30 31 32 public class DerbyProperties { 33 34 public static final String DSPORT = "ds.port"; 35 public static final String DSHOST = "ds.host"; 37 public static final String DS_SYS_HOME = "derby.system.home"; 38 39 private int port = 1527; 41 private String host = "localhost"; 43 private String systemHome = "."; 44 45 public DerbyProperties() {} 46 47 public DerbyProperties(IJavaProject javaProject) throws CoreException { 48 load(javaProject.getProject()); 49 } 50 public DerbyProperties(IProject project) throws CoreException { 51 load(project); 52 } 53 54 public void save(IProject project) throws CoreException { 55 56 project.setPersistentProperty(new QualifiedName ( 57 CommonNames.UI_PATH, DSPORT), Integer.toString(port)); 58 project.setPersistentProperty(new QualifiedName ( 59 CommonNames.UI_PATH, DSHOST), host); 60 project.setPersistentProperty(new QualifiedName ( 61 CommonNames.UI_PATH, DS_SYS_HOME), systemHome); 62 } 65 66 public void load(IProject project) throws CoreException { 67 68 String property = project.getPersistentProperty(new QualifiedName ( 69 CommonNames.UI_PATH, DSPORT)); 70 port = (property != null && property.length() > 0) ? Integer.parseInt(property) : port; 71 property = project.getPersistentProperty(new QualifiedName ( 72 CommonNames.UI_PATH, DSHOST)); 73 host = (property != null && property.length() > 0) ? property : host; 74 property = project.getPersistentProperty(new QualifiedName ( 75 CommonNames.UI_PATH, DS_SYS_HOME)); 76 systemHome = (property != null && property.length() > 0) ? property : systemHome; 77 } 81 public String toString(){ 82 return "Derby Server Properties:\n Port = "+getPort()+" Host = "+getHost()+" System Home = "+getSystemHome(); 83 } 84 85 88 public String getHost() { 89 return host; 90 } 91 94 public void setHost(String host) { 95 this.host = host; 96 } 97 100 public int getPort() { 101 return port; 102 } 103 106 public void setPort(int port) { 107 this.port = port; 108 } 109 112 public String getSystemHome() { 113 return systemHome; 114 } 115 118 public void setSystemHome(String systemHome) { 119 this.systemHome = systemHome; 120 } 121 122 } 123 124 | Popular Tags |