Skip to content

Commit a5dfc94

Browse files
committed
Cleanup and lombok
1 parent a4a5d77 commit a5dfc94

18 files changed

+704
-628
lines changed

JRomManager/src/jrm/compressors/NArchive.java

Lines changed: 105 additions & 470 deletions
Large diffs are not rendered by default.

JRomManager/src/jrm/compressors/ZipOptions.java

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package jrm.compressors;
1818

1919
import jrm.locale.Messages;
20+
import lombok.Getter;
2021

2122
/**
2223
* Zip supported levels of compression
@@ -32,22 +33,12 @@ public enum ZipOptions
3233
MAXIMUM(Messages.getString("ZipOptions.MAXIMUM"), 7), //$NON-NLS-1$
3334
ULTRA(Messages.getString("ZipOptions.ULTRA"), 9); //$NON-NLS-1$
3435

35-
private String desc;
36-
private int level;
36+
private @Getter String desc;
37+
private @Getter int level;
3738

3839
private ZipOptions(final String desc, final int level)
3940
{
4041
this.desc = desc;
4142
this.level = level;
4243
}
43-
44-
public String getName()
45-
{
46-
return desc;
47-
}
48-
49-
public int getLevel()
50-
{
51-
return level;
52-
}
5344
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
package jrm.compressors.sevenzipjbinding;
2+
3+
import java.io.FileNotFoundException;
4+
import java.io.RandomAccessFile;
5+
import java.util.HashMap;
6+
import java.util.Map;
7+
8+
import net.sf.sevenzipjbinding.IArchiveOpenVolumeCallback;
9+
import net.sf.sevenzipjbinding.IInStream;
10+
import net.sf.sevenzipjbinding.PropID;
11+
import net.sf.sevenzipjbinding.SevenZipException;
12+
import net.sf.sevenzipjbinding.impl.RandomAccessFileInStream;
13+
14+
public class Archive7ZOpenVolumeCallback implements IArchiveOpenVolumeCallback
15+
{
16+
/**
17+
*
18+
*/
19+
private final Closeables closeables;
20+
21+
/**
22+
* @param nArchive
23+
*/
24+
public Archive7ZOpenVolumeCallback(Closeables closeables)
25+
{
26+
this.closeables = closeables;
27+
}
28+
29+
private Map<String, RandomAccessFile> openedRandomAccessFileList = new HashMap<String, RandomAccessFile>();
30+
31+
public Object getProperty(PropID propID) throws SevenZipException
32+
{
33+
return null;
34+
}
35+
36+
public IInStream getStream(String filename) throws SevenZipException
37+
{
38+
try
39+
{
40+
RandomAccessFile randomAccessFile = openedRandomAccessFileList.get(filename);
41+
if (randomAccessFile != null)
42+
randomAccessFile.seek(0);
43+
else
44+
{
45+
closeables.addCloseables(randomAccessFile = new RandomAccessFile(filename, "r"));
46+
openedRandomAccessFileList.put(filename, randomAccessFile);
47+
}
48+
return new RandomAccessFileInStream(randomAccessFile);
49+
}
50+
catch (FileNotFoundException fileNotFoundException)
51+
{
52+
return null; // We return always null in this case
53+
}
54+
catch (Exception e)
55+
{
56+
throw new RuntimeException(e);
57+
}
58+
}
59+
}
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
package jrm.compressors.sevenzipjbinding;
2+
3+
import java.io.FileNotFoundException;
4+
import java.io.RandomAccessFile;
5+
import java.util.HashMap;
6+
import java.util.Map;
7+
8+
import net.sf.sevenzipjbinding.IArchiveOpenCallback;
9+
import net.sf.sevenzipjbinding.IArchiveOpenVolumeCallback;
10+
import net.sf.sevenzipjbinding.IInStream;
11+
import net.sf.sevenzipjbinding.PropID;
12+
import net.sf.sevenzipjbinding.SevenZipException;
13+
import net.sf.sevenzipjbinding.impl.RandomAccessFileInStream;
14+
15+
public class ArchiveRAROpenVolumeCallback implements IArchiveOpenVolumeCallback, IArchiveOpenCallback
16+
{
17+
/**
18+
*
19+
*/
20+
private final Closeables closeables;
21+
22+
/**
23+
* @param nArchive
24+
*/
25+
public ArchiveRAROpenVolumeCallback(Closeables closeables)
26+
{
27+
this.closeables = closeables;
28+
}
29+
30+
private Map<String, RandomAccessFile> openedRandomAccessFileList = new HashMap<String, RandomAccessFile>();
31+
private String name;
32+
33+
public Object getProperty(PropID propID) throws SevenZipException
34+
{
35+
switch (propID)
36+
{
37+
case NAME:
38+
return name;
39+
default:
40+
return null;
41+
}
42+
}
43+
44+
public IInStream getStream(String filename) throws SevenZipException
45+
{
46+
try
47+
{
48+
RandomAccessFile randomAccessFile = openedRandomAccessFileList.get(filename);
49+
if (randomAccessFile != null)
50+
randomAccessFile.seek(0);
51+
else
52+
{
53+
closeables.addCloseables(randomAccessFile = new RandomAccessFile(filename, "r"));
54+
openedRandomAccessFileList.put(filename, randomAccessFile);
55+
}
56+
name = filename;
57+
return new RandomAccessFileInStream(randomAccessFile);
58+
}
59+
catch (FileNotFoundException fileNotFoundException)
60+
{
61+
return null; // We return always null in this case
62+
}
63+
catch (Exception e)
64+
{
65+
throw new RuntimeException(e);
66+
}
67+
}
68+
69+
public void setCompleted(Long files, Long bytes) throws SevenZipException
70+
{
71+
}
72+
73+
public void setTotal(Long files, Long bytes) throws SevenZipException
74+
{
75+
}
76+
}

0 commit comments

Comments
 (0)