1 package com.xtremelabs.robolectric.shadows; 2 3 import android.content.IntentFilter; 4 import com.xtremelabs.robolectric.internal.Implementation; 5 import com.xtremelabs.robolectric.internal.Implements; 6 7 import java.util.ArrayList; 8 import java.util.Iterator; 9 import java.util.List; 10 11 /** 12 * Shadow of {@code IntentFilter} implemented with a {@link java.util.List} 13 */ 14 @SuppressWarnings({"UnusedDeclaration"}) 15 @Implements(IntentFilter.class) 16 public class ShadowIntentFilter { 17 List<String> actions = new ArrayList<String>(); 18 List<String> schemes = new ArrayList<String>(); 19 List<IntentFilter.AuthorityEntry> authoritites = new ArrayList<IntentFilter.AuthorityEntry>(); 20 __constructor__(String action)21 public void __constructor__(String action) { 22 actions.add(action); 23 } 24 25 @Implementation addAction(String action)26 public void addAction(String action) { 27 actions.add(action); 28 } 29 30 @Implementation getAction(int index)31 public String getAction(int index) { 32 return actions.get(index); 33 } 34 35 @Implementation countActions()36 public int countActions() { 37 return actions.size(); 38 } 39 40 @Implementation actionsIterator()41 public Iterator<String> actionsIterator() { 42 return actions.iterator(); 43 } 44 45 @Implementation matchAction(String action)46 public boolean matchAction(String action) { 47 return actions.contains(action); 48 } 49 50 @Implementation addDataAuthority(String host, String port)51 public void addDataAuthority(String host, String port) { 52 authoritites.add(new IntentFilter.AuthorityEntry(host, port)); 53 } 54 55 @Implementation getDataAuthority(int index)56 public final IntentFilter.AuthorityEntry getDataAuthority(int index) { 57 return authoritites.get(index); 58 } 59 60 @Implementation addDataScheme(String scheme)61 public void addDataScheme(String scheme) { 62 schemes.add(scheme); 63 } 64 65 @Implementation getDataScheme(int index)66 public String getDataScheme(int index) { 67 return schemes.get(index); 68 } 69 } 70