/** * Return those elements of {@code c} that are assignable to {@code klass}. */ @SuppressWarnings("unchecked") public static <S, T> Set<T> filterByType(Iterable<S> c, Class<T> klass) { Set<T> result = HashSetFactory.make(); for(S s : c) if(klass.isAssignableFrom(s.getClass())) result.add((T)s); return result; }
public void addScopedEntity(CAstNode construct, CAstEntity child) { if (!scopedEntities.containsKey(construct)) { Collection<CAstEntity> set = HashSetFactory.make(1); scopedEntities.put(construct, set); } scopedEntities.get(construct).add(child); } }
@Override public Collection<IField> getDeclaredStaticFields() { Set<IField> result = HashSetFactory.make(); for (IField F : declaredFields.values()) { if (F.isStatic()) { result.add(F); } } return result; }
static Collection<Annotation> getAnnotations(Collection<org.jf.dexlib2.iface.Annotation> as, ClassLoaderReference clr) { Collection<Annotation> result = HashSetFactory.make(); for(org.jf.dexlib2.iface.Annotation a : as) { result.add(getAnnotation(a, clr)); } return result; }
@Override public Collection<IField> getDeclaredInstanceFields() { Set<IField> result = HashSetFactory.make(); for (IField F : declaredFields.values()) { if (!F.isStatic()) { result.add(F); } } return result; }
@Override public Iterator<ModuleEntry> getEntries() { HashSet<ModuleEntry> result = HashSetFactory.make(); for (Enumeration e = file.entries(); e.hasMoreElements();) { ZipEntry Z = (ZipEntry) e.nextElement(); result.add(createEntry(Z)); } return result.iterator(); }
/** * SELECT attribute FROM t where column=value */ public static <T> Collection<T> selectWhereEquals(Table<T> t, String attribute, String column, T value) { Collection<Map<String,T>> rows = selectStarWhereEquals(t, column, value); Collection<T> result = HashSetFactory.make(); for (Map<String,T> p : rows) { result.add(p.get(attribute)); } return result; }
/** * SELECT attribute FROM t where column=value */ public static <T> Collection<T> selectWhereEquals(Table<T> t, String attribute, String column, T value) { Collection<Map<String,T>> rows = selectStarWhereEquals(t, column, value); Collection<T> result = HashSetFactory.make(); for (Map<String,T> p : rows) { result.add(p.get(attribute)); } return result; }
@Override public Iterator<ModuleEntry> getEntries() { HashSet<ModuleEntry> result = HashSetFactory.make(); for (Enumeration e = file.entries(); e.hasMoreElements();) { ZipEntry Z = (ZipEntry) e.nextElement(); result.add(createEntry(Z)); } return result.iterator(); }
@Override public Collection<IField> getDeclaredInstanceFields() { Set<IField> result = HashSetFactory.make(); for (IField F : declaredFields.values()) { if (!F.isStatic()) { result.add(F); } } return result; }
/** * return the set of all PARAM_CALLER, HEAP_PARAM_CALLER, and NORMAL statements (i.e., the actual call statement) associated with * a given call */ public Set<Statement> getCallStatements(SSAAbstractInvokeInstruction call) throws IllegalArgumentException { Set<Statement> callerParamStatements = getCallerParamStatements(call); Set<Statement> result = HashSetFactory.make(callerParamStatements.size() + 1); result.addAll(callerParamStatements); result.add(callSite2Statement.get(call.getCallSite())); return result; }
@Override public Collection<IField> getAllFields() { Collection<IField> result = HashSetFactory.make(); result.addAll(getAllInstanceFields()); result.addAll(getAllStaticFields()); return result; }
@Override public IClassLoader[] getLoaders() { Set<IClassLoader> loaders = HashSetFactory.make(); for (ClassLoaderReference loaderReference : analysisScope.getLoaders()) { loaders.add(getLoader(loaderReference)); } return loaders.toArray(new IClassLoader[0]); }
@Override public Collection<Annotation> getAnnotations() { Collection<Annotation> result = HashSetFactory.make(); try { result.addAll(getAnnotations(true)); result.addAll(getAnnotations(false)); } catch (InvalidClassFileException e) { } return result; }
@Override public Collection<Annotation> getAnnotations() { Collection<Annotation> result = HashSetFactory.make(); try { result.addAll(getAnnotations(true)); result.addAll(getAnnotations(false)); } catch (InvalidClassFileException e) { } return result; }
private static Set<CodeElement> getStaticFieldAccessCodeElts(SSAFieldAccessInstruction inst) { Set<CodeElement> elts = HashSetFactory.make(); final FieldReference fieldRef = inst.getDeclaredField(); elts.add(new StaticFieldElement(fieldRef)); // TODO: what about tainting the declaring class? return elts; }
@Override public Set<CGNode> getNodes(MethodReference m) { Set<CGNode> result = HashSetFactory.make(); for (CGNode x : cg.getNodes(m)) { if (containsNode(x)) { result.add(x); } } return result; }
/** * Get all the constructors of a class */ private static Collection<IMethod> getConstructors(IClass cls) { Collection<IMethod> result = HashSetFactory.make(); for (IMethod m : cls.getDeclaredMethods()) { if (m.isInit()) { result.add(m); } } return result; }
@Override public Iterator<T> getSuccNodes(T N) { Collection<T> succs = HashSetFactory.make(); for (U label : nodeToSuccLabels.get(N)) { succs.addAll(Iterator2Collection.toSet(getSuccNodes(N, label))); } return succs.iterator(); }
@Override public Iterator<T> getSuccNodes(T N) { Collection<T> succs = HashSetFactory.make(); for (U label : nodeToSuccLabels.get(N)) { succs.addAll(Iterator2Collection.toSet(getSuccNodes(N, label))); } return succs.iterator(); }