/** * Writes the given word to the given writer, after having adapted it, based on the renamed class * names. */ private void writeUpdatedWord(Writer writer, String word) throws IOException { if (word.length() > 0) { String newWord = word; boolean containsDots = word.indexOf('.') >= 0; // Replace dots by forward slashes. String className = containsDots ? word.replace('.', ClassConstants.INTERNAL_PACKAGE_SEPARATOR) : word; // Find the class corrsponding to the word. Clazz clazz = classPool.getClass(className); if (clazz != null) { // Update the word if necessary. String newClassName = clazz.getName(); if (!className.equals(newClassName)) { // Replace forward slashes by dots. newWord = containsDots ? newClassName.replace(ClassConstants.INTERNAL_PACKAGE_SEPARATOR, '.') : newClassName; } } writer.write(newWord); } }
/** Returns the appropriate <code>ClassFileVisitor</code>. */ private ClassFileVisitor classFileVisitor(ClassFile classFile) { return classPool.getClass(classFile.getName()) != null ? presentClassFileVisitor : missingClassFileVisitor; }