📄 applicationconfiguration.java
字号:
/*
* This file is part of the QuickServer library
* Copyright (C) 2003-2005 QuickServer.org
*
* Use, modification, copying and distribution of this software is subject to
* the terms and conditions of the GNU Lesser General Public License.
* You should have received a copy of the GNU LGP License along with this
* library; if not, you can download a copy from <http://www.quickserver.org/>.
*
* For questions, suggestions, bug-reports, enhancement-requests etc.
* visit http://www.quickserver.org
*
*/
package org.quickserver.util.xmlreader;
import java.util.*;
/**
* This class encapsulate the Application Configuration.
* The example xml is <pre>
<quickserver>
....
<application-configuration>
<property>
<property-name>FTP_ROOT</property-name>
<property-value>c:\</property-value>
</property>
<property>
<property-name>Server Name</property-name>
<property-value>My Server</property-value>
</property>
</application-configuration>
....
</quickserver>
</pre>
* @author Akshathkumar Shetty
* @since 1.3.2
*/
public class ApplicationConfiguration extends HashMap {
private String promptType = "gui";//OR console
/**
* Sets the PromptType.
* XML Tag: <prompt-type>true</prompt-typ>
* Allowed values = <code>gui</code> | <code>console</code>
* @see #getPromptType
* @since 1.4.5
*/
public void setPromptType(String promptType) {
if(promptType!=null && promptType.equals("")==false)
if(promptType.equals("gui") || promptType.equals("console"))
this.promptType = promptType;
}
/**
* Returns the PromptType
* @see #setPromptType
* @since 1.4.5
*/
public String getPromptType() {
return promptType;
}
/**
* Addes the {@link Property} passed to the HashMap
*/
public void addProperty(Property property) {
put(property.getName(), property.getValue());
}
/**
* Finds if any {@link Property} is present.
* @return <code>null</code> if no Property was found.
*/
public Property findProperty(String name) {
String temp = (String) get(name);
if(temp!=null) {
return new Property(name, temp);
} else {
return null;
}
}
/**
* Returns XML config of this class.
*/
public String toXML(String pad) {
if(pad==null) pad="";
StringBuffer sb = new StringBuffer();
sb.append(pad+"<application-configuration>\n");
sb.append(pad+"\t<prompt-type>"+getPromptType()+"</prompt-type>");
Iterator iterator = keySet().iterator();
while(iterator.hasNext()) {
String key = (String) iterator.next();
String value = (String) get(key);
sb.append(pad+"\t<property>");
sb.append(pad+"\t\t<property-name>"+key+"</property-name>\n");
sb.append(pad+"\t\t<property-value>"+value+"</property-value>\n");
sb.append(pad+"\t</property>\n");
}
sb.append(pad+"</application-configuration>\n");
return sb.toString();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -