⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 platformprofile.java

📁 plugin for eclipse
💻 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.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.Properties;


/**
 * Platform specific settings.
 * @author sallai
 *
 */
public class PlatformProfile {
	private String platformName;
	private List cppOptions = new ArrayList();
	private String cppExecutable;
	private SearchPath searchPathList;

	/**
	 * Load settings from a file in the classpath.
	 * @param fn filename
	 * @return the platform profile
	 * @throws IOException 
	 * @throws FileNotFoundException
	 */
	public static PlatformProfile load(String name) throws IOException {
		InputStream is = getStream(name);
		if(is != null) {
			return readObject(is);
		} else {
			return null;
		}
	}
    
    public static List getPlatforms() throws IOException
    {
        InputStream is = getStream("platforms");
        Properties p = new Properties();
        p.load(is);
        
        String s = p.getProperty("platforms");
        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/platform/"+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 PlatformProfile readObject(InputStream is) throws IOException {
		Properties p = new Properties();
		p.load(is);              
		
		PlatformProfile rval = new PlatformProfile();
		rval.setCppExecutable(p.getProperty("cppExecutable"));
		String options = p.getProperty("cppOptions");
		if(options!=null) {
			rval.setCppOptions(Arrays.asList(options.trim().split(" ")));
		}

		rval.setPlatformName(p.getProperty("platformName"));
		
		String spl = p.getProperty("searchPathList");
		if(spl!=null) {
			rval.setSearchPathList(SearchPath.readObject(spl.trim()));
		}
		is.close();
		
		return rval;
	}
	
	
	
	public void save(OutputStream out) throws FileNotFoundException {
        PrintStream p = new PrintStream(out); 
        p.println("cppExecutable="+cppExecutable);
        
        p.print("cppOptions=");
        Iterator it = cppOptions.iterator();
        while( it.hasNext() )
        {
            String s = (String)it.next();
            p.print(s);      
            if( it.hasNext() )
                p.print(" ");
        }
        p.println();
        p.println("platformName="+platformName);
        
        p.print("searchPathList=");
        it = searchPathList.iterator();
        while( it.hasNext() )
        {
            String s = (String)it.next();
            p.print(s);
            if( it.hasNext() )
                p.print(";");            
        }
        p.println();
        p.close();
	}

	public PlatformProfile() {}
	
	public PlatformProfile(String platformName, String cppExecutable, List cppOptions, SearchPath searchPathList) {
		this.setPlatformName(platformName);
		this.setCppExecutable(cppExecutable);
		this.setCppOptions(cppOptions);
		this.setSearchPathList(searchPathList);
	}
	
	
	/**
	 * @return Returns the cppExecutable.
	 */
	public String getCppExecutable() {
		return cppExecutable;
	}
	/**
	 * @param cppExecutable The cppExecutable to set.
	 */
	public void setCppExecutable(String cppExecutable) {
		this.cppExecutable = cppExecutable;
	}
	/**
	 * @return Returns the cppOptions.
	 */
	public List getCppOptions() {
		return cppOptions;
	}
	/**
	 * @param cppOptions The cppOptions to set.
	 */
	public void setCppOptions(List cppOptions) {
		this.cppOptions = cppOptions;
	}
	/**
	 * @return Returns the searchPathList.
	 */
	public SearchPath getSearchPathList() {
		return searchPathList;
	}
	/**
	 * @param searchPathList The searchPathList to set.
	 */
	public void setSearchPathList(SearchPath searchPathList) {
		this.searchPathList = searchPathList;
	}
	/**
	 * @return Returns the platformName.
	 */
	public String getPlatformName() {
		return platformName;
	}
	/**
	 * @param platformName The platformName to set.
	 */
	public void setPlatformName(String platformName) {
		this.platformName = platformName;
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -