Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 6ed703b67b0ba94b1db699d04debec3f32064afa (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/*******************************************************************************
 * Copyright (c) 2011 protos software gmbh (http://www.protos.de).
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 *******************************************************************************/


package org.eclipse.etrice.runtime.java.debugging;

import java.util.ArrayList;

/**
 * @author Thomas Schuetz
 *
 * Simple filtering that can be applied to MSCLogger to make the MSCs 
 * 
 * TODO: this is only a temporary solution for the current file based MSCLogger 
 */

public class MSCFilter {

	public MSCFilter() {
		filterList = new ArrayList<FilterItem>();
	}
	
	
	public void addFilter(FilterItem filter){
		filterList.add(filter);
	}

	public boolean applyTo(String text){
		for (FilterItem item : filterList){
			if (text.startsWith(item.filter)) return true;
		}
		return false;
	}

	public String reduceString(String string){
		if (filterList.size()==1)
			return string.replaceFirst(filterList.get(0).filter, "");
		else 
			return string;
	}
	
	private ArrayList<FilterItem> filterList= null;

	// Sub classes
	public static class FilterItem{
		private boolean exclude = false;
		private String filter = null;
		public FilterItem(String filter, boolean exclude) {
			super();
			this.exclude = exclude;
			this.filter = filter;
		}
	}
	
}

Back to the top