Skip to content
Merged
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.idea
*.pydevproject
.project
.metadata
Expand Down
19 changes: 19 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
Unreleased
----------

### Changes

`FileUtils.pagedLines()` and `FileUtils.expandRange()` now return the Apache Commons Lang 3 version of `LongRange`.
Users of these methods may need to make the following changes:

| Old | New |
|-------------------------------------------------|---------------------------------------------|
| `import org.apache.commons.lang.math.LongRange` | `import org.apache.commons.lang3.LongRange` |
| `new LongRange(min, max)` | `LongRange.of(min, max)` |
| `longRange.getMaximumLong()` | `longRange.getMaximum()` |
| `longRange.getMinimumLong()` | `longRange.getMinimum()` |

### Dependency upgrades

- **commons-lang**: 2.6 → 3.18.0

2.0.2
-----

Expand Down
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,9 @@
</dependency>

<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.18.0</version>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import java.io.PrintStream;
import java.util.List;

import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.StringUtils;
import org.archive.format.json.JSONView;
import org.archive.resource.Resource;
import org.archive.util.StreamCopy;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/archive/format/cdx/FieldSplitLine.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import java.util.ArrayList;
import java.util.List;

import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.StringUtils;

/**
* Base class for text lines that are split by a delimiter Some examples will be
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.archive.format.gzip.zipnum;

import org.apache.commons.lang.math.NumberUtils;
import org.apache.commons.lang3.math.NumberUtils;
import org.archive.util.iterator.CloseableIterator;

public class TimestampBestPickDedupIterator extends TimestampDedupIterator {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import java.util.logging.Level;
import java.util.logging.Logger;

import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.StringUtils;

public class CrossProductOfLists<T> {
private static final Logger LOG =
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/archive/format/json/JSONView.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import java.util.logging.Level;
import java.util.logging.Logger;

import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import java.util.logging.Level;
import java.util.logging.Logger;

import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.pig.backend.executionengine.ExecException;
import org.apache.pig.data.Tuple;
import org.apache.pig.data.TupleFactory;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/archive/io/arc/ARCRecord.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import java.util.logging.Logger;
import java.util.regex.Matcher;

import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.StringUtils;
import org.archive.format.http.HttpHeader;
import org.archive.io.ArchiveRecord;
import org.archive.io.ArchiveRecordHeader;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/archive/io/warc/WARCReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
import org.apache.commons.cli.PosixParser;
import org.apache.commons.lang.NotImplementedException;
import org.apache.commons.lang3.NotImplementedException;
import org.archive.io.ArchiveReader;
import org.archive.io.ArchiveRecord;

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/archive/io/warc/WARCWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
import java.util.logging.Level;
import java.util.logging.Logger;

import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.StringUtils;
import org.archive.format.ArchiveFileConstants;
import org.archive.io.UTF8Bytes;
import org.archive.io.WriterPoolMember;
Expand Down
18 changes: 9 additions & 9 deletions src/main/java/org/archive/util/FileUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

import org.apache.commons.io.IOUtils;
import org.apache.commons.io.filefilter.IOFileFilter;
import org.apache.commons.lang.math.LongRange;
import org.apache.commons.lang3.LongRange;


/** Utility methods for manipulating files and directories.
Expand Down Expand Up @@ -473,7 +473,7 @@ public static LongRange pagedLines(File file, long position,
if(signedDesiredLineCount>0) {
if(startPosition+bufferSize == fileEnd) {
// nothing more to read: return nothing
return new LongRange(fileEnd,fileEnd);
return LongRange.of(fileEnd,fileEnd);
} else {
// retry with larger lineEstimate
return pagedLines(file, position, signedDesiredLineCount, lines, Math.max(bufferSize,lineEstimate));
Expand Down Expand Up @@ -501,7 +501,7 @@ public static LongRange pagedLines(File file, long position,
}
int firstLine = lineStarts.getFirst();
int partialLine = lineStarts.getLast();
LongRange range = new LongRange(startPosition + firstLine, startPosition + partialLine);
LongRange range = LongRange.of(startPosition + firstLine, startPosition + partialLine);
List<String> foundLines =
IOUtils.readLines(new ByteArrayInputStream(buf,firstLine,partialLine-firstLine));

Expand All @@ -510,7 +510,7 @@ public static LongRange pagedLines(File file, long position,
range = expandRange(
range,
pagedLines(file,
range.getMinimumLong()-1,
range.getMinimum()-1,
signedDesiredLineCount+foundFullLines,
lines,
bufferSize/foundFullLines));
Expand All @@ -519,7 +519,7 @@ public static LongRange pagedLines(File file, long position,

lines.addAll(foundLines);

if(signedDesiredLineCount < 0 && range.getMaximumLong() < position) {
if(signedDesiredLineCount < 0 && range.getMaximum() < position) {
// did not get line containining start position
range = expandRange(
range,
Expand All @@ -530,12 +530,12 @@ public static LongRange pagedLines(File file, long position,
bufferSize/foundFullLines));
}

if(signedDesiredLineCount > 0 && foundFullLines < desiredLineCount && range.getMaximumLong() < fileEnd) {
if(signedDesiredLineCount > 0 && foundFullLines < desiredLineCount && range.getMaximum() < fileEnd) {
// need more forward lines
range = expandRange(
range,
pagedLines(file,
range.getMaximumLong(),
range.getMaximum(),
desiredLineCount - foundFullLines,
lines,
bufferSize/foundFullLines));
Expand All @@ -545,8 +545,8 @@ public static LongRange pagedLines(File file, long position,
}

public static LongRange expandRange(LongRange range1, LongRange range2) {
return new LongRange(Math.min(range1.getMinimumLong(), range2.getMinimumLong()),
Math.max(range1.getMaximumLong(), range2.getMaximumLong()));
return LongRange.of(Math.min(range1.getMinimum(), range2.getMinimum()),
Math.max(range1.getMaximum(), range2.getMaximum()));

}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/archive/util/PropertyUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import java.util.Properties;
import java.util.regex.Matcher;

import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.StringUtils;

/**
* Utilities for dealing with Java Properties (incl. System Properties)
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/archive/util/Recorder.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.StringUtils;
import org.archive.io.GenericReplayCharSequence;
import org.archive.io.RecordingInputStream;
import org.archive.io.RecordingOutputStream;
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/org/archive/util/TextUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.apache.commons.lang.StringEscapeUtils;
import org.apache.commons.lang3.StringEscapeUtils;

import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
Expand Down Expand Up @@ -198,7 +198,7 @@ public static String getFirstWord(String s) {
* @return The same string escaped.
*/
public static String escapeForHTMLJavascript(String s) {
return escapeForHTML(StringEscapeUtils.escapeJavaScript(s));
return escapeForHTML(StringEscapeUtils.escapeEcmaScript(s));
}

