📄 sensorboardprofile.java
字号:
/*
* Created on Aug 31, 2005
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package isis.anp.config;
import isis.commons.fs.SearchPath;
import java.beans.XMLEncoder;
import java.io.BufferedOutputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.Serializable;
import java.io.StringBufferInputStream;
import java.util.Arrays;
import java.util.List;
import java.util.Properties;
/**
* Sensorboars specific settings.
* @author sallai
*/
public class SensorBoardProfile implements Serializable {
private static final long serialVersionUID = 1L;
public String sensorBoardName;
public SearchPath searchPathList;
public static SensorBoardProfile load(String name) throws IOException {
InputStream is = getStream(name);
if(is != null) {
return readObject(is);
} else {
return null;
}
}
public static List getSensorBoards() throws IOException
{
InputStream is = getStream("sensorboards");
Properties p = new Properties();
p.load(is);
String s = p.getProperty("sensorboards");
if( s!=null )
{
s.trim();
return Arrays.asList(s.split(";"));
}
else
return null;
}
public static InputStream getStream(String name) throws IOException {
name = "isis/anp/config/sensorboard/"+name+".properties";
InputStream is = null;
// try with the current thread's classloader
is = Thread.currentThread().getContextClassLoader().getResourceAsStream(name);
if(is!=null) return is;
// try with the classloader that loaded this class
is = PlatformProfile.class.getClassLoader().getResourceAsStream(name);
if(is!=null) return is;
// try with the system classloader
is = ClassLoader.getSystemClassLoader().getResourceAsStream(name);
if(is!=null) return is;
throw new IOException("Could open resource stream for platform profile "+name);
}
public static SensorBoardProfile readObject(InputStream is) throws IOException {
Properties p = new Properties();
p.load(is);
SensorBoardProfile rval = new SensorBoardProfile();
rval.setSensorBoardName(p.getProperty("profileName"));
String spl = p.getProperty("searchPathList");
if(spl!=null) {
rval.setSearchPathList(SearchPath.readObject(new StringBufferInputStream(spl.trim())));
}
is.close();
return rval;
}
public void save(String fn) throws FileNotFoundException {
XMLEncoder e = new XMLEncoder(new BufferedOutputStream(new FileOutputStream(fn)));
e.writeObject(this);
e.close();
}
public SensorBoardProfile() {}
public SensorBoardProfile(String sensorBoardName, SearchPath searchPathList) {
this.setSensorBoardName(sensorBoardName);
this.setSearchPathList(searchPathList);
}
/**
* @return Returns the name.
*/
public String getSensorBoardName() {
return sensorBoardName;
}
/**
* @param name The name to set.
*/
public void setSensorBoardName(String name) {
this.sensorBoardName = name;
}
/**
* @return Returns the searchPathList.
*/
public SearchPath getSearchPathList() {
return searchPathList;
}
/**
* @param searchPathList The searchPathList to set.
*/
public void setSearchPathList(SearchPath searchPathList) {
this.searchPathList = searchPathList;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -