Methods Summary |
---|
public boolean | buildClosure(java.lang.String className)
logger.entering(myClassName, "buildClosure", className); // NOI18N
ClassFile cf;
if (!needToBuildClosure(className))
return true;
try {
cf = loader.load(className);
} catch (IOException e) {
handleFailure(className);
return false;
}
return buildClosure(cf);
|
private boolean | buildClosure(ClassFile cf)
boolean result = true;
callStack.push(cf);
if (needToBuildClosure(cf.getName())) {
visitedClasses.add(cf.getName());
Collection<String> names = cf.getAllReferencedClassNames();
closure.addAll(names);
// TODO: We should not be doing this here. Its just a quick &
// dirty solution.
for(Method m : cf.getMethods()) {
if(m.isNative()) {
final String methodDesc =
m.getOwningClass().getName()+ "." + m.getName(); // NOI18N
nativeMethods.add(methodDesc);
}
}
for (Iterator i = names.iterator(); i.hasNext();) {
String nextExternalName = (String) i.next();
if (!needToBuildClosure(nextExternalName)) continue;
ClassFile next;
try {
next = loader.load(nextExternalName);
} catch (IOException e) {
result = false;
handleFailure(nextExternalName);
continue;
}
boolean newresult = buildClosure(next);//recurssive call
result = newresult && result;
}
}
callStack.pop();
return result;
|
public java.util.Collection | getClosure()
return Collections.unmodifiableCollection(closure);
|
public java.util.Map | getFailed()
return Collections.unmodifiableMap(failed);
|
public java.util.Collection | getNativeMethods()
return Collections.unmodifiableCollection(nativeMethods);
|
private void | handleFailure(java.lang.String referencedClass)
String referencingPath = "";
try {
StringBuilder referencingPathBuffer = new StringBuilder();
for (Iterator i = callStack.iterator(); i.hasNext();) {
if (referencingPathBuffer.length() != 0)
referencingPathBuffer.append(File.separator);
referencingPathBuffer.append(((ClassFile) i.next()).getName());
}
referencingPath = referencingPathBuffer.toString();
} catch (EmptyStackException e) {
}
logger.finer(
"Could not locate " + referencingPath + File.separator + // NOI18N
referencedClass);
List<String> failedList = failed.get(referencingPath);
if (failedList == null) {
failedList = new ArrayList<String>();
failed.put(referencingPath, failedList);
}
failedList.add(referencedClass);
|
public void | reset()Reset the closure for next closure computation.
Clear the internal cache. It includes the result it has collected since
last reset(). But it does not clear the excludedd list. If you want to
reset the excluded list, create a new ClosureCompiler.
closure.clear();
visitedClasses.clear();
failed.clear();
nativeMethods.clear();
|
public java.lang.String | toString()
StringBuilder sb=new StringBuilder();
if(logger.isLoggable(Level.FINER)){
sb.append("\n<Closure>"); // NOI18N
sb.append("\n\t<ExcludedClasses>"); // NOI18N
for(Iterator i=excludedClasses.iterator(); i.hasNext();) {
sb.append("\n\t\t"); // NOI18N
sb.append((String)i.next());
}
sb.append("\n\t</ExcludedClasses>"); // NOI18N
sb.append("\n\t<ExcludedPackages>"); // NOI18N
for(Iterator i=excludedPackages.iterator(); i.hasNext();){
sb.append("\n\t\t"); // NOI18N
sb.append((String)i.next());
}
sb.append("\n\t</ExcludedPackages>"); // NOI18N
sb.append("\n\t<ExcludedPatterns>"); // NOI18N
for(Iterator i=excludedPatterns.iterator(); i.hasNext();){
sb.append("\n\t\t"); // NOI18N
sb.append((String)i.next());
}
sb.append("\n\t</ExcludedPatterns>"); // NOI18N
sb.append("\n\t<Classes>"); // NOI18N
for(Iterator i=closure.iterator(); i.hasNext();){
sb.append("\n\t\t"); // NOI18N
sb.append((String)i.next());
}
sb.append("\n\t</Classes>"); // NOI18N
}
sb.append("\n\t<Failed>"); // NOI18N
for(Iterator i=failed.entrySet().iterator(); i.hasNext();) {
Map.Entry referencingPathToFailedList=(Map.Entry)i.next();
sb.append("\n\t\t"); // NOI18N
sb.append("<ReferencingPath>"); // NOI18N
sb.append("\n\t\t\t"); // NOI18N
sb.append(referencingPathToFailedList.getKey());
sb.append("\n\t\t"); // NOI18N
sb.append("</ReferencingPath>"); // NOI18N
sb.append("\n\t\t"); // NOI18N
sb.append("<Classes>"); // NOI18N
for(Iterator iii=((List)referencingPathToFailedList.getValue()).iterator(); iii.hasNext();){
sb.append("\n\t\t\t"); // NOI18N
sb.append((String)iii.next());
}
sb.append("\n\t\t"); // NOI18N
sb.append("</Classes>"); // NOI18N
}
sb.append("\n\t</Failed>"); // NOI18N
sb.append("\n\t<NativeMethods>"); // NOI18N
for(String s : nativeMethods) {
sb.append("\n\t\t"); // NOI18N
sb.append(s);
}
sb.append("\n\t</NativeMethods>"); // NOI18N
if(logger.isLoggable(Level.FINER)){
sb.append("\n</Closure>"); // NOI18N
}
return sb.toString();
|