1 19 20 25 26 package soot.tagkit; 27 28 import soot.*; 29 30 import java.util.*; 31 32 34 39 public class AbstractHost implements Host 40 { 41 private final static List emptyList = Collections.EMPTY_LIST; 44 private List mTagList = emptyList; 45 46 47 public List getTags() 48 { 49 return mTagList; 50 } 51 52 53 public void removeTag(String aName) 54 { 55 int tagIndex; 56 if((tagIndex = searchForTag(aName)) != -1) { 57 mTagList.remove(tagIndex); 58 } 59 } 60 61 62 private int searchForTag(String aName) 63 { 64 int i = 0; 65 Iterator it = mTagList.iterator(); 66 while(it.hasNext()) { 67 Tag tag = (Tag) it.next(); 68 if(tag.getName().equals(aName)) 69 return i; 70 i++; 71 } 72 return -1; 73 } 74 75 76 public Tag getTag(String aName) 77 { 78 int tagIndex; 79 if((tagIndex = searchForTag(aName)) != -1) { 80 return (Tag) mTagList.get(tagIndex); 81 } 82 83 return null; 84 } 85 86 87 public boolean hasTag(String aName) 88 { 89 return (searchForTag(aName) != -1); 90 } 91 92 93 public void addTag(Tag t) 94 { 95 if (mTagList == emptyList) 96 mTagList = new ArrayList(1); 97 mTagList.add(t); 98 } 99 100 101 public void removeAllTags() { 102 mTagList = emptyList; 103 } 104 105 106 public void addAllTagsOf( Host h ) { 107 for( Iterator tIt = h.getTags().iterator(); tIt.hasNext(); ) { 108 final Tag t = (Tag) tIt.next(); 109 addTag( t ); 110 } 111 } 112 } 113 114 115 116 117 | Popular Tags |