Author: tilman
Date: Sat Mar 28 10:54:05 2026
New Revision: 1932609
Log:
PDFBOX-5660: refactor
Modified:
pdfbox/branches/2.0/debugger/src/main/java/org/apache/pdfbox/debugger/ui/RecentFiles.java
Modified:
pdfbox/branches/2.0/debugger/src/main/java/org/apache/pdfbox/debugger/ui/RecentFiles.java
==============================================================================
---
pdfbox/branches/2.0/debugger/src/main/java/org/apache/pdfbox/debugger/ui/RecentFiles.java
Sat Mar 28 10:54:02 2026 (r1932608)
+++
pdfbox/branches/2.0/debugger/src/main/java/org/apache/pdfbox/debugger/ui/RecentFiles.java
Sat Mar 28 10:54:05 2026 (r1932609)
@@ -50,10 +50,6 @@ public class RecentFiles
this.maximum = maximumFile;
this.pref = Preferences.userNodeForPackage(className);
filePaths = readHistoryFromPref();
- if (filePaths == null)
- {
- filePaths = new ArrayDeque<String>();
- }
}
/**
@@ -110,24 +106,20 @@ public class RecentFiles
*/
public List<String> getFiles()
{
- if (!isEmpty())
+ List<String> files = new ArrayList<String>();
+ for (String path : filePaths)
{
- List<String> files = new ArrayList<String>();
- for (String path : filePaths)
- {
- File file = new File(path);
- if (file.exists())
- {
- files.add(path);
- }
- }
- if (files.size() > maximum)
+ File file = new File(path);
+ if (file.exists())
{
- files.remove(0);
+ files.add(path);
}
- return files;
}
- return null;
+ if (files.size() > maximum)
+ {
+ files.remove(0);
+ }
+ return files;
}
/**
@@ -183,12 +175,7 @@ public class RecentFiles
{
Preferences node = pref.node(KEY);
int historyLength = node.getInt(HISTORY_LENGTH, 0);
- if (historyLength == 0)
- {
- return null;
- }
Queue<String> history = new ArrayDeque<String>();
-
for (int i = 1; i <= historyLength; i++)
{
int totalPieces = node.getInt(String.format(PIECES_LENGTH_KEY, i),
0);