View Javadoc
1   // ////////////////////////////////////////////////////////////////////////////
2   // dexterIM - Instant Messaging Framework
3   // Copyright (C) 2003 Christoph Walcher
4   //
5   // This program is free software; you can redistribute it and/or modify
6   // it under the terms of the GNU General Public License as published by
7   // the Free Software Foundation; either version 2 of the License, or
8   // (at your option) any later version.
9   //
10  // This program is distributed in the hope that it will be useful,
11  // but WITHOUT ANY WARRANTY; without even the implied warranty of
12  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  // GNU General Public License for more details.
14  //
15  // You should have received a copy of the GNU General Public License
16  // along with this program; if not, write to the Free Software
17  // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  //////////////////////////////////////////////////////////////////////////////
19  package net.sf.dexterim.ui;
20  
21  import java.util.ArrayList;
22  import java.util.Iterator;
23  import java.util.List;
24  
25  
26  /***
27   * @author christoph
28   *
29   */
30  public class BasicHexModel implements HexModel {
31  	private String text;
32  	private List filters;
33  	
34  	public BasicHexModel(String text) {
35  		this.text = text;
36  		this.filters = new ArrayList();
37  	}
38  	
39  	public BasicHexModel() {
40  		this(new String());
41  	}
42  	
43  	public void insertFilter(FilterMask filter, int index) {
44  		filters.add(index, filter);
45  	}
46  	
47  	public void appendFilter(FilterMask filter) {
48  		filters.add(filter);
49  	}
50  	
51  	public void removeFilter(FilterMask filter) {
52  		filters.remove(filter);
53  	}
54  	
55  	public List getFilters() {
56  		return filters;
57  	}
58  	
59  	public void setFilters(List filters) {
60  		this.filters = filters;
61  	}
62  	
63  	public void setText(String text) {
64  		this.text = text;
65  	}
66  	
67  	public String getText() {
68  		return text;
69  	}
70  	
71  	public String filterText() {
72  		String returnValue = text;
73  		
74  		for (Iterator iter = filters.iterator(); iter.hasNext();) {
75  			FilterMask filter = (FilterMask) iter.next();
76  			
77  			returnValue = filter.filter(returnValue);
78  		}
79  		
80  		return returnValue;
81  	}
82  }