KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > derby > ui > properties > DerbyProperties


1 /*
2
3     Derby - Class org.apache.derby.ui.properties.DerbyProperties
4     
5     Licensed to the Apache Software Foundation (ASF) under one or more
6     contributor license agreements. See the NOTICE file distributed with
7     this work for additional information regarding copyright ownership.
8     The ASF licenses this file to you under the Apache License, Version 2.0
9     (the "License"); you may not use this file except in compliance with
10     the License. You may obtain a copy of the License at
11     
12        http://www.apache.org/licenses/LICENSE-2.0
13     
14     Unless required by applicable law or agreed to in writing, software
15     distributed under the License is distributed on an "AS IS" BASIS,
16     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17     See the License for the specific language governing permissions and
18     limitations under the License.
19
20 */

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 JavaDoc DSPORT = "ds.port";
35     //public static final String DS_RUNNING_PORT = "ds.running.port";
36
public static final String JavaDoc DSHOST = "ds.host";
37     public static final String JavaDoc DS_SYS_HOME = "derby.system.home";
38     
39     //Default Derby Properties
40
private int port = 1527;
41     //private int runningPort=0;
42
private String JavaDoc host = "localhost";
43     private String JavaDoc 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 // project.setPersistentProperty(new QualifiedName (
63
// CommonNames.UI_PATH, DS_RUNNING_PORT), Integer.toString(runningPort));
64
}
65     
66     public void load(IProject project) throws CoreException {
67         
68         String JavaDoc 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 // property = project.getPersistentProperty(new QualifiedName (
78
// CommonNames.UI_PATH, DS_RUNNING_PORT));
79
// runningPort = (property != null && property.length() > 0) ? Integer.parseInt(property) : runningPort;
80
}
81     public String JavaDoc toString(){
82         return "Derby Server Properties:\n Port = "+getPort()+" Host = "+getHost()+" System Home = "+getSystemHome();
83     }
84     
85     /**
86      * @return Returns the host.
87      */

88     public String JavaDoc getHost() {
89         return host;
90     }
91     /**
92      * @param host The host to set.
93      */

94     public void setHost(String JavaDoc host) {
95         this.host = host;
96     }
97     /**
98      * @return Returns the port.
99      */

100     public int getPort() {
101         return port;
102     }
103     /**
104      * @param port The port to set.
105      */

106     public void setPort(int port) {
107         this.port = port;
108     }
109     /**
110      * @return Returns the systemHome.
111      */

112     public String JavaDoc getSystemHome() {
113         return systemHome;
114     }
115     /**
116      * @param systemHome The systemHome to set.
117      */

118     public void setSystemHome(String JavaDoc systemHome) {
119         this.systemHome = systemHome;
120     }
121     
122 }
123
124
Popular Tags