Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Axxerion #5

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,59 +14,61 @@
import com.google.common.io.Files;

public class ClassNameJarIterator implements ClassFileIterator {
private Iterator<String> classFiles = new ArrayList<String>().iterator();
private File jarFile;
private Iterator<String> classFiles = new ArrayList<String>().iterator();
private File jarFile;

public ClassNameJarIterator(final String classPath,
final BuildContext buildContext) {
public ClassNameJarIterator(final String classPath,
final BuildContext buildContext) {

jarFile = new File(classPath);
if (buildContext.hasDelta(classPath)) {
List<String> classNames = new ArrayList<>();
try {
JarInputStream jarFileStream = new JarInputStream(
new FileInputStream(jarFile));
JarEntry jarEntry;
jarFile = new File(classPath);
if (buildContext.hasDelta(classPath) && jarFile.exists()) {
List<String> classNames = new ArrayList<>();
try {
JarInputStream jarFileStream = new JarInputStream(
new FileInputStream(jarFile));
JarEntry jarEntry;

while (true) {
jarEntry = jarFileStream.getNextJarEntry();
if (jarEntry == null)
break;
while (true) {
jarEntry = jarFileStream.getNextJarEntry();
if (jarEntry == null) {
break;
}

if (jarEntry.getName().endsWith(".class"))
classNames.add(jarEntry.getName()
.replaceAll("/", "\\."));
if (jarEntry.getName().endsWith(".class")) {
classNames.add(jarEntry.getName()
.replaceAll("/", "\\."));
}

}
}

jarFileStream.close();
} catch (Exception e) {
e.printStackTrace();
}
classFiles = classNames.iterator();
} else {
classFiles = Collections.emptyIterator();
}
}
jarFileStream.close();
} catch (Exception e) {
e.printStackTrace();
}
classFiles = classNames.iterator();
} else {
classFiles = Collections.emptyIterator();
}
}

@Override
public boolean hasNext() {
return classFiles.hasNext();
}
@Override
public boolean hasNext() {
return classFiles.hasNext();
}

@Override
public String next() {
return Files.getNameWithoutExtension(classFiles.next()).replace(
File.separator, ".");
}
@Override
public String next() {
return Files.getNameWithoutExtension(classFiles.next()).replace(
File.separator, ".");
}

@Override
public File getLastFile() {
return jarFile;
}
@Override
public File getLastFile() {
return jarFile;
}

@Override
public void remove() {
classFiles.remove();
}
@Override
public void remove() {
classFiles.remove();
}
}
Loading