
org.jwat.tools.tasks.changed.ChangedTask Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jwat-tools Show documentation
Show all versions of jwat-tools Show documentation
JWAT-Tools uses the available JWAT libraries to make high level tasks available either from command-line or programmatically.
Common tasks include: Test, Compress, Decompress, CDX, Arc2Warc.
More specialised tasks include: Changed, ContainerMD, Delete, Extract, Interval, PathIndex, Unpack, Headers2CDX.
package org.jwat.tools.tasks.changed;
import java.io.File;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import org.jwat.tools.tasks.ProcessTask;
public class ChangedTask extends ProcessTask {
public List data = new ArrayList();
public List intervals = new ArrayList();
public ChangedTask() {
}
public void runtask(ChangedOptions options) {
filelist_feeder(options.filesList, this);
Collections.sort(data);
Interval interval;
long l;
int idx;
if (data.size() > 0) {
idx = 0;
interval = new Interval();
l = data.get(idx++);
interval.from = l;
interval.to = l;
intervals.add(interval);
while (idx < data.size()) {
l = data.get( idx++ );
if (l < (interval.to + 60000)) {
interval.to = l;
++interval.count;
} else {
interval = new Interval();
interval.from = l;
interval.to = l;
intervals.add(interval);
}
}
}
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
idx = 0;
while (idx < intervals.size()) {
interval = intervals.get( idx++ );
// TODO Save to supplied output file parameter!
System.out.println(dateFormat.format(new Date(interval.from)) + " -> " + dateFormat.format(new Date(interval.to)) + " : " + interval.count );
}
}
@Override
public void process(File srcFile) {
data.add( srcFile.lastModified() );
}
public static class Interval {
public long from;
public long to;
public int count = 1;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy