📄 sortfilter.java
字号:
/* * SortFilter.java * * Created on 28. September 2005, 21:01 * * To change this template, choose Tools | Template Manager * and open the template in the editor. */package de.spieleck.app.jacson.filter;import de.spieleck.app.jacson.JacsonException;import de.spieleck.app.jacson.JacsonRegistry;import de.spieleck.config.ConfigNode;import java.util.Comparator;import java.util.Iterator;import java.util.SortedSet;import java.util.TreeSet;/** * <h2>SortFilter</h2> * <h3>Description</h3> * <p>Filter class which sorts the incoming chunks</p> * <h3>Parameters</h3> * <table border="1" cellpadding="2" cellspacing="0"> * <tr> * <td valign="top"><b>Attribute</b></td> * <td valign="top"><b>Description</b></td> * <td align="center" valign="top"><b>Required</b></td> * </tr> * <tr> * <td valign="top">inverse</td> * <td valign="top">If inverse is false the chunks are sorted in their natural order. If inverse is true, the order of chunks is inverted.</td> * <td valign="top" align="center">No, default is false</td> * </tr> * </table> * * @version $Id: SortFilter.java 35 2005-10-03 22:08:55Z pcs $ * @version since 0.90 */public class SortFilter extends ConstFilter { SortedSet buffer; public void putChunk(String chunk) throws JacsonException { if(chunk == null) feedChunks(); else buffer.add(chunk); } public void init(ConfigNode config, JacsonRegistry registry) throws de.spieleck.app.jacson.JacsonConfigException { super.init(config, registry); //create a TreeSet with a specific comparator if inverse is true buffer = inverse ? new TreeSet(new Comparator(){ public int compare(Object o1, Object o2){ return -(((String) o1).compareTo((String) o2)); } }) : new TreeSet(); } /** * delivers the received chunks to the drain */ private void feedChunks() throws JacsonException{ Iterator it = buffer.iterator(); while(it.hasNext()) drain.putChunk((String)it.next()); drain.putChunk(null); } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -