@Override public String toString() { return "[" + this.caller.getQualifiedName() + " --> " + this.callee.getQualifiedName() + "]"; }
/** * Compares the construct with the given construct by comparing their qualified name. * @param _c * @return */ public final int compareTo(ConstructId _c) { return this.getQualifiedName().compareTo(_c.getQualifiedName()); }
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + this.getQualifiedName().hashCode(); return result; }
public final void addConstructIds(Collection<ConstructId> _classes) { for(ConstructId cid: _classes) { classNames.add(cid.getQualifiedName()); } }
/** * Returns true if the qualified name of the two constructs are equal, false otherwise. */ @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; ConstructId other = (ConstructId) obj; return this.getQualifiedName().equals(other.getQualifiedName()); }
/** * Returns all {@link JavaId}s whose qualified name starts with the given string. */ public static Set<ConstructId> filter(Set<ConstructId> _set, String _filter) { final Set<ConstructId> set = new HashSet<ConstructId>(); for(ConstructId c: _set) { if(c.getQualifiedName().startsWith(_filter)) { set.add(c); } } return set; }
@Override public String toString() { final StringBuffer b = new StringBuffer(); b.append("[qname="); b.append(this.constructId.getQualifiedName()); if(this.sha1!=null) { b.append(", libsha1=").append(this.sha1); } b.append("]"); return b.toString(); } }
/** * Returns the {@link JavaPackageId} of a given {@link ConstructId}. * * @param _cid * @return */ public static JavaPackageId getPackageId (ConstructId _cid) { JavaPackageId pid = null; if(_cid instanceof com.sap.psr.vulas.java.JavaPackageId) pid = (JavaPackageId) _cid; else if(_cid instanceof com.sap.psr.vulas.java.JavaId) pid = ((JavaId)_cid).getJavaPackageId(); else Callgraph.log.error("Cannot find the package id for construct [" + _cid.getQualifiedName() + "]"); return pid; }
public List<com.sap.psr.vulas.shared.json.model.ConstructId> getSharedConstructs() throws FileAnalysisException { List<com.sap.psr.vulas.shared.json.model.ConstructId> l= new ArrayList<com.sap.psr.vulas.shared.json.model.ConstructId>(); for(ConstructId c: this.getConstructs().keySet()) { l.add(new com.sap.psr.vulas.shared.json.model.ConstructId(ProgrammingLanguage.PY, c.getSharedType(),c.getQualifiedName())); } return l; } }
public List<com.sap.psr.vulas.shared.json.model.ConstructId> getSharedConstructs() throws FileAnalysisException { List<com.sap.psr.vulas.shared.json.model.ConstructId> l= new ArrayList<com.sap.psr.vulas.shared.json.model.ConstructId>(); for(ConstructId c: this.getConstructIds()) { l.add(new com.sap.psr.vulas.shared.json.model.ConstructId(ProgrammingLanguage.JAVA, c.getSharedType(),c.getQualifiedName())); } return l; }
public JsonElement serialize(ConstructId src, Type typeOfSrc, JsonSerializationContext context) { final JsonObject c = new JsonObject(); c.addProperty("lang", src.getLanguage().toString()); c.addProperty("type", JavaId.typeToString(((JavaId)src).getType())); c.addProperty("qname", src.getQualifiedName()); final Set<String> annotations = ((JavaId)src).getAnnotations(); if(!annotations.isEmpty()) { final JsonArray anno = new JsonArray(); for(String a: annotations) { anno.add(new JsonPrimitive(a)); } c.add("a", anno); } return c; }
/** * Transforms an object with a given core type (defined in vulas-core) into * an object having the corresponding shared type (defined in vulas-share). * @param _core_type * @return */ public static com.sap.psr.vulas.shared.json.model.ConstructId toSharedType(com.sap.psr.vulas.ConstructId _core_type) { return new com.sap.psr.vulas.shared.json.model.ConstructId(_core_type.getLanguage(), _core_type.getSharedType(), _core_type.getQualifiedName()); }
else cp = ClassPool.getDefault(); final CtClass ctclass = cp.get( ((JavaConstructorId)_constructors.get(0)).getDefinitionContext().getQualifiedName() );
this.getLog().info("Path constructed from stacktrace, length [" + path.size() + "]: entry point [" + path.get(0).getConstructId().getQualifiedName() + "], change list element [" + _id.getQualifiedName() + "]");
private ConstructId filterMethods(StackTraceElement _e, List<ConstructId> _methods) throws NotFoundException { final String class_qname = ((JavaMethodId)_methods.get(0)).getDefinitionContext().getQualifiedName(); if(m.getQualifiedName().equals(ClassVisitor.removeParameterQualification(ctm.getLongName())) && _e.getLineNumber()>=ctm.getMethodInfo().getLineNumber(0)) { current_distance = _e.getLineNumber() - ctm.getMethodInfo().getLineNumber(0); if(current_distance < shortest_distance) {
String aaa = c.getQualifiedName();
/** * This method look into the custom ClassPool and return a string with the * physical path of the JAR if is present in the resources loaded into the * ClassPool. If is not found it returns null * PS: We can add to the ClassPool all the resources that we want using * the method {@ClassPoolUpdater#appendToClasspath} * @param _cid the ConstructId that we want to search in the ClassPool * @return the JAR path or null if is not found */ public URL getJarResourcePath(ConstructId _cid) { URL url = null; if(_cid instanceof JavaId) { final JavaId jid = (JavaId)_cid; if(jid.getType()==JavaId.Type.METHOD || jid.getType()==JavaId.Type.CONSTRUCTOR || jid.getType()==JavaId.Type.CLASSINIT) { url = this.customClassPool.find(_cid.getDefinitionContext().getQualifiedName()); } else if(jid.getType()==JavaId.Type.CLASS || jid.getType()==JavaId.Type.INTERFACE || jid.getType()==JavaId.Type.ENUM || jid.getType()==JavaId.Type.NESTED_CLASS) { url = this.customClassPool.find(_cid.getQualifiedName()); } } return url; }