当前位置: 首页>>代码示例>>Java>>正文


Java MemoryHistory类代码示例

本文整理汇总了Java中jline.console.history.MemoryHistory的典型用法代码示例。如果您正苦于以下问题:Java MemoryHistory类的具体用法?Java MemoryHistory怎么用?Java MemoryHistory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


MemoryHistory类属于jline.console.history包,在下文中一共展示了MemoryHistory类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getJLineHistory

import jline.console.history.MemoryHistory; //导入依赖的package包/类
/**
 * Load the History from disk if a $HOME directory is defined, otherwise fall back to using an in-memory history object
 * 
 * @return
 * @throws IOException
 */
protected History getJLineHistory() throws IOException {
  String home = System.getProperty("HOME");
  if (null == home) {
    home = System.getenv("HOME");
  }
  
  // Get the home directory
  File homeDir = new File(home);
  
  // Make sure it actually exists
  if (homeDir.exists() && homeDir.isDirectory()) {
    // Check for, and create if necessary, the directory for cosmos to use
    File historyDir = new File(homeDir, ".cosmos");
    if (!historyDir.exists() && !historyDir.mkdirs()) {
      log.warn("Could not create directory for history at {}, using temporary history.", historyDir);
    }
    
    // Get a file for jline history
    File historyFile = new File(historyDir, "history");
    return new FileHistory(historyFile);
  } else {
    log.warn("Home directory not found: {}, using temporary history", homeDir);
    return new MemoryHistory();
  }
}
 
开发者ID:joshelser,项目名称:cosmos,代码行数:32,代码来源:CosmosConsole.java

示例2: getCommandHistory

import jline.console.history.MemoryHistory; //导入依赖的package包/类
/**Read the asciigenome history file and put it a list as current history. Or
 * return empty history file does not exist or can't be read. 
 * */
public History getCommandHistory(){
	History cmdHistory= new MemoryHistory();
	for(String x : this.getCommands()){
		cmdHistory.add(x);
	}
	return cmdHistory;
}
 
开发者ID:dariober,项目名称:ASCIIGenome,代码行数:11,代码来源:ASCIIGenomeHistory.java

示例3: testHistory

import jline.console.history.MemoryHistory; //导入依赖的package包/类
@Test
public void testHistory() throws IOException{
	
	ConsoleReader console= new ConsoleReader();
	//History history= new History(new File(System.getProperty("user.home") + File.separator + ".asciigenome_history"));
	History history= new MemoryHistory();
	history.add("foobar");
	history.add("baz");
	console.setHistory(history);
	System.out.println(console.getHistory());
}
 
开发者ID:dariober,项目名称:ASCIIGenome,代码行数:12,代码来源:UtilsTest.java

示例4: applyHistory

import jline.console.history.MemoryHistory; //导入依赖的package包/类
private void applyHistory() throws IOException {
	console.setHistory(new MemoryHistory());

	requestHistory();
	Message response = connector.receive();
	if(response instanceof HistoryResponse){
		HistoryResponse historyResponse = (HistoryResponse)response;
		for(String line : historyResponse.getHistoryLines()){
			console.getHistory().add(line);
		}
	}else{
		LOG.log(SEVERE, "The history can not be apply because the server sends an unexpected response!" + response);
	}
}
 
开发者ID:rainu,项目名称:jsimpleshell-rc,代码行数:15,代码来源:MessageDispatcher.java

示例5: Terminal

import jline.console.history.MemoryHistory; //导入依赖的package包/类
public Terminal(Configuration configuration) {
    try {
        this.configuration = configuration;

        jline.TerminalFactory.configure("auto");

        reader = new ConsoleReader();
        reader.setHistory(new MemoryHistory());
        reader.addCompleter(new ArgumentCompleter(selectCompleters()));
    
    } catch (IOException ex) {
        throw new RuntimeException(ex);
    }
}
 
开发者ID:SINTEF-9012,项目名称:cloudml,代码行数:15,代码来源:Terminal.java

示例6: EditingHistory

import jline.console.history.MemoryHistory; //导入依赖的package包/类
protected EditingHistory(Preferences prefs) {
    this.prefs = prefs;
    this.fullHistory = new MemoryHistory();
    this.currentDelegate = fullHistory;
    load();
}
 
开发者ID:kawasima,项目名称:try-artifact,代码行数:7,代码来源:EditingHistory.java

示例7: FileHistorian

import jline.console.history.MemoryHistory; //导入依赖的package包/类
private FileHistorian(MemoryHistory history) {
    this.history = history;
}
 
开发者ID:neo4j,项目名称:cypher-shell,代码行数:4,代码来源:FileHistorian.java

示例8: shellHistory

import jline.console.history.MemoryHistory; //导入依赖的package包/类
public static MemoryHistory shellHistory() {
    return shellHistory;
}
 
开发者ID:jerlang,项目名称:jerlang,代码行数:4,代码来源:Runtime.java

示例9: disableHistory

import jline.console.history.MemoryHistory; //导入依赖的package包/类
void disableHistory() {
    consoleReader.setHistory(new MemoryHistory());
    consoleReader.setHistoryEnabled(false);
}
 
开发者ID:dfoerderreuther,项目名称:console-builder,代码行数:5,代码来源:ConsoleReaderWrapper.java


注:本文中的jline.console.history.MemoryHistory类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。