historyrecord.java

来自「uPortal是开放源码的Portal门户产品」· Java 代码 · 共 40 行

JAVA
40
字号
package org.jasig.portal.channels.iccdemo;import java.util.Collections;import java.util.Iterator;import java.util.LinkedList;/** * A trivial class for keeping a queue of N strings. * This class is bound to jndi "chan-obj" context by CHistory, so * that CViewer (or other channels) could add to the history list. * * @author <a href="mailto:pkharchenko@interactivebusiness.com">Peter Kharchenko</a> * @version $Revision: 1.2 $ */public class HistoryRecord {    LinkedList history=new LinkedList();    int maxRecords=10;    public HistoryRecord() {};    public HistoryRecord(int maxRecords) {        this.maxRecords=maxRecords;    }    public void addHistoryRecord(String newRecord) {        history.addFirst(newRecord);        for(int i=0;i<history.size()-maxRecords;i++) {            history.removeLast();        }    }    public Iterator constIterator() {        return (Collections.unmodifiableList(history)).iterator();    }    public String get(int i) {        return (String)history.get(i);    }}

⌨️ 快捷键说明

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