Cleanup/consolidation/expansion of *Utils classes

* IoUtils.java
    remove class that confusingly-overlaps with commons IOUtils; move remaining methods to ArchiveUtils or archive's FileUtils
* ArchiveUtils.java, FileUtils.java
    receive relocated methods; eliminated deprecated or unused methods
* JSONUtils.java
    new class to collect common JSON actions
* Iteratorable.java
    wrap Iterator as Iterable for foreach usage
* (many)
    update to use alternate utils methods
This commit is contained in:
gojomo
2009-11-19 22:39:53 +00:00
parent 300ce15a06
commit e42e2ed7f6
21 changed files with 314 additions and 601 deletions
@@ -29,7 +29,7 @@ import org.archive.bdb.BdbModule;
import org.archive.modules.net.BdbServerCache;
import org.archive.spring.ConfigPath;
import org.archive.state.ModuleTestBase;
import org.archive.util.IoUtils;
import org.archive.util.ArchiveUtils;
/**
*
@@ -55,7 +55,7 @@ public class CrawlControllerTest extends ModuleTestBase {
fileWriter.write("http://www.pandemoniummovie.com");
fileWriter.close();
} finally {
IoUtils.close(fileWriter);
ArchiveUtils.closeQuietly(fileWriter);
}
File state = new File(tmp, "state");
@@ -69,11 +69,8 @@ public class CrawlControllerTest extends ModuleTestBase {
// def.set(bdb, BdbModule.DIR, state.getAbsolutePath());
bdb.start();
String cp = checkpoints.getAbsolutePath();
CrawlController controller = new CrawlController();
controller.setServerCache(new BdbServerCache());
controller.setCheckpointsDir(new ConfigPath("test",cp));
controller.start();
return controller;
}
@@ -24,7 +24,7 @@ import java.io.File;
import java.io.FileReader;
import org.archive.crawler.frontier.precedence.BaseUriPrecedencePolicy;
import org.archive.util.IoUtils;
import org.archive.util.ArchiveUtils;
/**
* Tests that operators can create precedence groups for URIs, and that URIs
@@ -158,7 +158,7 @@ public class Precedence1SelfTest extends SelfTestBase {
crawled = crawled + s + "\n";
}
} finally {
IoUtils.close(br);
ArchiveUtils.closeQuietly(br);
}
assertEquals(EXPECTED, crawled);