/**
Expand Down Expand Up @@ -239,7 +239,7 @@ public static void writeEscapedForHTML(String s, Writer w)
BufferedReader reader = new BufferedReader(new StringReader(s));
String line;
while((line=reader.readLine()) != null){
out.println(StringEscapeUtils.escapeHtml(line));
out.println(StringEscapeUtils.escapeHtml3(line));
}
}

Expand All @@ -253,7 +253,7 @@ public static CharSequence unescapeHtml(final CharSequence cs) {
return cs;
}

return StringEscapeUtils.unescapeHtml(cs.toString());
return StringEscapeUtils.unescapeHtml4(cs.toString());
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/org/archive/io/ArchiveReaderFactoryTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import java.net.URL;
import java.util.Iterator;

import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.StringUtils;
import org.archive.io.arc.ARCWriterTest;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/org/archive/url/UsableURIFactoryTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

import java.util.TreeMap;

import org.apache.commons.lang.SerializationUtils;
import org.apache.commons.lang3.SerializationUtils;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.*;
Expand Down
6 changes: 3 additions & 3 deletions src/test/java/org/archive/util/FileUtilsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import java.util.List;

import org.apache.commons.io.IOUtils;
import org.apache.commons.lang.math.LongRange;
import org.apache.commons.lang3.LongRange;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -216,7 +216,7 @@ private List<String> getTestTailLines(File file, int count, int estimate) throws
LongRange range = FileUtils.pagedLines(file,pos,-count,returnedLines,estimate);
Collections.reverse(returnedLines);
testLines.addAll(returnedLines);
pos = range.getMinimumLong()-1;
pos = range.getMinimum()-1;
} while (pos>=0);
Collections.reverse(testLines);
return testLines;
Expand Down Expand Up @@ -291,7 +291,7 @@ private List<String> getTestHeadLines(File file, int count, int estimate) throws
List<String> testLines = new LinkedList<String>();
do {
LongRange range = FileUtils.pagedLines(file,pos,count,testLines,estimate);
pos = range.getMaximumLong();
pos = range.getMaximum();
} while (pos<file.length());
return testLines;
}
Expand Down
Loading